TUI: restore hook-visible /new resets#49945
Conversation
Greptile SummaryThis PR restores hook-visible Key changes:
Confidence Score: 5/5
Last reviewed commit: "TUI: restore /new ho..." |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 37d84d03f8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b62dde6f7a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| target.canonicalKey ?? params.key, | ||
| { | ||
| sessionEntry: entry, | ||
| previousSessionEntry: entry, | ||
| sessionEntry: hookSourceEntry, | ||
| previousSessionEntry: hookSourceEntry, |
There was a problem hiding this comment.
Avoid logging
/new hooks under the fresh tui-* key
In the TUI /new flow, hookSourceKey now makes previousSessionEntry point at the session being left, but the emitted hook still uses sessionKey=target.canonicalKey. Bundled hooks such as src/hooks/bundled/command-logger/handler.ts:52-59 and src/hooks/bundled/session-memory/handler.ts:221-235 treat event.sessionKey as the conversation being archived, so installs with those hooks enabled will now record the old transcript under the brand-new tui-* key instead of the session that actually ended.
Useful? React with 👍 / 👎.
| // to other connected TUI clients sharing the original session key. | ||
| const uniqueKey = `tui-${randomUUID()}`; | ||
| const nextSessionKey = `agent:${normalizeAgentId(state.currentAgentId)}:${uniqueKey}`; | ||
| await client.resetSession(nextSessionKey, "new", state.currentSessionKey); |
There was a problem hiding this comment.
Skip creating a persisted session row before the user sends anything
Calling sessions.reset on a brand-new tui-* key means /new now writes a fresh SessionEntry immediately, even though no message was ever sent on that session. performGatewaySessionReset always persists a new entry for the requested key, and src/gateway/session-utils.ts:868-976 lists every store row, so repeatedly pressing /new will leave behind blank tui-* sessions that clutter the session picker/history. Before this change, /new only switched the local key and did not persist an empty session.
Useful? React with 👍 / 👎.
|
Codex review: needs changes before merge. Summary Reproducibility: yes. by source inspection. Current main's TUI Next step before merge Security Review findings
Review detailsBest possible solution: Preserve isolated TUI Do we have a high-confidence way to reproduce the issue? Yes, by source inspection. Current main's TUI Is this the best way to solve the issue? No. Calling Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 103cdd9d96f8. |
Summary
Describe the problem and fix in 2–5 bullets:
#49918reported that TUI/newstopped emitting hook-visiblecommand:newbehavior after the per-client session isolation change.command-loggerandsession-memorysilently stop running for TUI/new, even though users still expect a normal fresh-session reset./newnow resets the newly allocated per-clienttui-<uuid>session throughsessions.reset(reason="new")before switching the TUI to that unique key, and the command-handler test now locks that route in./resetbehavior stays in-place on the current session, and TUI session isolation still uses unique per-client keys.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
TUI
/newonce again emits the same hook-visible reset path as other reset flows, while still creating an isolatedtui-<uuid>session for the current TUI client.Security Impact (required)
Yes/No) NoYes/No) NoYes/No) NoYes/No) NoYes/No) NoYes, explain risk + mitigation:Repro + Verification
Environment
Steps
command:new.openclaw tuiand run/new.sessions.reset(reason="new")or only switches local session state.Expected
/newkeeps the isolatedtui-<uuid>behavior and still emits the standard hook-visiblecommand:newreset path.Actual
/newonly called localsetSession(uniqueKey)and skipped the gateway reset path entirely.Evidence
Attach at least one:
Verification commands run locally:
pnpm test -- src/tui/tui-command-handlers.test.tspnpm test -- src/gateway/server.sessions.gateway-server-sessions-a.test.ts -t 'sessions.reset emits internal command hook with reason'pnpm exec oxfmt --check src/tui/tui-command-handlers.ts src/tui/tui-command-handlers.test.tspnpm exec oxlint src/tui/tui-command-handlers.ts src/tui/tui-command-handlers.test.tsHuman Verification (required)
What you personally verified (not just CI), and how:
/newnow routes through gateway reset with reasonnew,/resetstill resets the shared current session, and existing gateway coverage still confirms thatsessions.reset(reason="new")emits the internal command hook.agent:main:tui-<uuid>session key generation for/newand preserved/resetbehavior.Review Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
Yes/No) YesYes/No) NoYes/No) NoFailure Recovery (if this breaks)
37d84d03f8src/tui/tui-command-handlers.ts,src/tui/tui-command-handlers.test.ts,CHANGELOG.md/newno longer emitting hook-visible resets, or TUI/newfalling back to the shared main session instead of a uniquetui-<uuid>keyRisks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write
None./newcould accidentally stop isolating the TUI client if the canonical unique key routing regresses.tui-<uuid>session handoff and the gateway reset call shape.