Skip to content

feat(hosts): return to the previous page and folder after the last terminal closes - #660

Merged
kipavy merged 2 commits into
devfrom
feat/hosts-folder-context-654
Oct 19, 2026
Merged

kipavy merged 2 commits into
devfrom
feat/hosts-folder-context-654

Conversation

@kipavy

@kipavy kipavy commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Closes #654

Problem

Closing the last terminal (with exit or by closing the tab) switches back to the Hosts page, which remounts and resets its folder path to the root. Users with nested folders had to click back down after every session.

Change

  • useFolderNavigation takes an optional rememberAs key and keeps the open folder in memory for the app session. Every caller passes its folder object type, so Hosts, Snippets, Keychain and Port Forwarding (desktop and mobile) reopen in the folder the user left.
  • Only the open folder id is stored. The breadcrumb is derived from that folder's ancestors, so a folder renamed or moved (e.g. by sync from another device) while a terminal was open restores under its current name and parent.
  • A folder that was deleted or is no longer in scope (vault switched, access lost) falls back to the root, as before.
  • The four mobile screens' copied setFolderPath((p) => p.slice(0, -1)) back handlers are replaced by a shared navigateUp.

Return to the previous page

  • The UI store keeps lastPageNav, the last page shown before the terminal view. leaveTerminal() goes back to it, but only while the terminal view is showing.
  • Both "last session gone" paths use it: the TitleBar guard (exit) and closeSessionTabs / split-tab close. Before, closing the last tab from Snippets or Keychain pulled the user to Hosts; now they stay where they are.
  • Hosts remains the fallback. Closing a terminal while others remain still activates another session (unchanged).

Side effect: switching between pages (Hosts → Snippets → Hosts) also keeps the folder. The memory does not survive an app restart.

Tests

  • New useFolderNavigation tests: restore after remount, deleted folder falls back to root, memory is per key and off without a key, renamed folder shows its current name, moved folder restores under its new parent, a parent cycle does not loop, navigateUp.
  • New uiStore.leaveTerminal tests: back to the previous page, stays on another page, members shortcuts count, Hosts fallback.
  • tsc --noEmit clean; layout / useKeyboard / store suites pass; hosts / snippets / keychain / port forwarding / mobile / hooks / utils test suites pass.
  • Not checked in the live app: the headless app container was unavailable.

Closing the last terminal remounts the Hosts page, which reset its folder
path to the root. Folder navigation now remembers the open folder per
object type for the app session, so Hosts, Snippets, Keychain and Port
Forwarding (desktop and mobile) reopen where the user left them.

Only the open folder id is kept; the breadcrumb is derived from its
ancestors, so a folder renamed or moved meanwhile restores under its
current name and parent, and a deleted or out-of-scope one falls back
to the root. Mobile back handling uses a shared navigateUp.

Closes #654
Closing the last terminal always switched to Hosts, and closing the last
tab from another page (Snippets, Keychain, ...) pulled the user to Hosts
too. The UI store now remembers the last page shown before the terminal
view, and leaveTerminal() goes back to it only when the terminal view is
showing. Hosts remains the fallback. Closing a terminal while others
remain still activates another session, unchanged.
@kipavy kipavy changed the title feat(hosts): return to the open folder after the last terminal closes feat(hosts): return to the previous page and folder after the last terminal closes Oct 19, 2026
@kipavy
kipavy merged commit c6bf832 into dev Oct 19, 2026
5 checks passed
@kipavy
kipavy deleted the feat/hosts-folder-context-654 branch October 19, 2026 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant