Skip to content

fix(ui): fork active sessions from stable history - #123718

Merged
clawsweeper merged 9 commits into
mainfrom
fix/fork-active-session-last-completed
Aug 14, 2026
Merged

clawsweeper merged 9 commits into
mainfrom
fix/fork-active-session-last-completed

Conversation

@clawsweeper

@clawsweeper clawsweeper commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users who forked a session while its agent was working received a backend rejection even though the Control UI offered the action.

Why This Change Was Made

Active-session forks now request an explicit stable boundary and copy the transcript only through the most recent completed assistant message. The in-flight user/tool turn stays in the parent. Inactive forks keep their existing full-transcript behavior, and active menus name the boundary as “Fork from last completed message.”

This is additive to the Gateway contract (forkFrom: "last-completed") and keeps rewind, branch switching, model-selection-locked sessions, and command-hook rollover behavior unchanged. The published one-argument Swift transport API is preserved; the new overload delegates compatibly for legacy conformers while updated iOS/macOS transports implement the stable-boundary route.

User Impact

Users can fork a working session immediately without stopping it or waiting for completion. The new session opens from the last completed response, while the parent continues running normally.

Evidence

  • Exact-head CI run 31839608406 passed all 143 jobs.
  • Shared OpenClawKit and macOS Swift tests passed, including a regression that compiles and routes an old-style one-argument transport conformer.
  • iOS builds, lifecycle tests, and screenshot capture passed.
  • Android Play/Wear/third-party builds, tests, and ktlint passed.
  • Gateway, protocol, Control UI, real-Gateway/E2E, lint, type, security, and Node matrices passed.
  • Gateway coverage verifies that an active parent with a completed turn followed by an in-flight tool-use turn forks only through the completed turn.
  • Storage coverage verifies that both the 100K token cap and copy operation use the same selected stable prefix.
  • git diff --check origin/main...HEAD passed.
  • Guarded review artifacts validated with zero findings and READY FOR /prepare-pr.
  • A live active-fork visual was requested from Mantis, but the supplied capture did not show the resulting child boundary. This maintainer-authored PR is outside the external-contributor proof gate; no unsupported visual proof is claimed.

AI-assisted implementation; the change, compatibility boundary, and owner paths were reviewed directly.

@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper
clawsweeper marked this pull request as ready for review August 14, 2026 15:51
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Aug 14, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 14, 2026
@clawsweeper

clawsweeper Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed August 14, 2026, 3:39 PM ET / 19:39 UTC.

ClawSweeper review

What this changes

The PR adds a stable-history fork mode so web, Android, iOS, and macOS clients can fork an active session without copying its in-flight turn.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

The active-fork approach is focused, but the PR still breaks the published one-argument Swift transport API; it needs that additive compatibility repair before merge.

Priority: P1
Reviewed head: 68801905c54dde9feae66dd0d5e9be701c9bb759

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The core approach is focused, but a P1 public-API compatibility defect remains.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored PR is outside the external-contributor proof gate; the prepared screenshot is supplemental and does not demonstrate the fork result.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored PR is outside the external-contributor proof gate; the prepared screenshot is supplemental and does not demonstrate the fork result.
Evidence reviewed 5 items Published Swift contract: Current main exposes OpenClawChatUI as a library and its public transport protocol requires the one-argument fork method with a default implementation.
Library export: OpenClawKit publishes OpenClawChatUI as a Swift library, so its public protocol requirement is a downstream source-compatibility contract.
Prior finding remains at head: The prior ClawSweeper review identified this exact API replacement; the supplied final patch still replaces the one-argument requirement and default with a two-argument form.
Findings 1 actionable finding [P1] Preserve the one-argument Swift fork API
Security None None.

How this fits together

Session menus send fork requests through the Gateway, which creates a child from persistent transcript history. The new mode selects the last completed assistant boundary while the parent session continues running.

flowchart LR
  A[Session menus] --> B[Gateway fork request]
  B --> C[Active-run decision]
  C --> D[Stable transcript boundary]
  D --> E[Child session]
  A --> F[Parent continues running]
Loading

Before merge

  • Preserve the one-argument Swift fork API (P1) - The public transport protocol currently requires forkSession(parentKey:). Replacing it makes downstream callers fail to compile, while conformers that implement only the old method inherit the new throwing default when the view model uses the boundary-aware overload. Keep the old requirement/default and add a delegating overload for the stable boundary.
  • Resolve merge risk (P1) - Merging the replacement protocol requirement breaks downstream callers and can route existing conformers to the default unsupported-operation error.
  • Complete next step (P2) - A narrow, mechanical compatibility repair and regression test can be automated without changing the Gateway design.

Findings

  • [P1] Preserve the one-argument Swift fork API — apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatTransport.swift:747
Agent review details

Security

None.

PR surface

Source +164, Tests +122, Other +124. Total +410 across 49 files.

View PR surface stats
Area Files Added Removed Net
Source 22 195 31 +164
Tests 6 131 9 +122
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 21 154 30 +124
Total 49 480 70 +410

Review metrics

Metric Value Why it matters
Production versus test delta production +231/-52; tests and test support +213/-16; generated catalog +36/-2 The change spans client, Gateway, and transcript-owner code, making the public API compatibility boundary important before merge.
Gateway fork parameter 1 added (forkFrom) The new request parameter changes which session history is persisted into forked children.

Stored data model

Persistent data-model change detected: serialized state: packages/gateway-protocol/src/schema/sessions-create.ts, serialized state: src/auto-reply/reply/session-fork.ts, serialized state: src/config/sessions/session-accessor.sqlite-parent-fork.ts, serialized state: src/config/sessions/session-accessor.sqlite-parent-session.ts, serialized state: src/config/sessions/session-accessor.types.ts, serialized state: src/gateway/server-methods/sessions-create.ts, and 12 more. Confirm migration or upgrade compatibility proof before merge.

Mantis proof suggestion

A web chat run can directly show the stable child boundary and continuing parent. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis web UI chat proof: verify that an active-session fork on the current head creates a child at the last completed message while the parent continues running.

Merge-risk options

Maintainer options:

  1. Restore the additive Swift API (recommended)
    Keep the original transport requirement and add the stable-boundary overload as a compatibility layer before merge.
  2. Pause the change
    Do not merge if maintaining the published OpenClawChatUI transport contract is not intended.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Preserve the one-argument OpenClawChatTransport fork requirement and default, add a delegating stable-boundary overload, and cover an old-style conformer.

Technical review

Best possible solution:

Retain the one-argument transport requirement and default, then add a boundary-aware overload that delegates compatibly while updated Gateway transports implement the stable-history request.

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

Yes, by source: current main rejects a fork when its parent has active work, while the UI offers the action; the proposed Swift API regression is also directly reproducible by compiling an old-style caller or conformer.

Is this the best way to solve the issue?

No: the Gateway/storage boundary is appropriate, but replacing the published Swift method is not the best fix; an additive overload preserves existing consumers.

Full review comments:

  • [P1] Preserve the one-argument Swift fork API — apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatTransport.swift:747
    The public transport protocol currently requires forkSession(parentKey:). Replacing it makes downstream callers fail to compile, while conformers that implement only the old method inherit the new throwing default when the view model uses the boundary-aware overload. Keep the old requirement/default and add a delegating overload for the stable boundary.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3289e08c3005.

Labels

Label justifications:

  • P1: The PR targets a broken active-session fork workflow and currently introduces a public client compatibility regression.
  • merge-risk: 🚨 compatibility: The diff replaces a public protocol requirement rather than adding an overload.
  • merge-risk: 🚨 session-state: The new request changes the transcript boundary copied into a forked session.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This member-authored PR is outside the external-contributor proof gate; the prepared screenshot is supplemental and does not demonstrate the fork result.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. This member-authored PR is outside the external-contributor proof gate; the prepared screenshot is supplemental and does not demonstrate the fork result.

Evidence

Acceptance criteria:

  • [P1] cd apps/shared/OpenClawKit && swift test.
  • [P1] pnpm test src/gateway/server.sessions.create.test.ts.

What I checked:

Likely related people:

  • steipete: Current-main blame covers the public transport requirement, and the PR commits cover the native session-fork changes. (role: recent public-transport and session-path contributor; confidence: high; commits: f65a6f81de6d, c65975467524; files: apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatTransport.swift, apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+SessionActions.swift)

Rank-up moves

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

  • Restore the additive Swift API shape and add focused old-conformer compatibility coverage.
  • Capture a redacted exact-head active-fork run showing the child boundary and continuing parent.

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 (7 earlier review cycles)
  • reviewed 2026-08-14T16:08:59.344Z sha f9ee919ac0b0fae71577f39c3e1f90d1b0fffccb :: found issues before merge. :: [P1] Preserve the authoritative active-run fact for sidebar forks | [P2] Apply the fork cap to the selected stable prefix
  • reviewed 2026-08-14T16:19:02.975Z sha 99cd6c68b60f1f4665cb3144fb3a5c254a55fbcf :: found issues before merge. :: [P1] Preserve raw active-run state for sidebar fork requests | [P2] Apply the fork cap to the selected stable prefix
  • reviewed 2026-08-14T16:32:06.431Z sha 3159e01fb1c3d925c1dd78f5c5c353eafdc11d36 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-14T16:49:23.946Z sha 84fe7529cdd75fedf9220c8fb78351c2dd62beea :: needs changes before merge. :: [P1] Route active native forks through the stable boundary
  • reviewed 2026-08-14T17:35:53.518Z sha f2758fb :: needs changes before merge. :: [P1] Route Android active forks through the stable boundary | [P2] Label native stable-history forks
  • reviewed 2026-08-14T18:31:21.772Z sha cfd79416b4c6a85f91595e3c543a53f35270ebcf :: needs maintainer review before merge. :: none
  • reviewed 2026-08-14T19:00:12.226Z sha 28135c2be3a1bfdcd3709d0636123727b573c984 :: needs changes before merge. :: [P1] Preserve the one-argument Swift fork API

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 14, 2026
@clawsweeper

Copy link
Copy Markdown
Contributor Author

@openclaw-mantis web UI chat proof: verify that forking an active session creates a child from the last completed message while the parent keeps running.

@openclaw-barnacle openclaw-barnacle Bot added app: ios App: ios app: macos App: macos labels Aug 14, 2026
@openclaw-mantis

Copy link
Copy Markdown
Contributor

Mantis Web UI Chat Proof

Summary: Mantis ran the OpenClaw Control UI chat proof against the candidate ref, sent a message through the mocked Gateway, rendered the final reply in the browser, and captured browser artifacts for review.

Control UI web chat proof

Control UI web chat proof

Full videos:

Raw QA files: https://artifacts.openclaw.ai/mantis/web-ui-chat-proof/pr-123718/run-31823198477-1/index.json

@clawsweeper clawsweeper reopened this Aug 14, 2026
@clawsweeper
clawsweeper force-pushed the fix/fork-active-session-last-completed branch from e06a1b6 to f2758fb Compare August 14, 2026 17:27
@openclaw-barnacle openclaw-barnacle Bot added app: android App: android and removed size: M labels Aug 14, 2026
@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. labels Aug 14, 2026
@clawsweeper
clawsweeper force-pushed the fix/fork-active-session-last-completed branch from 28135c2 to 6880190 Compare August 14, 2026 19:02
@openclaw-barnacle openclaw-barnacle Bot removed the cli CLI command changes label Aug 14, 2026
@clawsweeper clawsweeper Bot added proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 14, 2026
@clawsweeper
clawsweeper force-pushed the fix/fork-active-session-last-completed branch from 592b627 to 80d76aa Compare August 14, 2026 20:40
@clawsweeper

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper

Copy link
Copy Markdown
Contributor Author

Landing evidence for 22014628480dbb472ba3e59ec6f7b5110f590407: exact-head CI run 31839608406 passed all 143 jobs; guarded review artifacts validate with zero findings and READY FOR /prepare-pr; the ClawSweeper P1 was repaired additively by preserving forkSession(parentKey:), adding a delegating boundary-aware overload, updating iOS/macOS transports, and compiling an old-style conformer regression. No unsupported live visual proof is claimed.

@clawsweeper
clawsweeper merged commit c127454 into main Aug 14, 2026
201 checks passed
@clawsweeper
clawsweeper deleted the fix/fork-active-session-last-completed branch August 14, 2026 21:13
@clawsweeper

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 15, 2026
* fix(ui): fork active sessions from stable history

* fix(protocol): align active fork types

* test(ui): match main-session fork routing

* fix(sessions): unify stable fork admission

* fix(native): fork active sessions from stable history

* fix(android): fork active sessions from stable history

* style(android): simplify active fork result handling

* fix(native): preserve legacy fork transport API

* test(native): complete legacy fork transport stub

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: android App: android app: ios App: ios app: macos App: macos app: web-ui App: web-ui gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants