Skip to content

Run the repo's Custom GitHub Issue Command when starting a workspace from an issue - #6827

Merged
brennanb2025 merged 5 commits into
mainfrom
brennanb2025/issue-command-consistency
Jul 3, 2026
Merged

brennanb2025 merged 5 commits into
mainfrom
brennanb2025/issue-command-consistency

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Repos can configure a small shell script (the Custom GitHub Issue Command) that runs in a side pane whenever you start working from a GitHub issue. The New Workspace composer used to run it, but that path was switched off in May when the composer became quick-create-only (#1985) — so lately nothing ran the script. This PR makes the one-click "start workspace from issue" button run it.

The safety rules are the ones the composer's automation used: nothing runs if the repo hasn't configured a script, scripts from the repo's shared orca.yaml ask for your approval first, and if you already declined trust, it stays skipped. The instructions given to the AI agent don't change at all — it still just gets the issue link; the only new thing is that the repo's script now also runs.

What changes

The one-click "Start workspace from issue" button now runs the repo's Custom GitHub Issue Command as a trust-gated side-pane split when you start a workspace from a GitHub issue, using the same trust gating and delivery seam the composer's issue automation used. Note (correcting an earlier version of this description): the composer's automation is currently disabled at its only mount (enableIssueAutomation: false in NewWorkspaceComposerModal, since #1985), so at HEAD no surface ran the script at all — this PR makes the quick button the first surface to run it again.

What does NOT change

The seeded agent prompt for the quick button stays the bare issue link (it is not rewritten to Complete <url>). This PR only adds running the configured issue-command shell script; it does not alter the agent's prompt text.

Behavior details

  • Runs only for GitHub issues on git repos. PRs, Linear, and non-git/folder targets never run it.
  • Only runs when the repo actually configured an issue command (.orca/issue-command local override, or shared orca.yaml). No config → nothing runs.
  • Trust gating mirrors the composer: if setup-trust was declined, the issue command is skipped too; shared orca.yaml commands prompt via the existing confirm-orca-yaml-hooks modal (once per content version); local .orca/issue-command overrides auto-run (user-owned). Reads fail closed — a read error means no command runs and workspace creation still proceeds.
  • Delivered through the existing queueTabIssueCommandSplit path, threaded into both activation branches (activateAndRevealWorktree when the user is watching, and ensureWorktreeHasInitialTerminal when they've moved on — the common one-click case).
  • Runtime-owned repos (review fix): runtime worktrees mirror their session tabs asynchronously, so right after create there is often no tab to queue on — previously the commands were silently dropped. A new hook-command-delayed-delivery module (mirroring agent-startup-delayed-delivery's lazy-subscription shape) holds setup/issue commands until the first mirrored tab lands, and drops them if the worktree disappears first.
  • Trust-state freshness (review fix): both trust checks re-read the store at call time, so an "Always trust" checked on the setup prompt (or stamped by a concurrent create) short-circuits the issue-command prompt instead of re-prompting from a pre-prompt snapshot.

Design approach

Resolve the issue command on the quick-create background path (createGitHubWorkItemWorkspaceInBackground) right after the existing setup/PR/agent preflight, reusing the setup trust decision and the existing ensureHooksConfirmed(..., 'issueCommand') trust check. Carry the rendered command on WorktreeCreationRequest.issueCommand and deliver it from executeWorktreeCreation into both activation branches. No new IPC or schema — reuses readRuntimeIssueCommand and the existing split-pane delivery seam.

Scope note (interpretation Brennan should see)

The original issue could be read two ways. Confirmed direction: keep the quick-start agent prompt as the bare link; the fix is that the Custom GitHub Issue Command script now runs when starting from an issue. The earlier "seed the prompt with Complete <url>" interpretation was explicitly rejected and is not in this PR.

Open question for Brennan: the composer modal — which is also this quick path's fallback when preflight can't background (repo missing, host unavailable, setup needs answers, agent startup failure) — still does not run issue commands: its automation flag is off and its live submitQuick path never resolves one. So after this PR, the same "start from this issue" intent runs the script from the quick button but not from the modal. The new WorktreeCreationRequest.issueCommand plumbing already supports the modal (it submits through the same executeWorktreeCreation), so giving submitQuick the same resolve+trust+attach block is a small follow-up if you want full parity — deliberately not smuggled into this PR.

Validation

  • Headline behavior: implemented (not partial). Verified end-to-end in a dev build: starting a workspace from a GitHub issue on a repo with a local .orca/issue-command spawned a side-pane split that ran the rendered command ({{issue}}/{{artifact_url}} substituted), while the primary agent pane's prompt stayed the bare issue URL.
  • Negative cases verified: PR item → no issue command; setup-trust declined → skipped (issue-command trust never reached); repo with no config → nothing runs.
  • Broad app consistency: gating semantics ported from the composer's submitShouldRunIssueAutomation + issueCommand delivery (that code path is currently disabled at its mount — see the open question above).
  • Perf: off every hot loop (one-shot, gated to the configured-issue-command path), fails closed, reuses the composer's spawn machinery. The runtime delayed-delivery subscription exists only between create and first mirrored tab, then unsubscribes. Accepted gap: on the configured + not-yet-trusted branch the issue command is read twice (once for content, once inside the trust check) — at most one extra serial RPC per create, and partly a trust-correctness requirement; not worth widening the shared ensureHooksConfirmed signature to remove. Known TOCTOU footnote: if orca.yaml changes between those two back-to-back reads, the trust dialog shows the newer content while the older read runs — same-shaped (and much narrower) window than the composer's read-at-open/trust-at-submit behavior.
  • Code review: two-reviewer loop converged clean, then a post-hoc adversarial review round (independent Codex xhigh reviewer + manual verification) found three real issues; the two code bugs are fixed in this PR (runtime tab-mirror delivery drop, stale trust snapshot) and the third is the composer-parity open question above.
  • Tests: 67 focused tests pass across github-work-item-background-create.test.ts, worktree-creation-flow.test.ts, worktree-activation.test.ts, and the new hook-command-delayed-delivery.test.ts (delayed delivery: holds-then-delivers-once, immediate-delivery, drops-when-worktree-gone; plus trust-snapshot freshness). Typecheck and lint clean; full suite green locally on the merged tree apart from a WSL daemon test that is byte-identical to main and fails there too on macOS.
  • Merge-with-main fix: the earlier verify failure came from testing the merge ref — main's #6320 added awaits ahead of the activation branches in executeWorktreeCreation, starving this branch's fixed two-tick test flush. Merged main in, threaded issueCommand from preparedRequest, and switched the two delivery tests to vi.waitFor (the file's post-#6320 convention) so await-count drift can't silently starve them again.

SSH / cross-platform

readRuntimeIssueCommand and the trust check already route by repo-owner host (local IPC vs runtime RPC), so SSH/runtime repos resolve the command on the correct host. SSH repos deliver through the normal local tab-creation path. Runtime-owned repos deliver through the new delayed-delivery queue once their session tabs mirror in (this was the review-found drop, now fixed and unit-tested). No new platform-specific code; command rendering is string substitution and the shell launch reuses the same downstream path as the composer.

Remaining gaps

  • The literal TaskPage DOM button wasn't clicked (dev profile had no GitHub auth/live issues); validation exercised the identical production function the button calls, with real store/IPC and default deps.
  • SSH/runtime repo execution validated by reasoning + resolver coverage + the new delayed-delivery unit tests, not a live remote run.

Made with Orca 🐋

…from an issue

The one-click "Start workspace from issue" button never ran a repo's
Custom GitHub Issue Command, while the New Workspace composer does. Resolve
the repo's issue command on the quick-create background path and run it as a
trust-gated side-pane split, mirroring the composer.

Only GitHub issues on git repos run it (PRs/Linear excluded). Trust gating
mirrors the composer: a declined setup-trust skips it; shared orca.yaml
commands prompt via the existing confirmation modal; local .orca/issue-command
overrides auto-run. Reads fail closed so workspace creation still proceeds.

The seeded agent prompt is unchanged (stays the bare issue link).

Co-authored-by: Orca <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

An optional issueCommand field ({ command: string; env?: Record<string, string> }) is added to WorktreeCreationRequest. Background GitHub work item creation now reads runtime issue-command content, confirms hooks under a separate issueCommand scope, and conditionally includes the rendered command in the request. The worktree execution flow threads issueCommand through both activation paths, and web-runtime activation now queues hook-command delivery until the first mirrored terminal tab exists.

🚥 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
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 names the main change: running the repo's Custom GitHub Issue Command when starting from an issue.
Description check ✅ Passed The description is mostly complete and covers summary, behavior, testing, review, and notes, though Screenshots and Security Audit are not explicit.
✨ Finishing Touches
📝 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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1d7ef9b9-ae63-4a48-b98e-a50217a04b90

📥 Commits

Reviewing files that changed from the base of the PR and between 499b900 and ad9ab52.

📒 Files selected for processing (5)
  • src/renderer/src/lib/github-work-item-background-create.test.ts
  • src/renderer/src/lib/github-work-item-background-create.ts
  • src/renderer/src/lib/pending-worktree-creation.ts
  • src/renderer/src/lib/worktree-creation-flow.test.ts
  • src/renderer/src/lib/worktree-creation-flow.ts

brennanb2025 and others added 2 commits June 29, 2026 18:57
A declined setup-trust decision also skips the issue command, so guard the
whole branch on trustDecision !== 'skip' before the up-to-15s read instead of
reading just to drop the result. Stops a declined trust from stalling
workspace creation. (CodeRabbit)

Co-authored-by: Orca <[email protected]>
Review fixes:
- Runtime-owned worktrees mirror session tabs asynchronously, so the
  setup/issue-command delivery in ensureWorktreeHasInitialTerminal found
  no tab right after create and silently dropped the commands. Hold them
  in a delayed-delivery queue (mirroring agent-startup-delayed-delivery)
  until the first mirrored tab lands.
- Both trust checks in the quick-create flow re-read the store at call
  time so an "Always trust" stamped by the setup prompt (or a concurrent
  create) short-circuits the issue-command prompt instead of re-prompting
  from the pre-prompt snapshot.

Co-authored-by: Orca <[email protected]>

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

🧹 Nitpick comments (1)
src/renderer/src/lib/hook-command-delayed-delivery.ts (1)

32-39: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Consider a selector-based subscription instead of subscribing to the whole store.

useAppStore.subscribe(() => flushPendingHookCommandDeliveries()) fires on every store mutation, not just tabsByWorktree changes. If subscribeWithSelector middleware is already applied to this store, selecting tabsByWorktree would avoid scanning the pending map on unrelated updates. Low priority given the map is typically empty/small.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 64b3523c-2b23-4292-96a8-f2a60d29c6ad

📥 Commits

Reviewing files that changed from the base of the PR and between b67bfe9 and c2761f8.

📒 Files selected for processing (6)
  • src/renderer/src/lib/github-work-item-background-create.test.ts
  • src/renderer/src/lib/github-work-item-background-create.ts
  • src/renderer/src/lib/hook-command-delayed-delivery.test.ts
  • src/renderer/src/lib/hook-command-delayed-delivery.ts
  • src/renderer/src/lib/worktree-activation.test.ts
  • src/renderer/src/lib/worktree-activation.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer/src/lib/github-work-item-background-create.ts
  • src/renderer/src/lib/github-work-item-background-create.test.ts

brennanb2025 and others added 2 commits July 2, 2026 17:50
…very tests

Post-merge adjustments: executeWorktreeCreation now flows through
prepareRequestForCreate (#6320), so thread issueCommand from the prepared
request, and assert delivery via vi.waitFor — the fixed two-tick flush
starved once main added awaits ahead of the activation branches, which is
exactly how the merge-build verify check failed.

Co-authored-by: Orca <[email protected]>
@brennanb2025
brennanb2025 merged commit 11ca495 into main Jul 3, 2026
1 check passed
@brennanb2025
brennanb2025 deleted the brennanb2025/issue-command-consistency branch July 3, 2026 01:09
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant