Repository navigation
fix(native-chat): auto-rename the workspace on a structured chat's first turn - #19138
Conversation
…rst turn Structured native chat (Claude and Codex) never reached the first-work workspace rename. The orchestrator has a single production caller, the agent-hook server listener, and structured sessions never set ORCA_PANE_KEY, so no hook event could ever be attributed to one. The renderer knew this and suppressed pendingFirstAgentMessageRename for structured launches at three sites, which also closed the gate the folder-workspace title rename depends on. The host's status feed already computes the exact edge: status 'working' with a latestPrompt normalized the same way the hook payload is, and a workspaceId that IS the worktree id. Publish that projection to the host, thread it out to the runtime, and hand it to the same orchestrator the hook path uses. Re-projections of state the host already knew (restore, an arriving subscriber) are flagged as replays and map to the orchestrator's existing isReplay gate, so a host restart cannot rename off a stale journal. One host and one journal serve both providers, so this covers Claude and Codex together. Verified in a live Electron instance, worktrees created through the real composer and prompts sent through the real chat composer: Codex langouste -> retry-helper-exponential-backoff Claude prowfish -> parse-csv-headers
|
Warning Review limit reachedNext included review available in 26 seconds. View limit detailsLimit details: You’ve used all 10 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (7)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (12)
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughStructured native chat now preserves pending first-agent-message rename state during workspace and worktree creation. The status feed publishes projected summaries to an optional observer and marks replayed projections. Runtime wiring connects the observer to a structured-session rename hook. The hook renames working sessions using the workspace ID and ignores replayed or non-working statuses. Lifecycle publishers now use coalescing keys. Tests cover status publication, observer failures, replay handling, rename behavior, and lifecycle settlement. Merge Risk: ⚪ Minimal · up to No concrete merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description gives a detailed explanation of the problem, solution, rationale, verification, and known limitations. However, it omits required template sections, including the linked issue, visual proof or an explicit N/A statement, the Testing checklist, AI Disclosure, Review, Agent skill boundary confirmation, Notes, and the final Checklist. Resolution Add the missing required sections. Include a valid issue reference after ✨ Finishing Touches 💡 2📝 Generate docstrings 💡
⚔️ Resolve merge conflicts 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
ℹ️ Minor suggestions only — the structured-chat rename wiring is correct and the
firstWorkRenameDepsextraction is behavior-preserving. One test-coverage gap inline, plus a retry-cadence note.
Reviewed changes
- Status-feed observer —
onStatusChangedfires per projection change (aftersummariesEqualdedup) with areplayflag that marks restore (onReadable) and arriving-subscriber re-projections so a re-projection of already-known state can't rename on a stale prompt. maybeAutoRenameWorkspaceOnFirstStructuredTurnseam — maps aworkingsummary to the existingmaybeAutoRenameBranchOnFirstWorkorchestrator, resolving the workspace fromsummary.workspaceIdwithpaneKey: ''and no tab resolution.firstWorkRenameDepsextraction — the hook entry point and the new structured seam now share one deps builder; the extracted deps are a mechanical move with no behavioral delta.- Renderer flag pass-through — the three
structuredLaunch ? false : …sites now forwardpendingFirstAgentMessageRename, re-enabling the rename (and the folder-workspace title rename) for structured launches.
ℹ️ Nitpicks
- Retry cadence differs from the TUI path: because the observer only fires on projection change, a transient first-turn
retry-later(e.g. upstream-probe/generation failure) is not retried within the same turn — the creature name sticks until the next turn'sworkingprojection. This is acknowledged in the PR description, but worth knowing it is a structural difference, not just "existing behavior."
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Owning-runtime deps —
maybeAutoRenameWorkspaceOnFirstStructuredTurnno longer reads the desktopmainProcessStatesingletons; it takesFirstWorkBranchRenameDepsas an explicit argument, and the local runtime builds them fromthis.requireStore()+this, so a session renames against the runtime that actually owns it. firstWorkRenameDepsextraction — the deps builder moved out ofbranch-rename-hook.tsintofirst-work-rename-runtime.ts(mechanical, behavior-preserving), now shared by the hook entry point and the structured seam.- Fast-turn coalescing — Claude and Codex turn-lifecycle publishers tag the
runningpublish with aturn-start:<session>:<turn>coalescing key so a completion arriving before the journal drains can no longer coalesce theworkingprojection away under the defaultpublishkey. - Manual-rename guard —
runFolderWorkspaceTitleAutoRenamesnapshots the display name before generation and bails (clearing any stale badge) if the pending marker cleared or the name changed during the async generation.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Grok QA — rendered first-turn auto-rename (SHA
|
Grok QA follow-up correction (SHA
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
isFolderReposhort-circuit inrunAutoRename— a folder-kind repo whose structured session carries a synthetic worktree-shapedworkspaceIdnow bails before any git probe (rev-parse,branch -m, SSH-provider resolution), clearing a stale error badge and settling the id permanently.- Folder-project regression coverage — the structured-seam rename test is parametrized over git-worktree and folder-workspace ids, and a new test pins that a folder project with a synthetic worktree id never touches git, the SSH provider, or name generation.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Final Grok
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the new commit is a merge of main (through 6fd03a7) plus a reconciliation of the PR's structured-chat rename wiring onto the resulting tree.
- Main merge — pulled in the latest
main(provider-activity publish frames, late-dispatch settlement, provider user-echo suppression, sidebar agent-row restore, and the rest of the 196-file delta) without altering the PR's rename behavior. attachContextreworked ontolifetimeContext()— the host's attach context now spreads thelifetimeContext()helper (deps,runtimeState,sessions,now) instead of re-listing them, so the PR'sonStatusChangedwiring andreplaypublish carry through cleanly.summariesEqualwidened — the projection dedup now also comparesmodel,toolName,toolInput, andlastAssistantMessage, so theonStatusChangedobserver fires on the same richer change set the subscribers already saw.- Status-feed tests adapted —
feedForgains arecordfixture and the sink'spublish(activity)signature is distinguished in the fast-turn test, keeping the coalescing-key regression coverage green against the new sink.
Status-feed, codex-settlement, and first-work-rename suites all pass post-merge.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Review/fix loop completed on Four meaningful fixes were pushed:
Synced current Validation: 243 tests across 18 targeted files, full typecheck, changed-code quality and standalone runtime build passed after the merge resolution. After the small host-context reuse, 42 host lifecycle tests, Node typecheck and commit hooks passed. The independent merge reviewer also passed 153 tests. Before/after regressions reproduce the manual-title race, lost fast-turn signal and unwanted folder Git probes. A 100-publication burst retains two journal publications, plus one coalesced Claude activity update from current main; unchanged projections cause no observer fanout. All GitHub checks are green on the final SHA, including the required Grok Electron screenshots and backing-state evidence show real composer submissions renaming Claude and Codex workspaces and preserving a manual name. Those positive runs used Limits: synthetic folder projects never armed first-turn naming; adding that feature is outside this PR. The separate The PR has not been merged. |
…rst turn (stablyai#19138) * fix(native-chat): auto-rename the workspace on a structured chat's first turn Structured native chat (Claude and Codex) never reached the first-work workspace rename. The orchestrator has a single production caller, the agent-hook server listener, and structured sessions never set ORCA_PANE_KEY, so no hook event could ever be attributed to one. The renderer knew this and suppressed pendingFirstAgentMessageRename for structured launches at three sites, which also closed the gate the folder-workspace title rename depends on. The host's status feed already computes the exact edge: status 'working' with a latestPrompt normalized the same way the hook payload is, and a workspaceId that IS the worktree id. Publish that projection to the host, thread it out to the runtime, and hand it to the same orchestrator the hook path uses. Re-projections of state the host already knew (restore, an arriving subscriber) are flagged as replays and map to the orchestrator's existing isReplay gate, so a host restart cannot rename off a stale journal. One host and one journal serve both providers, so this covers Claude and Codex together. Verified in a live Electron instance, worktrees created through the real composer and prompts sent through the real chat composer: Codex langouste -> retry-helper-exponential-backoff Claude prowfish -> parse-csv-headers * fix(native-chat): preserve first-work rename across runtime and queued turns * fix(native-chat): skip branch rename for folder projects --------- Co-authored-by: Merge Sim <sim@local>













What
Structured native chat (Claude and Codex) never got the first-work workspace rename that TUI agents get from their hooks. This wires it up.
Why it was broken — two halves
1. No signal.
maybeAutoRenameBranchOnFirstWorkhas exactly one production caller:maybeAutoRenameBranchOnFirstWorkFromHook, driven by theagentHookServerlistener inmain-window-agent-status.ts. Structured sessions never setORCA_PANE_KEY— only renderer terminal panes do — so no hook event can be attributed to one.2. The renderer had the feature switched off for structured launches. Three
structuredLaunch ? false : …sites suppressedpendingFirstAgentMessageRename, because half 1 meant the "Naming…" card would spin forever. That flag also gates the folder-workspace title rename (runAutoRenamerefuses without it), so fixing only the main-process half would leave folder workspaces broken.The fix
The host's status feed already computes the exact edge:
status: 'working'with alatestPromptrun through the samenormalizePromptField(200 chars, single line) the hook payload gets, and aworkspaceIdthat is the worktree id — folder workspaces included. So the generated name has parity with the TUI path.StructuredAgentSessionStatusFeed.onStatusChanged→StructuredAgentSessionHost.onSessionStatusChanged→ runtime dep →maybeAutoRenameWorkspaceOnFirstStructuredTurn(new export inbranch-rename-hook.ts, which now shares one deps builder with the hook entry point).Both providers run through one host and one journal, so this covers Claude and Codex together.
Replay flag is load-bearing
statusFeed.publishis also called on restore (onReadable) and on subscriber arrival. Both now pass{ replay: true }, mapping to the orchestrator's existingisReplaygate. Without it, a host restart re-fires "working" off a stale journal and renames on an old prompt.Verification
Live Electron instance (isolated profile, private renderer port), worktrees created through the real Create-worktree composer with a blank name, prompts sent through the real chat composer:
langousteretry-helper-exponential-backoff, sidebar "Retry helper exponential backoff"prowfishparse-csv-headers, sidebar "Parse csv headers"git rev-parse --abbrev-ref HEADin each worktree confirms the branches moved on disk. Main process logged[auto-branch-rename] renamed …for both.pendingFirstAgentMessageRenameistrueat create on this branch (it isfalseonmain) and cleared on rename.The model call at the very end of name generation was pointed at a deterministic script in the rig (a supported "custom agent command" setting) because the rig lacked
CODEX_LB_API_KEY. Everything else — status edge, worktree resolution, creature-branch gate, upstream probe,git branch -m, sidebar update — was real, and that final stretch is untouched by this diff.Also observed: a
retry-laterverdict does not settle the worktree, so the next turn re-fires the rename. That is existing behavior and it worked as intended.Checks
pnpm tcclean · changed-code quality gate clean (all three gates) · new unit tests for the feed observer contract and the structured seam.Two suites in
agent-session-wire/flake under parallel load (different files failed on each run, one a timing test); they pass individually and are unrelated to this change.