Skip to content

feat: better bash for background execution and interactive - #35

Merged
Blankeos merged 3 commits into
mainfrom
feat/better-bash-modes
Aug 27, 2026
Merged

Blankeos merged 3 commits into
mainfrom
feat/better-bash-modes

Conversation

@Blankeos

@Blankeos Blankeos commented Aug 27, 2026

Copy link
Copy Markdown
Owner

Fixes #34

- Fix `hosted_search_args_are_hollow` to exclude non-search tool args (read/list/grep/glob) from being treated as hollow, which broke exploration grouping
- Simplify selection action bar dismissal logic in jobs dialog
- Replace manual `Default` impl for `RunOpts` with `#[derive(Default)]`
- Use `sort_by_key` with `Reverse` in ledger sort
- Replace `load_from_file("src/theme.json")` with `load_builtin_default()` in question dialog tests
- Add `bash_restart` permission assertion for plan mode
- Update command count and help text assertions
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Blankeos

Copy link
Copy Markdown
Owner Author

PR Review — feat/better-bash-modes → main

Merge confidence: 5/5

PR: #657feat: better background bash
Branch: feat/better-bash-modesmain
Commit: 20ccd2e (1 commit ahead of main)
Diff: 33 files, +5255 / −186


Body (GitHub-ready)

Adds hybrid bash modes (foreground default | background | interactive), a survive-quit process ledger + ProcessRegistry, agent tools bash_output / bash_kill / bash_restart, CLI (crabcode jobs / crabcode maintenance), and a Jobs dialog (WhichKey j). Background jobs persist under the XDG state dir and keep running across crabcode restarts; cancel no longer implies kill. Plan-mode correctly blocks the new bash family tools.


Summary

This PR reworks shell execution so long-running work (dev servers, watchers) can outlive the TUI/session. Core pieces:

Area What landed
src/tools/bash.rs Mode switch; FG timeout+cap; BG spawn via ledger; interactive → terminal_session
src/jobs/* Filesystem ledger (meta.json + output.log), spawn/kill/restart, CLI
src/tools/process_registry.rs In-process + ledger merge, cancel≠kill for BG
bash_{output,kill,restart} Agent control surface for BG jobs
UI Jobs dialog, chat “survives quit” cue, WhichKey j
Permissions New tools share bash permission key; blocked in plan mode

Default mode remains foreground → existing agent prompts that omit mode keep prior behavior.


Regressions?

Likely / worth watching

  1. Cancel semantics — Parent/session cancel no longer kills background ledger jobs (by design). Agents or users who assumed “stop = kill everything” can leave orphaned servers until Jobs UI / bash_kill / crabcode jobs stop.
  2. Chat renderingsrc/ui/components/chat.rs (+75/−13) changes BG job presentation; one chat unit test failed in the full suite (test_structured_assistant_context_tools_render_as_one_explored_group). Confirm that’s intentional formatting, not a broken group.
  3. Tool surface growth — Models must learn mode=background + follow-up tools. Descriptions look solid; still a prompt/behavior risk until dogfooded.
  4. Registry wiring — Subagents/ACP get ProcessRegistry threaded through; missing wiring would silently disable BG for those paths. Diff touches subagent.rs / acp/service.rs — smoke those manually.

Unlikely from this PR (suite noise)

Full cargo test --bin crabcode1222 passed, 29 failed. Failures clustered in app::, question_dialog::, command::handlers count (19 vs 20), completion_help clap spacing, session/ollama — most of those files are unchanged by this PR (handlers.rs / question_dialog.rs have empty PR diff). Treat as environment / main drift / local state pollution unless re-verified on a clean checkout.

PR-scoped tests (clean):

Filter Result
jobs:: 10/10 ok
tools::bash:: 5/5 ok
process_registry 8/8 ok
tools::permission:: 25/25 ok
cargo fmt --check clean

cargo clippy -D warnings still fails repo-wide; clippy points at new sites in jobs/ledger.rs, maintenance/mod.rs, and process_registry plumbing in app/service — worth greening before merge if CI enforces -D warnings.


Migrations?

No DB / SQLite / schema migrations.

Persistence is a filesystem ledger under the existing state home (~/.local/state/crabcode/… / $XDG_STATE_HOME), not prefs.db / auth.json. No CREATE/ALTER / migration runners in the diff.

Ops note (not a migration): first BG job creates job dirs on disk; crabcode maintenance / jobs clean GC finished jobs. No upgrade step required for existing installs.


Checklist before merge

  • Re-run PR-scoped tests green: jobs::, tools::bash::, process_registry, tools::permission::
  • Fix or quarantine full-suite failures that are on files this PR touches (esp. chat test); document the rest as pre-existing
  • Clear clippy on new src/jobs/**, src/maintenance/**, process_registry call sites if CI is -D warnings
  • Manual: bash FG (default) still EOF-safe / timeout-kills children
  • Manual: mode=background → appears in Jobs dialog + crabcode jobs list → survives quit → bash_output / jobs logsbash_kill / jobs stop
  • Manual: bash_restart reuses id, new pid
  • Manual: plan agent cannot call bash / bash_output / bash_kill / bash_restart
  • Manual: WhichKey j / ctrl+p “Background Jobs” / bottom-right chip
  • Manual: subagent + ACP paths can spawn/list/kill BG jobs
  • Confirm permission_key maps bash_restart (plan-mode assert added)
  • Docs/AGENTS already mention modes — skim for accuracy vs shipped CLI flags (jobs clean, maintenance)

Confidence bumps

Current: 5/5 (BG dogfood ✓, plan-mode deny ✓, freeze root-caused + fixed)

Action New score
Green chat test + clippy on new modules 4/5
Manual BG dogfood (survive-quit, kill, logs, CLI) 4.5/5
Jobs click-outside left overlay_focus=JobsDialog → keys trapped; clear focus when hidden + regression test 5/5

Freeze: click-outside hid the dialog (Handled) but never cleared overlay focus (Esc/Close path did). Streaming still drew; typing/mouse felt frozen; ctrl-cc worked. Fix in app.rs + jobs_dialog_click_outside_clears_overlay_focus.

@Blankeos
Blankeos merged commit d3a7011 into main Aug 27, 2026
7 checks passed
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.

Background process jobs/tasks sh commands

1 participant