Skip to content

Improve project action terminal readiness#3175

Open
Quicksaver wants to merge 286 commits into
pingdotgg:mainfrom
Quicksaver:split/terminal-backed-project-actions
Open

Improve project action terminal readiness#3175
Quicksaver wants to merge 286 commits into
pingdotgg:mainfrom
Quicksaver:split/terminal-backed-project-actions

Conversation

@Quicksaver

@Quicksaver Quicksaver commented Jun 19, 2026

Copy link
Copy Markdown

Summary

This branch tracks the terminal-backed project action work after syncing with the fork's current main and then merging the latest upstream/main. The production behavior is already present on origin/main; the remaining branch-local delta now includes upstream PR review fixes for VS Code bootstrap/webview safety and command-output merging, test compatibility cleanup in apps/server/src/terminal/Manager.test.ts, one focused project-action terminal readiness hardening patch, and the latest upstream mainline merge.

The underlying project action behavior still routes actions through stable action-specific terminals, waits for the selected terminal to be input-ready before writing, avoids busy terminals when choosing a target, and keeps POSIX subprocess detection conservative when process-tree inspection cannot prove the shell is idle.

What Changed

  • Reuses stable encoded action-* terminal IDs for project scripts, with numeric fallback suffix allocation when existing action terminals are busy.
  • Waits for input readiness through terminal output/attach state before writing project-action commands, timing out instead of hanging indefinitely.
  • Avoids reusing busy action terminals and keeps fallback action terminal IDs separate from script IDs such as action-build-2.
  • Uses readable fallback labels such as Action: build (2) so fallback instances do not collide visually with primary action terminals.
  • Keeps POSIX subprocess detection conservative when process-tree inspection fails, while allowing proven idle login shells to be reused.
  • Keeps focused coverage for action terminal ID selection, fallback collision avoidance, prompt readiness, idle-shell detection, conservative ps fallback behavior, and action terminal labels.
  • After the latest mainline sync, updates Manager.test.ts compatibility by referencing TerminalManager.__testing through the existing namespace import and avoiding the unstable ChildProcessSpawner.ExitCode import in test output helpers.
  • Treats an attach stream ending before input readiness as a typed strict-readiness failure, while preserving the best-effort UI path that still writes after readiness failures.
  • Addresses Macroscope and Cursor review findings by sanitizing VS Code workspace bootstrap 500 responses, preserving malformed readiness diagnostics while keeping transient body-read retries bounded, disposing webview resources on render failure without masking the render error, cleaning MCP bridge socket resources on listen failure, escaping case-insensitive inline script closing sequences, trimming Codex file-change kind strings, and avoiding duplicate/truncated command-output prefix merges including multiline strict-prefix snapshots.

Why

When running a custom action, the terminal can open and receive the inserted action before the shell is ready. Once the terminal later becomes ready, it may no longer be able to receive that action. The project action path therefore needs to wait for an input-ready prompt, reuse stable action terminals only when they are genuinely usable, and fail conservatively when terminal busy/idle state cannot be proven.

This branch is now mostly preservation and review history for behavior already carried by the fork's mainline, plus upstream PR review fixes, the small test/readiness compatibility deltas needed after the latest main sync, and the current upstream mainline merge.

No per-branch CUSTOMIZED.md is present. That merge-maintenance inventory is intentionally branch-local to main.

Validation

  • Previously run: pnpm exec vp check
  • Previously run: pnpm exec vp run typecheck
  • Previously run: pnpm exec vp test run apps/web/src/projectScriptTerminals.test.ts apps/server/src/terminal/Layers/Manager.test.ts packages/shared/src/terminalLabels.test.ts
  • Previously run: pnpm exec vp test run apps/server/src/terminal/Layers/Manager.test.ts packages/shared/src/terminalLabels.test.ts apps/web/src/projectScriptTerminals.test.ts
  • Latest run: pnpm exec vp test run apps/web/src/session-logic.test.ts apps/vscode-extension/src/backendManager.test.ts apps/vscode-extension/src/webview.test.ts apps/vscode-extension/src/mcpBridge.test.ts apps/vscode-extension/src/extension.test.ts
  • Latest run: pnpm exec vp check
  • Latest run: pnpm exec vp run typecheck
  • Assessment follow-up also reran focused session-logic, backendManager, webview, and mcpBridge tests plus vp check and vp run typecheck after the review-hardening commits.
  • Latest Cursor follow-up run: pnpm exec vp test run apps/web/src/session-logic.test.ts
  • Latest Cursor follow-up run: pnpm exec vp check
  • Latest Cursor follow-up run: pnpm exec vp run typecheck
  • Latest run: pnpm exec vp test run apps/web/src/projectScriptTerminals.test.ts
  • Latest run: pnpm exec vp check
  • Latest run: pnpm exec vp run typecheck

Review Follow-up

  • Fixed Cursor Bugbot's POSIX subprocess test mock comment by making the ps mock distinguish the direct child command lookup from the full process-table lookup.
  • Fixed Cursor Bugbot's duplicate action tab label comment by formatting fallback action terminal instances with a parenthesized suffix, so action-build:2 renders differently from action-build-2.
  • Ran CodeRabbit, Codex, Blast, final CodeRabbit, and final Codex assessment passes; Blast suggested additional test hardening, which was committed in f4a01d8214347a69ced926fde34354e3dfd3aa12.
  • Synced the branch with origin/main; the current branch-local diff over origin/main is the Manager.test.ts test compatibility cleanup described above.
  • Fixed Macroscope's six new review threads in commits fd6a6d884, 8bc52982, ade76fe93, 490454e1, and 8abfd42e, then ran the required CodeRabbit, Codex, Blast, final CodeRabbit, and final Codex assessment sequence for those changes.
  • Fixed Cursor Bugbot's multiline stdout prefix duplication thread in fc153e138, preserving shorter multiline prefix snapshots without dropping ambiguous one-character streamed chunks, then ran CodeRabbit, Codex, Blast, final CodeRabbit, and final Codex assessment passes. CUSTOMIZED.md was later removed from this branch in 3046aa4a0 because it is intentionally branch-local to main only.
  • Replied to and resolved Macroscope's stale CUSTOMIZED.md path-reference thread without code or doc changes, because CUSTOMIZED.md is absent from this branch.
  • Merged the latest upstream/main through 6e48d8093; no additional validation was run because this was a merge-only PR metadata refresh.

Proof

  • No screenshots, screencasts, or log files were added.

Note

High Risk
Touches orchestration persistence and provider interrupt paths for subagents, auth compatibility endpoints, and desktop backend discovery advertisements—areas where regressions affect thread lifecycle, security sessions, and multi-client connectivity.

Overview
This PR is a large fork/integration batch rather than a single feature: it wires Codex subagent lineage through orchestration projection (parentRelation / subagent columns on thread create/update and snapshot queries), child-thread runtime ingestion (shell creation, launch prompts, resume-to-running, title generation), and interrupt routing through the root provider session with explicit failure when no child turn exists.

Host and desktop: Server config gains VS Code-oriented bootstrap fields (workspace folders, active folder key, host MCP servers, hostIntegration), plus t3 stdio-to-uds for MCP stdio relay. Legacy HTTP routes restore bearer bootstrap and session revoke compatibility. Desktop backend runs now write and heartbeat backend advertisements in t3Home, refresh them on readiness, and remove them on run finalization/stop (with a regression test). Electron context menus collapse duplicate leading/trailing separators.

Docs and agent workflow: New maintainer docs (SUBAGENTS.md, SOURCE_CONTROL.md, POWER_CONSUMPTION.md) and .agents/skills/* orchestration skills for updating/porting worktrees and addressing PR comments from parallel branches. AGENTS.md notes the fork and CUSTOMIZED.md.

Misc: Auth/session test hooks (deleteExpired, stale desktop bootstrap bearer cleanup policy), sanitizeErrorCause for bounded diagnostics, mobile EAS owner/project id change, .gitignore for *.vsix, and assorted mock/test harness updates (ACP/Codex cwd logging, integration text-generation layer ordering).

Reviewed by Cursor Bugbot for commit 2a02f76. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add VS Code extension, source control panel, and subagent thread hierarchy support

  • Introduces a new VS Code extension (apps/vscode-extension/) with a webview renderer, BackendManager for desktop backend connectivity, a Unix-socket MCP bridge, client settings persistence, and virtual workspace cache for GitHub virtual folders.
  • Adds a SourceControlPanelService and SourceControlPanel UI with comprehensive VCS operations (staging, committing, pull/push, branch management, diff rendering), exposed via new vcsPanel* WebSocket RPCs and scoped by auth.
  • Implements subagent thread hierarchy throughout the stack: orchestration now cascades deletes/archives to subagent descendants, provider runtime ingestion creates child threads from collab events and routes notifications to deterministic child thread IDs, and the sidebar and messages timeline render hierarchical thread rows with status and live duration.
  • Improves project action terminal readiness in ChatView by reusing existing sessions when idle, waiting for readiness before sending input, and closing terminal UIs when terminals are disabled by host preferences.
  • Adds host appearance and display preferences (hostAppearance.ts, hostDisplayPreferences.ts) so VS Code webviews can override the app theme, fonts, and thread conversation width via window.t3HostBridge.
  • Risk: database migration 033 adds parent/subagent relation columns to projection_threads; migration 034 backfills root_thread_id for existing rows, which may be slow on large databases.

Macroscope summarized 6e48d80.

Quicksaver added 30 commits June 1, 2026 09:41
Filter dependencies during packaging to include only necessary modules, reducing bundle size and potential issues. Allow "./" as a valid base URL for web builds, making configuration more flexible and developer-friendly.
- Add desktop bootstrap MCP server plumbing
- Wire host integration through server config
- Project Codex bridge events into the VS Code extension
- Tighten message timeline row derivation
- Add stdio-to-uds relay for provider MCP clients
- Pass host MCP metadata into Claude, Cursor, and OpenCode
- Update MCP docs for provider-specific configuration
- Keep conversation locks outside the webview composer\n- Allow the composer picker to switch providers in VS Code\n- Cover the new lock resolution behavior with unit tests
- Clean up stdio relay socket lifecycle
- Clamp OpenCode MCP timeouts and skip invalid values
- Improve VS Code MCP timeout docs and tests
- Share MCP timeout normalization across server and VS Code
- Reject invalid bootstrap timeout values at schema boundary
- Harden VS Code MCP bridge message handling and cleanup
- Document the command allowlist and timeout minimum
- Re-export the minimum from shared MCP helpers\n- Keep desktop bootstrap schema as the source of truth
- Read allowlist from t3code.mcp.allowedRunCommands
- Keep default commands and prefix matching
- Update docs and tests for custom patterns
- Cache parsed patterns until t3code setting changes
- Reject malformed allowlist entries and dedupe valid ones
- Update schema and tests for config refresh and validation
- Resolve allowlist directly from workspace config
- Drop cache invalidation listener and cached state
- Allow activateExtension on vscodeRunCommand
- Activate installed extensions before registration checks
- Cover activation and validation cases in tests
- Check contributed commands before activating an extension
- Fail fast when the requested command is not declared
- Cover the new guard with a rejection test
- Gate activateExtension behind a new allowlist
- Update MCP bridge behavior and validation
- Document and test the new setting
- Advertise VS Code MCP bridges from the extension\n- Discover and probe matching host MCP servers on startup\n- Preserve security checks and add cleanup for stale records\n- Cover advertisement and discovery flow with focused tests
- Advertise VS Code backends in shared local files
- Route live owner commands through local peer APIs
- Merge peer events into desktop shell and thread streams
- Fall back to bootstrap servers on discovery failures
- Treat Windows named pipes as probe-validated
- Add regression coverage for provider-start fallback
- Accept dispatchable thread.turn.start payloads in local peer HTTP
- Export the dispatchable command schema for shared decoding
- Cover normalized attachment IDs in contract tests
- Share advertisement file helpers across host and backend flows
- Reject non-loopback peer URLs and tighten local-peer request handling
- Add fallback paths and tests for discovery and route authorization
- Query peers sequentially until one returns a result
- Avoid sending owner-sensitive commands to later peers
- Cover the interrupt dispatch path with a regression test
- Align VS Code extension deps with the upstream Effect catalog

- Switch local peer HTTP calls and server tests to Effect HTTP

- Tighten orchestration test decoding for thread.turn.start
- Resolve catalog dependencies from the root workspace catalog

- Keep packaged VS Code manifests installable outside the monorepo
- Add forceDesktopLayout to sidebar provider

- Keep thread sidebar open in desktop shells

- Add regression coverage for desktop rendering
- Preserve provider lock in all hosts
- Remove VS Code-only composer unlock path
- Update unit coverage for shared lock behavior
- Buffer and coalesce subagent activity output
- Preserve local behavior for future upstream merges
- Document branch-specific changes in CUSTOMIZED.md
- Let chat surfaces use full available width by default
- Keep the VS Code setting as an explicit opt-in override
- Cover the new default with a focused web test
- Update extension docs to describe empty as no max width
- Label desktop-bootstrap bearer sessions as VS Code
- Shorten their bearer TTL and revoke stale ones
- Add authenticated session revocation on backend stop
- Route thread archive stop commands through peer context
- Update tests for auth, federation, and backend cleanup
- Remove the 12-hour TTL override for backend bearer sessions

- Keep stale desktop-bootstrap cleanup separate from live tokens
- Restrict self-revoke route to bearer sessions

- Make backend revocation timeout portable and resilient

- Preserve peer archive-stop routing fallback
- Stop provider sessions when archive routing lookup fails

- Add regression coverage for lookup failure fallback
- Add bearer-only HTTP authentication for revocation

- Cover revocation when cookie and bearer auth coexist
- Add YAML manifests for worktree comment, port, spawn, and update skills
- Disable implicit invocation for each new agent skill
- State that subagents only need branch-local step context
- Remove instructions to share overall process status
# Conflicts:
#	apps/desktop/src/backend/DesktopBackendManager.ts
#	apps/server/src/auth/SessionStore.test.ts
#	apps/server/src/provider/Layers/CodexSessionRuntime.test.ts
#	apps/server/src/sourceControl/AzureDevOpsSourceControlProvider.test.ts
#	apps/server/src/sourceControl/GitHubSourceControlProvider.test.ts
#	apps/server/src/sourceControl/GitLabCli.ts
#	apps/web/src/environments/primary/auth.ts
#	apps/web/src/environments/primary/target.ts
#	apps/web/src/hooks/useTheme.ts
#	packages/effect-acp/src/client.test.ts
#	packages/effect-acp/src/protocol.test.ts
- Route provider failures through shared sourceControlProviderError
- Rename host bootstrap helpers to desktop-managed compatibility names
- Add typed project-action terminal readiness errors and tests
- Sanitize provider error causes and URL diagnostics

- Treat terminal closure as strict readiness failure

- Add source-control test alias and compatibility comments
- Add fallback userinfo stripping for unparseable embedded URLs
- Cover malformed embedded URL sanitization
- Preserve latest running child activity rows in parent timelines
- Add per-generation sidebar indentation for visible subagents
- Update subagent dedupe and visibility tests
…ed-project-actions

# Conflicts:
#	apps/server/src/terminal/Layers/Manager.ts
#	apps/server/src/terminal/Manager.test.ts
…-project-actions

# Conflicts:
#	apps/server/src/terminal/Manager.test.ts
#	apps/server/src/terminal/Manager.ts
#	apps/web/src/components/ChatView.tsx
#	apps/web/src/projectScriptTerminals.test.ts
#	apps/web/src/projectScriptTerminals.ts
@github-actions github-actions Bot added size:XXL 1,000+ changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). labels Jun 21, 2026
Comment thread apps/server/src/vscodeWorkspaceBootstrap/http.ts Outdated
Comment thread apps/web/src/session-logic.ts Outdated
Comment thread apps/vscode-extension/src/backendManager.ts
Comment thread apps/vscode-extension/src/extension.ts
Comment thread apps/vscode-extension/src/webview.ts Outdated
Comment thread apps/web/src/session-logic.ts Outdated
- Return readiness errors without retrying malformed payloads
- Dispose VS Code webview resources if setup fails
- Escape injected inline script content and tighten work log parsing
- Release transient server resources before socket cleanup
- Retry stalled readiness body reads after abort timeout

- Cover stalled JSON readiness bodies before bootstrap
- Sanitize bootstrap errors and preserve cleanup failures
- Split malformed readiness from transient body read failures
- Cover script escaping and ambiguous output prefix merges
- Append prefix-matching tool updates for multiline output

- Cover multi-character prefix chunks in session-log tests
Comment thread apps/web/src/session-logic.ts
- Keep multiline tool.updated snapshots from reappending prefix chunks
- Update regression tests for shorter multiline snapshot updates
- Keep one-character prefix snapshots from duplicating output

- Update session-log coverage for the snapshot case
- Append prefix-shaped incremental command output updates

- Restore regression coverage for prefix chunk merging
- Keep multiline tool.updated snapshots from duplicating output
- Update tests to cover shorter prefix snapshots
- Remove the unconditional multiline prefix snapshot override

- Update the command output merge regression test
Comment thread CUSTOMIZED.md Outdated
…ed-project-actions

# Conflicts:
#	apps/server/src/provider/Layers/CursorProvider.test.ts
#	apps/web/src/components/AppSidebarLayout.tsx
#	apps/web/src/components/NoActiveThreadState.tsx
#	apps/web/src/components/Sidebar.tsx
#	apps/web/src/components/chat/ChatHeader.tsx
#	apps/web/src/components/ui/sidebar.tsx
#	apps/web/src/routes/_chat.index.tsx
#	apps/web/src/routes/settings.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant