Skip to content

Run script + CMD+R hotkey — start/stop project dev command per chat #139

@flazouh

Description

@flazouh

Problem

I want a "Run" command bound to CMD+R that runs my project's dev/run script (e.g. bun dev, pnpm dev) in the focused chat's worktree, so I can iterate without leaving Acepe.

Current behavior

  • Keybinding registry: packages/desktop/src/lib/keybindings/bindings/defaults.ts:16-236 defines DEFAULT_KEYBINDINGS. No binding for $mod+r / "project.run" exists.
  • Current $mod+ bindings include: t → THREAD_CREATE, w → THREAD_CLOSE, p → command palette, etc.
  • Registration flow: KeybindingManager.registerKeybindings() (keybinding-manager.ts:53) calls keybindingsService.upsertAction(); handlers wired in separate methods (e.g. setThreadCreateHandler line 223).
  • No Tauri global shortcuts are registered — all shortcuts are in-app via tinykeys.
  • No "run project" infrastructure exists today (no Tauri command for running an arbitrary shell process, no UI pane for stdout/stderr of a run script).

Proposed change

1. Config

Extend .acepe.json schema + global Settings:

{
  "worktree": {
    "runCommand": "bun dev",          // single string, or
    "runCommands": ["bun dev"],       // array for composed setups
    "runCwd": "."                     // relative to worktree root
  }
}

Auto-detect from package.json scripts (prefer dev, start, serve in that order).

2. Hotkey

Add to defaults.ts:

{ key: "$mod+r", command: KEYBINDING_ACTIONS.PROJECT_RUN, when: "threadActive && !settingsOpen && !modalOpen" }

Register corresponding handler in KeybindingManager.

3. Execution

New Tauri command project_run_start(panel_id, cwd, command):

  • Spawns the run command in the worktree cwd (or main repo cwd if no worktree).
  • Reuses the env-allowlist machinery from worktree_config.rs:32-62.
  • Streams stdout/stderr as Tauri events project:run-output tagged by panel_id.
  • Tracks the child PID so project_run_stop(panel_id) can SIGTERM → SIGKILL it.

4. UI

  • New "Run" pane attached to the agent panel (collapsible, like the terminal pane). Shows streaming output, status (running/stopped/crashed), exit code.
  • Visual indicator in the panel header when a run is active.
  • CMD+R toggles: starts if idle, no-ops / focuses pane if running. CMD+SHIFT+R restarts.
  • Confirmation or idempotency check to avoid spawning duplicate processes.

5. Lifecycle

  • Run processes attached to a panel should be SIGTERMed when the panel is closed.
  • If the worktree is deleted (git worktree remove), the run process is stopped first.

Files to touch

  • packages/desktop/src-tauri/src/git/worktree_config.rs:66-80 — schema.
  • New: packages/desktop/src-tauri/src/project/run.rs (or similar) + wiring in lib.rs.
  • packages/desktop/src/lib/keybindings/bindings/defaults.ts:16-236 + keybinding-manager.ts:53 — new binding + handler.
  • packages/desktop/src/lib/acp/components/agent-panel/ — new Run pane + store.

Acceptance criteria

  • CMD+R in a focused chat starts the project's run script in that chat's worktree.
  • Output streams into a pane without blocking the UI.
  • Closing the panel stops the run process.
  • CMD+R is a no-op (or focuses the run pane) if already running; CMD+SHIFT+R restarts.
  • Auto-detect from package.json scripts when no runCommand is configured.
  • Errors surface clearly (non-zero exit, command not found, etc.).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions