Skip to content

fix(ui): restart active turns after permission changes - #131978

Closed
jalehman wants to merge 7 commits into
mainfrom
openclaw/nova-shell
Closed

jalehman wants to merge 7 commits into
mainfrom
openclaw/nova-shell

Conversation

@jalehman

@jalehman jalehman commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where changing a session's permission mode during an active turn only affected the next run. Users had to stop the turn manually and send continue to make the new permission profile take effect immediately.

Why This Change Was Made

Permission changes now use a typed Gateway-owned restart lifecycle: patch the permission mode, interrupt the exact active run, and resume from the existing transcript with trusted internal-system provenance. Exact run identity fences stale requests so they cannot interrupt a successor run, and idle sessions continue to update permissions without starting work.

The Control UI no longer synthesizes a visible user continue message. It shows a system restart notice and keeps command interpretation and external delivery disabled for the internal continuation.

User Impact

Changing permissions during an active turn now immediately restarts that turn under the selected profile. Users no longer need to stop the run and type continue themselves.

Evidence

  • Real Gateway boundary: node scripts/run-vitest.mjs src/gateway/server.chat.gateway-server-chat.test.ts -t "sessions.restartTurn" — 2 passed, covering exact-run restart and stale-ID non-interruption.

  • Gateway owner tests: node scripts/run-vitest.mjs src/gateway/server-methods/sessions-restart-turn.test.ts — 3 passed.

  • Focused suites: gateway protocol 63 passed; reply-run registry 88 passed; Control UI 30 passed.

  • Browser flow: OPENCLAW_CAPTURE_UI_PROOF=1 node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/chat-flow.models-reasoning.e2e.test.ts -t 'restarts an active turn after changing its permission mode' — 1 passed, 12 skipped.

  • Before (Guarded, active turn):

    Guarded active turn before changing permissions

  • After (Workspace, restarted turn, no synthetic user message):

    Workspace permission selected after the turn restart

  • git diff --check passed.

  • Mandatory autoreview passed with no actionable findings (confidence 0.99).

Known local gate gap: node scripts/check-changed.mjs passed formatting, policy guards, and core production typecheck, then hit an environment-only core-test typecheck failure because this linked worktree resolved the parent checkout's stale [email protected] while ui/package.json requires 3.0.1.

Production LOC: +351/-31 (net +320) | Tests/test support: +445/-34 (net +411). Production growth is the new typed Gateway protocol and lifecycle owner; the obsolete UI-authored stop/send path is removed.

@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@jalehman
jalehman marked this pull request as ready for review August 28, 2026 17:40
@clawsweeper clawsweeper Bot added 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: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 7:56 PM ET / 23:56 UTC.

ClawSweeper review

What this changes

Adds a Gateway RPC that restarts an active chat turn after a permission-mode change, with Control UI handling, protocol support, and Gateway/UI coverage.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

The PR supplies a Gateway-owned, exact-run restart path for active-turn permission changes and now visibly rejects ambiguous active-run state; no introduced functional or security defect was found. Keep it open for normal maintainer review while exact-head checks finish.

Priority: P2
Reviewed head: cbcd036e14b7f0941b8e8d2a73d045ae4e933d61

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent, well-covered owner-boundary repair with exact-head lifecycle validation still pending.
Proof confidence 🌊 off-meta tidepool Not applicable: The PR is maintainer-authored, so the external-contributor proof gate does not apply; its supplied Gateway/UI behavior evidence is consistent with the inspected implementation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The PR is maintainer-authored, so the external-contributor proof gate does not apply; its supplied Gateway/UI behavior evidence is consistent with the inspected implementation.
Evidence reviewed 6 items Introduced owner boundary: The head’s Gateway handler validates the restart request, requires the existing session mutation authorization, interrupts the expected active run, patches permissions, and invokes the internal continuation path.
Exact-run lifecycle fence: The admission path rejects an interrupt unless the supplied run identity matches the reply registry or the active abort controller, then revalidates around interruption and continuation.
Visible UI ambiguity handling: The Control UI only restarts when exactly one active run ID is known; otherwise it shows the translated unavailable error rather than silently applying a normal session patch.
Findings None None.
Security None None.

How this fits together

The Control UI changes a session’s permission mode through Gateway session APIs. For an active chat turn, this change interrupts the exact running turn, applies the permission update, and continues it through the existing chat lifecycle.

flowchart LR
  A[Control UI permission picker] --> B[Active-run identity check]
  B -->|one exact run| C[Gateway restart request]
  B -->|zero or multiple runs| D[Visible unavailable message]
  C --> E[Exact-run fence and authorization]
  E --> F[Permission patch]
  F --> G[Continuation through chat lifecycle]
  G --> H[Refreshed chat and restart notice]
Loading

Before merge

  • Resolve merge risk (P1) - This adds a lifecycle and persisted-recovery continuation path; exact-head Gateway and Control UI checks should complete before merge.
  • Resolve merge risk (P1) - Production code grows by 447 net classified lines for a new protocol and lifecycle owner; the review did not establish a net-neutral refactor that preserves the required owner boundary.
  • Complete next step (P2) - No repair finding remains; maintainer review should retain the session-state risk until exact-head checks finish.
Agent review details

Security

None.

PR surface

Source +446, Tests +683, Other +61. Total +1190 across 47 files.

View PR surface stats
Area Files Added Removed Net
Source 34 552 106 +446
Tests 11 720 37 +683
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 61 0 +61
Total 47 1333 143 +1190

Review metrics

Metric Value Why it matters
Classified code delta production +553/-106 (net +447); tests +720/-37 (net +683); generated protocol +60/-0 The substantial production growth implements a new Gateway protocol and restart lifecycle, so its exact-head validation matters before merge.

Stored data model

Persistent data-model change detected: serialized state: packages/gateway-protocol/src/schema/sessions-restart-turn.ts, serialized state: src/gateway/server-methods/sessions-restart-turn.ts, serialized state: ui/src/lib/sessions/index.ts, serialized state: ui/src/lib/sessions/session-capability.ts, serialized state: ui/src/lib/sessions/session-scoped-operations.ts, unknown-data-model-change: src/gateway/server-methods/sessions-restart-turn.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Complete lifecycle validation (recommended)
    Wait for the exact-head Gateway and Control UI checks covering interruption, continuation, and recovery state before merging.

Technical review

Best possible solution:

Keep the single Gateway-owned restart flow with its exact-run fence and visible ambiguous-ID rejection, then complete exact-head validation before landing.

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

Yes—source and targeted Gateway/UI tests define a current path: change permissions while one exact chat run is active; this review did not execute the tests.

Is this the best way to solve the issue?

Yes—the Gateway-owned exact-run fence and internal continuation are safer than a UI-side abort/send sequence because authorization and lifecycle state remain at their existing owners.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4fd9392c209a.

Labels

Label justifications:

  • P2: This is a bounded repair to active chat permission handling with no demonstrated broad outage or data-loss impact.
  • merge-risk: 🚨 session-state: Merging changes interruption, continuation, and persisted recovery handling for an active session turn.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The PR is maintainer-authored, so the external-contributor proof gate does not apply; its supplied Gateway/UI behavior evidence is consistent with the inspected implementation.

Evidence

Acceptance criteria:

  • [P1] Exact-head Gateway restart-turn coverage.
  • [P1] Exact-head Control UI permission-restart coverage.

What I checked:

Likely related people:

  • Peter Steinberger: Recent merged history covers remote session-permission serialization and adjacent chat lifecycle work. (role: recent area contributor; confidence: medium; commits: e82700626d9c, 047470456ff2; files: ui/src/pages/chat/chat-settings-patches.ts, src/gateway/server-methods/chat-send-admission.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let the exact-head Gateway and Control UI checks complete before merge.

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 (5 earlier review cycles)
  • reviewed 2026-08-28T17:48:35.043Z sha 390e8b9 :: needs changes before merge. :: [P2] Fence the permission patch with the active run
  • reviewed 2026-08-28T20:44:10.926Z sha 7e356b7 :: found issues before merge. :: [P2] Separate restart keys from chat run IDs | [P2] Keep permission updates usable for overlapping active runs
  • reviewed 2026-08-28T21:09:33.367Z sha 9448cd6 :: found issues before merge. :: [P2] Separate restart keys from chat run IDs | [P2] Resolve the active run after queued permission updates
  • reviewed 2026-08-28T22:00:45.882Z sha 24c17fc :: found issues before merge. :: [P2] Accept the exact admitted run before registry publication | [P2] Resolve queued permission changes against the successor run
  • reviewed 2026-08-28T23:10:04.741Z sha 02ffbb0 :: found issues before merge. :: [P2] Handle active sessions without exact run IDs

@jalehman
jalehman force-pushed the openclaw/nova-shell branch from 390e8b9 to 7e356b7 Compare August 28, 2026 20:30
@openclaw-barnacle openclaw-barnacle Bot added app: android App: android app: web-ui App: web-ui gateway Gateway runtime size: XL maintainer Maintainer-authored PR labels Aug 28, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. labels Aug 28, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 28, 2026
@jalehman

Copy link
Copy Markdown
Contributor Author

Addressed the latest ClawSweeper lifecycle findings in 02ffbb0b97c.

  • The ACK→reply-registry window now retains the exact admitted abort-controller identity. A missing or replaced controller fails closed; it cannot be reported as interrupted or replayed.
  • Serialized permission changes now carry the prior restart result's successor run ID, so a rapid second selection targets the replacement turn.
  • Permission continuation atomically rotates any retained restart-recovery claim before dispatch. A successor restart-aborted before adoption exits as an intentional non-execution; stale persisted claims still reject.

Proof:

node scripts/run-vitest.mjs src/gateway/server.chat.gateway-server-chat.test.ts src/auto-reply/reply/restart-recovery-claim.test.ts ui/src/pages/chat/chat-send.test.ts --reporter=dot
68 gateway + 9 recovery-claim + 286 UI tests passed

env -u CODEX_HOME .agents/skills/autoreview/scripts/autoreview --mode uncommitted --max-priority P1 --stream-engine-output
clean: no P0/P1 findings (0.87)

OCM exact-head package runtime: pr131978-02ffbb0-env
Gateway: pr131978-live, 127.0.0.1:19011, OpenClaw 2026.8.1 (02ffbb0)
Rapid live flow: parent ACK -> workspace restart -> guarded restart
Both restart RPCs returned started; final successor returned status=ok; session settled done/guarded with no active runs and no new recovery-claim error.

This follow-up is production +97 net and tests +145 net. The production growth is the exact pre-publication identity fence, atomic recovery-claim handoff, and serialized successor identity required by the three distinct races; it reuses the existing chat-abort registry, restart-safe transcript transaction, and picker tail rather than adding a parallel lifecycle path.

check:changed passed all completed guards plus core typecheck; its core-test type lane remains blocked by the checkout's existing parent-resolved pako declaration gap. The independent OCM release-style package build completed successfully from the exact pushed checkout.

@clawsweeper clawsweeper Bot removed the rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. label Aug 28, 2026
@clawsweeper clawsweeper Bot added 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 status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 28, 2026
@jalehman

Copy link
Copy Markdown
Contributor Author

Follow-up repair proof for exact head cbcd036e14b7f0941b8e8d2a73d045ae4e933d61:

  • Fixed the failed check-lint-core-2 job by moving the shared exact abort-entry predicate into the restart-recovery owner, bringing chat-send-admission.ts below the 700-line cap, and removing the Promise-executor return flagged by lint.
  • Addressed ClawSweeper's final P2: when a session is active but has zero or multiple projected run IDs, the Control UI now shows a visible retry-after-completion error and does not silently apply the permission change only to the next turn.
  • ClawSweeper reviewed this exact head with no actionable or security findings: fix(ui): restart active turns after permission changes #131978 (comment)

Validation:

node scripts/run-vitest.mjs src/gateway/server.chat.gateway-server-chat.test.ts ui/src/pages/chat/chat-pane-session-controls.test.ts
  68 Gateway + 25 Control UI tests passed

OPENCLAW_LOCAL_CHECK=0 GOMAXPROCS=2 node --import tsx scripts/run-oxlint-shards.mts --only=core --split-core --core-stripe=2/5 --threads=1
  passed the exact previously failing CI stripe

node scripts/check-changed.mjs -- src/gateway/server-methods/chat-restart-recovery.ts src/gateway/server-methods/chat-send-admission.ts src/gateway/server.chat.gateway-server-chat.test.ts ui/src/i18n/locales/en.ts ui/src/pages/chat/chat-pane-session-controls.test.ts ui/src/pages/chat/chat-pane-session-controls.ts
  passed all selected core, core-test, and UI lanes

env -u CODEX_HOME .agents/skills/autoreview/scripts/autoreview --mode local --max-priority P1 --stream-engine-output
  clean; no P0/P1 findings, correctness confidence 0.94

OCM release-shaped proof:

runtime: pr131978-cbcd036-env
environment: pr131978-live
gateway: running and RPC-reachable on exact build 2026.8.1-cbcd036e14b7
cutover: snapshot-backed upgrade completed successfully

Exact-head CI run 33221572624 currently has no failures. All executed jobs are green; ios-screenshots-ipad-13 remains runner-queued, so final CI completion is still pending.

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

Labels

app: android App: android app: web-ui App: web-ui gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant