Move a session to another folder from the menu #7

Open
opened 2026-08-19 23:55:18 +00:00 by dusan · 0 comments
Owner

Context

Membership lives in exactly one place: each folder's sessions list key, with
scratch-sessions for unfiled sessions
(docs/spec/session-model.md). The model exposes:

Store::move_session(&self, id: &str, folder: Option<&str>, position: usize)
Store::shift_session(&self, id: &str, delta: isize) -> bool

Both are unit-tested, including moving between folders and clamping a position
past the end.

The gap

The sidebar's context menu offers only Move Up and Move Down, which call
shift_session and therefore move a session within the list it is already in.
There is no way to move a session into another folder, or out of one to
Scratch, from the UI. move_session's cross-folder path is reachable only from
tests.

Dragging a row would also do it, but that needs the sidebar replaced with a
hand-built list — see issue #1. This issue is the menu, which is worth having
regardless: a keyboard user should not need to drag anything.

Approach

Add a Move to folder ▸ submenu to the session context menu, built in
session_menu() in crates/terminalko/src/window.rs. It has to be built per
row rather than once, because it needs the target folder and the session:

  • the menu is already built per row — connect_setup_menu stores the session in
    imp.menu_target — so the action can take just the folder id and act on
    target_session(), exactly as session-colour does today;
  • action win.session-move-to(folder_id), where an empty string means Scratch;
  • the session's current folder should be marked or omitted, so the menu does not
    offer a move that does nothing.

Position: appending to the end of the target list is the obvious behaviour
(move_session(id, folder, usize::MAX) clamps).

Acceptance criteria

  • A session can be moved into any folder and out to Scratch from its context
    menu, and the new place survives a restart.
  • Moving a session whose page is open does not close the page, stop the
    session, or lose its selection — membership is the only thing that changes.
  • The session's accent updates if it inherits one from a folder and the folder
    changes.
  • The menu does not offer the folder the session is already in.
  • ./build-aux/ci.sh and ./build-aux/smoke.sh pass; docs/spec/session-sidebar.md
    mentions the submenu.

Notes

  • Store::move_session already detaches from wherever the session was, so no
    bookkeeping is needed beyond calling it and rebuilding the sidebar.
  • BSD-2 rules in CONTRIBUTING.md apply.
## Context Membership lives in exactly one place: each folder's `sessions` list key, with `scratch-sessions` for unfiled sessions (`docs/spec/session-model.md`). The model exposes: ```rust Store::move_session(&self, id: &str, folder: Option<&str>, position: usize) Store::shift_session(&self, id: &str, delta: isize) -> bool ``` Both are unit-tested, including moving between folders and clamping a position past the end. ## The gap The sidebar's context menu offers only **Move Up** and **Move Down**, which call `shift_session` and therefore move a session *within* the list it is already in. There is no way to move a session **into another folder**, or out of one to *Scratch*, from the UI. `move_session`'s cross-folder path is reachable only from tests. Dragging a row would also do it, but that needs the sidebar replaced with a hand-built list — see issue #1. This issue is the menu, which is worth having regardless: a keyboard user should not need to drag anything. ## Approach Add a **Move to folder ▸** submenu to the session context menu, built in `session_menu()` in `crates/terminalko/src/window.rs`. It has to be built per row rather than once, because it needs the target folder *and* the session: * the menu is already built per row — `connect_setup_menu` stores the session in `imp.menu_target` — so the action can take just the folder id and act on `target_session()`, exactly as `session-colour` does today; * action `win.session-move-to(folder_id)`, where an empty string means *Scratch*; * the session's current folder should be marked or omitted, so the menu does not offer a move that does nothing. Position: appending to the end of the target list is the obvious behaviour (`move_session(id, folder, usize::MAX)` clamps). ## Acceptance criteria - A session can be moved into any folder and out to *Scratch* from its context menu, and the new place survives a restart. - Moving a session whose page is open does **not** close the page, stop the session, or lose its selection — membership is the only thing that changes. - The session's accent updates if it inherits one from a folder and the folder changes. - The menu does not offer the folder the session is already in. - `./build-aux/ci.sh` and `./build-aux/smoke.sh` pass; `docs/spec/session-sidebar.md` mentions the submenu. ## Notes - `Store::move_session` already detaches from wherever the session was, so no bookkeeping is needed beyond calling it and rebuilding the sidebar. - BSD-2 rules in `CONTRIBUTING.md` apply.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dusan/terminalko#7
No description provided.