Repository navigation
Create sessions unnamed; name them from the first prompt - #697
Merged
Merged
Conversation
CreateSession now selects authoritatively, so the TUI's roster-diff selection leg could mis-pick in the 128-event window and is removed. The follow-up only adopts focus, and only for the session the supervisor already made selected. Also update the /resume title fixture: it now shares the session naming rule instead of echoing the raw first message. refs: 2cce550, 5845d38
CI builds the PR merge commit, not the branch head. main still carried the inline composer for `n`, so the merge produced a tree where types.rs had the field removed and input.rs/tests still used it. That is what #697 was failing on, not the branch itself. - drop the `navigator_new_session` guard main added to the Up-to-tab-row path; with the inline composer gone, an open peek is the only prior owner of Up - rewrite the two tests that asserted the composer buffer: `n` at the strip is now a session verb, and the tab row swallows it as a bare key
mohitranka
force-pushed
the
feat/unnamed-session-creation
branch
from
September 15, 2026 07:52
e087fe0 to
ac61615
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Starting a session is currently a prompt-first act:
nopens an inline composer on the Sessions tab, and the text typed there is submitted asCreateSession { label: "", first_prompt: Some(text) }. That one string both creates the session and names it, so there is no way to open a session's panes and then decide what to ask. The session does not exist until you have already decided.This reorders that:
nallocates the session and its worktree immediately, selects it, and puts the cursor in the composer. The name arrives from the first prompt submitted in that composer.Approach
Most of the machinery for this already existed and is reused rather than rebuilt:
render.rsalready synthesizessession 1/session 2for an empty label at render time, andsession_title_hintalready falls back for/resume. Nothing new is persisted to show a temporary name, and no UUID is invented — a persisted placeholder would have deleted that behavior.supervisor.rs). That is why the trust modal needs no change here: it fires onfirst_prompt.is_some() && !already_trusted, and managed worktrees already inherit trust by the ancestor walk inis_trusted_at.SubmitPromptrenames before enqueueing and before starting the driver, so by the timematerialize_managed_branchruns at the end of turn 1, the label is set and the branch gets a real name. No ordering change was needed — only the discipline of keeping the rename on submit.The one substantive naming change:
title_from_promptnow emits lowercase kebab-case capped at 4 normalized tokens, and is documented as not display-only, which its old doc comment wrongly claimed (unique_session_branchalready readtask.labelintoforge/<slug>).User-visible changes
Rewrite the lexerbecomesrewrite-the-lexer. This is deliberate — it makes the navigator row and the branch name the same string by construction, and it is the only way the invariant can be exact.ncreates a session and focuses its composer instead of opening an inline task buffer./resumerows now agree with the navigator instead of echoing the raw truncated first message.--help failspreviously produced the branchforge/-help-fails;trim_matches('-')only stripped the ends, so the leading-survived. It is nowhelp-fails.Safety implications
nshould not put a modal in front of an operator who is not expecting one.CreateSessionnow selects before thefirst_prompt.is_some() && !already_trustedbranch, because the overlay only opens when the new session is already selected; selecting afterwards would make the modal unreachable for the one case it still exists for.rollback_creationclears a selection naming the rolled-back session. Selecting before trust is confirmed means a cancelled creation would otherwise leave durable state pointing at a removed row.sanitize_labelis untouched. It remains the../and ref-reserved-character boundary, and it still guards the subagent label path (create_worktree), whose labels are model-authored and do not get the 4-word rule.set_selectedwrites onlyrepository_state.selected_session_id;ownership,slotandlifecyclelive on thesessionsrow.Validation
cargo test --package forge-types --locked title_from_prompt→ 6 passedcargo test --package forge-core --locked session_title_hint→ 2 passedcargo test --package forge-storage --locked sanitize_label→ 1 passedcargo test --package forge-session --locked create→ 2 passed, including a new ordering regression test asserting a prompt-less session ends up with labelfix-the-login-bugand branchforge/fix-the-login-bugcargo test --package forge-session --locked trust→ 6 passedcargo test --package forge-tui --locked multi_task→ 30 passed, including the newn_allocates_an_unnamed_session_and_hands_the_cursor_to_its_composercargo check --package forge-tui --all-targets --locked→ cleancargo fmt --all -- --check→ clean for every touched crateNot run, and called out per CONTRIBUTING:
cargo test --workspace/clippy --workspacewere not run (AGENTS.md forbids the full suite, and a shared volume hit 100% during development). One pre-existing environmental failure remains inforge-session:primary_and_managed_actors_share_hitl_question_and_continue_commandsfails withsandbox-exec: sandbox_apply: Operation not permittedbecause the test's own nested sandbox cannot start inside an already-sandboxed host. It does not touchCreateSession, and it fails at the sandbox call before any of this code runs.Known limits
sanitize_labeltruncates to 40 whileTITLE_MAX_CHARSis 60, so a name that is a single very long token is shortened on the way into Git and the two diverge. Ordinary prompts are far under 40 tokens-wise, so this is unreachable in practice, but it is a real hole in the "one value, never two" property. Closing it means aligning the two caps, which crosses into theforge-storagesecurity bound.forge/untitled-sessionis now reachable in a way it was not before: a first prompt that normalizes to nothing, or a turn that writes a file before any valid name exists, can produce that branch name permanently, sinceset_session_branchis one-way.AttachWorktreestill registers without selecting — same class of bug as the one fixed here, deliberately out of scope.nbinding's behavior and lowercase session names in the navigator, task strip and/resume.Design doc
docs/unnamed-session-creation-plan.mdis the decision record: the frozen contract, what already worked and must not be "fixed", the hazards, and the limits above.FORGE-DESIGN.md§7.7 and §12 are updated in-tree.