Skip to content

Keep editable prompts available during workspace creation - #18872

Closed
nwparker wants to merge 12 commits into
nwparker/faster-worktree-create-ASTRA-astronautfrom
nwparker/instant-creation-draft-safety
Closed

nwparker wants to merge 12 commits into
nwparker/faster-worktree-create-ASTRA-astronautfrom
nwparker/instant-creation-draft-safety

Conversation

@nwparker

@nwparker nwparker commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by #18876, stacked directly on #18793. That approach retains immediate editable prompts while omitting the early real-workspace/deferred-shell lifecycle. This PR is closed; its branch and earlier trial release remain available for comparison.

Files Added Deleted Net
Test 23 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1564 $\color{#cf222e}{\Huge{\mathbf{−}}}$​19 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1545
Prod 40 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1627 $\color{#cf222e}{\Huge{\mathbf{−}}}$​55 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1572

Cold workspace creation leaves users waiting before they can start their prompt. This adds an optional saved prompt editor during creation and keeps the same editor, text, caret, and focus when the terminal appears. Untouched drafts hand focus to the terminal as before.

Drafts persist locally with revision checks. Send requires a durable attempt record, the original terminal incarnation, and a runtime readiness check; uncertain delivery retains the source without replay. Conflicting edits can be saved separately without overwriting another window. Runtime activation changes are capability-gated, with legacy behavior preserved for older peers.

Stacked on #18842 (which is stacked on #18793). Includes the terminal.send incarnation fence. Current head b66ade1 merges main 062db77 (tab minimum width change); the four affected tab tests pass.

Review and validation

  • All 125 new messages across the five bundled non-English locales pass catalog validation; rendered Japanese recovery/status controls were inspected.
  • 67 draft tests and 48 runtime/focus tests pass; related creation-flow/transport tests also passed before the final isolated fixes.
  • Final renderer changes pass web typecheck, lint, React checks, and formatting.
  • Rendered Electron checks: continuous editor handoff, untouched creation, saved-draft recovery, full app restart persistence, CAS conflict recovery, update-menu refusal, and an actual Codex prompt/reply with source retained.
  • Independent review/fix loop repaired conflict recovery and false delivery status for newer text edited during an earlier Send. Newer text stays unsent; uncertain and restored attempts retain no-replay protection.
  • Final elegance pass reused the shared timeout implementation. Read-only capability/target/readiness queries now have bounded waits; late responses cannot trigger delivery. Write operations retain their uncertainty fence.
  • Full CI passed on f6eb4f5, including all eight test shards and Linux/Windows packaging. The async-spawn cancellation test now advances its timeout only after spawn starts, fixing the exposed scheduling race. Newer changes are five translation catalogs and the small main tab-width merge, validated locally. Current-head CI run 33986948551 passed all eight test shards, typecheck, static analysis, cross-version wire compatibility and Linux/Windows packaging. The additional ready-triggered CI run 33987738834 also passed. Pullfrog reviewed the exact b66ade1 head across all 51 changed files and found no new issues; its check completed successfully. Its remaining note is the broader caller-owned foreground activation behavior, already covered by creation-flow and folder-startup tests.

Performance evidence

Downloaded signed/notarized Mac trial at b66ade1, fresh isolated profile, two real Create trials: editor visible in 206.5 ms on the first cold Create and 17.5 ms after five seconds of composer preparation. Workspace selection took 5.31 seconds and 647 ms respectively. Typed text and focus survived handoff; screenshot inspected. No backend delay injected and no prompt sent. These small samples verify installer behavior, not universal latency.

Development Electron, browser click capture to animation-frame observation, three samples: editor visible in 55–118 ms. Immediate Create selected the workspace in 5.47 seconds; prepared samples selected it in 492–660 ms. These are not packaged comparisons and do not establish a regression or win against B's earlier controlled 18 ms selection / 105 ms terminal result.

Production renderer in the same development Electron main, two real Create trials without injected backend delay: editor visible in 25.5 and 29.2 ms. Typed text remained visible and focused after handoff (screenshot inspected). Selection took 4.70 seconds on immediate Create and 1.80 seconds after five seconds in the composer. This isolates renderer build mode; it is still not an installer benchmark.

Real typing at 64 stored drafts and near the 64 KiB text limit: p95 input-to-frame 12.8–16 ms, no observed long tasks. The editor makes the cold wait useful; it does not eliminate checkout or guarantee immediate agent readiness.

Remaining user-facing limitations

  • Direct Send supports native local desktop terminals; SSH, WSL and paired destinations use copying.
  • Conservative readiness detection may refuse Send. A menu appearing between probe and write can leave partial delivery requiring terminal inspection.
  • Another open window's newly saved drafts appear after reload.
  • Storage is limited to 64 drafts and 64 KiB per draft; existing text is retained when limits are reached.

Merge risk: moderate due to the new persisted delivery lifecycle and incomplete live platform/topology coverage. Native macOS rendered delivery was verified; actual Windows/Linux rendered Send and all remote topology combinations were not. The readiness checklist's mobile-backcompat-review and win-linux-compat-review dependency skills are unavailable locally; no complete formal checklist verdict is claimed. No outstanding candidate finding requires counsel validation after the fixes.

Combined A+B+C trial at b66ade1: https://github.com/stablyai/orca-adhoc/releases/tag/v1.4.198-adhoc.20260905192425 (workflow 33986950377). Mac publishing succeeded. Downloaded Apple Silicon ZIP passed SHA-512/size, archive integrity, deep/strict code signature, notarization staple, and embedded source/version checks. Windows publishing also succeeded; the downloaded installer passed SHA-512/size/version verification. Both release jobs in 33986950377 succeeded. Windows is unsigned. The PR is ready for review; both current-head CI runs and Pullfrog review have completed successfully. The prior published A+B trial does not contain C.

@nwparker
nwparker marked this pull request as ready for review September 5, 2026 19:38

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

Reviewed the full 51-file diff end to end, spanning the terminal input incarnation fence, worktree-creation payload/arg plumbing, the new creation-draft subsystem, and the focus/activation handoff.

  • terminal.send incarnation fence — assertTerminalSendIncarnation wires an optional expectedIncarnationId through beforeWrite/reserveWrite, re-checking resolveLiveLeafForHandle().ptyId and getTerminalProcessIncarnation(handle) immediately before and at the synchronous write reservation, so a rebind mid-send throws terminal_handle_stale before any bytes land.
  • Draft persistence — a new IndexedDB store (creation-draft-connection.ts/creation-draft-database.ts) with durability: 'strict', optimistic revision conflict checks, a 64-draft / 64 KiB capacity, and a zustand session (creation-draft-session.ts) with a write-behind queue and conflict-copy recovery.
  • Draft delivery — creation-draft-delivery.ts + creation-draft-submit.ts persist a durable attempt before sending, capture/verify the terminal incarnation, sanitize bracketed paste, and never auto-replay after an uncertain outcome.
  • Focus/activation ownership — callerOwnsCompletion makes the renderer the single activation owner on foreground create, shouldPreserveEditableFocus keeps the draft (and any editable field) focused across the terminal handoff, and completeWorktreeCreation skips terminal focus when a draft has text.
  • Wire compatibility — two new runtime capabilities gate the new worktree.create/terminal.send fields; remote targets fall back to legacy params when the peer lacks the capability.

The incarnation fence, delivery no-replay guarantees, and conflict-copy paths are each backed by focused unit tests that assert exact behavior (refused-before-bytes, accepted/bytesWritten equality, bounded late responses), not just pass/no-pass.

ℹ️ Foreground activation is now renderer-owned for local targets

callerOwnsCompletion: !background (create-requested-worktree.ts:52) forces activate: false on the backend startup for every local, non-web foreground creation — not just draft flows — and relies on executeWorktreeCreation → activateAndRevealWorktree to reproduce the activation. Remote targets are capability-gated (worktree.caller-completion.v1), but the local path is unconditional because renderer and host share one binary, so there is no mixed-version concern to gate on. This collapses what was previously a double activation (backend activate: true plus the renderer reveal) into a single renderer-owned owner. Nothing actionable; noting it because it is a broad behavior change riding under a feature PR, and it is the one spot a future regression would surface first. The foreground activation, background (activate:false + surfaceOwner:false), and folder-workspace paths are all covered by the new runtime-folder-worktree-startup.test.ts and the updated creation-flow tests.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

The single commit since the prior review extends the existing surfaceOwner: false foreground-activation fence to the setup terminal, so the setup script no longer steals surface ownership (and focus) from the creation draft.

  • Extended the surfaceOwner: false fence to the setup terminal — spawnLocalStartupAndSetupTerminals now adds ...(sequencedStartup.activate === false ? { surfaceOwner: false } : {}) to both the split and new-tab setup spawn paths, mirroring the startup terminal's existing pattern at worktree-remote.ts:466.
  • Updated the creation-flow tests — worktrees-local-create-flow.test.ts now asserts surfaceOwner: false on both the createTerminal (new-tab) and splitTerminal (split) setup paths under startup: { activate: false }.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

Reviewed the two commits since the prior review, both renderer-side focus-preservation fixes.

  • Preserve focus when adopting background terminal splits — splitManagedPane/openSplitPane now honor an optional activate flag (PaneSplitOptions.activate), skipping setActivePaneId, terminal.focus(), and the active-pane opacity pass (restoring opacity against the current active pane via the drag callback) when activate === false. The flag threads from SplitTerminalPaneDetail through terminal-pane-mount-events.ts and is populated from shouldActivate in terminal-presentation-ipc-bridge.ts, so a background runtime split no longer steals focus from the creation draft.
  • Preserve focus while replaying terminal split layouts — replayTerminalLayout now passes activate: focusInitialPane into each splitPane, so a layout replay for a workspace whose editable draft holds focus no longer re-activates/focuses each replayed split pane mid-replay; the final setActivePane in restoreTerminalPaneLayout still reconciles the active pane and opacity.

Both changes are additive (callers that omit activate keep the prior always-activate behavior), renderer-only, and each is backed by an exact-assertion test that would fail if the fix regressed: pane-split-close.test.ts and terminal-pane-mount-events-focus.test.ts cover activate across undefined/true/false, and layout-serialization.test.ts covers both focus intents.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

The single commit since the prior review adds one line of test coverage to useIpcEvents-terminal-create-surfacing.test.ts.

  • Asserted explicit activation in terminal split events — the orca-split-terminal-pane dispatch assertion for the presentation: 'focused' split path now pins activate: true, matching what terminal-presentation-ipc-bridge.ts:177 already emits (activate: shouldActivate). Because the surrounding assertion uses expect.objectContaining, dropping or mis-setting that flag would previously still pass; the new exact assertion makes the focused path fail if the flag regresses, complementing the activate: false background-split coverage already in the same test.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@nwparker nwparker closed this Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants