Skip to content

feat(session): add named new and close chat commands - #95700

Closed
BSG2000 wants to merge 19 commits into
openclaw:mainfrom
BSG2000:feat/named-session-chat-commands
Closed

BSG2000 wants to merge 19 commits into
openclaw:mainfrom
BSG2000:feat/named-session-chat-commands

Conversation

@BSG2000

@BSG2000 BSG2000 commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Users can name sessions with /name, but starting a new named session from chat required an extra step. Chat users also had no direct command to close/archive the current non-main session, leaving session cleanup dependent on UI surfaces or backend tools.

Why This Change Was Made

This PR extends session-management slash commands so /new can create a freshly reset, named session with explicit name syntax while preserving the existing /new <model> and post-reset prompt fallthrough behavior. It also adds /close and /delete for archiving the current non-main session through the gateway session lifecycle.

User Impact

  • /new Beispielsessionname, /new --name Beispielsessionname, /new name:Beispielsessionname, and quoted /new "Planning notes" can start a fresh named session.
  • Existing model forms such as /new gpt-5.5, /new opus, and native provider/model values keep falling through to model selection.
  • /close and /delete archive the active non-main session from chat, but refuse main sessions and require operator.admin for internal gateway clients.

Related

Evidence

  • pnpm exec oxfmt --check src/auto-reply/reply/commands-delete-session.ts src/auto-reply/reply/commands-delete-session.test.ts src/auto-reply/reply/commands-reset.ts src/auto-reply/reply/commands-reset-hooks.test.ts
  • pnpm exec vitest run src/auto-reply/reply/commands-delete-session.test.ts src/auto-reply/reply/commands-reset-hooks.test.ts src/auto-reply/reply/commands-name.test.ts — 37 tests passed
  • pnpm tsgo:core:test

AI Assistance

AI-assisted with GitHub Copilot CLI. I reviewed the generated changes, resolved addressed Codex review conversations, and validated the touched command surfaces locally.


ClawSweeper chat proof (exact head 066cae5c25)

Isolated gateway built from this PR head (dist/build-info.json commit matches git rev-parse HEAD), fresh state dir, dummy model provider (no secrets), persistent admin-scoped GatewayClient over ws. Transcript below shows the visible chat replies plus the resulting sessions.list state for every command.

== build-info ==
{
  "version": "2026.7.2",
  "commit": "066cae5c2517bba7f01d7066784076d5f40e9bca",
  "builtAt": "2026-07-29T17:51:38.343Z"
}

== git rev-parse HEAD ==
066cae5c2517bba7f01d7066784076d5f40e9bca

connected: role=operator scopes=[operator.admin,…] via ws://127.0.0.1:19099

───── Scene A: named /new + model fallthrough ─────

== sessions.list — before ==

[agent:main:web:proof-naming]
> /new --name ClawSweeper Proof
< ✅ New session started as “ClawSweeper Proof”.

== sessions.list — after `/new --name ClawSweeper Proof` ==
{"key":"agent:main:web:proof-naming","label":"ClawSweeper Proof","sessionId":"69622255-0113-418d-a44c-4064f682c1fd"}

[agent:main:web:proof-naming]
> /new gpt-5.6-luna
< [run error] LLM request failed.

== sessions.list — after `/new gpt-5.6-luna` (model fallthrough — no label hijack) ==
{"key":"agent:main:web:proof-naming","label":"ClawSweeper Proof","sessionId":"69622255-0113-418d-a44c-4064f682c1fd"}

───── Scene B: /close on a non-main session ─────

[agent:main:web:proof-close]
> /new --name Close Target
< ✅ New session started as “Close Target”.

== sessions.list — before `/close` (session agent:main:web:proof-close exists) ==
{"key":"agent:main:web:proof-close","label":"Close Target","sessionId":"dbeddb7f-65be-4db7-94b9-0c7f855f1eff"}
{"key":"agent:main:web:proof-naming","label":"ClawSweeper Proof","sessionId":"69622255-0113-418d-a44c-4064f682c1fd"}

[agent:main:web:proof-close]
> /close
< ✅ Session closed and archived.

== sessions.list — after `/close` (session agent:main:web:proof-close removed) ==
{"key":"agent:main:web:proof-naming","label":"ClawSweeper Proof","sessionId":"69622255-0113-418d-a44c-4064f682c1fd"}

Notes:

  • /new gpt-5.6-luna falls through to a model directive (the [run error] is the dummy provider rejecting inference, which is expected here) — the session label is not hijacked.
  • /close on agent:main:web:proof-close returns its visible confirmation and the session is gone from sessions.list. This works because this head also fixes the admission-handoff deadlock and preserves the initiating reply run during cleanup (see latest commit).

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 619760fe92

ℹ️ 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".

Comment thread src/auto-reply/reply/commands-reset.ts Resolved
@BSG2000

BSG2000 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the two Codex findings in ff8ada9f58:

  • /close and /delete now route through sessions.delete via the gateway RPC instead of calling the low-level store lifecycle directly, so cleanup, active-run handling, bindings, and lifecycle hooks stay centralized.
  • /new now preserves model-looking tails for the existing /new [model] / fallthrough behavior, while native structured CommandArgs.title and explicit name forms (--name, name:, quoted titles) name the new session.

Validation:

  • pnpm exec vitest run src/auto-reply/reply/commands-delete-session.test.ts src/auto-reply/reply/commands-reset-hooks.test.ts src/auto-reply/reply/commands-name.test.ts
  • pnpm exec oxfmt --check --threads=1 src/auto-reply/reply/commands-name.ts src/auto-reply/reply/commands-reset.ts src/auto-reply/reply/commands-delete-session.ts src/auto-reply/reply/commands-delete-session.test.ts src/auto-reply/reply/commands-reset-hooks.test.ts src/auto-reply/commands-registry.shared.ts
  • pnpm tsgo:core:test

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ff8ada9f58

ℹ️ 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".

Comment thread src/auto-reply/reply/commands-reset.ts Resolved
Comment thread src/auto-reply/reply/commands-reset.ts Resolved
@BSG2000

BSG2000 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the latest Codex review items in 9ffb2f2991:

  • /close//delete now require operator.admin for internal gateway clients before deleting sessions.
  • Deletion is blocked for every agent main session key (agent:*:main), not only the default main session.
  • /new now treats configured model aliases such as opus as model-selection fallthrough instead of session titles.
  • Native /new structured title args also fall through when they look like configured model refs.

Validation:

  • pnpm exec oxfmt --check src/auto-reply/reply/commands-delete-session.ts src/auto-reply/reply/commands-delete-session.test.ts src/auto-reply/reply/commands-reset.ts src/auto-reply/reply/commands-reset-hooks.test.ts
  • pnpm exec vitest run src/auto-reply/reply/commands-delete-session.test.ts src/auto-reply/reply/commands-reset-hooks.test.ts src/auto-reply/reply/commands-name.test.ts
  • pnpm tsgo:core:test

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9ffb2f2991

