Skip to content

feat(native-chat): unify local agent entrypoint routing - #18248

Merged
brennanb2025 merged 21 commits into
mainfrom
brennanb2025/entrypoint-routing-recovery
Sep 3, 2026
Merged

brennanb2025 merged 21 commits into
mainfrom
brennanb2025/entrypoint-routing-recovery

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1338 $\color{#cf222e}{\Huge{\mathbf{−}}}$​360 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​978
Prod 48 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2408 $\color{#cf222e}{\Huge{\mathbf{−}}}$​730 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1678

Summary

Centralize local agent-start routing so every supported visible entrypoint makes one shared decision about structured native Codex chat, legacy Chat UI, or terminal TUI. Structured Codex is used only when the experimental toggle, local capability, ownership, workspace, and launch-option gates all allow it. Unsupported, remote, SSH, WSL, Windows, floating, customized, or toggle-off launches retain their existing terminal/legacy behavior.

ELI5

Before, different buttons and creation flows each made their own guess about how to start an agent. That meant the same Codex launch could open different surfaces depending on where it started. Now they all ask one shared router the same question. If the launch is a supported local structured-Codex case, Orca opens one structured chat tab; otherwise it uses the established fallback for that host and context.

User-facing before / after

Before

  • New-tab, dashboard, source-control, quick-command, fork, continuation, and fix/recovery actions could take separate launch paths.
  • Folder-workspace creation, full worktree creation, quick worktree creation, direct work-item launch, and onboarding had separate routing decisions.
  • A launch could race another launch, cancellation, or unknown outcome and produce duplicate prompts, duplicate fallbacks, or a late tab.
  • Remote/SSH/WSL/floating/Windows/customized launches had to preserve their legacy host-owned behavior independently.

After

  • All visible local launchers use the shared route funnel and the same capability/ownership checks.
  • Eligible local Codex launches create one structured native-chat tab with durable prompt staging and cancellation/unknown-outcome fencing.
  • Ineligible launches continue through the existing terminal or legacy Chat UI path; remote execution remains host-owned and never launches locally.
  • Normal tab activation, close, focus, worktree scope, provider/account ownership, and legacy toggle-off behavior are preserved.

Entrypoints covered

Shared launchAgentInNewTab callers

  1. Dashboard agent start (components/dashboard/launch-dashboard-agent.ts)
  2. Source-control agent action (components/right-sidebar/runSourceControlAgentActionStart.ts)
  3. Source-control recovery launch (components/right-sidebar/source-control/ai/recovery-launch.ts)
  4. Git-history commit action (components/right-sidebar/source-control/sync/use-git-history-commit-actions.ts)
  5. Quick Launch button (components/tab-bar/QuickLaunchButton.tsx)
  6. Tab-bar create menu (components/tab-bar/use-tab-bar-create-menu-controller.ts)
  7. Terminal agent-session fork (components/terminal-pane/terminal-agent-session-fork.ts)
  8. Terminal create actions (components/use-terminal-create-actions.ts)
  9. Fix-checks agent launch (lib/fix-checks-agent-launch.ts)
  10. Agent-session continuation (lib/launch-agent-session-continuation.ts)
  11. Quick command in a new tab (lib/run-quick-command-in-new-tab.ts)

Direct creation families using the same route policy

  1. Folder-workspace composer submit (components/sidebar/folder-workspace-composer-submit.ts)
  2. Full worktree creation (hooks/composer-state/full-creation-execution.ts)
  3. Quick worktree creation (hooks/composer-state/quick-creation-execution.ts)
  4. New-tab launch adapter (lib/launch-agent-in-new-tab.ts)
  5. Direct work-item launch (lib/launch-work-item-direct.ts)
  6. Onboarding folder-agent startup (lib/onboarding-folder-agent-startup.ts)

Intentionally outside this visible route: background/non-visible sessions, AI Vault resume launches, and floating-terminal controls.

Manual Electron validation

Exact branch/head: brennanb2025/entrypoint-routing-recovery at 81beb4735c5395a7b61f92e69435217f35fd2787.

Using Electron + Playwright CDP on that exact worktree, the New tab → Codex flow rendered one structured Codex Chat tab while preserving the pre-existing terminal tab; the backing tab inventory contained an agent-session entry. The app identity was verified as brennanb2025/entrypoint-routing-recovery before testing.

Earlier Electron evidence on the same lane lineage also covered toggle-off Codex TUI, structured Codex creation, Claude Chat UI, tab switching/closing, and cancellation-toast suppression; those checks are called out separately from the exact-head proof above.

Automated validation

  • Focused routing/recovery and i18n tests: 21 files, 167 tests passed
  • Existing changed test files: 142 tests passed
  • Web typecheck passed
  • Changed-code quality: 0 new findings
  • Oxlint and diff checks passed
  • Locale coverage audit passed
  • Electron CDP identity and visible-state proof passed

Review status

Fresh Claude Fable and Codex exact-head reviews: LAND, no proven P0/P1/P2 findings.

CI note

All required package, test-shard, changed-E2E, typecheck, static-analysis, and verify checks passed. The only failing check is the untouched SSH skill-installation harness (skill-install-workspace-not-found), which is unrelated to the changed files and has reproduced outside this lane.

Author: @BrennanKB5

@brennanb2025
brennanb2025 force-pushed the brennanb2025/entrypoint-routing-recovery branch from ea0c449 to e8c1a69 Compare September 2, 2026 21:06
@coderabbitai

coderabbitai Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 0d3ddc77-2824-47a0-8bc5-c30847ce54d5

📥 Commits

Reviewing files that changed from the base of the PR and between 38b1d64 and b5f0a2c.

📒 Files selected for processing (13)
  • src/renderer/src/hooks/composer-state/composer-submit-orchestration.ts
  • src/renderer/src/hooks/composer-state/full-creation-execution.test.ts
  • src/renderer/src/hooks/composer-state/full-creation-execution.ts
  • src/renderer/src/hooks/composer-state/quick-creation-execution.ts
  • src/renderer/src/hooks/useComposerState-host-context-boundaries.test.ts
  • src/renderer/src/lib/agent-trust-preflight.ts
  • src/renderer/src/lib/launch-work-item-direct-agent-routing.ts
  • src/renderer/src/lib/launch-work-item-direct.ts
  • src/renderer/src/lib/structured-agent-session-launch.test.ts
  • src/renderer/src/lib/structured-agent-session-launch.ts
  • src/renderer/src/lib/worktree-creation-flow-agent-trust-preflight.test.ts
  • src/renderer/src/lib/worktree-creation-flow-execute.ts
  • src/renderer/src/lib/worktree-creation-structured-session.ts
💤 Files with no reviewable changes (2)
  • src/renderer/src/hooks/composer-state/full-creation-execution.test.ts
  • src/renderer/src/hooks/composer-state/composer-submit-orchestration.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/renderer/src/hooks/composer-state/full-creation-execution.ts
  • src/renderer/src/lib/worktree-creation-structured-session.ts
  • src/renderer/src/lib/launch-work-item-direct-agent-routing.ts
  • src/renderer/src/lib/structured-agent-session-launch.ts
  • src/renderer/src/lib/structured-agent-session-launch.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

The change centralizes agent launch route selection and adds structured Codex session recovery, prompt staging, cancellation, and fallback handling. Workspace creation, onboarding, direct work-item launches, and new-tab launches now support structured native chat when eligible. Activation avoids redundant terminal creation when a structured session provides the initial surface. Local runtime capabilities are cached and refreshed before structured session synchronization. Tests cover routing, recovery, prompt delivery, cancellation, and activation behavior.

Merge Risk: 🟡 Moderate · up to b5f0a

This PR changes local agent launches to create durable native chat sessions, but some failure and cancellation paths can leave staged prompts or sessions uncleared, bypass the established trust check, or open a workspace without a usable chat or terminal. The current head is not merge-ready until these bounded security and launch-reliability risks are fixed or explicitly accepted.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.76% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 74 functions across 50 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description clearly explains the change, motivation, behavior, entrypoints, and validation. However, it omits the required Linked Issue section and link, and it does not provide the required Visua… Add the repository template sections, including a linked issue after “Fixes #”, Visual Proof with before-and-after attachments or exactly “N/A” with a reason, AI Disclosure, Agent skill upstream boundary, Notes, and the completed Checklist.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: centralizing local agent entrypoint routing for native chat.
Full details: Description check

Explanation

The description clearly explains the change, motivation, behavior, entrypoints, and validation. However, it omits the required Linked Issue section and link, and it does not provide the required Visual Proof attachments or the exact N/A statement. Several required checklist sections are also missing.

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Actionable comments posted: 8

🧹 Nitpick comments (1)
src/renderer/src/components/sidebar/NonGitFolderDialog.tsx (1)

104-104: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove or correct the unreachable structured branch.

When connectionId is non-empty, worktreeRefreshOptions(undefined, connectionId) returns toSshExecutionHostId(connectionId). resolveDismissedOnboardingFolderAgentLaunch passes this value to resolveAgentLaunchRoute, which requires executionHostId === 'local' for structured-native-chat. The branch cannot run in this SSH flow. Confirm the intended host ID; otherwise remove lines 104–120.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 41848ee6-f0b2-407f-bf79-947b81f90b82

📥 Commits

Reviewing files that changed from the base of the PR and between 4ff96df and e8c1a69.

📒 Files selected for processing (48)
  • src/renderer/src/components/native-chat/structured-agent-session-outbox-storage.ts
  • src/renderer/src/components/sidebar/NonGitFolderDialog.tsx
  • src/renderer/src/components/sidebar/folder-workspace-agent-startup.ts
  • src/renderer/src/components/sidebar/folder-workspace-composer-submit.ts
  • src/renderer/src/components/tab-group/useTabGroupTabCloseCommands.structured-session.test.ts
  • src/renderer/src/components/tab-group/useTabGroupTabCloseCommands.ts
  • src/renderer/src/hooks/composer-state/composer-submit-orchestration.ts
  • src/renderer/src/hooks/composer-state/folder-submit-orchestration.ts
  • src/renderer/src/hooks/composer-state/full-creation-execution.test.ts
  • src/renderer/src/hooks/composer-state/full-creation-execution.ts
  • src/renderer/src/hooks/composer-state/full-creation-finalization.ts
  • src/renderer/src/hooks/composer-state/full-creation-issue-command.ts
  • src/renderer/src/hooks/composer-state/full-creation-startup.ts
  • src/renderer/src/hooks/composer-state/full-creation-structured-launch.ts
  • src/renderer/src/hooks/composer-state/quick-creation-execution.ts
  • src/renderer/src/hooks/composer-state/quick-creation-request.ts
  • src/renderer/src/lib/agent-launch-routing-caller-census.test.ts
  • src/renderer/src/lib/agent-launch-routing.test.ts
  • src/renderer/src/lib/agent-launch-routing.ts
  • src/renderer/src/lib/launch-agent-in-new-tab-cwd.test.ts
  • src/renderer/src/lib/launch-agent-in-new-tab.ts
  • src/renderer/src/lib/launch-agent-structured-chat-guard.test.ts
  • src/renderer/src/lib/launch-agent-tab-order.ts
  • src/renderer/src/lib/launch-structured-codex-session.test.ts
  • src/renderer/src/lib/launch-structured-codex-session.ts
  • src/renderer/src/lib/launch-work-item-direct-agent-routing.ts
  • src/renderer/src/lib/launch-work-item-direct-prompt-delivery.ts
  • src/renderer/src/lib/launch-work-item-direct.ts
  • src/renderer/src/lib/onboarding-folder-agent-startup.ts
  • src/renderer/src/lib/pending-worktree-creation.ts
  • src/renderer/src/lib/structured-agent-session-launch-prompt.ts
  • src/renderer/src/lib/structured-agent-session-launch-recovery.ts
  • src/renderer/src/lib/structured-agent-session-launch.test.ts
  • src/renderer/src/lib/structured-agent-session-launch.ts
  • src/renderer/src/lib/structured-native-chat-availability.test.ts
  • src/renderer/src/lib/structured-native-chat-availability.ts
  • src/renderer/src/lib/worktree-activation-emptied-workspace-reseed.test.ts
  • src/renderer/src/lib/worktree-activation-nav-registration.ts
  • src/renderer/src/lib/worktree-activation-store-contract.ts
  • src/renderer/src/lib/worktree-activation.ts
  • src/renderer/src/lib/worktree-agent-activation-seam.test.ts
  • src/renderer/src/lib/worktree-creation-flow-execute.ts
  • src/renderer/src/lib/worktree-creation-structured-session.ts
  • src/renderer/src/lib/worktree-initial-terminal-seeding.ts
  • src/renderer/src/runtime/local-runtime-capabilities.test.ts
  • src/renderer/src/runtime/local-runtime-capabilities.ts
  • src/renderer/src/runtime/local-structured-session-tabs-sync.ts
  • src/renderer/src/store/repos/repo-add-actions.ts
💤 Files with no reviewable changes (2)
  • src/renderer/src/lib/structured-native-chat-availability.test.ts
  • src/renderer/src/lib/structured-native-chat-availability.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.

Comment on lines +93 to +95
if (args.structuredLaunch || !args.agent || !window.api.agentTrust?.markTrusted) {
return
}

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Restore the empty-path guard before the trust write.

The previous inline code required worktreePath before it called markTrusted. This guard is gone. When result.worktree.path is empty, this helper now sends an empty workspacePath to the trust IPC. Add the path check.

🛡️ Proposed fix
-  if (args.structuredLaunch || !args.agent || !window.api.agentTrust?.markTrusted) {
+  if (
+    args.structuredLaunch ||
+    !args.agent ||
+    !args.workspacePath ||
+    !window.api.agentTrust?.markTrusted
+  ) {
     return
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (args.structuredLaunch || !args.agent || !window.api.agentTrust?.markTrusted) {
return
}
if (
args.structuredLaunch ||
!args.agent ||
!args.workspacePath ||
!window.api.agentTrust?.markTrusted
) {
return
}

return
}
const supported = status.capabilities?.includes(STRUCTURED_AGENT_SESSION_RUNTIME_CAPABILITY)
const supported = capabilities.includes(STRUCTURED_AGENT_SESSION_RUNTIME_CAPABILITY)

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Recompute support after tab restoration.

Line 136 uses the first capability refresh. restoreLocalStructuredSessionTabsOnce() performs a second refresh on first use. If the capability changes between these reads, this code can subscribe after support was removed or skip subscription after support was added. Read the cached capabilities after restoration, or pass one refresh result through both operations.

Proposed fix
-import { refreshLocalRuntimeCapabilities } from './local-runtime-capabilities'
+import {
+  readLocalRuntimeCapabilities,
+  refreshLocalRuntimeCapabilities
+} from './local-runtime-capabilities'
 
-  const capabilities = await refreshLocalRuntimeCapabilities()
+  await refreshLocalRuntimeCapabilities()
   if (args.isDisposed()) {
     return
   }
-  const supported = capabilities.includes(STRUCTURED_AGENT_SESSION_RUNTIME_CAPABILITY)
   await restoreLocalStructuredSessionTabsOnce()
   if (args.isDisposed()) {
     return
   }
+  const supported = readLocalRuntimeCapabilities().includes(
+    STRUCTURED_AGENT_SESSION_RUNTIME_CAPABILITY
+  )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const supported = capabilities.includes(STRUCTURED_AGENT_SESSION_RUNTIME_CAPABILITY)
const supported = readLocalRuntimeCapabilities().includes(
STRUCTURED_AGENT_SESSION_RUNTIME_CAPABILITY
)

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

Important

The routing, ownership gates, and prompt-durability logic are solid, but one coalescing path silently drops a racing prompt and misreports its delivery to the caller. Details below.

Reviewed changes

  • Central route resolver — resolveAgentLaunchRoute folds the structured / legacy-native-chat / terminal decision into one fail-closed function gated on execution host, platform, project runtime, and the host's advertised capability, wired into every local entrypoint.
  • Durable prompt staging — structured Codex launches stage the prompt in a localStorage outbox, then dispatch it after agentSession.create, requeueing on refusal and falling back to the preserved terminal launch through claimDefinitiveRefusalFallback.
  • Launch coalescing, cancellation, reconcile — one launch identity per worktree with re-reconcile on unknown visibility, plus cancelStructuredCodexLaunch on tab close.
  • Capability gating — local-runtime-capabilities.ts reads the live host's capabilities (fail-closed) and replaces the removed canUseStructuredNativeChat.
  • Activation surface control — providesInitialSurface / createNewTerminalForStartup keep an unwanted terminal out of structured launches while preserving the refusal-fallback terminal.
  • Mechanical extraction — creation orchestration split into focused helpers (full-creation-*, launch-work-item-direct-*, worktree-creation-structured-session, launch-agent-tab-order) with no stated behavior change.

ℹ️ Nitpicks

  • trackLaunchFailureToast (src/renderer/src/lib/structured-agent-session-launch.ts:138) attaches a .catch to every state.promise value it is handed without the state.promise === promise staleness guard that trackLaunchSettlement uses, so repeated reconcileUnknownLaunch failures can emit duplicate "Could not open Codex chat" toasts.
  • cancelStructuredCodexLaunch (src/renderer/src/lib/structured-agent-session-launch.ts:228) discards the staged prompt optimistically, before closeStructuredAgentSession is confirmed by the tab-close caller; a failed close leaves the host session alive with its prompt already deleted.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏


export type StructuredCodexLaunchOptions = {
prompt?: string
promptDelivery?: 'auto-submit' | 'submit-after-ready'

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.

promptDelivery is accepted here and threaded from src/renderer/src/lib/launch-agent-in-new-tab.ts:227 and src/renderer/src/lib/launch-work-item-direct-agent-routing.ts:132, but neither settleStructuredCodexLaunchPrompt nor structuredCodexLaunchState reads it, so submit-after-ready collapses to immediate dispatch on the structured path. Honor the distinction or drop the option so it doesn't advertise behavior that doesn't exist.

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

ℹ️ Follow-up commits are clean — no new issues. The prior review's open finding (and the minor prompts in structured-agent-session-launch.ts) are untouched by these commits and still stand.

Reviewed changes

  • Import dedup — full-creation-execution.ts folds the duplicated CLIENT_PLATFORM import back into the existing @/lib/new-workspace line.
  • Deps-array consolidation — folder-submit-orchestration.ts replaces eight settings?.{field} entries with the single settings reference the submit callback now closes over, satisfying the exhaustive-deps gate.
  • Caller-census completion — worktree-activation-surface-caller-wiring.test.ts registers the six new providesInitialSurface callers and broadens the activation-call regex to [\s\S]*? so nested activation calls are matched.

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

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: a98caf0b-132e-4845-9a66-5fa64ba88413

📥 Commits

Reviewing files that changed from the base of the PR and between f814462 and 92665cb.

📒 Files selected for processing (1)
  • src/renderer/src/lib/worktree-activation-surface-caller-wiring.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.

// are stripped first — commenting the flag out in place must fail this test.
const ACTIVATION_CALL_WITH_OPT_OUT =
/activateAndReveal(?:Worktree|FolderWorkspace|Workspace)\((?:[^()]|\([^()]*\))*?providesInitialSurface: true/
/activateAndReveal(?:Worktree|FolderWorkspace|Workspace)\([\s\S]*?providesInitialSurface: true/

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep the opt-out match within the same activation call.

[\s\S]*? can cross the closing ) and match providesInitialSurface: true from a later activation call or unrelated code. A file with an earlier activation call that lacks the flag can therefore pass the census incorrectly. Use a parser or balanced-call scanner to verify the property belongs to the matched activation call.

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

Important

The two new commits swap the resolver's platform from CLIENT_PLATFORM to the resolved launch platform, which silently admits WSL / repair-required local repos to structured Codex chat — the exact boundary resolveAgentLaunchRoute's own runtimeRefused gate (and this PR's summary) is meant to preserve.

Reviewed changes

  • Routing now feeds the launch platform — full-creation-execution.ts and quick-creation-execution.ts replace platform: CLIENT_PLATFORM with platform: selectedRepoAgentLaunchPlatform in their resolveAgentLaunchRoute calls, and thread selectedRepoAgentLaunchPlatform through the composer submission inputs.
  • Boundary assertions updated — useComposerState-host-context-boundaries.test.ts drops the CLIENT_PLATFORM routing assertion in favor of the selectedRepoAgentLaunchPlatform literal.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | 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.

Caution

The revert restores the correct CLIENT_PLATFORM routing gate, but leaves selectedRepoAgentLaunchPlatform wired to the wrong hook — the branch no longer typechecks (pnpm tc:web emits TS2353 + TS2345).

Reviewed changes

  • Routing gate restored — full-creation-execution.ts and quick-creation-execution.ts revert resolveAgentLaunchRoute's platform back to CLIENT_PLATFORM, and drop selectedRepoAgentLaunchPlatform from full-creation-execution.ts's input type; the startup plan still receives the launch platform.
  • Boundary test scoped — useComposerState-host-context-boundaries.test.ts isolates the startup-plan assertions with sourceBetween, so the routing-call region no longer trips the not.toContain('platform: CLIENT_PLATFORM') check.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | 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 critical issues — the two follow-up commits are solid; one minor reuse suggestion inline.

Reviewed changes

  • Typecheck restored — selectedRepoAgentLaunchPlatform moved from the useFullCreationExecution call back onto useFullSubmitPreparation, clearing the TS2353/TS2345 the prior review flagged (pnpm tc:web is clean).
  • Coalesced prompt delivery fixed — the existing-launch branch now stages and dispatches a second caller's prompt and returns a per-caller promptDeliveryResult, so a racing continuation no longer silently drops its context (new test covers the success path).
  • Shared trust preflight — extracted preflightAgentTrust into agent-trust-preflight.ts and wired it into the structured-launch refusal fallbacks (direct work-item + worktree creation) so a terminal fallback pre-marks Codex trust.
  • Late-activation tab surface preserved — setActiveTabType gained an optional worktreeId; activateStructuredAgentSessionTab passes it so agent-session activation in a non-active worktree no longer clobbers the visible tab type.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

import { TUI_AGENT_CONFIG } from '../../../shared/tui-agent-config'
import type { TuiAgent } from '../../../shared/tui-agent'

export async function preflightAgentTrust(args: {

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.

This new shared helper consolidates the markTrusted/preflightTrust lookup, but markDirectWorkItemAgentTrusted (launch-work-item-direct-agent-routing.ts:88), which this same PR adds, still inlines the identical field read and differs only by a structuredLaunch guard. Consider delegating to preflightAgentTrust so the two copies can't drift.

@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 in these four commits. Approval stays withheld only because three prior Pullfrog threads remain open and were not touched by this delta: the promptDelivery option still dead in the structured path, the coalesced-refusal ??= fallback first-wins residual, and the markDirectWorkItemAgentTrusted/preflightAgentTrust duplication nit.

Reviewed changes

  • Default-args classification — hasExplicitTuiAgentArgs ignores per-launch args that equal the agent's built-in default (e.g. Codex's --dangerously-bypass-approvals-and-sandbox) so resolved defaults no longer read as TUI customization and force a terminal fallback; wired into hasExplicitTuiLaunchCustomization and every routing call site.
  • Structured quick-command history — runQuickCommandInNewTab records quick-command recency immediately for structured launches (which publish their tab asynchronously), using the caller's group or its active-group fallback.

Both changes ship focused tests that would fail under the prior behavior.

Pullfrog  | Fix it ➔ | 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 in these two commits. One advances a prior open thread — the whole-outbox discard removes the orphaned-prompt residual on refusal/cancel — but the coalesced-refusal ??= first-wins fallback and the two other open threads remain, so approval stays withheld.

Reviewed changes

  • Cleared the abandoned launch outbox — discardStagedPrompt removed only the first caller's stagedPromptId, orphaning coalesced prompts in localStorage after a refusal or cancellation. It's replaced by discardStructuredAgentSessionLaunchOutbox, which clears the entire session outbox on both paths.
  • Cancelled dismissed worktree launches — launchStructuredWorktreeSession now takes creationId, subscribes to the store, and when the pending creation is dismissed mid-launch it cancels the in-flight Codex launch and retires any already-created session (closing it and its tab). executeWorktreeCreation short-circuits instead of completing the handoff. A focused test covers the dismiss-mid-launch path.

Pullfrog  | Fix it ➔ | 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 in this commit. The coalesced-refusal ??= first-wins thread is now fully resolved; the two remaining minor threads (promptDelivery still unread in the structured path, and the markDirectWorkItemAgentTrusted/preflightAgentTrust duplication) are untouched by this delta and still hold approval.

Reviewed changes

  • Per-caller refusal fallbacks — structured-agent-session-launch.ts now models coalesced launches as a StructuredLaunchCallerGroup (structured-agent-session-launch-callers.ts). Each caller keeps its own claimDefinitiveRefusalFallback callback, and settleStructuredLaunchCallersWithFallback runs every caller's fallback on refusal, closing the first-wins residual.
  • visibilityUnknown outcome — startStructuredCodexLaunch exposes isVisibilityUnknown(), and the full-creation, direct work-item, and worktree-creation flows now distinguish a definitive refusal (terminal fallback) from "couldn't confirm the session opened" (retry surface, no terminal fallback), each backed by a focused test.
  • Retry surface for unknown outcomes — executeWorktreeCreation keeps the pending creation in an error state ("Retry to check again") instead of completing the handoff when visibility is unknown, rather than reporting completion with no session to show.

Pullfrog  | Fix it ➔ | 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 critical issues — one minor observation inline on the recovery-retry progress state.

Reviewed changes

  • Extracted shared handoff — the post-create completion (clearing the pending entry, terminal seeding, agent startup, terminal focus, note persistence) moved into completeWorktreeCreation so the primary and recovery paths share one routine.
  • Uncertain-launch reconciliation — markStructuredWorktreeLaunchUnconfirmed now records structuredLaunchRecoveryWorktreeId, and retryBackgroundWorktreeCreation routes that entry to retryStructuredWorktreeLaunch, which reuses the already-created worktree and reconciles its Codex session instead of recreating it.
  • Focused coverage — the unknown-outcome test now asserts a recovery retry reconciles without a second createWorktree.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

store.setActivePendingWorktreeCreation(creationId)
store.setActiveView('terminal')
store.setSidebarOpen(true)
if (entry.structuredLaunchRecoveryWorktreeId) {

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.

The phase reset above runs before this branch and unconditionally sets phase: 'fetching' (plus status: 'creating'), so a recovery retry shows "Fetching base branch…" while actually reconciling an existing Codex session on an already-created worktree. Consider skipping the phase reset on this branch (or using an indeterminate phase) so the panel doesn't imply a git fetch is in progress.

@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 blocking issues — the release mechanism is correct and well-tested, with one consistency gap noted below.

Reviewed changes

  • Exposed per-caller release after unknown outcomes — startStructuredCodexLaunch now returns releaseCallerAfterUnknownOutcome, backed by a new releaseStructuredLaunchCallerAfterUnknownOutcome in the caller group that settles and drops the caller when the group outcome is unknown.
  • Recovery retry reuses the queued prompt — launchStructuredWorktreeSession gained recoverUnknownLaunch, starting the retry with empty options so the already-staged outbox prompt is not re-enqueued (no duplicate agentSession.send).
  • Refusal isolation between first and retry callers — the worktree-creation flow releases its caller on an unknown outcome, so a later recovery retry that is refused runs only the retry caller's terminal fallback, not the abandoned first caller's.

ℹ️ Direct work-item and full-creation structured launches still orphan their caller after an unknown outcome

releaseCallerAfterUnknownOutcome is only invoked by the worktree-creation recovery path. settleDirectWorkItemStructuredLaunch (src/renderer/src/lib/launch-work-item-direct-agent-routing.ts:162) and settleFullCreationStructuredLaunch (src/renderer/src/hooks/composer-state/full-creation-structured-launch.ts:41) observe the same isVisibilityUnknown() and claim the same definitive refusal fallback, but leave their caller in the coalesced group. A later re-launch of the same worktree reuses the identity and, if refused, settleStructuredLaunchCallersWithFallback still runs the abandoned first caller's terminal fallback, reopening the exact spurious-terminal case this commit fixes for the creation path.

Technical details
# Release the unknown-outcome caller in the direct and full-creation flows too

## Affected sites
- src/renderer/src/lib/launch-work-item-direct-agent-routing.ts:162 — returns `{ visibilityUnknown: true }` without releasing the caller.
- src/renderer/src/hooks/composer-state/full-creation-structured-launch.ts:41 — same shape; returns on unknown without release.
- src/renderer/src/lib/structured-agent-session-launch-callers.ts:226 — `releaseStructuredLaunchCallerAfterUnknownOutcome` exists but is only called from `worktree-creation-structured-session.ts:154`.

## Required outcome
- Decide whether the direct work-item and full-creation flows can re-reuse the same worktree identity after an unknown outcome; if so, release their caller there too so a refused re-launch cannot double-fire the abandoned fallback.

## Open questions for the human
- Is re-launch after an unknown outcome expected to mint a fresh intent (new identity) in those flows, making release unnecessary?

Pullfrog  | Fix it ➔ | 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 critical issues from the merge — one small cleanup from the merge resolution surfaced inline.

Reviewed changes

  • Merged origin/main into the branch — two merge commits (0a0230ef94, dacac4a) brought upstream native-chat and SSH/execution-host work into the shared files this PR also touches. No new PR-authored behavior change.
  • Reconciled shared launch files onto main's race-resistant logic — structured-agent-session-launch.ts gained useStructuredCodexLaunchStatus (a useSyncExternalStore status hook plus listener notification), structured-agent-session-launch-recovery.ts gained hasAdoptedStructuredSession (short-circuits verifyPublishedSession when the tab is already in unifiedTabsByWorktree), and local-structured-session-tabs-sync.ts gained publication-epoch/version fences and subscription reconnect logic. The branch's caller-group / refusal-fallback / releaseCallerAfterUnknownOutcome features survive intact.
  • Store-adoption verification — verifyPublishedSession now consults the renderer store before the inventory RPC, so adopted sessions resolve without an extra round-trip.

ℹ️ Nitpicks

  • The merge left a duplicate cancelStructuredCodexLaunch (see inline) in the single-tab close path.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

worktreeId
)
if (item.contentType === 'agent-session') {
cancelStructuredCodexLaunch(worktreeId, item.entityId)

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.

This new cancelStructuredCodexLaunch duplicates the call a few lines down (currently line 129), leaving back-to-back identical calls with two stacked // Why comments. The merge kept this PR's pre-existing cancel and main's #18251 "still-reconciling create" cancel, but the call is idempotent so the second is dead. Remove one call (both comments are worth keeping).

@brennanb2025
brennanb2025 merged commit c4f335b into main Sep 3, 2026
32 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* feat(native-chat): unify local agent entrypoint routing

* fix(native-chat): satisfy entrypoint routing quality gates

* test(native-chat): keep activation caller census complete

* fix(native-chat): honor selected runtime platform in routing

* fix(native-chat): pass runtime platform through full creation

* fix(native-chat): include runtime platform dependency

* fix(native-chat): preserve client platform routing gate

* fix(native-chat): preserve trust and coalesced prompts

* fix(native-chat): preserve target tab surface on late activation

* fix(native-chat): retain quick-command history for structured tabs

* test(native-chat): cover structured quick-command group history

* fix(native-chat): ignore resolved default agent args in routing

* test(native-chat): cover default agent args classification

* fix(native-chat): keep direct launch within lint limits

* fix(native-chat): clear abandoned launch outbox

* fix: cancel dismissed structured worktree launches

* fix(native-chat): preserve coalesced launch recovery

* fix(native-chat): reconcile uncertain worktree launches

* fix(native-chat): reuse uncertain launch caller

---------

Co-authored-by: Merge Sim <sim@local>
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.

1 participant