Skip to content

Cli Session Launch Latency#377

Merged
arul28 merged 4 commits into
mainfrom
ade/cli-session-launch-latency-5e13552e
May 27, 2026
Merged

Cli Session Launch Latency#377
arul28 merged 4 commits into
mainfrom
ade/cli-session-launch-latency-5e13552e

Conversation

@arul28
Copy link
Copy Markdown
Owner

@arul28 arul28 commented May 27, 2026

Summary

Describe the change.

What Changed

Key files and behaviors.

Validation

How you tested.

Risks

Anything to watch.

ADE   Open in ADE  ·  ade/cli-session-launch-latency-5e13552e branch  ·  PR #377

Summary by CodeRabbit

  • New Features
    • Persistent composer drafts with recovery and queued background sends.
    • “Claim” controls allowing lanes/sessions to be attributed to browser, iOS simulator, and app-control tools.
  • Bug Fixes
    • More reliable terminal/PTy initial-input handling and cleanup.
    • Improved draft restore/merge behavior after failed launches.
  • UI
    • Sidebar and panel warnings updated for tool ownership; terminal scrolling improved.
  • Tests
    • Expanded coverage for drafts, session launches, ownership/claim flows, and terminal behavior.

Review Change Stack

Greptile Summary

This PR reduces CLI session launch latency by making session creation optimistic — the terminal opens immediately after PTY launch returns rather than waiting for a backend refresh. It also introduces persistent composer draft snapshots (stored in localStorage with debounced writes), a new multi-job launch-status strip replacing the single backgroundLaunchNotice, and an explicit "claim" ownership model for browser, iOS simulator, and app-control panels.

  • Optimistic sessions: useLaneWorkSessions now stores a pendingOptimisticSession map (TTL 2 min) so the terminal tab opens before the server confirms the session, merging the optimistic ptyId into persisted rows as they arrive.
  • Draft persistence: writeComposerDraftSnapshot writes a ComposerDraftStorageSnapshot to localStorage on a 350 ms debounce; the hydration effect reads it back on scope switch, guarded by composerDraftHydratingRef to skip the write-back triggered by the hydration state batch.
  • Claim API: builtInBrowserService, iosSimulatorService, and appControlService each gain a claim({ laneId, chatSessionId }) endpoint, replacing the previous auto-attach-on-session-creation path for the iOS simulator.

Confidence Score: 5/5

Safe to merge. The optimistic session, draft persistence, and claim ownership changes are well-scoped and independently fallback-safe.

The optimistic session map has a 2-minute TTL and graceful server-reconciliation logic, so stale entries clean themselves up. Draft persistence uses a debounced write with a flush-on-cleanup guard, and the hydration flag correctly prevents write-back races for the common case. The new claim endpoints only update in-memory owner state and emit status events with no persistent side effects. The failInitialInputLaunch change is a correctness improvement over the previous silent-discard. No data-loss or session-corruption paths were identified.

AgentChatPane.tsx warrants extra attention due to its size and the interplay between the hydration effect, write effect, and composerDraftHydratingRef guard.

Important Files Changed

Filename Overview
apps/desktop/src/renderer/components/chat/AgentChatPane.tsx Core of the PR: replaces single backgroundLaunchNotice with a DraftLaunchJob list, adds debounced localStorage draft persistence, makes composer clear eagerly on launch with explicit Restore on failure. The composerDraftHydratingRef guard works correctly but triggers one redundant write per scope switch.
apps/desktop/src/renderer/components/lanes/useLaneWorkSessions.ts Core latency improvement: removes awaitInitialInput, adds pendingOptimisticSessions map (2-min TTL) so the terminal opens before the server confirms the session. mergePendingOptimisticSession reconciles the server ptyId once it arrives.
apps/desktop/src/main/services/pty/ptyService.ts Adds failInitialInputLaunch: if writeInitialInput() throws (non-await path), the PTY session is now terminated with SIGTERM instead of silently swallowed.
apps/desktop/src/main/services/builtInBrowser/builtInBrowserService.ts Adds ownerLaneId/ownerChatSessionId/ownerClaimedAt fields plus a claim() endpoint. Ownership is cleared when all tabs close or on reset.
apps/desktop/src/renderer/components/terminals/TerminalView.tsx Adds shouldFollowTerminalOutput() guard so scrollToBottom is only called when viewport is near the bottom. Wheel event now uses capture phase and stopPropagation.
apps/desktop/src/renderer/components/terminals/WorkSidebar.tsx Replaces local browserViewLaneId tracking with a live browserStatus subscription. Merges toolAttributionReason and contextDisabledReason into a single warningReason banner.
apps/ade-cli/src/cli.ts Adds claim sub-commands for ios-sim, app-control, and browser; refactors readToolClaimArgs to read --lane and --chat-session (or env vars ADE_LANE_ID / ADE_CHAT_SESSION_ID).

Sequence Diagram

sequenceDiagram
    participant U as User
    participant CP as AgentChatPane
    participant LWS as useLaneWorkSessions
    participant PTY as ptyService
    participant BE as Backend

    U->>CP: Click Launch
    CP->>CP: buildDraftLaunchSnapshotForCurrentState()
    CP->>CP: clearDraftLaunchComposer(snapshot)
    CP->>CP: setDraftLaunchJobs creating-lane
    CP->>CP: resolveDraftLaunchLane [async]
    CP->>LWS: launchPtySession(launchFields)
    LWS->>PTY: spawn PTY process
    PTY-->>LWS: sessionId + ptyId [immediate]
    LWS->>LWS: pendingOptimisticSessions.set(sessionId)
    LWS->>LWS: upsertSessionSnapshot [UI shows terminal NOW]
    LWS->>LWS: selectLane / focusSession / openSessionTab
    LWS-->>BE: refresh() [background]
    PTY->>PTY: writeInitialInput() [async]
    BE-->>LWS: persisted session returned
    LWS->>LWS: mergePendingOptimisticSession
    CP->>CP: patchDraftLaunchJob ready
    CP->>CP: openLaunchedDraftSession
Loading

Comments Outside Diff (2)

  1. apps/desktop/src/renderer/components/chat/AgentChatPane.tsx, line 5389-5425 (link)

    P2 Unthrottled localStorage write on every state change

    writeComposerDraftSnapshot is called on every render where any dependency changes — including draft (which updates on every keystroke) and currentNativeControls (which may produce a new object reference on each render). With large context snapshots (many attachments, VM items, orchestration annotations), this is a JSON.stringify + localStorage.setItem call per character typed. Consider debouncing the write or using a setTimeout/requestIdleCallback to coalesce rapid changes.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: apps/desktop/src/renderer/components/chat/AgentChatPane.tsx
    Line: 5389-5425
    
    Comment:
    **Unthrottled localStorage write on every state change**
    
    `writeComposerDraftSnapshot` is called on every render where any dependency changes — including `draft` (which updates on every keystroke) and `currentNativeControls` (which may produce a new object reference on each render). With large context snapshots (many attachments, VM items, orchestration annotations), this is a `JSON.stringify` + `localStorage.setItem` call per character typed. Consider debouncing the write or using a `setTimeout`/`requestIdleCallback` to coalesce rapid changes.
    
    How can I resolve this? If you propose a fix, please make it concise.

    Fix in Claude Code

  2. apps/desktop/src/renderer/components/terminals/OrchestratorComposerEntry.test.tsx

    P2 Test coverage for ade:work:start-orchestrator-chat event contract dropped

    This file was deleted but none of its tests were ported to AgentChatPane.test.tsx. The AgentChatPane.test.ts migration did port all of its describe blocks (the diff explicitly labels them "consolidated from AgentChatPane.test.ts"), but OrchestratorComposerEntry.test.tsx was deleted silently. The ade:work:start-orchestrator-chat event dispatch contract — the only mechanism by which the composer routes to the chat-orchestrator draft kind — is now untested.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: apps/desktop/src/renderer/components/terminals/OrchestratorComposerEntry.test.tsx
    Line: 1-28
    
    Comment:
    **Test coverage for `ade:work:start-orchestrator-chat` event contract dropped**
    
    This file was deleted but none of its tests were ported to `AgentChatPane.test.tsx`. The `AgentChatPane.test.ts` migration did port all of its describe blocks (the diff explicitly labels them "consolidated from `AgentChatPane.test.ts`"), but `OrchestratorComposerEntry.test.tsx` was deleted silently. The `ade:work:start-orchestrator-chat` event dispatch contract — the only mechanism by which the composer routes to the `chat-orchestrator` draft kind — is now untested.
    
    How can I resolve this? If you propose a fix, please make it concise.

    Fix in Claude Code

Fix All in Claude Code

Prompt To Fix All With AI
Fix the following 3 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 3
apps/desktop/src/renderer/components/chat/AgentChatPane.tsx:8335
The `isReady && !isFailed` guard is redundant. Both `isReady` (`status === "ready"`) and `isFailed` (`status === "failed"`) are checked against the same status field, so they are always mutually exclusive — `isReady` being `true` already implies `isFailed` is `false`.

```suggestion
              isReady && "border-emerald-300/20 bg-emerald-500/[0.08] text-emerald-100/90",
```

### Issue 2 of 3
apps/desktop/src/renderer/components/lanes/useLaneWorkSessions.ts:64-83
**Optimistic session shown even when persisted session has no ptyId yet**

`mergePendingOptimisticSession` patches the optimistic `ptyId` onto the persisted row and keeps the pending entry alive (`keepPending: true`) until the persisted row also carries the same `ptyId`. A different lane tab reading the server record before the server writes the `ptyId` would see a running session with `ptyId: null` and be unable to attach to the terminal. The 2-minute TTL provides eventual cleanup, but the window could be surprising in split-lane setups. Consider documenting the expected convergence time or shortening the TTL for the common case where the server catches up within seconds.

### Issue 3 of 3
apps/desktop/src/renderer/components/chat/AgentChatPane.tsx:5286-5310
**Spurious `localStorage` write triggered by every scope-switch hydration**

After the hydration effect runs, its batched state updates (`setDraft`, `setAttachments`, etc.) cause the write effect to fire a second time with `composerDraftHydratingRef.current === false`. At that point the write effect proceeds to serialize and store the just-loaded snapshot back to the same key. The data written is identical to what was just read, so there is no corruption, but every scope switch causes one unnecessary `JSON.stringify` + `localStorage.setItem` of the full snapshot. Extending the hydration guard to cover the second-pass write or setting the pending write ref without scheduling the timer during hydration would avoid this.

Reviews (3): Last reviewed commit: "Fix rebase follow-up validation issues" | Re-trigger Greptile

@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
ade Ignored Ignored Preview May 27, 2026 7:22pm

@arul28
Copy link
Copy Markdown
Owner Author

arul28 commented May 27, 2026

@copilot review but do not make fixes

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

📝 Walkthrough

Walkthrough

Removes conditional PTY awaitInitialInput flag in favor of explicit initialInput/initialInputDelayMs, adds optimistic PTY session insertion and merge-on-refresh, implements composer draft localStorage snapshots and a multi-job draft-launch queue, and adds claim/ownership APIs and CLI plumbing for browser, iOS simulator, and app-control surfaces with UI and test updates.

Changes

PTY initial-input, optimistic sessions, and terminal behavior

Layer / File(s) Summary
Renderer PTY launch parameter change
apps/desktop/src/renderer/components/terminals/useWorkSessions.ts, apps/desktop/src/renderer/components/terminals/useWorkSessions.test.ts
launchPtySession and related tests forward initialInput / initialInputDelayMs to window.ade.pty.create instead of setting awaitInitialInput: true.
Optimistic PTY session handling & refresh merging
apps/desktop/src/renderer/components/lanes/useLaneWorkSessions.ts, apps/desktop/src/renderer/components/lanes/useLaneWorkSessions.test.ts
Adds pending optimistic PTY summaries with TTL, merges them into fetched rows during refresh, upserts by startedAt, and immediately focuses/opens non-background sessions without awaiting the forced refresh.
PTY service initial-input failure handling & tests
apps/desktop/src/main/services/pty/ptyService.ts, apps/desktop/src/main/services/pty/ptyService.test.ts
Added failInitialInputLaunch teardown to log pty.initial_input_launch_failed, terminate PTY, and close with exitCode 1; tests updated to expect failed termination logging on initial-input errors.
Terminal auto-scroll and wheel behavior
apps/desktop/src/renderer/components/terminals/TerminalView.tsx, apps/desktop/src/renderer/components/terminals/TerminalView.test.tsx
Compute followOutput based on xterm buffer viewport to avoid forcing scroll when user scrolled up; allow wheel scrolling when mouse-tracking is active and stop propagation when handled; tests added for scrollback behavior.

Composer Draft Persistence & Multi-Job Launch System

Layer / File(s) Summary
Draft snapshot types and job model
apps/desktop/src/renderer/components/chat/AgentChatPane.tsx
Introduce ComposerDraftStorageSnapshot, DraftLaunchSnapshot, DraftLaunchJob types and job-state tracking for per-launch snapshots and statuses.
Normalization, validation, and persistence helpers
apps/desktop/src/renderer/components/chat/AgentChatPane.tsx
Add normalization/coercion for frames, attachments, provider-specific context items, screenshot-stripping, deduplication, and robust read/write localStorage helpers with debounce.
Hydration, write lifecycle, and session creation
apps/desktop/src/renderer/components/chat/AgentChatPane.tsx
Debounced snapshot writes, scoped storage keys, hydration guards on scope change, and createSessionForLane/buildDraftLaunchSnapshotForCurrentState updated to accept and apply full launchState including nativeControls.
Job-based launch execution and UI
apps/desktop/src/renderer/components/chat/AgentChatPane.tsx
Replace single busy/notice flow with per-job lifecycle and draftLaunchJobs UI list (spinner/status, Restore/Open/Dismiss), patching job statuses on ready/failed completion and merging failed-restores into composer draft.
Composer tests and pure-unit helpers
apps/desktop/src/renderer/components/chat/AgentChatPane.test.tsx
Large set of tests added/expanded: persistence, restoration merging, malformed-entry tolerance, concurrent background launches, UI label updates, and consolidated pure-function unit tests.

Claim / Tool Ownership APIs and CLI

Layer / File(s) Summary
CLI claim flags, parsing, and plans
apps/ade-cli/src/cli.ts, apps/ade-cli/src/cli.test.ts
Add readToolClaimArgs() with env fallback, new claim subcommands for browser/app-control/ios-sim, and ensure planned actions include laneId/chatSessionId; tests added to assert claim carry.
Built-in browser claim & ownership
apps/desktop/src/main/services/builtInBrowser/builtInBrowserService.ts, apps/desktop/src/main/services/builtInBrowser/builtInBrowserService.test.ts, apps/ade-cli/src/services/builtInBrowser/desktopBridgeClient.ts, apps/desktop/src/main/services/builtInBrowser/desktopBridgeServer.ts
Add ownerLaneId/ownerChatSessionId/ownerClaimedAt, claim() method, propagate claim fields through createTab/navigate/switchTab/showPanel, and expose built_in_browser.claim via desktop bridge; tests verify ownership propagation.
iOS simulator & app-control claim APIs
apps/desktop/src/main/services/ios/iosSimulatorService.ts, apps/desktop/src/main/services/appControl/appControlService.ts, tests
Add claim() to services, IosSimulatorClaimArgs/AppControlClaimArgs types, sanitize claim ids, set claimedAt when values change, emit session-updated, and tests verifying claiming without relaunch.
IPC, allowlist, types, and docs
apps/desktop/src/main/services/ipc/registerIpc.ts, apps/desktop/src/main/services/adeActions/registry.ts, apps/desktop/src/shared/types/*, apps/desktop/resources/agent-skills/*
Add BuiltInBrowserClaimArgs, IosSimulatorClaimArgs, AppControlClaimArgs, extend BuiltInBrowserStatus with owner fields, add claim to allowlists, update IPC parsing helpers, and add docs/practical examples for claim.

UI wiring and tests for ownership & sidebar behavior

Layer / File(s) Summary
WorkSidebar and panel wiring
apps/desktop/src/renderer/components/terminals/WorkSidebar.tsx, apps/desktop/src/renderer/components/terminals/WorkSidebar.test.tsx
Fetch and subscribe to built-in browser status, compute toolAttributionReason from browserStatus.ownerLaneId, prefer warningReason over prior lane-mismatch disabling, and pass ignoreChatOwnership/controlDisabledReason={null} to panels; tests updated accordingly.
Chat iOS panel ownership opt-out
apps/desktop/src/renderer/components/chat/ChatIosSimulatorPanel.tsx, ChatIosSimulatorPanel.test.tsx
Add ignoreChatOwnership prop (default false) to disable other-session ownership detection for embedding scenarios; tests include claimedAt fixture.
AgentChatComposer minor UX fixes
apps/desktop/src/renderer/components/chat/AgentChatComposer.tsx, tests
Treat macOS VM context chips like other context chips for serialization/offset calc; adjust background launch label behavior and orchestration model-picker visibility; tests added for orchestration UI states.
Various test and mock updates
multiple test files and browser mocks
Adjust mocks to include owner fields, update expectations for awaitInitialInput removal, and add/modify tests across sync, terminal, and composer suites.
  • Estimated code review effort: 🎯 4 (Complex) | ⏱️ ~60 minutes

  • Possibly related PRs:

    • arul28/ADE#328: overlaps useLaneWorkSessions refresh / launch ordering changes.
    • arul28/ADE#320: related initial-input handling in CLI PTY launch paths.
    • arul28/ADE#243: overlapping AgentChatPane / built-in browser context changes.
  • Suggested labels:
    desktop

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Cli Session Launch Latency' is specific and directly aligned with the PR's stated purpose of reducing CLI/terminal session launch latency through targeted architectural changes.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ade/cli-session-launch-latency-5e13552e

@capy-ai
Copy link
Copy Markdown

capy-ai Bot commented May 27, 2026

Capy auto-review is paused for this organization because the monthly auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews.

Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review

Scope: 16 file(s), +1268 / −459
Verdict: Minor issues

This PR speeds up Work draft chat/CLI launches with optimistic session rows, async session-list refresh, non-blocking PTY initial input, persisted composer drafts, and multi-step DraftLaunchJob status UI. The main residual risk is optimistic rows being overwritten by a fast forced refresh before the backend list includes the new session.


🐛 Functionality

[High] Forced refresh can drop optimistic lane sessions before the tab opens

File: apps/desktop/src/renderer/components/lanes/useLaneWorkSessions.ts:L161-L168
Issue: launchPtySession inserts an optimistic row, opens the tab, then fires refresh({ force: true }) without awaiting it. refresh replaces sessions with the IPC list only; unlike useWorkSessions, there is no pending-optimistic merge, so a refresh that returns before persistence will remove the just-launched session id from sessions / laneOpenItemIds.
Repro: Launch a tracked CLI/shell session from a lane Work pane on a fast machine (or with a warm listSessionsCached); if the forced refresh wins the race, the new tab id disappears and the pane falls back to another session or draft until a later refresh.
Fix: Reuse the pendingOptimisticSessionsRef / mergePendingOptimisticSession pattern from useWorkSessions.ts, or merge the create result into refresh output until the authoritative list contains the session id.

[Medium] Initial prompt write failures are no longer surfaced for Work/Lane/sync launches

File: apps/desktop/src/renderer/components/lanes/useLaneWorkSessions.ts:L522-L533
Issue: This PR stops passing awaitInitialInput: true when initialInput is present (also in useWorkSessions.ts and apps/ade-cli/src/services/sync/syncRemoteCommandService.ts). ptyService then schedules writeInitialInput() asynchronously and ignores failures (void writeInitialInput().catch(() => {}) in apps/desktop/src/main/services/pty/ptyService.ts around L3467), so create/launch can succeed while the prompt never lands.
Repro: Launch a Work draft CLI session (or work.startCliSession over sync) with initialInput against a PTY that exits immediately or rejects the first write; the UI shows a running session but no injected prompt and no launch error.
Fix: Keep awaitInitialInput: true for launch paths that depend on initialInput, or propagate write failures back through pty.create / the draft-launch job failed state.


⚡ Performance

[Medium] Composer draft persistence rewrites large visual context on every edit

File: apps/desktop/src/renderer/components/chat/AgentChatPane.tsx:L5145-L5170
Issue: The new writeComposerDraftSnapshot effect persists iosElementContextItems, appControlContextItems, and related fields (including screenshotDataUrl) to localStorage on every change to draft, attachments, controls, and context arrays. Large base64 screenshots make JSON.stringify + setItem run on each keystroke, which can jank the composer and hit quota (writes fail silently in the catch block at L1789-L1793).
Impact: Typing in a draft with one or more simulator/app-control screenshots can trigger multi‑MB main-thread writes per keypress; persistence may stop working without user feedback.
Fix: Debounce/throttle persistence, strip or externalize screenshot payloads from the stored snapshot (keep paths/ids only), or persist text/model separately from heavy context blobs.


Notes

Positive patterns worth keeping: hasFetchedOnceRef / userIsViewingDraft guards reduce draft↔tab fighting; freezing launch settings in DraftLaunchSnapshot avoids model/permission drift mid-flight; malformed localStorage draft entries are normalized instead of crashing the composer.

I did not run the desktop test suite in this environment; findings are from diff review and tracing the launch/refresh paths end to end.

Open in Web View Automation 

Sent by Cursor Automation: BUGBOT in Versic

Comment thread apps/desktop/src/renderer/components/chat/AgentChatPane.tsx Outdated
Comment thread apps/desktop/src/renderer/components/chat/AgentChatPane.tsx
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/desktop/src/renderer/components/chat/AgentChatPane.tsx (1)

5331-5345: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Don't let the first send override an orchestrator-lead launch back to the snapshot mode.

The create path explicitly forces interactionMode: "orchestrator-lead" for orchestrator drafts, but the first agentChat.send(...) still uses prepared.interactionMode from the pre-launch snapshot. That can downgrade the very first turn to "default"/"plan" and skip the orchestration tool gates you just enabled. Use createdSession.interactionMode here, or omit the send-time override for orchestrator launches.

Also applies to: 5693-5702

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/desktop/src/renderer/components/chat/AgentChatPane.tsx` around lines
5331 - 5345, The first send call is using prepared.interactionMode (the
pre-launch snapshot) which can downgrade an orchestrator launch; after creating
the session with window.ade.agentChat.create (where orchestratorOverrides sets
interactionMode: "orchestrator-lead"), change the send-time override so it uses
created.interactionMode (or createdSession.interactionMode) instead of
prepared.interactionMode — or simply omit the send-time interactionMode override
for orchestrator launches; update the same pattern found around agentChat.send
in the later block (lines ~5693-5702) to ensure the orchestrator-lead mode is
preserved.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/desktop/src/renderer/components/chat/AgentChatPane.tsx`:
- Around line 1653-1732: The renderer currently re-serializes and writes full
visual-context (including screenshotDataUrl blobs) on every draft keystroke;
update the draft-persistence effect in AgentChatPane to (1) debounce the save
(e.g., 300–500ms) so rapid keystrokes don't trigger synchronous writes and (2)
strip large fields before persisting by removing screenshotDataUrl (and any
other heavy binary/blob fields) from items produced by
normalizeComposerIosContextItems, normalizeComposerAppControlContextItems,
normalizeComposerBuiltInBrowserContextItems and
normalizeComposerMacosVmContextItems—preserve stable ids/attachment paths (id,
componentId, sessionId, any stored path fields) so restore still works. Ensure
the debounced function is cleaned up on unmount and that the persisted payload
is small enough to avoid localStorage quota failures.

---

Outside diff comments:
In `@apps/desktop/src/renderer/components/chat/AgentChatPane.tsx`:
- Around line 5331-5345: The first send call is using prepared.interactionMode
(the pre-launch snapshot) which can downgrade an orchestrator launch; after
creating the session with window.ade.agentChat.create (where
orchestratorOverrides sets interactionMode: "orchestrator-lead"), change the
send-time override so it uses created.interactionMode (or
createdSession.interactionMode) instead of prepared.interactionMode — or simply
omit the send-time interactionMode override for orchestrator launches; update
the same pattern found around agentChat.send in the later block (lines
~5693-5702) to ensure the orchestrator-lead mode is preserved.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4c523276-071b-4305-897e-47970e88576d

📥 Commits

Reviewing files that changed from the base of the PR and between 5e7e3f9 and fd0eff6.

⛔ Files ignored due to path filters (5)
  • docs/features/chat/README.md is excluded by !docs/**
  • docs/features/chat/composer-and-ui.md is excluded by !docs/**
  • docs/features/lanes/README.md is excluded by !docs/**
  • docs/features/terminals-and-sessions/README.md is excluded by !docs/**
  • docs/features/terminals-and-sessions/ui-surfaces.md is excluded by !docs/**
📒 Files selected for processing (11)
  • apps/ade-cli/src/services/sync/syncRemoteCommandService.ts
  • apps/desktop/src/main/services/sync/syncHostService.test.ts
  • apps/desktop/src/main/services/sync/syncRemoteCommandService.test.ts
  • apps/desktop/src/renderer/components/chat/AgentChatPane.test.ts
  • apps/desktop/src/renderer/components/chat/AgentChatPane.test.tsx
  • apps/desktop/src/renderer/components/chat/AgentChatPane.tsx
  • apps/desktop/src/renderer/components/lanes/useLaneWorkSessions.test.ts
  • apps/desktop/src/renderer/components/lanes/useLaneWorkSessions.ts
  • apps/desktop/src/renderer/components/terminals/OrchestratorComposerEntry.test.tsx
  • apps/desktop/src/renderer/components/terminals/useWorkSessions.test.ts
  • apps/desktop/src/renderer/components/terminals/useWorkSessions.ts
💤 Files with no reviewable changes (4)
  • apps/desktop/src/renderer/components/terminals/OrchestratorComposerEntry.test.tsx
  • apps/desktop/src/renderer/components/chat/AgentChatPane.test.ts
  • apps/desktop/src/renderer/components/terminals/useWorkSessions.ts
  • apps/ade-cli/src/services/sync/syncRemoteCommandService.ts

Comment thread apps/desktop/src/renderer/components/chat/AgentChatPane.tsx
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/desktop/resources/agent-skills/ade-browser/SKILL.md (1)

11-17: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add claim to the allowlisted-method list for consistency.

Line 11 and Line 28 document claim, but the method list in Line 17 omits it. That makes the same page internally inconsistent and can mislead operators.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/desktop/resources/agent-skills/ade-browser/SKILL.md` around lines 11 -
17, The allowlisted-methods list in SKILL.md for BuiltInBrowserService is
missing the claim method described elsewhere; update the allowlisted methods
array/list shown (the list that currently contains getStatus, showPanel,
setBounds, navigate, createTab, switchTab, closeTab, reload, goBack, goForward,
stop, startInspect, stopInspect, captureScreenshot, selectPoint, selectCurrent,
clearSelection) to include claim so the documentation is internally consistent
with the other references to claim and the CLI behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/ade-cli/src/cli.ts`:
- Around line 5617-5627: The claim subcommand blocks (the branches where sub ===
"claim" in apps/ade-cli/src/cli.ts that build the execute action for
ios_simulator and the other two occurrences) must validate that a lane argument
was provided; before returning the execute descriptor (and before calling
collectGenericObjectArgs/readToolClaimArgs), check for the presence of the lane
flag/parameter (e.g., args.lane or the parsed flag used for lanes) and if
missing return a CLI parse error/usage failure (or throw) so the command fails
fast; update all three claim branches to perform this validation and surface a
clear message when lane is absent.

---

Outside diff comments:
In `@apps/desktop/resources/agent-skills/ade-browser/SKILL.md`:
- Around line 11-17: The allowlisted-methods list in SKILL.md for
BuiltInBrowserService is missing the claim method described elsewhere; update
the allowlisted methods array/list shown (the list that currently contains
getStatus, showPanel, setBounds, navigate, createTab, switchTab, closeTab,
reload, goBack, goForward, stop, startInspect, stopInspect, captureScreenshot,
selectPoint, selectCurrent, clearSelection) to include claim so the
documentation is internally consistent with the other references to claim and
the CLI behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3ab56131-842e-453f-83ed-024c41e64118

📥 Commits

Reviewing files that changed from the base of the PR and between fd0eff6 and 410c906.

📒 Files selected for processing (34)
  • apps/ade-cli/src/cli.test.ts
  • apps/ade-cli/src/cli.ts
  • apps/ade-cli/src/services/builtInBrowser/desktopBridgeClient.ts
  • apps/desktop/resources/agent-skills/ade-app-control/SKILL.md
  • apps/desktop/resources/agent-skills/ade-browser/SKILL.md
  • apps/desktop/resources/agent-skills/ade-ios-simulator/SKILL.md
  • apps/desktop/src/main/services/adeActions/registry.test.ts
  • apps/desktop/src/main/services/adeActions/registry.ts
  • apps/desktop/src/main/services/appControl/appControlService.test.ts
  • apps/desktop/src/main/services/appControl/appControlService.ts
  • apps/desktop/src/main/services/builtInBrowser/builtInBrowserService.test.ts
  • apps/desktop/src/main/services/builtInBrowser/builtInBrowserService.ts
  • apps/desktop/src/main/services/builtInBrowser/desktopBridgeServer.ts
  • apps/desktop/src/main/services/ios/iosSimulatorService.test.ts
  • apps/desktop/src/main/services/ios/iosSimulatorService.ts
  • apps/desktop/src/main/services/ipc/registerIpc.ts
  • apps/desktop/src/main/services/pty/ptyService.test.ts
  • apps/desktop/src/main/services/pty/ptyService.ts
  • apps/desktop/src/renderer/browserMock.ts
  • apps/desktop/src/renderer/components/chat/AgentChatComposer.test.tsx
  • apps/desktop/src/renderer/components/chat/AgentChatComposer.tsx
  • apps/desktop/src/renderer/components/chat/AgentChatPane.test.tsx
  • apps/desktop/src/renderer/components/chat/AgentChatPane.tsx
  • apps/desktop/src/renderer/components/chat/ChatIosSimulatorPanel.test.tsx
  • apps/desktop/src/renderer/components/chat/ChatIosSimulatorPanel.tsx
  • apps/desktop/src/renderer/components/lanes/useLaneWorkSessions.test.ts
  • apps/desktop/src/renderer/components/lanes/useLaneWorkSessions.ts
  • apps/desktop/src/renderer/components/terminals/TerminalView.test.tsx
  • apps/desktop/src/renderer/components/terminals/TerminalView.tsx
  • apps/desktop/src/renderer/components/terminals/WorkSidebar.test.tsx
  • apps/desktop/src/renderer/components/terminals/WorkSidebar.tsx
  • apps/desktop/src/shared/types/appControl.ts
  • apps/desktop/src/shared/types/builtInBrowser.ts
  • apps/desktop/src/shared/types/iosSimulator.ts
✅ Files skipped from review due to trivial changes (2)
  • apps/desktop/src/renderer/components/chat/ChatIosSimulatorPanel.test.tsx
  • apps/desktop/resources/agent-skills/ade-ios-simulator/SKILL.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/desktop/src/renderer/components/lanes/useLaneWorkSessions.test.ts
  • apps/desktop/src/renderer/components/chat/AgentChatPane.test.tsx
  • apps/desktop/src/renderer/components/chat/AgentChatPane.tsx

Comment thread apps/ade-cli/src/cli.ts
@arul28 arul28 force-pushed the ade/cli-session-launch-latency-5e13552e branch from 410c906 to e8920a1 Compare May 27, 2026 19:22
@arul28 arul28 merged commit 880c477 into main May 27, 2026
27 checks passed
@arul28 arul28 deleted the ade/cli-session-launch-latency-5e13552e branch May 27, 2026 19:36
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