From 0aace09917f09dbaa609a69830a6e5f3bfbc18a8 Mon Sep 17 00:00:00 2001 From: vrubelroman Date: Sun, 1 Nov 2026 09:12:01 +0300 Subject: [PATCH] fix(ui): keep the migrated session, visible theme-save errors, trash only refused items, mirror leaves archives (QA-16..QA-19) - QA-16: a session read from the old location is applied even when moving it to an unwritable state dir fails; the error goes to the status line. - QA-19: the theme selector no longer overwrites a "save failed" status with "Theme: X"; finalizeTheme reports success itself. - QA-17: a trash job keeps going after an item the trash refuses; only the refused items are offered for permanent deletion, the rest are trashed. - QA-18: mirroring into a pane that is inside an archive (or a remote host) clears its archive mounts and removes their temp dirs. Co-Authored-By: Claude Opus 5.5 --- internal/ui/model.go | 45 ++++++++++++++++++++++++++++---------- internal/ui/qa_rc2_test.go | 4 ---- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/internal/ui/model.go b/internal/ui/model.go index ba7652c..bc0e7ea 100644 --- a/internal/ui/model.go +++ b/internal/ui/model.go @@ -1642,10 +1642,9 @@ func (m Model) handleModalKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) { return m, nil } selected := m.themeSelector.names[m.themeSelector.cursor] - m.finalizeTheme(selected) + m.finalizeTheme(selected) // sets the status, including a save failure (QA-19) m.themeSelector = nil m.modal = modalState{} - m.status = fmt.Sprintf("Theme: %s", selected) log.Printf("[THEME] Applied: %s", selected) return m, nil case isModalCloseKey(msg, m.keys): @@ -2651,6 +2650,9 @@ func (m *Model) handleMirrorPane() (tea.Model, tea.Cmd) { // drop the passive pane's old mounts (which may be the same client). mount.Client.Acquire() releaseMounts(passive.ClearRemotes()) + for _, am := range passive.ClearArchives() { + _ = os.RemoveAll(am.TempDir) + } passive.Remote = append(passive.Remote, mount) passive.Path = active.Path if err := m.reloadRemotePane(passive.ID, ""); err != nil { @@ -2665,8 +2667,12 @@ func (m *Model) handleMirrorPane() (tea.Model, tea.Cmd) { m.status = "Mirror is not supported inside an archive" return m, nil } else { - // Local directory — simple path copy + // Local directory — simple path copy. The passive pane leaves any + // archive it was in (QA-18): its mount and temp dir go away. releaseMounts(passive.ClearRemotes()) + for _, mount := range passive.ClearArchives() { + _ = os.RemoveAll(mount.TempDir) + } passive.Path = targetPath if err := m.reloadPane(passive.ID, ""); err != nil { m.status = fmt.Sprintf("Mirror failed: %v", err) @@ -3120,6 +3126,7 @@ func (m *Model) finalizeTheme(name string) { return } m.configPath = savedPath + m.status = fmt.Sprintf("Theme: %s", name) } func copyTextToClipboard(text string) error { @@ -5286,6 +5293,8 @@ func (m *Model) startDeleteJob(kind fileOpKind, sources []string) tea.Cmd { if kind == opPermanentDelete { verb = "delete permanently" } + var trashFailed []string + var firstErr error for i, sourcePath := range sources { select { case <-ctx.Done(): @@ -5305,16 +5314,20 @@ func (m *Model) startDeleteJob(kind fileOpKind, sources []string) tea.Cmd { err = vfs.MoveToTrash(sourcePath) } if err != nil { - done := archiveDoneMsg{ - jobID: jobID, - sourcePaths: append([]string(nil), sources...), - err: fmt.Errorf("%s %s: %w", verb, sourcePath, err), + if kind == opPermanentDelete { + m.archiveProgress <- archiveDoneMsg{ + jobID: jobID, + sourcePaths: append([]string(nil), sources...), + err: fmt.Errorf("%s %s: %w", verb, sourcePath, err), + } + return } - if kind != opPermanentDelete { - done.trashFailed = append([]string(nil), sources[i:]...) + // Keep trashing the rest: only items the trash refused + // are offered for permanent deletion (QA-17). + trashFailed = append(trashFailed, sourcePath) + if firstErr == nil { + firstErr = fmt.Errorf("%s %s: %w", verb, sourcePath, err) } - m.archiveProgress <- done - return } m.archiveProgress <- archiveProgressMsg{ @@ -5330,6 +5343,8 @@ func (m *Model) startDeleteJob(kind fileOpKind, sources []string) tea.Cmd { m.archiveProgress <- archiveDoneMsg{ jobID: jobID, sourcePaths: append([]string(nil), sources...), + err: firstErr, + trashFailed: trashFailed, } }() return nil @@ -5452,8 +5467,10 @@ func copyCursorMemory(src map[string]string) map[string]string { func applySession(m *Model) { s, err := config.LoadSession() if err != nil { + // A session read from the old location is still applied when moving + // it to the state dir fails (QA-16); the error goes to the status. log.Printf("[SESSION] load failed: %v", err) - return + m.status = fmt.Sprintf("Session error: %v", err) } if s.ActivePane == "" && s.Left.Path == "" && s.Right.Path == "" { log.Printf("[SESSION] no previous session found") @@ -6402,6 +6419,8 @@ func (m *Model) startRemoteDeleteJob(sources []string, client *remote.SSHClient) func() tea.Msg { go func() { defer client.Release() + var trashFailed []string + var firstErr error for i, sourcePath := range sources { select { case <-ctx.Done(): @@ -6439,6 +6458,8 @@ func (m *Model) startRemoteDeleteJob(sources []string, client *remote.SSHClient) m.archiveProgress <- archiveDoneMsg{ jobID: jobID, sourcePaths: append([]string(nil), sources...), + err: firstErr, + trashFailed: trashFailed, } }() return nil diff --git a/internal/ui/qa_rc2_test.go b/internal/ui/qa_rc2_test.go index 71a9cf9..3e43dc9 100644 --- a/internal/ui/qa_rc2_test.go +++ b/internal/ui/qa_rc2_test.go @@ -143,7 +143,6 @@ func TestQAOldSessionMigratedThroughUI(t *testing.T) { // old session is read but not applied, because applySession drops the // session whenever Load returns an error. func TestQAOldSessionRestoredWhenStateDirReadOnly(t *testing.T) { - t.Skip("BUG QA-16 (P2): if migrating the session to an unwritable state dir fails, state.Load returns the old session with an error and ui.applySession (model.go:5453-5457) discards it: panes are not restored") if os.Geteuid() == 0 { t.Skip("root ignores permissions") } @@ -183,7 +182,6 @@ func newTestModelKeepEnv(t *testing.T, left, right string) Model { // item may be offered for permanent deletion; the ordinary file belongs in // the trash. func TestQATrashOfferOnlyForRefusedItems(t *testing.T) { - t.Skip("BUG QA-17 (P2): when the trash refuses one item, the permanent-delete offer covers it AND every later selected item, which the trash would have accepted (model.go:5314: trashFailed = sources[i:]); confirming deletes them irrecoverably") dir := t.TempDir() long := strings.Repeat("a", 250) // + ".trashinfo" > NAME_MAX writeFile(t, filepath.Join(dir, long), "x") @@ -235,7 +233,6 @@ func TestQATrashLongNameOffered(t *testing.T) { // directory: it stays "read-only" on the real filesystem, can never leave // the archive (root is the temp dir) and the temp dir lingers. func TestQAMirrorIntoArchivePane(t *testing.T) { - t.Skip("BUG QA-18 (P2, since v0.2.7): mirror (p) into a pane that is inside an archive sets its path to a real directory but keeps the archive mount: the pane treats the real filesystem as a read-only archive and Backspace never closes the archive (model.go:2667-2669, handleMirrorPane local branch only clears remote mounts)") dir := t.TempDir() writeFile(t, filepath.Join(dir, "inner.txt"), "in") if err := vfs.CreateArchive(context.Background(), []string{filepath.Join(dir, "inner.txt")}, filepath.Join(dir, "box.zip"), nil); err != nil { @@ -326,7 +323,6 @@ func TestQARemoteMkdirVariants(t *testing.T) { // ...)", but the theme selector overwrites the status with "Theme: X" right // after, so a theme that was not persisted looks saved. func TestQAThemeSaveFailureVisible(t *testing.T) { - t.Skip("BUG QA-19 (P2): theme selector overwrites finalizeTheme's \"save failed\" status with \"Theme: X\" (model.go:1645-1648): a theme that was not saved looks saved") isolateEnv(t) dir := t.TempDir() writeFile(t, userConfig(t), "[ui]\nicon_mode = \n")