Skip to content

feat(worktrees): track setup progress and recover cancelled drafts - #608

Merged
rynfar merged 13 commits into
pylonfrom
upstream/2026-09-17-worktree-setup
Sep 17, 2026
Merged

rynfar merged 13 commits into
pylonfrom
upstream/2026-09-17-worktree-setup

Conversation

@rynfar

@rynfar rynfar commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

New worktrees previously exposed little setup progress, and a cancelled or interrupted setup could strand its prompt or leave a starting session behind. This adopts the complete upstream setup series across server, web/desktop, and mobile: staged checkout/script progress, cancellation with cleanup, durable prompts and history, optional blocking setup scripts, and a fresh composer for background sends.

Pylon adaptations preserve admission receipts, source epochs, compaction, provider ownership, remote authorization and existing message context. Additional fixes retain retry drafts through early prompt persistence, keep failed background sends separate from newer drafts, settle interrupted preparing receipts even when rollback fails, scope retention timers, and stop motion when hidden, unfocused or reduced-motion is enabled. Canonical sandbox paths are excluded from session discovery on macOS.

Closes #605. Continues #598 and the existing-port reconciliation in #604. The review cursor stays unchanged. This group accounts for 10 of the 164 remaining sources in the frozen range, leaving 154 after merge. No release or physical-device update is included.

Verification

  • 1,389 focused tests passed across 27 files, including the new draft-retention regression and the 64-test timeline rendering suite.
  • Scoped typechecks passed for server, web, mobile, contracts, client-runtime and desktop; final web and mobile checks passed after recovery and native sheet changes. Scoped lint reports no errors.
  • Mutation check: the preparing-receipt regression fails with the old implementation and passes with the fix.
  • Isolated web and iOS: live stages and script output; leaving/reopening; cancellation removes the worktree without starting a provider; foreground cancellation restores the original prompt; iOS cancellation of a background send preserves both the original prompt and a separately edited new draft.
  • Before/after clients use baseline 2ed2480add and the task implementation against the same disposable setup. Before/after screenshots and web videos and final iOS cancellation evidence are uploaded. iOS is the representative native platform; Android-specific sheet execution was not exercised. Blocking scripts and live cancellation require an updated server; older servers retain their existing behavior.
  • Final native check: Details → Cancel setup → Edit task restores both the original prompt and an additional note entered during setup. The iOS modal uses the existing React Native layout to keep its buttons responsive.
  • Rebased cleanly onto ad3325050d (including fix(prime): restore follow-up input after stopping subagents #606), whose Prime-only changes do not overlap this series. CI must pass on the PR head before merge.

Upstream attribution

Original author commits are preserved with cherry-pick provenance. Thanks to the upstream contributors for the complete setup series; Pylon-specific follow-up fixes are in a separate commit.

  • dd6ba84dc96f83000388e14b90f6533d5f63315d — fix(server): fall back when new worktrees are unavailable (#6208)
  • 73b206f4bf99e7e98ae144a9d9edbf7cb2700fc1 — feat(web): show each worktree setup step and let users cancel it (#11372)
  • 5ea6439816470288d3f2b6b43635fea41fbbb101 — feat(web): inline worktree setup rows and async setup scripts (#11832)
  • 5623089aea68ca62811f51321686c259fa4c810f — fix(server): disable color probes in worktree setup (#11843)
  • 0310cbf9f46ca94e9df0231a3440bca08ac44709 — fix: keep worktree setup visible after leaving and reopening the thread (#11836)
  • 2c19283afed1e3b69a9af33360980527aeb37494 — feat(server): persist the worktree setup send and progress on the thread (#11852)
  • ae53072af0560c0606202b87b5fdb7e52d48ac5c — fix(web): keep the composer ready during background worktree setup (#11883)
  • 0f5a1513e09fb41e0d0f86157aff64cc3657975d — fix(web): stop the worktree setup card from flashing and shifting (#12015)
  • 3bee4c286e586c2eb7f8d196a65b4b5ea6a95241 — fix(server): settle cancelled worktree setup before rollback (#12176)
  • 4abb07eac3d47543b5804e8039633ac8ad7f67d2 — feat(mobile): port worktree setup progress and agent handoff (#12177)

Implemented with GPT-6 in Codex.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

tris203 and others added 11 commits September 17, 2026 13:14
Preflight repository and base commit availability before creating the thread. Fall back to the project checkout for non-Git directories and repositories without a usable base commit, while preserving valid worktree setup.

(cherry picked from commit dd6ba84dc96f83000388e14b90f6533d5f63315d)
…372)

Starting a thread in a new worktree showed one static "Setting up worktree" line while git fetched, checked out files, and the setup script ran. Users could not tell which step was slow, see setup script output without hunting for the terminal, or stop a setup that was going wrong.

The timeline now shows a card with each step and its elapsed time. Check out files has a percent bar fed by git's own progress output. The setup script step shows the last lines of its terminal inline and links to the full terminal. Cancel stops the bootstrap and removes the half built worktree. Work locally cancels, switches the draft to the project checkout, and resends.

The server keeps an in-memory per-thread snapshot of the bootstrap stages and streams it over a new subscribeWorktreeSetup RPC. The bootstrap runs as a child fiber so worktreeSetup.cancel can interrupt it, and the turn handoff is uninterruptible. The setup script's exit code comes from a per-run sentinel echoed after the command in the setup PTY.

Created with Claude Fable 5.1 in Claude Code.

(cherry picked from commit 73b206f4bf99e7e98ae144a9d9edbf7cb2700fc1)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
(cherry picked from commit 5ea6439816470288d3f2b6b43635fea41fbbb101)
(cherry picked from commit 5623089aea68ca62811f51321686c259fa4c810f)
…ad (#11836)

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit 0310cbf9f46ca94e9df0231a3440bca08ac44709)
…ead (#11852)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
(cherry picked from commit 2c19283afed1e3b69a9af33360980527aeb37494)
…11883)

Co-authored-by: shivam <91240327+shivamhwp@users.noreply.github.com>
(cherry picked from commit ae53072af0560c0606202b87b5fdb7e52d48ac5c)
…2015)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
(cherry picked from commit 0f5a1513e09fb41e0d0f86157aff64cc3657975d)
(cherry picked from commit 3bee4c286e586c2eb7f8d196a65b4b5ea6a95241)
(cherry picked from commit 4abb07eac3d47543b5804e8039633ac8ad7f67d2)
@vercel

vercel Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
pylon-marketing Ready Ready Preview Sep 17, 2026 7:34pm UTC

@github-actions github-actions Bot added size:XXL vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Sep 17, 2026
@rynfar

rynfar commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator Author

Verified against disposable Pylon state. Baseline 2ed2480add and updated clients show the same running setup.

Web before Web after
Before: one setup status After: live checkout and script stages
iOS before iOS after iOS details

Cancellation restored the original prompt to its draft:

Recovered prompt after cancellation

Live progress and details:

web-setup-progress.mp4

Cancellation and prompt recovery:

web-cancel-recovery.mp4

Also verified: cancelling a background setup from iOS removes its worktree, restores "Original background task prompt." in its original draft, and leaves "New draft must stay untouched." in the separate fresh web draft. No provider turn started. The setup used an intentionally waiting script to exercise cancellation.

@rynfar

rynfar commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@rynfar

rynfar commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator Author

Completed the combined-diff review, including upstream PR context and Pylon entry points. Findings fixed before landing:

  • Preparing-session receipt interruption now records failure if thread rollback also fails; the regression fails without the fix.
  • Early prompt persistence no longer finalizes the web retry draft before an agent owns it. Live cancellation returns the original prompt.
  • Background failure recovery only updates its own draft; a separate newly edited draft remains intact (verified by cancellation from iOS).
  • Retention timers belong to the service scope. Native/web motion stops when unfocused or backgrounded and respects reduced motion.
  • Live setup subscriptions are capability-gated for older servers. Existing auth scopes, admission state, compaction/source epochs, inline context, and provider-specific code are preserved.
  • macOS canonical worktree paths remain excluded from imported-session scanning; the previous test failure also reproduced at baseline.

CI's unused-export finding was fixed in b60c5a4a53291edac60cdfea57e59baca9af24f3. Final-head CI remains the merge gate. The automated review request has not returned a review; this is the implementation agent's review, not an independent approval.

@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 13.9 KiB 14.0 KiB +41 B (+0.3%) 15.1 KiB ✅
Codex Thread snapshot wire 7.2 KiB 7.2 KiB 0 B (0.0%) 7.3 KiB ✅
Codex Live turn WebSocket wire 6.7 KiB 6.8 KiB +41 B (+0.6%) 7.8 KiB ✅
Codex Live turn WebSocket decoded 58.0 KiB 58.0 KiB +44 B (+0.1%) 66.4 KiB ✅
Codex Live turn messages 9 10 +1 (+11.1%) 21 ✅
Claude Total thread wire 14.0 KiB 14.0 KiB −11 B (−0.1%) 15.1 KiB ✅
Claude Thread snapshot wire 7.2 KiB 7.2 KiB −14 B (−0.2%) 7.3 KiB ✅
Claude Live turn WebSocket wire 6.8 KiB 6.8 KiB +3 B (+0.0%) 7.8 KiB ✅
Claude Live turn WebSocket decoded 58.9 KiB 58.9 KiB +44 B (+0.1%) 66.4 KiB ✅
Claude Live turn messages 9 10 +1 (+11.1%) 21 ✅

Baseline: ad33250 · PR result: 01c1f50 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 115.6 KiB
  • Claude decoded thread snapshot: 116.3 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@rynfar

rynfar commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator Author

Final iOS verification: replaced the nested navigation stack inside the setup modal because its React actions did not receive taps. The existing React Native modal layout responds immediately. A fresh mobile send was cancelled from Details; Edit task recovered both the original prompt and the note entered during setup. Cancellation also worked after reopening the app. The server removed both unfinished threads without starting a provider turn.

Updated sheet, recovered draft, and native cancellation video:

mobile-final-details mobile-final-recovered
mobile-cancel-recovery.mp4

@rynfar
rynfar merged commit 738b5ed into pylon Sep 17, 2026
20 checks passed
@rynfar
rynfar deleted the upstream/2026-09-17-worktree-setup branch September 17, 2026 19:43

This branch was successfully deployed

1 active deployment
Preview — 01c1f500 Deployed Sep 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upstream integration cycle: worktree setup progress and cancellation

5 participants