Repository navigation
fix(cli): Resolve a reused Local session name to its newest open session - #2435
Conversation
Every `local run --session web` creates a new session, so after two runs `web` matched two sessions and every lookup by that name failed with "matches more than one session", even when the older run had closed. The session store now resolves a name to its newest open session, or to its newest session when none is open; session IDs still resolve exactly. When several open sessions share the name, control responses name the chosen session and the others in a header, and the CLI prints one stderr note with each other session's ID, state, and age. The CLI still reports an older daemon's 409 for a shared name as a user error. Co-Authored-By: Aditya Mathur <57684218+MathurAditya724@users.noreply.github.com>
Co-Authored-By: Aditya Mathur <57684218+MathurAditya724@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Reads by a name that several open sessions share still use the newest, but close, reset, and retention changes now answer 409 ambiguous_session with each match's state and age, so a second `session close <name>` cannot close a live run in another terminal. The CLI lists them as hints. The choice header now names at most five other sessions plus a `more` count, so a pile of runs that were killed and never closed cannot push it past fetch's header limit. Each route resolves its session once, the note also prints on error responses and only once per session, and the header name lives in the session store instead of the Hono app module. Co-Authored-By: Aditya Mathur <57684218+MathurAditya724@users.noreply.github.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ea9be5d. Configure here.
Viewer UI actions authenticate with the session's stream capability, not the control token, so the ambiguous-name 409 now lists the matching sessions only for control clients, as the read-side choice header does.
|
Review update: #2432 and #2433 are now on main. A merge preview for this exact head conflicts in packages/cli/src/commands/local/control-plane.ts, around session ingest. Please rebase on current main and preserve both the new ID-pinned session selection and #2432’s structured HTTP 200/JSON acknowledgement (including recordActivity on accepted outcomes). I am testing the session-store/control-plane/management behavior separately, but this PR needs a conflict-free updated head before it can be retested and merged. |
Keep #2432's 200 JSON acknowledgement for session ingest, recording activity only for accepted envelopes, on the session ID resolved once at the top of the handler. Co-Authored-By: Aditya Mathur <57684218+MathurAditya724@users.noreply.github.com>
Co-Authored-By: Aditya Mathur <57684218+MathurAditya724@users.noreply.github.com>
|
Fixed the conflict. Both changes are kept: ingest still pins the session ID once at the top, and it now uses #2432's 200 JSON ack, recording activity only for accepted envelopes. I merged main in instead of rebasing, so the existing history stays as it was. #2434 came in clean in the same pass. Ready to retest. |
MathurAditya724
left a comment
There was a problem hiding this comment.
Reviewed b578e8f integrated with current main after #2430. Checked deterministic newest-open selection, retained fallback, ID-pinned async routes, capability isolation, bounded choice headers, and ambiguous-write protection. The rebase preserves the accepted-ingest response and activity behavior.
Full workspace tsc, lint and test passed. Independent real daemon/CLI testing passed 13 scenarios: repeated-name reads, all three ambiguous mutations, exact-ID reads, selecting the next open session after close, and newest-retained fallback. No remaining actionable findings.

Every
sentry local run --session webcreates a new session, so after the second run the namewebmatched two sessions and every lookup by name failed, even when the first run had already finished. Agents restart dev servers all the time, so this came up a lot.Now reading by name just works. A name picks its open session, or the newest one if none is open. If several are open, reads use the newest and print one short note saying which one, with the others' IDs and ages. Session IDs work exactly as before.
Changing a session by name is stricter, because guessing wrong there can close someone's live run in another terminal.
session close, reset and retention refuse a name that several open sessions share and list them with their state and age, so you can pick by ID. With only one open session under that name, closing by name still works.Before:
After:
This lives in the one place in the daemon that already resolves session names, so
event list,event view,session view,session closeand the other session routes all follow the same rule. The note names at most five other sessions plus a count, so a pile of runs that were killed and never closed can't make it huge. A daemon started by an older CLI still returns its old error for any shared name, and the CLI still reports that as a normal user error. The--sessiondocs and the Local design rules now describe how names resolve.Possible follow-up:
run --sessioncould reuse a session that is still open under the same name instead of creating a new one each run. This PR doesn't change that.via @MathurAditya724.
--
View Session [Sentry]