Create a session in a chosen folder #9

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

Context

Ctrl+Shift+T, and New Session in the New menu, call new_session
add_session in crates/terminalko/src/window.rs:

let folder = self
    .selected_session_id()
    .and_then(|id| self.store().folder_of(&id))
    .map(|folder| folder.id().to_owned());

self.store().create_session(folder.as_deref(), name)

So a new session joins the folder of whatever is selected, and lands unfiled
when nothing is selected or the selection is unfiled.

The gap

There is no way to say which folder a new session should go in. With a session in
Work selected, a new session cannot be created in Personal without creating it
and then moving it — and moving between folders is itself only possible after
issue #7.

Approach

Two additions, both small once #6's per-section menus exist:

  1. From a folder's own menu. adw::SidebarSection::set_menu_model allows a
    menu per section, and because it is built per section the folder id can be
    baked into the action target: win.session-new-in(folder_id). This is the
    natural place — right-click Work, New Session Here.
  2. From the New menu, a New Session in ▸ submenu listing folders, for
    people who reach for the header bar rather than a right-click. The New menu is
    already rebuilt from code (rebuild_new_menu), so adding a submenu of folders
    is a few lines.

Keep the existing behaviour for the plain Ctrl+Shift+T: following the selection
is right when no folder is named.

Acceptance criteria

  • A session can be created directly in a named folder, from a folder's context
    menu and from the New menu, and it appears in that folder immediately and after
    a restart.
  • Ctrl+Shift+T still creates a session beside the selection.
  • Creating a session in a folder selects and opens it, as creating one does today.
  • The New menu's folder list reflects folders created or deleted since the window
    opened.
  • ./build-aux/ci.sh and ./build-aux/smoke.sh pass.

Notes

  • Depends on nothing, but overlaps issue #6: do that one first and this becomes
    mostly a menu entry.
  • BSD-2 rules in CONTRIBUTING.md apply.
## Context `Ctrl+Shift+T`, and *New Session* in the New menu, call `new_session` → `add_session` in `crates/terminalko/src/window.rs`: ```rust let folder = self .selected_session_id() .and_then(|id| self.store().folder_of(&id)) .map(|folder| folder.id().to_owned()); self.store().create_session(folder.as_deref(), name) ``` So a new session joins the folder of whatever is **selected**, and lands unfiled when nothing is selected or the selection is unfiled. ## The gap There is no way to say which folder a new session should go in. With a session in *Work* selected, a new session cannot be created in *Personal* without creating it and then moving it — and moving between folders is itself only possible after issue #7. ## Approach Two additions, both small once #6's per-section menus exist: 1. **From a folder's own menu.** `adw::SidebarSection::set_menu_model` allows a menu per section, and because it is built per section the folder id can be baked into the action target: `win.session-new-in(folder_id)`. This is the natural place — right-click *Work*, *New Session Here*. 2. **From the New menu**, a *New Session in ▸* submenu listing folders, for people who reach for the header bar rather than a right-click. The New menu is already rebuilt from code (`rebuild_new_menu`), so adding a submenu of folders is a few lines. Keep the existing behaviour for the plain `Ctrl+Shift+T`: following the selection is right when no folder is named. ## Acceptance criteria - A session can be created directly in a named folder, from a folder's context menu and from the New menu, and it appears in that folder immediately and after a restart. - `Ctrl+Shift+T` still creates a session beside the selection. - Creating a session in a folder selects and opens it, as creating one does today. - The New menu's folder list reflects folders created or deleted since the window opened. - `./build-aux/ci.sh` and `./build-aux/smoke.sh` pass. ## Notes - Depends on nothing, but overlaps issue #6: do that one first and this becomes mostly a menu entry. - 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#9
No description provided.