Skip to content

feat(tui): render the sidebar background-activity strip - #685

Merged
mohitranka merged 1 commit into
mainfrom
feat/background-activity-strip
Sep 14, 2026
Merged

mohitranka merged 1 commit into
mainfrom
feat/background-activity-strip

Conversation

@mohitranka

Copy link
Copy Markdown
Contributor

The defect

The operator could already move a selection over background tasks with ↑↓ and act on them with x / a / d / i, but nothing drew them. task_selection.task() was read only by the command handlers and by focus, never by a renderer, and every caller of the layout passed background_h = 0 — so regions.background, the strip layout.rs reserves between the queue and the composer, was permanently zero-height. The keys worked; the rows were invisible.

What changed

The strip is now a real surface. It is deliberately not a log: a [✓] row retires a minute after it finished; everything else waits for x.

Three rules are load-bearing, and each is pinned by a test:

  • Ordering is blocked → failed → active → queued → done. failed outranks active because a failure is the only other state that can need an operator, and truncation takes from the tail — so the rows that get cut are always the ones still progressing or already finished. Naive ordering hides the failure first.
  • Cancelled is not folded into Done. Sharing the TTL would have aged out a cancellation the operator never performed (a stopped session, an interrupted turn), leaving no evidence it happened.
  • The strip yields before the transcript. The renderer only requests a height; layout.rs clamps it against the transcript's Min floor, so a merely running job can never take a row from the conversation.

Blocked rows also name the asker and draw the pending request — the tool plus its already-redacted arguments — on a second line, so "task #4 needs approval" becomes "explore wants to run bash".

Notes for the reviewer

  • started_at / finished_at already existed on BackgroundTaskHandle; the snapshot now carries them for the elapsed column and the expiry clock. No other crate constructs the struct, so the field addition is additive.
  • The clamp in layout.rs is a no-op at background_h = 0, which is why the 22 existing layout tests still pass unchanged.
  • Scope is the view-model, the widget and the wiring. Drill-in to a subagent's session and out-of-band notification are deliberately not in this PR.

Verification

  • 7 view-model tests (crates/forge-tui/src/tasks_strip.rs), 5 widget tests (crates/forge-tui/src/widgets/background_strip.rs), 2 snapshot tests.
  • cargo fmt --all -- --check clean.
  • cargo clippy --workspace --all-targets --locked -- -D warnings clean.
  • Locally, 3 app::tests::tasks tests fail because this machine refuses to apply the tool sandbox, so spawning a real background shell fails. They fail identically on the base commit (verified by stashing), and CI installs sandbox dependencies.

The operator could already move over background tasks with `↑↓` and act on
them with `x`/`a`/`d`/`i`, but nothing drew them: `task_selection.task()` was
read only by the commands and by focus, never by a renderer, and every caller
of the layout passed `background_h = 0`, so the region `layout.rs` reserves
for the strip was always zero-height. The keys worked; the rows were
invisible.

The strip is now a real surface, docked between the outbound-message queue and
the composer. It is deliberately not a log: a `[✓]` row retires a minute after
it finished, and everything else waits for `x`.

Three rules are load-bearing, and each is pinned by a test:

- Ordering is blocked -> failed -> active -> queued -> done. `failed` outranks
  `active` because a failure is the only other state that can need an
  operator, and truncation takes from the tail, so the rows that get cut are
  always the ones still progressing or already finished. Naive ordering hides
  the failure first.
- `Cancelled` is not folded into `Done`. Sharing the TTL would have aged out a
  cancellation the operator never performed (a stopped session, an interrupted
  turn), leaving no evidence it happened.
- The strip yields before the transcript. The renderer only requests a height;
  `layout.rs` clamps it against the transcript's `Min` floor, so a merely
  running job can never take a row from the conversation.

Blocked rows also name the asker and draw the pending request (tool plus its
already-redacted arguments) on a second line, so "task #4 needs approval"
becomes "explore wants to run bash".

`started_at`/`finished_at` were already on `BackgroundTaskHandle`; the snapshot
now carries them for the elapsed column and the expiry clock.

Tests: 7 view-model, 5 widget, 2 snapshot. `cargo fmt --all -- --check` and
`cargo clippy --workspace --all-targets --locked -- -D warnings` clean.
@mohitranka
mohitranka merged commit 37ea60f into main Sep 14, 2026
3 checks passed
mohitranka added a commit that referenced this pull request Sep 14, 2026
A background subagent stopping for approval changed nothing the operator
could read. `poll_background_tasks` swept only terminal transitions, so the
block was invisible apart from the footer chip's `· 1 need` — a count that
does not say who is asking, and which the operator has to notice unprompted.

Subagent approvals live on the task (`BackgroundTaskStatus::
WaitingForApproval`), not on the session, so there is no transcript card to
relabel: the strip row and the feedback line are the whole surface. The strip
row already names the asker after #685; this adds the transition that was
missing.

- A task newly entering `WaitingForApproval` now raises a warning on the
  feedback strip and a toast: `explore needs approval: bash`.
- Approve, deny and "not waiting" feedback name the task rather than its row
  id, so answering one of several in-flight agents is unambiguous.
- `push_toast` hardcoded `FeedbackSeverity::Ok` for both the toast and the
  feedback strip it writes. A needs-approval notice would therefore have
  rendered as a success and clobbered the severity. `push_toast_with` takes
  the severity; `push_toast` is now a thin `Ok` wrapper.

Tests: a subagent that blocks names itself and its tool on the feedback strip
with `Warn` severity, and the approval confirmation names the task.
mohitranka added a commit that referenced this pull request Sep 14, 2026
…ions (#688)

The design system described the footer's counts-only chip and referred per-item
detail to "the task view", which did not exist as a named surface. The strip now
renders (#685, #686) and notifies (#687), so the rules that shipped — and the
reason each exists — belong in the design language rather than only in the code.

Adds §9.12 (the strip) and §9.13 (out-of-band notification), and points Row 1
of §9.3 at them. The rules recorded are the ones that are load-bearing and easy
to undo by accident: the derived height that keeps the transcript's floor,
the ordering that stops truncation hiding a failure, `cancelled` staying
distinct from `done`, the one-minute expiry, and the focus gate on the
notification.
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