Skip to content

Add quick action buttons to session detail header#231

Merged
dhilgaertner merged 2 commits intomainfrom
feature/crow-230-quick-action-buttons
May 1, 2026
Merged

Add quick action buttons to session detail header#231
dhilgaertner merged 2 commits intomainfrom
feature/crow-230-quick-action-buttons

Conversation

@dhilgaertner
Copy link
Copy Markdown
Contributor

Summary

  • Adds PR-status-aware quick action buttons to the session detail header so users can act on a session card without switching into it and typing a prompt by hand.
  • Each button maps 1:1 to an existing status badge: Rebase & Fix Conflicts (conflicts), Address Review (changes requested), Fix Checks (failing CI), Merge PR (ready to merge).
  • Click → routes through a new dispatchManual on AutoRespondCoordinator → injects a deterministic single-line prompt into the session's managed Claude Code terminal via TerminalManager.shared.send.
  • The addressChanges and fixChecks prompts share text with the existing auto-respond pipeline (AutoRespondPrompts) so manual and auto paths stay consistent. New prompts added for fixConflicts and mergePR, including GitLab variants.
  • Buttons hide when the PR is merged or no status is known, and disable (with a tooltip) when the session has no managed terminal.

Test plan

  • make build passes
  • make test passes (CrowCore + Tests/)
  • Open a session whose PR has merge conflicts → Rebase button appears, click types the rebase prompt into the terminal
  • Open a session with changes requested → Address Review button appears
  • Open a session with failing checks → Fix Checks button appears
  • Open a session that is ready to merge (passing + approved + mergeable) → Merge PR button appears as the prominent green action
  • Open a session whose PR is merged → no quick action buttons render
  • Open a session with no managed terminal → buttons render disabled with tooltip
  • Existing detail header buttons (Open VS Code, Open Terminal, In Review, Mark Completed, Delete) are unchanged

Closes #230

🤖 Generated with Claude Code

Copy link
Copy Markdown
Collaborator

@dgershman dgershman left a comment

Choose a reason for hiding this comment

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

Code & Security Review

Critical Issues

None found.

Security Review

Strengths:

  • Prompts are deterministic string templates — no user-controlled input is interpolated unsafely into shell commands.
  • parsePRNumber(from:) safely parses via Int(last), which returns nil for non-numeric input rather than crashing or allowing injection.
  • The --force-with-lease flag in the rebase prompt is the correct safe alternative to --force.
  • dispatchManual re-validates terminal state (managed terminal exists, surface initialized, PR link present) before sending, rather than trusting the UI's canDispatchQuickAction gate alone. Defense in depth.

Concerns:

  • None material. The prompt text is sent to a local terminal, not an external API, so the blast radius of any prompt content issue is limited to the local Claude Code session.

Code Quality

Well done:

  • Clean separation: QuickAction enum in CrowCore (view layer), QuickActionPrompts in the app layer alongside AutoRespondPrompts. The model doesn't depend on prompt-building logic.
  • addressChanges and fixChecks correctly delegate to AutoRespondPrompts.build via synthetic PRStatusTransition values — single source of truth for prompt text.
  • The @ViewBuilder pattern in quickActionButtons is idiomatic SwiftUI. Conditional rendering based on PRStatus fields (mergeable, reviewStatus, checksPass, isReadyToMerge) is clean and maps directly to the existing status badges.
  • Disabled state + tooltip for sessions without a managed terminal is good UX.
  • AutoRespondCoordinator is @MainActor, and the onQuickAction closure is called from SwiftUI button actions (main thread), so thread safety is correct.

Minor observations (non-blocking):

  1. Session.provider is optional (Provider?) — dispatchManual defaults to .github via ?? .github when nil. This matches the existing dispatch(_:) pattern at line 56, so it's consistent, but worth noting that a session with no explicit provider will silently get GitHub-flavored prompts.
  2. Synthetic PRStatusTransition uses UUID() for sessionID — this is fine since AutoRespondPrompts.build never reads sessionID, but it's a slight code smell. A static sentinel UUID or making sessionID non-required for prompt building would be cleaner, though not worth the refactor now.
  3. Multiple quick action buttons can show simultaneously (e.g., conflicts + failing checks). This seems intentional and correct — a PR can have multiple issues at once.

Summary Table

Priority Issue
🟢 Synthetic UUID() in QuickActionPrompts — cosmetic, matches existing pattern
🟢 provider ?? .github fallback — consistent with existing code

Recommendation: Approve — clean feature addition that correctly extends the existing auto-respond architecture with a manual dispatch path. Good separation of concerns, proper guard chains, and consistent prompt reuse. All 136 CrowCore tests pass.

dhilgaertner and others added 2 commits May 1, 2026 16:37
Maps each PR status badge to a button that injects the next-step prompt
(Rebase & Fix Conflicts, Address Review, Fix Checks, Merge PR) into the
session's managed Claude Code terminal so the user can act in one click
without switching focus. Reuses the auto-respond dispatch path; the
addressChanges and fixChecks prompts share text with AutoRespondPrompts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Auto-respond and the new quick action dispatch were calling
TerminalManager.shared.send and existingSurface(for:) directly. That
silently fails for terminals on the tmux backend (CROW_TMUX_BACKEND=1)
since the surface check returns nil for tmux-backed terminals.

Switch both paths to TerminalRouter.send and add a backend-aware
TerminalRouter.canSend gate (Ghostty: surface exists; tmux: window
binding registered). Adds TmuxBackend.isRegistered(id:) to support it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dhilgaertner dhilgaertner force-pushed the feature/crow-230-quick-action-buttons branch from 6f0930f to e284f41 Compare May 1, 2026 21:43
@dhilgaertner dhilgaertner merged commit 3919e8d into main May 1, 2026
2 checks passed
@dhilgaertner dhilgaertner deleted the feature/crow-230-quick-action-buttons branch May 1, 2026 21:53
dhilgaertner added a commit that referenced this pull request May 4, 2026
…xes (#238)

Closes #235

## Summary

- Adds `docs/automation.md` as the canonical guide to Settings →
Automation and the full auto-flow lifecycle.
- Updates `docs/architecture.md` with the dual Ghostty/tmux backend
(#229), the new `TerminalRouter` dispatch, the Settings tab split
(#228), and the Review Board surface (#188, #205, #207, #210, #212,
#220, #226, #231).
- Adds `crow rename-terminal` (#206) to `docs/cli-reference.md`.
- Adds troubleshooting rows for tmux backend missing, Ghostty surface
retry (#218), GitLab nested groups (#233), `GITLAB_HOST` silent skip
(#215), auto-respond not firing, and the silent no-op `hook-event`
behavior (#234).
- Adds `CROW_TMUX_BACKEND` and `CROW_HOOK_DEBUG` to the
`docs/configuration.md` env-var table.
- Backfills `CHANGELOG.md` `[Unreleased]` with every PR from #137
through #234, grouped by theme.
- Updates `README.md` features list and docs index for the new
automation suite, review board, terminal renaming, and tmux opt-in.
- Appends an "Implementation Status (2026-05)" footer to
`docs/terminal-runtime-research.md` noting #229 shipped the headless-PTY
backend recommended in the original research.

The audit checklist called out as deliverable #1 in the issue is posted
as a [comment on
#235](#235 (comment)).

## Test plan

- [ ] `git diff --stat main` shows only the listed `docs/`,
`CHANGELOG.md`, and `README.md` files
- [ ] Render each modified doc on GitHub and confirm anchors /
cross-links resolve
- [ ] Confirm `crow --help` matches the command list in
`docs/cli-reference.md` (only `rename-terminal` was missing pre-PR)
- [ ] Walk every PR number in the CHANGELOG against `git log
--since=2026-04-15 main --oneline` and confirm each one resolves
- [ ] Re-export `docs/crow-screenshot.jpeg` against the current
Settings/Review-Board UI — **deferred to a follow-up**, called out in
the audit comment

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add quick action buttons to session card status badges

2 participants