ℹ️ 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".

Comment thread src/auto-reply/reply/commands-reset.ts Resolved
Comment thread src/auto-reply/reply/commands-reset.ts Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jun 22, 2026
@BSG2000

BSG2000 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper please review this PR after the latest Codex follow-ups.

I updated the PR body per CONTRIBUTING with What Problem This Solves / Why / User Impact / Evidence, resolved the addressed Codex threads, and pushed 6c833411fc for the latest native /new and configured-main-session edge cases.

Evidence is in the PR body; latest local checks:

  • pnpm exec oxfmt --check src/auto-reply/reply/commands-delete-session.ts src/auto-reply/reply/commands-delete-session.test.ts src/auto-reply/reply/commands-reset.ts src/auto-reply/reply/commands-reset-hooks.test.ts
  • pnpm exec vitest run src/auto-reply/reply/commands-delete-session.test.ts src/auto-reply/reply/commands-reset-hooks.test.ts src/auto-reply/reply/commands-name.test.ts (37 tests passed)
  • pnpm tsgo:core:test

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. labels Jun 22, 2026
@clawsweeper

clawsweeper Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 15, 2026, 4:54 AM ET / 08:54 UTC (Revision 33).

ClawSweeper review

What this changes

Adds explicit names to new-session chat commands and close/delete commands, with Gateway cleanup handling and Control UI integration.

Merge readiness

⛔ Blocked before merge - 23 items remain

This remains useful, distinct work absent from current main. The latest commit resolves late rename-error publication, but session lifecycle defects, incomplete generation guards, and insufficient current behavior proof still block merge.

Priority: P2
Reviewed head: e1b2ea9f15d08abad5c7d230601534d8bbeb5647
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Positive historical evidence and the latest UI repair do not overcome the remaining lifecycle, generation, and outcome defects.
Proof confidence 🦪 silver shellfish (2/6) Needs stronger real behavior proof before merge: Authority-chain proof required: the historical GatewayClient trace and inspected Telegram images show earlier positive behavior, but not the current deletion drain, Control UI naming, or non-admin and interrupted/released-origin rejection before final deletion. Add current fresh/existing-session evidence and required Control UI before/after screenshots; redacted terminal output and logs count for lifecycle proof. Remove private endpoints, identifiers, and credentials. Updating the PR body should trigger review; otherwise ask a maintainer for @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🧂 unranked krab (1/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: Authority-chain proof required: the historical GatewayClient trace and inspected Telegram images show earlier positive behavior, but not the current deletion drain, Control UI naming, or non-admin and interrupted/released-origin rejection before final deletion. Add current fresh/existing-session evidence and required Control UI before/after screenshots; redacted terminal output and logs count for lifecycle proof. Remove private endpoints, identifiers, and credentials. Updating the PR body should trigger review; otherwise ask a maintainer for @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 10 items Current main still lacks the proposed command behavior: Inspected the fetched main command registry and reset handler. Main supports /name and ordinary /new, but does not register these close/delete commands or implement explicit new-session naming. REST searches for named-session and close-session command PRs found no verified merged replacement.
Latest release retains the existing command contract: The v2026.9.4 command reference documents /new model/prompt behavior and /name, without the proposed naming or close/delete additions. The tag was inspected through GitHub because it was not available locally.
Introduction and review continuity: Verified introduced hunks against the pinned merge base and inspected the exact head's raw parent record. GitHub's commit endpoint confirms the latest commit changes only the board test and session-creation module. Recovered the previous completed review's twelve findings from #95700 (comment). Late rename-error publication is fixed; the generation guard remains incomplete. Some older blobs were unavailable locally, so the latest-commit comparison used GitHub's commit patch. No test-merge removal claims are made.
Findings 12 actionable findings [P1] Preserve the exact initiating reply throughout deletion
[P1] Validate explicit names before committing the reset
[P1] Require the persisted reset generation before naming
Security Needs attention Originating authority is not checked at deletion commit: The handoff replaces admission interruption callbacks, while final deletion checks the nested RPC's authority without checking the adopted origin's liveness. Cancellation and release before final I/O remain materially unproven.
Shared channel replies expose local worktree paths: Preserved-worktree replies include raw filesystem paths and branch names without restricting their audience to an authorized local operator.

How this fits together

Chat commands arrive through channel adapters or the Control UI. Gateway session operations coordinate active replies, stored conversations, and transcript cleanup before returning confirmations and updated session lists.

flowchart TD
A[Channel chat command] --> C[Command parsing and authorization]
B[Control UI command] --> C
C --> D[Gateway session lifecycle]
D --> E[Active replies and admissions]
E --> F[Session and transcript storage]
F --> G[Confirmation and session list]
Loading

Decision needed

Question Recommendation
Should native /new free text become a session title, or should naming require explicit --name/name: syntax across surfaces? Require explicit naming: Preserve existing model and prompt interpretation and remove the parallel implicit-name classifier.

Why: The proposed native behavior changes the established model/prompt contract, while the actual registry still supplies generic raw arguments.

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: Authority-chain proof required: the historical GatewayClient trace and inspected Telegram images show earlier positive behavior, but not the current deletion drain, Control UI naming, or non-admin and interrupted/released-origin rejection before final deletion. Add current fresh/existing-session evidence and required Control UI before/after screenshots; redacted terminal output and logs count for lifecycle proof. Remove private endpoints, identifiers, and credentials. Updating the PR body should trigger review; otherwise ask a maintainer for @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Preserve the exact initiating reply throughout deletion (P1) - The new exemption protects Gateway controllers only. prepareSessionLifecycleDrain still calls replyRunRegistry.abort, abortReplyRunBySessionId, and reply waits for the initiating command; its final active-work check includes that reply too. The subsequent cleanup call also omits preserveActiveReplyRun. A command-only /close therefore cancels or waits on its own confirmation. Carry the exact reply identity through every drain and cleanup layer.
  • Validate explicit names before committing the reset (P1) - get-reply.ts calls initSessionState before this handler, and initialization commits the reset. Consequently /new --name= reports invalid input after changing the conversation. The Control UI parser also treats empty name syntax as ordinary unnamed creation. Validate naming before initialization or creation; the direct-handler tests bypass the destructive ordering.
  • Require the persisted reset generation before naming (P1) - The new named-reset caller awaits hooks before this projection. If the session disappears during that wait, the fallback to params.sessionEntry recreates the deleted row. A later durable reset also retains its session ID, bypassing this ID-only check. Require the persisted row and captured lifecycle revision for named-reset writes rather than seeding stale state.
  • Bind board naming to the authoritative reset result (P1) - The added guard reads currentSessionId from refreshed UI state, while requestSessionReset discards the reset response and clearChatHistory awaits another history read. That state can already describe a successor. Moreover, durable resets retain sessionId, so even a correctly captured ID cannot reject a later reset. Carry the reset result's lifecycle revision through the wrappers and require it on the label patch.
  • Align native naming with the registered argument contract (P2) - The /new definition has acceptsArgs but no title argument. parseCommandArgs therefore supplies CommandArgs.raw, so this read misses real native free-text input despite the new naming documentation. Implement the agreed behavior through the registered parser contract, or document and retain explicit naming only.
  • Preserve unknown deletion outcomes beyond timeouts (P2) - A connection can close after deletion commits, and post-delete unbinding can reject before the response. This timeout-only branch rethrows both cases without the transcript-write block, presenting an unconfirmed deletion as failure and allowing finalization against deleted state. Distinguish confirmed rejection from unknown post-dispatch outcomes and reconcile the original target before suggesting retry.
  • Settle composer payloads after consumed naming failures (P2) - A completed board reset followed by failed naming produces this new uncertain result. The immediate submit path releases attachments and clears owned composer fallback only for completed, while failed/cancelled results use restoration. It does neither for this outcome, retaining payload ownership after the command is consumed. Add settlement without restoring a retryable reset.
  • Confirm naming after the label is persisted (P2) - A routed reset hook suppresses the naming acknowledgment even though the hook ran before the label write and could not know its result. A successful named-new request can therefore produce only generic startup text. Publish the naming result after persistence while preserving intentional delivery suppression.
  • Bind deletion to the Gateway serving the command (P2) - This unqualified callGateway selects its destination again from configuration and environment. If the configured remote target or URL override differs from the serving Gateway, /close reaches another process, invalidates its process-local handoff, and can affect copied session state there. Invoke the serving lifecycle owner or capture and enforce its intended endpoint.
  • Preserve incomplete named-reset outcomes (P2) - When reset returns uncertain, or the pane becomes stale before naming begins, the label patch is skipped but this return reports completion. The named operation is then retired as successful despite an unconfirmed reset or unapplied name. Return a consumed incomplete outcome and retain appropriate recovery feedback.
  • Update remaining callers of the session-creation result contract (P2) - Changing createSession() to string outcomes leaves chat-pane-session-access.test.ts:67,86 expecting false and chat-pane-retained-presentation.test.ts:580 expecting a boolean. Those assertions cannot pass with this implementation. Update the remaining contract consumers while preserving their authorization and navigation checks.
  • Keep local worktree details out of shared channel replies (P2) - When cleanup preserves a worktree, this sends its raw branch and filesystem path to the originating conversation. Channel command authorization does not establish that everyone reading a shared conversation may see operator usernames or private project paths. Return a generic channel warning and reserve details for an authorized local surface. This was missed in the previous review; the command file is unchanged from that head.
  • Resolve security concern: Originating authority is not checked at deletion commit - The handoff replaces admission interruption callbacks, while final deletion checks the nested RPC's authority without checking the adopted origin's liveness. Cancellation and release before final I/O remain materially unproven.
  • Resolve security concern: Shared channel replies expose local worktree paths - Preserved-worktree replies include raw filesystem paths and branch names without restricting their audience to an authorized local operator.
  • Resolve merge risk (P1) - The independently authorized deletion RPC has not demonstrated that cancellation or release of its originating chat authority prevents final storage deletion.
  • Resolve merge risk (P1) - Implementing the advertised implicit native naming would replace existing free-text prompt interpretation without recorded product acceptance.
  • Resolve merge risk (P1) - Historical proof does not cover the current lifecycle composition or fresh and existing Control UI sessions under concurrent resets.
  • Complete next step (P2) - Resolve the findings, settle explicit versus implicit native naming, obtain security-owner involvement, and supply current behavior and final-effect authority proof.
  • Improve patch quality - Repair the complete close initiator lifecycle and resolve the remaining naming and outcome findings.
  • Improve patch quality - Demonstrate current naming and close behavior, including Control UI screenshots and concurrent-reset rejection.
  • Improve patch quality - Prove non-admin rejection and invalidation of interrupted or released originating authority before final deletion.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

  • [P1] Preserve the exact initiating reply throughout deletion — src/gateway/server-methods/sessions-delete.ts:209-212
  • [P1] Validate explicit names before committing the reset — src/auto-reply/reply/commands-reset.ts:510-516
  • [P1] Require the persisted reset generation before naming — src/auto-reply/reply/commands-name.ts:69-82
  • [medium] Originating authority is not checked at deletion commit — src/gateway/server-methods/sessions-delete.ts:85
  • [medium] Shared channel replies expose local worktree paths — src/auto-reply/reply/commands-delete-session.ts:231
Agent review details

Security

Needs attention: The handoff needs originating-authority proof, and shared replies expose local worktree details; no supply-chain change was found.

PR surface

Source +1059, Tests +2577, Docs +4. Total +3640 across 35 files.

View PR surface stats
Area Files Added Removed Net
Source 23 1182 123 +1059
Tests 11 2586 9 +2577
Docs 1 9 5 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 35 3777 137 +3640

Review metrics

Metric Value Why it matters
Gateway request surface 3 optional RPC parameters added The handoff token and two run exemptions expand the externally accepted lifecycle contract.

Mantis proof suggestion

Control UI chat proof would help verify visible naming, selected-session identity, and incomplete reset outcomes. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis verify /new --name in ordinary and board-backed Control UI chats, inspect the resulting session name and selection, and capture redacted before/after screenshots plus diagnostics for failed or interrupted naming.

Merge-risk options

Maintainer options:

  1. Repair lifecycle and generation ownership (recommended)
    Carry exact initiator and reset-generation facts through the existing owners, resolve the findings, and demonstrate current behavior before merging.
  2. Narrow the feature
    Separate explicit naming from destructive close commands if the combined authority and cleanup changes cannot be completed coherently.

Technical review

Best possible solution:

Require explicit naming, validate before reset, and keep naming and deletion with the serving Gateway's lifecycle owner using live initiator authority and authoritative generation-bound results.

Do we have a high-confidence way to reproduce the issue?

Yes for the remaining patch defects: source traces establish self-cancellation, validation after reset, and missing generation checks. These paths were inspected without executing target code.

Is this the best way to solve the issue?

No. Reusing Gateway lifecycle operations is appropriate, but the current composition does not preserve initiator, generation, and outcome ownership; explicit naming would also avoid a competing model classifier.

Full review comments:

  • [P1] Preserve the exact initiating reply throughout deletion — src/gateway/server-methods/sessions-delete.ts:209-212
    The new exemption protects Gateway controllers only. prepareSessionLifecycleDrain still calls replyRunRegistry.abort, abortReplyRunBySessionId, and reply waits for the initiating command; its final active-work check includes that reply too. The subsequent cleanup call also omits preserveActiveReplyRun. A command-only /close therefore cancels or waits on its own confirmation. Carry the exact reply identity through every drain and cleanup layer.
    Confidence: 0.99
  • [P1] Validate explicit names before committing the reset — src/auto-reply/reply/commands-reset.ts:510-516
    get-reply.ts calls initSessionState before this handler, and initialization commits the reset. Consequently /new --name= reports invalid input after changing the conversation. The Control UI parser also treats empty name syntax as ordinary unnamed creation. Validate naming before initialization or creation; the direct-handler tests bypass the destructive ordering.
    Confidence: 0.99
  • [P1] Require the persisted reset generation before naming — src/auto-reply/reply/commands-name.ts:69-82
    The new named-reset caller awaits hooks before this projection. If the session disappears during that wait, the fallback to params.sessionEntry recreates the deleted row. A later durable reset also retains its session ID, bypassing this ID-only check. Require the persisted row and captured lifecycle revision for named-reset writes rather than seeding stale state.
    Confidence: 0.98
  • [P1] Bind board naming to the authoritative reset result — ui/src/pages/chat/chat-pane-session-creation.ts:290-305
    The added guard reads currentSessionId from refreshed UI state, while requestSessionReset discards the reset response and clearChatHistory awaits another history read. That state can already describe a successor. Moreover, durable resets retain sessionId, so even a correctly captured ID cannot reject a later reset. Carry the reset result's lifecycle revision through the wrappers and require it on the label patch.
    Confidence: 0.99
  • [P2] Align native naming with the registered argument contract — src/auto-reply/reply/commands-reset.ts:284-289
    The /new definition has acceptsArgs but no title argument. parseCommandArgs therefore supplies CommandArgs.raw, so this read misses real native free-text input despite the new naming documentation. Implement the agreed behavior through the registered parser contract, or document and retain explicit naming only.
    Confidence: 0.99
  • [P2] Preserve unknown deletion outcomes beyond timeouts — src/auto-reply/reply/commands-delete-session.ts:195-208
    A connection can close after deletion commits, and post-delete unbinding can reject before the response. This timeout-only branch rethrows both cases without the transcript-write block, presenting an unconfirmed deletion as failure and allowing finalization against deleted state. Distinguish confirmed rejection from unknown post-dispatch outcomes and reconcile the original target before suggesting retry.
    Confidence: 0.97
  • [P2] Settle composer payloads after consumed naming failures — ui/src/pages/chat/chat-commands.ts:392-393
    A completed board reset followed by failed naming produces this new uncertain result. The immediate submit path releases attachments and clears owned composer fallback only for completed, while failed/cancelled results use restoration. It does neither for this outcome, retaining payload ownership after the command is consumed. Add settlement without restoring a retryable reset.
    Confidence: 0.97
  • [P2] Confirm naming after the label is persisted — src/auto-reply/reply/commands-reset.ts:550-555
    A routed reset hook suppresses the naming acknowledgment even though the hook ran before the label write and could not know its result. A successful named-new request can therefore produce only generic startup text. Publish the naming result after persistence while preserving intentional delivery suppression.
    Confidence: 0.93
  • [P2] Bind deletion to the Gateway serving the command — src/auto-reply/reply/commands-delete-session.ts:172-179
    This unqualified callGateway selects its destination again from configuration and environment. If the configured remote target or URL override differs from the serving Gateway, /close reaches another process, invalidates its process-local handoff, and can affect copied session state there. Invoke the serving lifecycle owner or capture and enforce its intended endpoint.
    Confidence: 0.95
  • [P2] Preserve incomplete named-reset outcomes — ui/src/pages/chat/chat-pane-session-creation.ts:322-323
    When reset returns uncertain, or the pane becomes stale before naming begins, the label patch is skipped but this return reports completion. The named operation is then retired as successful despite an unconfirmed reset or unapplied name. Return a consumed incomplete outcome and retain appropriate recovery feedback.
    Confidence: 0.98
  • [P2] Update remaining callers of the session-creation result contract — ui/src/pages/chat/chat-pane-session-creation.ts:203-208
    Changing createSession() to string outcomes leaves chat-pane-session-access.test.ts:67,86 expecting false and chat-pane-retained-presentation.test.ts:580 expecting a boolean. Those assertions cannot pass with this implementation. Update the remaining contract consumers while preserving their authorization and navigation checks.
    Confidence: 0.99
  • [P2] Keep local worktree details out of shared channel replies — src/auto-reply/reply/commands-delete-session.ts:228-232
    When cleanup preserves a worktree, this sends its raw branch and filesystem path to the originating conversation. Channel command authorization does not establish that everyone reading a shared conversation may see operator usernames or private project paths. Return a generic channel warning and reserve details for an authorized local surface. This was missed in the previous review; the command file is unchanged from that head.
    Confidence: 0.94
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4a54a573d56a.

Labels

Label justifications:

  • P2: This is a bounded session-management feature, not an established urgent production regression.
  • merge-risk: 🚨 session-state: Follow-up naming can recreate deleted state or rename a later reset generation.
  • merge-risk: 🚨 message-delivery: The close lifecycle still aborts or awaits the reply responsible for its confirmation.
  • merge-risk: 🚨 security-boundary: Originating authority is not proven through final deletion, and channel replies expose local worktree details.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Authority-chain proof required: the historical GatewayClient trace and inspected Telegram images show earlier positive behavior, but not the current deletion drain, Control UI naming, or non-admin and interrupted/released-origin rejection before final deletion. Add current fresh/existing-session evidence and required Control UI before/after screenshots; redacted terminal output and logs count for lifecycle proof. Remove private endpoints, identifiers, and credentials. Updating the PR body should trigger review; otherwise ask a maintainer for @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. Naming and close/delete change visible Telegram command behavior that the Test Server can observe.

Evidence

Security concerns:

  • [medium] Originating authority is not checked at deletion commit — src/gateway/server-methods/sessions-delete.ts:85
    The handoff replaces admission interruption callbacks, while final deletion checks the nested RPC's authority without checking the adopted origin's liveness. Cancellation and release before final I/O remain materially unproven.
    Confidence: 0.94
  • [medium] Shared channel replies expose local worktree paths — src/auto-reply/reply/commands-delete-session.ts:231
    Preserved-worktree replies include raw filesystem paths and branch names without restricting their audience to an authorized local operator.
    Confidence: 0.94

What I checked:

  • Current main still lacks the proposed command behavior: Inspected the fetched main command registry and reset handler. Main supports /name and ordinary /new, but does not register these close/delete commands or implement explicit new-session naming. REST searches for named-session and close-session command PRs found no verified merged replacement. (src/auto-reply/commands-registry.shared.ts:556, 4a54a573d56a)
  • Latest release retains the existing command contract: The v2026.9.4 command reference documents /new model/prompt behavior and /name, without the proposed naming or close/delete additions. The tag was inspected through GitHub because it was not available locally. Public docs: docs/tools/slash-commands.md. (docs/tools/slash-commands.md:201, 4a54a573d56a)
  • Introduction and review continuity: Verified introduced hunks against the pinned merge base and inspected the exact head's raw parent record. GitHub's commit endpoint confirms the latest commit changes only the board test and session-creation module. Recovered the previous completed review's twelve findings from feat(session): add named new and close chat commands #95700 (comment). Late rename-error publication is fixed; the generation guard remains incomplete. Some older blobs were unavailable locally, so the latest-commit comparison used GitHub's commit patch. No test-merge removal claims are made. (ui/src/pages/chat/chat-pane-session-creation.ts:288, e1b2ea9f15d0)
  • Close exemption does not cover reply cleanup: The new exemption reaches Gateway controller cancellation, but the lifecycle drain still aborts and waits on reply registries and includes them in its active-work check. The subsequent cleanup call also omits preserveActiveReplyRun. Added Gateway tests supply a controller or admission separately rather than the complete initiating reply. (src/gateway/server-methods/sessions-lifecycle-drain.ts:203, e1b2ea9f15d0)
  • Naming validation and generation checks: get-reply initializes session state before command handling; session initialization commits the reset. The new validation therefore runs afterward. Durable resets retain sessionId, while naming checks only that ID and can seed a missing row from captured state. Control UI reset wrappers discard the response identity before the new label patch reads refreshed UI state. (src/auto-reply/reply/commands-name.ts:72, e1b2ea9f15d0)
  • Authority handoff needs final-effect verification: sessions.delete consumes the new handoff without an interruption callback. Consumption replaces the original admission callbacks, and the deletion guard checks the independently authorized RPC and session generation without checking adopted lease liveness. The supplied tests do not demonstrate rejection after originating authority is interrupted or released. (src/gateway/server-methods/sessions-delete.ts:85, e1b2ea9f15d0)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • BSG2000: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • zachisfine: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • openclaw/openclaw-secops: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (32 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-08T19:38:26.376Z sha 28defa051093d27052499ed08b8ec459346729b6 :: needs real behavior proof before merge. :: [P1] Adopt the close initiator throughout the deletion lifecycle | [P1] Forward naming options through the production pane binding | [P2] Read native arguments from the registered command contract | [P1] Validate explicit names before committing a reset | [P1] Require the persisted lifecycle generation for named writes | [P1] Bind board-reset naming to the returned reset generation
  • reviewed 2026-09-09T06:29:05.755Z sha f8fbbdc43103a4fe1d19cae5f7877a10a41ea9ae :: needs real behavior proof before merge. :: [P1] Adopt the close initiator throughout the deletion lifecycle | [P1] Validate explicit names before committing the reset | [P1] Require the persisted generation for named-session writes | [P1] Bind board-reset naming to the returned reset generation | [P1] Reuse the canonical model-selection result | [P2] Read native arguments from the registered command contract
  • reviewed 2026-09-13T07:36:31.390Z sha 995ceca1abd9ebfcb411a1290e5fe01031b9fb0c :: needs real behavior proof before merge. :: [P1] Adopt the close initiator throughout the deletion lifecycle | [P1] Validate explicit names before committing the reset | [P1] Require the persisted generation for named-session writes | [P1] Bind board-reset naming to the returned reset generation | [P1] Reuse the canonical model-selection result | [P2] Read native arguments from the registered command contract
  • reviewed 2026-09-13T10:01:00.660Z sha 7ad0eafa91de59a07d46549d939dee02dd537970 :: needs real behavior proof before merge. :: [P1] Preserve the initiating reply throughout deletion | [P1] Validate explicit names before committing a reset | [P1] Require a persisted matching generation for named writes | [P1] Bind board-reset naming to the returned generation | [P1] Reuse the canonical reset-model decision | [P2] Align native naming with the registered argument contract
  • reviewed 2026-09-13T10:18:04.217Z sha ed843efa6dd054d857cff6a8298f9b0b2cc1e2b3 :: needs real behavior proof before merge. :: [P1] Preserve the initiating reply throughout deletion | [P1] Validate explicit names before committing a reset | [P1] Require a persisted matching generation for named writes | [P1] Bind board-reset naming to the returned generation | [P1] Reuse the canonical reset-model decision | [P2] Align native naming with the registered argument contract
  • reviewed 2026-09-13T10:30:54.229Z sha ed843efa6dd054d857cff6a8298f9b0b2cc1e2b3 :: needs real behavior proof before merge. :: [P1] Preserve the initiating reply throughout deletion | [P1] Validate explicit names before committing a reset | [P1] Require a persisted matching generation for named writes | [P1] Bind board-reset naming to the returned generation | [P1] Reuse the canonical reset-model decision | [P2] Align native naming with the registered argument contract
  • reviewed 2026-09-15T07:17:01.295Z sha 483b85c054b1dae2d7ba33c2be56bdf4b1960cb1 :: needs real behavior proof before merge. :: [P1] Preserve the initiating reply throughout deletion | [P1] Validate explicit names before committing a reset | [P1] Require a persisted matching generation for named writes | [P1] Bind board-reset naming to the returned generation | [P1] Reuse the canonical reset-model decision | [P2] Align native naming with the registered argument contract
  • reviewed 2026-09-15T08:20:24.133Z sha 8ae3d07 :: needs real behavior proof before merge. :: [P1] Preserve the initiating reply throughout deletion | [P1] Validate explicit names before committing a reset | [P1] Require a persisted matching generation for named resets | [P1] Bind board-reset naming to the returned generation | [P2] Align native naming with the registered argument contract | [P2] Preserve unknown deletion outcomes beyond timeouts

@clawsweeper
clawsweeper Bot temporarily deployed to qa-live-shared June 22, 2026 12:44 Inactive
@openclaw-mantis

Copy link
Copy Markdown
Contributor

Mantis Telegram Desktop Proof

Summary: Mantis captured native Telegram Desktop before/after GIF evidence with Convex-leased Telegram credentials.

Main screenshot This PR screenshot
Baseline native Telegram Desktop screenshot Candidate native Telegram Desktop screenshot
Main This PR
Baseline native Telegram Desktop proof GIF Candidate native Telegram Desktop proof GIF

Motion-trimmed clips:

Raw QA files: https://artifacts.openclaw.ai/mantis/telegram-desktop/pr-95700/run-27953443017-1/index.json

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. labels Jun 22, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7ad0eafa91

ℹ️ 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".

return "consumed-error";
}
}
return resetResult === "failed" ? "cancelled" : "completed";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve uncertainty from board-backed named resets

When a board-backed Control UI session runs a named /new and clearChatHistory() returns "uncertain" after a disconnect or timeout, the label patch is correctly skipped, but this line converts the outcome to "completed". The submit and outbox paths then remove the command and release its recovery payload as if the reset and rename were confirmed, even though the session may have reset without the requested name—or may not have reset at all. Propagate the uncertain outcome and reconcile it rather than reporting completion.

AGENTS.md reference: ui/AGENTS.md:L15-L19

Useful? React with 👍 / 👎.

Comment on lines +569 to +573
"close",
"Close the current session (archives unless incognito; not for main).",
"session",
"standard",
),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allow close commands without model access

When the Control UI has modelRequiredReason set because no model is configured or model setup is failing, these new commands lack a modelIndependent policy, so isModelIndependentChatCommand() returns false and both the slash menu and direct send path disable /close and /delete. Closing a session does not require model execution, so register both commands as model-independent (at least for their no-argument form) to keep cleanup available in this state.

Useful? React with 👍 / 👎.

Comment on lines +569 to +573
"close",
"Close the current session (archives unless incognito; not for main).",
"session",
"standard",
),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Let close commands run beside active session work

When /close or /delete arrives while another run owns the session, these definitions are not marked activeRunSafe, so dispatch waits on the existing run's admission instead of resolving the command concurrently. The command therefore cannot reach sessions.delete and its explicit active-run cancellation until the competing run finishes; a long-running or stuck turn can prevent the user from closing the session at all. Mark both close aliases as active-run-safe so their lifecycle drain can perform the cancellation they were designed to own.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 483b85c054

ℹ️ 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".

Comment on lines +294 to +298
labelPatched = await sessions.patch(
previousSessionKey,
{ label: options.label },
labelAgentId ? { agentId: labelAgentId } : undefined,
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bind the board rename to the reset incarnation

When another client resets this board-backed session after clearChatHistory() returns but before this patch completes, the session key and local view remain current while its session ID has changed. Because the label patch supplies no expectedSessionId, it renames the newer conversation and reports the original named /new as successful. Carry the reset result's incarnation into this request—or make reset-and-label atomic—so a late patch is rejected instead of modifying a successor session.

AGENTS.md reference: ui/AGENTS.md:L11-L14

Useful? React with 👍 / 👎.

BSG2000 and others added 18 commits September 15, 2026 10:03
Extracts reusable writeSessionLabel from /name, adds /close and /delete (alias) session commands routed via gateway sessions.delete, and supports naming a fresh session with /new --name / name: / native title args.

Chat-initiated /close hands its retained session-work admission to the server via a single-use admission handoff (admissionHandoffId), so the nested cross-context sessions.delete RPC adopts the initiating lease instead of deadlocking on it; the abort path exempts the initiating chat run through exemptChatRunId/exemptRunId. Model-directive detection stays scoped to the active agent and uses the synchronous alias/config heuristic so /new stays off the plugin cold-load path.

Squashed reapplication of the PR branch on current main (rounds 1-7 of Codex review feedback included).

Co-authored-by: Copilot <[email protected]>
Address Codex review round 8:

- Replace the prefix-based model-ref heuristic in isModelRefTail with a
  classification mirror of the reset-model resolver: same allowed-key set
  (buildAllowedModelSetWithFallbacks), same explicit/provider-scoped/fuzzy
  attempts, and cold plugin catalog escalation only for slash-form tails.
  Fallback refs no longer swallow session names; unknown brand words
  (e.g. "Gemini planning") name the session instead of being dropped.
  Exact alias hits stay directives even when policy hides the target so
  the resolver keeps ownership of policy errors.
- Reject native structured titles that are explicit model flags
  (--model / model:) so they reach the reset-model resolver instead of
  freezing the flag text as a label.
- Bind the /new label write to the targeted session incarnation:
  writeSessionLabel now takes expectedSessionId and refuses to relabel
  when a concurrent reset rotated the session while hooks ran.
- Run the unauthorized/admin gates for /close before the tail-shape
  check, retry the admission handoff with the raw RPC session key when
  the normalized key does not match, and drop the unused
  expectedSessionUpdatedAt plumbing.
- Add regression tests for all of the above.

Co-authored-by: Copilot <[email protected]>
…al failures

Address Codex round-9 findings on the named /new flow:

- Surface the post-reset session identity (sessionId + lifecycleRevision)
  from sessions.reset through the UI session store, and send it as
  expectedSessionId/expectedLifecycleRevision CAS guards on the follow-up
  label patch so a stale incarnation can never be renamed.
- Stop reporting a landed-but-partially-failed /new as retryable:
  createSession now returns completed/cancelled/consumed-error, and a
  failed or rejected label patch after a committed reset maps to
  "uncertain" dispatch (error surfaced on the pane, draft not restored)
  instead of "cancelled".
- Normalize manifest aliases when matching cold plugin catalog entries in
  /new model classification (e.g. google/gemini-3-pro now matches its
  gemini-3.1-pro-preview catalog entry without cold-loading plugins).

Co-authored-by: Copilot <[email protected]>
… /close timeouts honestly

Codex round-10 findings on the named-session chat commands PR:

- /new <bare-plugin-model-id> before the first catalog publish fell through to
  session naming because classification only consulted the warm prepared
  catalog. Classification now substitutes the synchronous manifest model
  catalog (loadManifestModelCatalog with fallbackToMetadataScan: false) as the
  classification catalog while cold, so manifest-declared plugin models run
  the identical allowed-set machinery cold and warm. Runtime-augmented models
  still escalate through the existing slash-gated cold resolver.
- /close raced its 20s client budget against the gateway's post-mutation
  worktree cleanup: the server commits the deletion before that cleanup and
  only responds afterwards, so a timeout surfaced as an error for a close
  that had already committed. The budget now covers drain + a 45s cleanup
  allowance, and an expired budget yields an honest uncertainty reply while
  leaving the local store entry untouched.
- docs: the /close row now states that incognito sessions are deleted without
  an archive and that the main session is refused with /reset as the pointer.

Adds regression tests for the cold manifest classification (directive
without a catalog load, non-model title still names the session) and for the
/close timeout path (uncertainty reply, preserved local entry, non-timeout
errors rethrown).

Co-authored-by: Copilot <[email protected]>
… session

A chat-initiated `/close` holds two session-work admissions (the gateway
chat.send admission plus its nested reply-turn admission), but the admission
handoff only carried the first covering admission. The server adopted that
one and then blocked draining the other -- which the initiating turn itself
held -- so every chat `/close` on an active session timed out UNAVAILABLE
after 15s without deleting anything.

- Make admission handoffs composite: `createSessionWorkAdmissionHandoffForCurrent`
  now hands off every covering admission in the current async context, and
  `consumeSessionWorkAdmissionHandoff` adopts them all under one lease (the
  wire protocol is unchanged). A released member admission invalidates the
  token so consumers fall back to the drain path.
- Even with the deadlock fixed, the confirmation reply was silently dropped:
  `ensureSessionRuntimeCleanup` aborted the initiating reply run via
  `abortEmbeddedAgentRun` -> `abortReplyRunBySessionId`, so the dispatch
  pipeline saw an aborted reply operation and never delivered the reply.
  Thread `preserveActiveReplyRun` through `cleanupSessionBeforeMutation` and
  skip both the reply-run abort and the run-end wait for the initiating turn
  when the delete adopted an admission handoff. Competing runs are still
  aborted by chat.abort and drained by `interruptSessionWorkAdmissions`.

Regression coverage: composite-handoff adoption and member-release
invalidation in session-lifecycle-admission.test.ts; preserve-reply-run
abort/wait semantics in runs.test.ts.

Co-authored-by: Copilot <[email protected]>
…ly model ids

Two /new classification gaps from review:

- Bare model ids from runtime/refreshable-discovery catalogs (e.g. LM Studio)
  were frozen as session names while the prepared catalog was still cold: the
  on-demand escalation was gated to provider/model-shaped tokens and the
  manifest fallback cannot represent runtime-only entries. Bare tokens now
  escalate under the resolver fuzzy precondition when an installed plugin
  declares runtime/refreshable discovery (new
  manifestModelCatalogDeclaresRuntimeDiscovery helper), matching loaded
  entries by exact id so ordinary titles cannot be swallowed. Installs
  without such plugins never pay a catalog load for plain session names.

- Explicit name prefixes with empty values (/new --name=, /new --name,
  /new name:) fell through the explicit-name parse; native surfaces
  persisted the raw directive as the session label. The parser now returns
  a missing-name marker and /new replies with a validation error before the
  reset hooks run, so no reset happens and nothing is labeled.

Co-authored-by: Copilot <[email protected]>
…and qualify native close/delete descriptions

Codex round 2 on the chat-command lifecycle work:

- The delete-session timeout reply now carries the same transcript-mirror
  block as the success replies: sessions.delete commits the deletion before
  slow worktree cleanup, so on an RPC timeout the session is likely gone and
  persisting the uncertainty reply would resurrect an orphan transcript row
  via createIfMissing. transcriptOwner is captured before the RPC so the
  timeout branch can reuse it (deleteSessionSuccessReply renamed to
  deleteSessionOutcomeReply to cover both outcomes).
- Native /close and /delete registry descriptions no longer promise
  unconditional archiving; archiving is skipped for incognito sessions and
  the commands are rejected for main.

Co-authored-by: Copilot <[email protected]>
…solution

- Preserve /close initiator via exemptRunId -> excludeRunIds wiring in chat.abort handler
- Register native close/delete command metadata with qualified lifecycle descriptions
- Align UI /new flow with ChatNewSessionResult and keep consumed-error semantics
- Restore board-preserving /new label patch behavior after reset

Co-authored-by: Copilot <[email protected]>
Post-rebase validation surfaced several places where main's independent
evolution since this PR's last review round required adaptation:

- session-lifecycle-admission: assign the `lease` back-reference on
  `SessionWorkAdmission` (it was declared but never set), which is what
  `createSessionWorkAdmissionHandoffForCurrent` needs to build a handoff
  for the initiator's own retained admission.
- session-work-admission-handoff: add the now-required `isActive` member
  to the composed lease returned by `composeSessionWorkAdmissionLeases`,
  reporting active only while every underlying lease in the handoff
  bundle is still active.
- commands-reset: adapt to main's model-selection-shared refactor
  (`buildAllowedModelSetWithFallbacks` -> `createModelVisibilityPolicyWithFallbacks`,
  `resolveModelRefFromDirectiveString` -> `resolveModelRefFromString`).
  Also tighten `isModelRefTail`'s alias/fuzzy-match attempts to only
  trust a resolved selection when it is an alias hit or its key is in
  the allowlisted catalog, since main's newer unrestricted-policy
  behavior in `resolveModelDirectiveSelection` now returns a synthetic
  off-catalog selection for any bare word, which was otherwise
  misclassifying plain-text `/new` session names as model directives.
- commands-name: replace the manual `entries` uniqueness scan in
  `writeSessionLabel` with the `isLabelInUse` callback that
  `applySessionPatchProjection`'s context now provides instead of a raw
  entry list.
- commands-reset-hooks.test / commands-delete-session.test: update
  renamed identifiers (`upsertSessionEntry` -> `replaceSessionEntry`,
  `setCurrentPluginMetadataSnapshot` -> `setGatewayPluginMetadataSnapshot`),
  and replace hand-rolled `PluginMetadataSnapshot` literals with
  `createPluginMetadataSnapshotFixture` now that the snapshot shape
  carries additional required fields. Also pin an empty plugin snapshot
  in the "does not cold-load the catalog for a plain multi-word session
  name" test so it does not pick up this repo's real bundled
  lmstudio/ollama plugins (which do declare refreshable discovery) as a
  side effect of the bare-token runtime-discovery check.

Co-authored-by: Copilot <[email protected]>
…Session

The pageState.createChatSession wrapper set up in ChatPaneLifecycle
dropped its `options` parameter when delegating to `this.createSession`,
so named `/new --name <title>` requests from the Control UI chat pane
silently lost the requested label end-to-end.

Add a regression test that asserts createChatSession forwards its
options argument to createSession unchanged.

Co-authored-by: Copilot <[email protected]>
The rebase of PR openclaw#95700 onto current origin/main surfaced a real type error:
`isResetAuthorized`, `parseNamedNewSessionTail`, `isModelRefTail`, and
`getNativeCommandTitleTail` were typed to take the full `HandleCommandsParams`,
but `maybeHandleResetCommand` only has `ResetCommandParams` available
(`resolvedThinkLevel`/`resolvedReasoningLevel` are resolved later in
`handleCommands`, after reset handling runs). None of these functions actually
read the omitted fields, so narrow their parameter type to `ResetCommandParams`
instead. `writeSessionLabel` (and its internal `syncNameSessionEntry` helper) in
`commands-name.ts` has the same property and is narrowed the same way, with
`ResetCommandParams` now exported from `commands-reset.ts` for reuse.

Co-authored-by: Copilot <[email protected]>
…nto sessions.delete

Two review findings on PR openclaw#95700 pointed at parameters the client already
sends but the server silently dropped:

- `admissionHandoffId`: a chat-initiated /close hands its own retained
  session-work admission to this RPC because deleting through the nested
  gateway call leaves the admission's async context, so without adopting
  the handoff the server would treat the initiator's own admission as
  competing work and block until it drains, which can never happen until
  this very RPC returns. `sessions-delete.ts` now consumes the handoff via
  `consumeSessionWorkAdmissionHandoff` and runs the whole deletion under the
  adopted lease, so `isCompetingSessionWorkAdmissionActive` and the
  interruption path both see it as the initiating turn instead of a
  competitor. Falls back to today's drain-and-retry behavior whenever the
  token is absent, stale, or scoped to a different identity.

- `exemptChatRunId`: the lifecycle drain aborts competing chat runs on the
  session before deleting it; without exempting the initiating run, that
  abort would terminate the /close turn itself and surface an aborted state
  instead of the deletion success reply. `exemptChatRunId` now flows into
  the drain's own `abortChatRunsForSessionKeyWithPartials` call via
  `excludeRunIds`, and into `hasGatewaySessionAbortOwner` (used by the
  authoritative-work recheck) so the exempted run is not later reported as
  still active either.

Added regression tests covering both: adopting a handed-off admission
completes without interrupting it, and an exempted chat run survives the
delete's session-wide abort.

Co-authored-by: Copilot <[email protected]>
…rship

Codex flagged that chat.abort trusted the client-supplied exemptRunId
without checking whether the requester actually owns that run, letting a
non-admin caller shield any run (including ownerless ones normally in
scope for a session-wide abort) from being aborted just by naming it.

Gate the exemption on canRequesterAbortChatRun(..., { requireOwnerMatch:
true }) unless the requester is admin, falling back to aborting the run
normally when ownership does not match or no entry is found. Add a
regression test proving a non-admin caller cannot protect an ownerless
run they do not own via exemptRunId, alongside the existing self-exemption
test that must keep working unchanged.

Co-authored-by: Copilot <[email protected]>
…gent

Codex flagged that the /close and /delete main-session guard called
resolveMainSessionKey(cfg), which resolves an ambient owner and throws
AgentSelectionRequiredError for explicit multi-agent fleets with no single
default agent. That crashed the guard (and therefore the whole command)
for any non-main session in that configuration, not just main-session
deletions.

Use resolveAgentMainSessionKey({ cfg, agentId: params.agentId }) instead,
which resolves the active agent's own main key without requiring an
unambiguous ambient owner. The "global" scope and other-agent main-key
checks alongside it are unaffected. Add regression tests covering both a
successful non-main deletion and a still-blocked own-main deletion under
explicit multi-agent ownership.

Co-authored-by: Copilot <[email protected]>
…check

Codex flagged that once a command-only /close preserves its own initiating
reply run during cleanup (preserveActiveReplyRun), the final success check
in ensureSessionRuntimeCleanup still called isEmbeddedAgentRunActive(sessionId)
without that option, so it kept counting the preserved reply run as active
work. Every command-only /close therefore returned UNAVAILABLE ("session is
still active") even after every genuine embedded run had drained.

Add a matching preserveReplyRun option to isEmbeddedAgentRunActive (mirroring
the existing option on waitForEmbeddedAgentRunEnd) and thread it into that
final check via the existing preserveActiveReplyRun parameter. Add a
regression test proving the preserved reply run is excluded only when the
option is requested, while ordinary callers still see it as active.

Co-authored-by: Copilot <[email protected]>
…as a prompt

Codex flagged that the /new documentation promises text-command surfaces
preserve a non-model free-text tail as the prompt, but Control UI intercepts
typed /new, parses only an explicit --name/name: label from the tail, and
never dispatches it as a message -- silently dropping the promised prompt for
Control UI users. Qualify both the Control UI note and the Argument notes
entry to state this Control UI exception explicitly.

Co-authored-by: Copilot <[email protected]>
The /new model classifier was building its prepared-model catalog request
without the active agent's agentDir/workspaceDir, so a model published only
under that agent's workspace was treated as a plain session title instead of
falling through to the reset-model resolver. Mirror the canonical
applyResetModelOverride catalog scope for classification so the same model
remains visible and is resolved consistently.

Add a regression test covering a prepared-catalog model that exists only under
that agent-scoped workspace.

Co-authored-by: Copilot <[email protected]>
Allow /close and /delete to remain available without a model and while an active run is present, matching the command semantics already enforced by the session lifecycle handlers.

Co-authored-by: Copilot <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8ae3d0737e

ℹ️ 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".

stopReason: params.action,
requester: { isAdmin: true },
includeProtectedRuns: true,
excludeRunIds: params.exemptChatRunId ? new Set([params.exemptChatRunId]) : undefined,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Exempt the initiating reply operation from the drain

When /close has no older active run, command resolution registers the command itself in replyRunRegistry; this new exclusion only protects the Gateway chat controller, while the callback below still calls replyRunRegistry.abort(key)/abortReplyRunBySessionId, and replyWork then waits for that same operation to finish. The operation cannot finish until this nested sessions.delete returns, so the drain times out and the close confirmation is lost. Fresh evidence beyond the earlier self-abort comments is that the now-wired excludeRunIds is still not honored by the reply-registry aborts or waits. Carry the initiating reply-operation identity through this entire drain.

AGENTS.md reference: AGENTS.md:L96-L96

Useful? React with 👍 / 👎.

// Only patch on a confirmed-completed reset: an "uncertain" reset may not
// have landed a fresh incarnation, so patching the label could rename the
// wrong session.
if (options?.label && isCurrent() && resetResult === "completed") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve named-reset failure when the pane becomes stale

If the connection, agent, or pane context changes while clearChatHistory() is pending and the reset returns "completed", isCurrent() is false, so this condition silently skips the requested label patch; line 310 nevertheless returns "completed", causing the /new --name ... command to be retired as successful even though the new session is unnamed. Distinct from the already reported late patch-error case, this happens before the patch starts and produces no error at all; return a consumed/uncertain result or reconcile the label against the originating owner.

AGENTS.md reference: ui/AGENTS.md:L11-L14

Useful? React with 👍 / 👎.

if (deletion.worktreePreserved) {
const { branch, path } = deletion.worktreePreserved;
return deleteSessionOutcomeReply(
`✅ Session ${closedVerb}.\n⚠️ Its worktree could not be removed and may hold uncommitted or unpushed work: branch “${branch}” at ${path}. Remove it manually when you no longer need it.`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Redact preserved-worktree paths from channel replies

When cleanup preserves a dirty or unpushed worktree, this reply sends its raw branch and filesystem path back to the originating chat. Channel callers only need to be command-authorized—not owner/admin—so in a shared Discord, Slack, or Telegram conversation the path can disclose operator usernames, repository layout, or private project names to other allowed command users. Return a generic cleanup warning on channel surfaces, or expose these details only through an owner/admin-local surface.

AGENTS.md reference: AGENTS.md:L90-L90

Useful? React with 👍 / 👎.

Comment on lines +134 to +136
handoff.entries.some((entry) =>
identities.some((identity) => !entry.admission.identities.has(identity)),
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the legacy handoff shape across hot reloads

When an update or duplicated runtime chunk loads this module while the process-global handoff map still contains a token created by the previous implementation, that entry has the legacy { admission, lease } shape rather than entries. This new unconditional handoff.entries.some(...) then throws when the token is consumed; the reverse old-consumer/new-producer pairing is also incompatible, so an in-flight lifecycle handoff can fail and strand its session admission during a live update. Normalize both shapes or version and migrate the process-global singleton before using the new representation.

AGENTS.md reference: AGENTS.md:L69-L69

Useful? React with 👍 / 👎.

Keep the board-backed reset rename anchored to the post-reset session incarnation instead of patching whatever session currently owns the key. This avoids renaming a newer session after an uncertain reset.

Co-authored-by: Copilot <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XL stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant