Repository navigation
feat(new-workspace): unified source picker + non-submitted URL drafts for agents - #1426
Merged
Merged
Conversation
Co-authored-by: Orca <[email protected]>
Co-authored-by: Orca <[email protected]>
…ertical alignment Co-authored-by: Orca <[email protected]>
…e icons, tooltips on pill actions Co-authored-by: Orca <[email protected]>
Co-authored-by: Orca <[email protected]>
… actually appears in the agent input Co-authored-by: Orca <[email protected]>
…i/opencode type-chars) Co-authored-by: Orca <[email protected]>
…pi/opencode Replaces per-agent strategy guesswork with a measured readiness check: title-idle / non-shell-foreground stable for 1.5s / 2.5s minimum floor. Verified against codex, pi, opencode, claude in a node-pty + xterm-headless test rig — bracketed paste lands in the input buffer for all four. Co-authored-by: Orca <[email protected]>
The TUI-ready heuristic in agent-paste-draft.ts works for every tested agent (claude/codex/pi/opencode), so the AgentDraftInjectionStrategy field, type-chars + bracketed-paste-slow code paths, and per-agent overrides are dead. Keep the `agent` arg on pasteDraftWhenAgentReady for future per-agent escape hatches without touching every call site. Co-authored-by: Orca <[email protected]>
Both TUIs open with a 'Do you trust this folder?' menu on first launch that consumes keystrokes as menu input — pasting a URL there either selects an arbitrary option or quits the session. Mark them with skipDraftUrlInjection so the workspace still opens cleanly; the user types/pastes the URL themselves once past the trust menu. Co-authored-by: Orca <[email protected]>
…/copilot Replaces the empirical TUI-ready waits with two deterministic mechanisms: 1) `claude --prefill <text>` flag — Claude launches with the URL already in its input box, no submit. Eliminates the readiness/paste race entirely for the most common agent. 2) DECSET 2004 (`\x1b[?2004h`) detection on the PTY data stream for every other agent. That escape is the protocol-level "input layer ready, accepting bracketed paste" handshake — emitted by claude/codex/pi/ opencode/gemini/cursor-agent/copilot the moment the input box mounts. We tap it via a sidecar subscription on pty-dispatcher (no interference with the primary xterm handler) and paste as soon as it lands. The 8s budget is now an upper bound, not a target. Cursor-agent and Copilot's "Do you trust this folder?" menus are bypassed by writing the same trust artifacts the CLIs themselves write after the user accepts: - Cursor: `~/.cursor/projects/<slug>/.workspace-trusted` (slug = abs path with leading `/` stripped, remaining `/` → `-`). - Copilot: append cwd to `trustedFolders` in `~/.copilot/config.json` (the same array the bundled `addTrustedFolder` writes). Verified against the cursor-agent CLI bundle (versions/2026.04.17-787b533/ index.js: `_=".workspace-trusted"`) and the @github/copilot 1.0.32 bundle (`isFolderTrusted` / `addTrustedFolder` both read/write `trustedFolders`). Both check via realpath() before string-comparing, so the trust preset canonicalizes too. skipDraftUrlInjection is dropped — both agents now get the draft URL paste once the trust menu is pre-resolved. Tests: 24 passing across tui-agent-startup, agent-trust-presets, pty-dispatcher routing. Co-authored-by: Orca <[email protected]>
OpenCode emits DECSET 2004 at ~500ms during alt-screen setup, then runs a 1.3s splash render with NO bytes on the PTY, then paints the actual input box at ~1.85s. Pasting on the bare ?2004h signal lands during the silent gap and the bytes are dropped. The fix: take ?2004h as the necessary precondition, then wait for the TUI's render burst to finish — defined as 1500ms of stream silence after the most recent post-?2004h byte. This captures both the fast TUIs (claude/pi/codex emit setup escapes in one burst then go quiet) and the slow ones (opencode emits, sleeps for the splash, emits again, then goes quiet). Verified against opencode/claude/pi in a node-pty rig: paste lands on the first try with the new strategy. The hard 8s timeout still caps the wait when an agent fails to launch. Co-authored-by: Orca <[email protected]>
If the preload bundle is older than the renderer (a real situation in electron-vite dev because preload changes only apply on full restart, not HMR), `window.api.agentTrust` is undefined and the launch crashes with "Cannot read properties of undefined (reading 'markTrusted')" before the worktree even opens. Guard the call sites in launch-work-item-direct and useComposerState to skip the trust pre-write when the IPC isn't exposed, and wrap the invoke in try/catch so an IPC error never blocks the launch — the user just sees the trust menu and accepts it manually, same as before this feature shipped. Co-authored-by: Orca <[email protected]>
4 tasks done
…yolo-create The Use CTA on the Tasks page used to create+activate a worktree synchronously, which surprised users — the worktree appeared in the sidebar before they had a chance to confirm name / agent / setup. The unified New Workspace dialog landed in this branch already supports opening with a linked work item pre-filled (see openComposerForItem / openComposerForLinearItem), so just route Use through it. The launchWorkItemDirect helper stays exported for ProjectViewWrapper, which has its own UX where the immediate-create flow is the right call. Co-authored-by: Orca <[email protected]>
Merging main brought in the Autohand Code agent test (PR #1382), which predated this branch's addition of `agent` to AgentStartupPlan. Aligning the assertion fixes the lone CI test failure on this PR. Co-authored-by: Orca <[email protected]>
Two minor follow-ups from self-review: 1. `pasteDraftWhenAgentReady` no longer reads `expectedProcess` — readiness is gated on DECSET 2004 alone now, not on PTY foreground process. Drop it from the signature and from the two callers (launch-work-item-direct, new-workspace). 2. The pty-dispatcher's sidecar fan-out iterates the live Set, which is safe against deleting the current element but not against a watcher that synchronously subscribes a sibling. Snapshot via Array.from before the loop. Cheap (Set is tiny) and removes the latent footgun. No behavior change. Co-authored-by: Orca <[email protected]>
The CreateFromTab refactor in this branch replaced the separate "Workspace name" Input with a single SmartWorkspaceNameField whose default-mode placeholder is "Type a name, #1234, branch, GitHub or Linear URL". The worktree-create e2e test was still anchoring on the old "Workspace name" text and could not find the input. Update the placeholder regex to match the new copy. Free-form text typed into smart mode is treated as a workspace name by submitQuick — same contract the test used before. Verified locally: targeted e2e passes in 2.2s. Co-authored-by: Orca <[email protected]>
brennanb2025
added a commit
that referenced
this pull request
May 5, 2026
Conflicts resolved: - launch-work-item-direct.ts: kept telemetry threading (launchSource, telemetrySource, agent_started/agent_error events) on top of main's unified-picker refactor (pasteDraftWhenAgentReady, agentTrust preflight, buildAgentDraftLaunchPlan). Dropped launchFromBranch — main removed its only caller (CreateFromTab) so the helper is dead code. - NewWorkspaceComposerModal.tsx: dropped the Quick / Create-from tab UI removed in #1426; kept the telemetrySource passthrough into ComposerModalData and useComposerState. - TaskPage.tsx: kept main's behavior of opening the composer (telemetry flows via openComposerForItem / openComposerForLinearItem). - useComposerState.ts: merged imports — kept agent-paste-draft + draft launch plan from main, kept tuiAgentToAgentKind / AgentStartedTelemetry from telemetry branch. - useIpcEvents.ts: kept telemetrySource: 'shortcut' on Cmd+N composer open; dropped initialTab (no longer a tabbed UI). - CreateFromTab.tsx: accepted main's deletion. Co-authored-by: Orca <[email protected]>
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
… for agents (stablyai#1426) * Fix new workspace composer focus restore * Unify new workspace source selection * WIP: selected source pill in smart workspace name field Co-authored-by: Orca <[email protected]> * fix(new-workspace): truncate source pill so it doesn't expand the dialog Co-authored-by: Orca <[email protected]> * feat(new-workspace): add open-in-browser button to source pill, fix vertical alignment Co-authored-by: Orca <[email protected]> * refactor(new-workspace): drop redundant kind suffix, distinct PR/issue icons, tooltips on pill actions Co-authored-by: Orca <[email protected]> * fix(new-workspace): type linked URL into agent input without auto-submit Co-authored-by: Orca <[email protected]> * fix(new-workspace): use bracketed-paste for draft URL injection so it actually appears in the agent input Co-authored-by: Orca <[email protected]> * feat(agents): per-agent draft injection strategy (codex slow paste, pi/opencode type-chars) Co-authored-by: Orca <[email protected]> * fix(agents): smarter TUI-ready heuristic + bracketed paste for codex/pi/opencode Replaces per-agent strategy guesswork with a measured readiness check: title-idle / non-shell-foreground stable for 1.5s / 2.5s minimum floor. Verified against codex, pi, opencode, claude in a node-pty + xterm-headless test rig — bracketed paste lands in the input buffer for all four. Co-authored-by: Orca <[email protected]> * refactor(agents): drop unused per-agent draft strategy abstraction The TUI-ready heuristic in agent-paste-draft.ts works for every tested agent (claude/codex/pi/opencode), so the AgentDraftInjectionStrategy field, type-chars + bracketed-paste-slow code paths, and per-agent overrides are dead. Keep the `agent` arg on pasteDraftWhenAgentReady for future per-agent escape hatches without touching every call site. Co-authored-by: Orca <[email protected]> * feat(agents): skip draft URL injection for copilot + cursor-agent Both TUIs open with a 'Do you trust this folder?' menu on first launch that consumes keystrokes as menu input — pasting a URL there either selects an arbitrary option or quits the session. Mark them with skipDraftUrlInjection so the workspace still opens cleanly; the user types/pastes the URL themselves once past the trust menu. Co-authored-by: Orca <[email protected]> * feat(agents): native --prefill for claude, trust pre-write for cursor/copilot Replaces the empirical TUI-ready waits with two deterministic mechanisms: 1) `claude --prefill <text>` flag — Claude launches with the URL already in its input box, no submit. Eliminates the readiness/paste race entirely for the most common agent. 2) DECSET 2004 (`\x1b[?2004h`) detection on the PTY data stream for every other agent. That escape is the protocol-level "input layer ready, accepting bracketed paste" handshake — emitted by claude/codex/pi/ opencode/gemini/cursor-agent/copilot the moment the input box mounts. We tap it via a sidecar subscription on pty-dispatcher (no interference with the primary xterm handler) and paste as soon as it lands. The 8s budget is now an upper bound, not a target. Cursor-agent and Copilot's "Do you trust this folder?" menus are bypassed by writing the same trust artifacts the CLIs themselves write after the user accepts: - Cursor: `~/.cursor/projects/<slug>/.workspace-trusted` (slug = abs path with leading `/` stripped, remaining `/` → `-`). - Copilot: append cwd to `trustedFolders` in `~/.copilot/config.json` (the same array the bundled `addTrustedFolder` writes). Verified against the cursor-agent CLI bundle (versions/2026.04.17-787b533/ index.js: `_=".workspace-trusted"`) and the @github/copilot 1.0.32 bundle (`isFolderTrusted` / `addTrustedFolder` both read/write `trustedFolders`). Both check via realpath() before string-comparing, so the trust preset canonicalizes too. skipDraftUrlInjection is dropped — both agents now get the draft URL paste once the trust menu is pre-resolved. Tests: 24 passing across tui-agent-startup, agent-trust-presets, pty-dispatcher routing. Co-authored-by: Orca <[email protected]> * fix(agents): wait for post-?2004h render burst to settle before paste OpenCode emits DECSET 2004 at ~500ms during alt-screen setup, then runs a 1.3s splash render with NO bytes on the PTY, then paints the actual input box at ~1.85s. Pasting on the bare ?2004h signal lands during the silent gap and the bytes are dropped. The fix: take ?2004h as the necessary precondition, then wait for the TUI's render burst to finish — defined as 1500ms of stream silence after the most recent post-?2004h byte. This captures both the fast TUIs (claude/pi/codex emit setup escapes in one burst then go quiet) and the slow ones (opencode emits, sleeps for the splash, emits again, then goes quiet). Verified against opencode/claude/pi in a node-pty rig: paste lands on the first try with the new strategy. The hard 8s timeout still caps the wait when an agent fails to launch. Co-authored-by: Orca <[email protected]> * fix(agents): guard agentTrust IPC so stale preload doesn't crash launch If the preload bundle is older than the renderer (a real situation in electron-vite dev because preload changes only apply on full restart, not HMR), `window.api.agentTrust` is undefined and the launch crashes with "Cannot read properties of undefined (reading 'markTrusted')" before the worktree even opens. Guard the call sites in launch-work-item-direct and useComposerState to skip the trust pre-write when the IPC isn't exposed, and wrap the invoke in try/catch so an IPC error never blocks the launch — the user just sees the trust menu and accepts it manually, same as before this feature shipped. Co-authored-by: Orca <[email protected]> * feat(tasks): route 'Use' through the New Workspace dialog instead of yolo-create The Use CTA on the Tasks page used to create+activate a worktree synchronously, which surprised users — the worktree appeared in the sidebar before they had a chance to confirm name / agent / setup. The unified New Workspace dialog landed in this branch already supports opening with a linked work item pre-filled (see openComposerForItem / openComposerForLinearItem), so just route Use through it. The launchWorkItemDirect helper stays exported for ProjectViewWrapper, which has its own UX where the immediate-create flow is the right call. Co-authored-by: Orca <[email protected]> * test(agents): include `agent` field in autohand startup-plan assertion Merging main brought in the Autohand Code agent test (PR stablyai#1382), which predated this branch's addition of `agent` to AgentStartupPlan. Aligning the assertion fixes the lone CI test failure on this PR. Co-authored-by: Orca <[email protected]> * refactor(agents): drop unused expectedProcess arg + snapshot sidecar set Two minor follow-ups from self-review: 1. `pasteDraftWhenAgentReady` no longer reads `expectedProcess` — readiness is gated on DECSET 2004 alone now, not on PTY foreground process. Drop it from the signature and from the two callers (launch-work-item-direct, new-workspace). 2. The pty-dispatcher's sidecar fan-out iterates the live Set, which is safe against deleting the current element but not against a watcher that synchronously subscribes a sibling. Snapshot via Array.from before the loop. Cheap (Set is tiny) and removes the latent footgun. No behavior change. Co-authored-by: Orca <[email protected]> * test(e2e): match the unified smart-name input's new placeholder The CreateFromTab refactor in this branch replaced the separate "Workspace name" Input with a single SmartWorkspaceNameField whose default-mode placeholder is "Type a name, stablyai#1234, branch, GitHub or Linear URL". The worktree-create e2e test was still anchoring on the old "Workspace name" text and could not find the input. Update the placeholder regex to match the new copy. Free-form text typed into smart mode is treated as a workspace name by submitQuick — same contract the test used before. Verified locally: targeted e2e passes in 2.2s. Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Orca <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two threads landed in this branch:
Unified the New Workspace dialog — replaces the separate "Create from…" tab with a single source-picker (Smart / GitHub / Branch / Linear / Name) inline with the workspace name field. ~1320 lines of
CreateFromTabremoved; the smart field now owns search, mode tabs, cross-repo URL detection, and a dismissible source pill.Selected-source pill + non-submitted URL drafts — when the user picks a GitHub issue/PR or Linear item, the agent launches with that URL pre-filled in its input as a draft (no auto-submit). Replaces the previous
Complete <url>autosubmitted prompt template.What's in the pill
min-w-0cascade through flex/grid ancestors sotruncateactually bites).Agent draft injection — deterministic signals only
Earlier revisions of this branch used empirical waits (
MIN_TUI_READY_MS = 2500ms+ title/foreground stability heuristics). Those were replaced with two protocol-level mechanisms — no per-agent timing constants left:1. Native prefill flag where available. Claude Code ships
--prefill <text>, which launches the TUI with the text already in the input box and nothing submitted. We use it for Claude (per #926) and thedraftPromptFlagshape onTuiAgentConfiglets us drop in additional agents as one-liners when their CLIs ship the equivalent.2. PTY stream readiness for everything else. For agents without a native flag (codex / pi / opencode / cursor-agent / copilot), bracketed paste is gated on two stream signals tapped via a sidecar subscription on
pty-dispatcher:\x1b[?2004h(DECSET 2004 — bracketed-paste-enable) — the protocol-level "I accept bracketed paste" handshake. Every prefill-capable TUI emits this when its input layer is wired up.8s hard timeout caps the wait if a launch fails. No
MIN_TUI_READY_MS, no foreground-process polling, no title-stable heuristic.Cursor-agent + Copilot trust pre-write
Both CLIs gate first-launch in an unfamiliar directory behind a "Do you trust this folder?" menu that consumes keystrokes (numbered options / single-letter shortcuts). Earlier revisions marked these agents
skipDraftUrlInjection: trueand surfaced a toast — that's gone now. Instead, before spawning the agent, main writes the same trust artifact each CLI writes after the user accepts:~/.cursor/projects/<slug>/.workspace-trusted(slug = abs path with leading/stripped, remaining/→-; payload{ trustedAt, workspacePath })trustedFoldersin~/.copilot/config.jsonVerified against the
cursor-agent2026.04.17-787b533 bundle (_=".workspace-trusted") and the@github/copilot1.0.32 bundle (isFolderTrusted/addTrustedFolderboth read/writetrustedFolders). Both check via realpath() before string-comparing, so the trust preset canonicalizes too. The IPC and call sites are guarded so a stale preload bundle (preload doesn't HMR in electron-vite) skips the pre-write silently rather than crashing the launch with "Cannot read properties of undefined".Other tweaks
AgentStartupPlancarries theagentid so the paste path can apply per-agent behavior without re-deriving it from the launch command.Verification
pnpm tc:webclean,pnpm tc:nodecleanpnpm exec vitest run src/renderer/src/lib/tui-agent-startup.test.ts src/main/agent-trust-presets.test.ts src/main/ipc/register-core-handlers.test.ts— 20/20 passing (4 new tests forbuildAgentDraftLaunchPlan, 4 new tests for the trust presets)oxlintclean across all touched filesMade with Orca 🐋