Skip to content

fix(web): badge Needs attention only for unrecovered tool failures - #235

Merged
nullStack65 merged 2 commits into
release/native-0.1.10from
fix/needs-attention-unresolved-only
Nov 27, 2026
Merged

nullStack65 merged 2 commits into
release/native-0.1.10from
fix/needs-attention-unresolved-only

Conversation

@nullStack65

Copy link
Copy Markdown
Owner

Problem

The activity pill showed ⚠ Needs attention for any failed tool call in a run, even when the agent immediately retried and the retry succeeded.

Fix

  • chatActivityContext (packages/client-runtime/src/chatActivity.ts) now treats a failed tool call (command, file change, file/web search, dynamic tool) as recovered once a later call in the same run completes cleanly (not failed, exit code 0, no failing output). It exposes recoveredItemIds and recoveredRuns.
  • Recovered failures no longer add attention. Failures after the last clean call still do. Failed runs, error items, failed notifications and pending approvals/inputs are unchanged.
  • collapseTimelineActivity (web) and foldThreadFeedActivity (mobile) use the same recovery data, so both clients agree.

Tests

  • chatActivity.test.ts: retry recovers, last call failed stays flagged, running/failing later calls don't recover, other runs don't recover, some vs all recover, failed run stays flagged, error items never recover.
  • MessagesTimeline.logic.test.ts: the same cases at the pill level (attention true/false). The recovery case fails on base.
  • Ran: chatActivity.test.ts (17), MessagesTimeline.logic.test.ts (154), pending-thread-feed.test.ts (13), plus check:changed format/lint/tests/react-compiler.

Known unrelated failures (same on base)

  • knip fails on two unused .github/scripts/*.cjs files.
  • Typecheck errors are in Sidebar.logic.test.ts and botOrgTree.test.ts, none in touched files.
  • 2 projectGrouping.test.ts failures in client-runtime.

Deploy: none

Prior art

No new tooling or homegrown component; this narrows an existing helper. Searched: existing chatActivity.ts attention logic.

🤖 Generated with Claude Code

A failed tool call a later call in the same run recovered no longer marks
the activity pill; failed runs, errors and pending requests still do.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@nullStack65

Copy link
Copy Markdown
Owner Author
{
  "schema": "closura-review-gate/v1",
  "kind": "full",
  "review_kind": "full",
  "reviewer": "Gemini 4 Neon, Antigravity",
  "reviewer_family": "gemini",
  "author_session": "nullStack65/t3code#235@e59c4ebc29420047e8e3e2785c38be87304b0e93",
  "reviewer_session": "gemini-review-pr235-20261127T034600Z-9a7a1c38",
  "fresh_context": true,
  "round_id": "gemini-review-pr235-20261127T034600Z-9a7a1c38",
  "reviewed_head": "e59c4ebc29420047e8e3e2785c38be87304b0e93",
  "reviewed_base": "b64e48d52718896b379866bfa4099dbaa908abb8",
  "intent": [
    "R1: Recovered tool call failures followed by a clean completed call in the same run do not show Needs attention (partially met: works for status=failed event/work rows in chatActivityContext and web, but fails on mobile work-toggle rows [F1] and on recovered exitCode!=0/outputIndicatesFailure work-toggle rows [F2])",
    "R2: Genuine unrecovered failures (last call failed, failed run, error items, failed notifications, pending approvals/input requests) still show Needs attention (partially met: failed runs, error items, notifications, and pending requests are preserved, but a trailing non-zero-exit/outputIndicatesFailure work-toggle failure after an earlier recovered failure in the same run is silently suppressed on web [F2])",
    "R3: Consistent behavior across shared client-runtime, web, and mobile timelines (not met: mobile foldThreadFeedActivity does not apply recovery gating to work-toggle rows and has no recovery test coverage [F1])"
  ],
  "verdict": "changes_requested",
  "prior_findings": [],
  "findings": [
    {
      "id": "F1",
      "severity": "important",
      "outcome": "open",
      "file": "apps/mobile/src/features/threads/pending-thread-feed.ts",
      "line": 166,
      "summary": "Mobile `foldThreadFeedActivity` still unconditionally adds `row.id` to `attentionIds` for `row.type === \"work-toggle\" && row.hasFailure`, omitting the recovery check that web added in `MessagesTimeline.logic.ts:2680-2682`. When an agent run has a failed tool call in one collapsed `work-toggle` group (setting `hasFailure: true` via `apps/mobile/src/lib/threadActivity.ts:2395-2400`) followed later in the same run (e.g. after an intermediate agent message) by a clean retry, `chatActivityContext` marks the failure recovered and web clears the badge, while mobile still flags `attention` and auto-expands the activity fold. Fix: gate mobile's `work-toggle` failure check on recovery consistently with web (after fixing F2), and add regression tests in `apps/mobile/src/features/threads/pending-thread-feed.test.ts` covering recovered vs unrecovered `work-toggle` and `activity-group` failures.",
      "check": "git show e59c4ebc29420047e8e3e2785c38be87304b0e93:apps/mobile/src/features/threads/pending-thread-feed.ts:166 vs MessagesTimeline.logic.ts:2680-2682"
    },
    {
      "id": "F2",
      "severity": "important",
      "outcome": "open",
      "file": "packages/client-runtime/src/chatActivity.ts",
      "line": 123,
      "summary": "`recoveredRuns` is monotonic (never cleared when a later tool call in the same run fails) and asymmetric with `workEntryDisplayIndicatesToolFailure` (`packages/client-runtime/src/work-log/presentation.ts:334-365`) for `command_execution` items that finish with `status: \"completed\"` plus `exitCode !== 0` or `outputIndicatesFailure: true`. Two concrete defects follow: (1) False negative on web: if a run recovers an earlier `status: \"failed\"` tool call (`recoveredRuns.add(runId)`), and then ends with a `work-toggle` whose last tool call has `status: \"completed\"` with `exitCode: 1` or `outputIndicatesFailure: true` (or a `declined`/failing `dynamic_tool`), `activityItemNeedsAttention` is false so nothing enters `attentionByRun`, while `recoveredRuns.has(row.runId)` remains true and suppresses `row.hasFailure` in `MessagesTimeline.logic.ts:2680-2682` — hiding a genuine unrecovered trailing failure. (2) False positive on web/mobile: if a run's earlier failed `command_execution` had `status: \"completed\"` with `exitCode: 1` / `outputIndicatesFailure: true` (setting `work-toggle.hasFailure = true`) and a later call succeeds cleanly, the earlier call never entered `unrecoveredByRun`, so `recoveredRuns` never includes `runId` and the earlier `work-toggle` still badges Needs attention. Fix: track failing tool calls symmetrically with `toolCallSucceeded` (including `command_execution` with non-zero `exitCode` or `outputIndicatesFailure`), and only include a run in `recoveredRuns` when all of its tracked tool failures are recovered (i.e. clear `recoveredRuns.delete(runId)` on any subsequent tool failure, or compute `recoveredRuns` after the loop when `unrecoveredByRun.get(runId)` is empty).",
      "check": "git show e59c4ebc29420047e8e3e2785c38be87304b0e93:packages/client-runtime/src/chatActivity.ts:51-135 and packages/client-runtime/src/work-log/presentation.ts:334-365"
    }
  ],
  "skipped_nits": []
}

Independent 1-round cross-family review at e59c4ebc29420047e8e3e2785c38be87304b0e93 (base b64e48d52718896b379866bfa4099dbaa908abb8).

  • Verified: error items, failed runs (run.status === "failed"), failed notifications, pending approval_request / user_input_request items, and context-compaction failures remain flagged and cannot be recovered by later tool calls. Basic status: "failed" → status: "completed" recovery works in chatActivityContext and web event/work rows.
  • Changes requested:
    • F1 (important): apps/mobile/src/features/threads/pending-thread-feed.ts:166 still flags row.type === "work-toggle" && row.hasFailure unconditionally without checking recovery, diverging from web and leaving recovered work-toggle failures flagged on mobile.
    • F2 (important): recoveredRuns in packages/client-runtime/src/chatActivity.ts:123 is never cleared when a later failure occurs in the same run, and unrecoveredByRun only tracks activityItemNeedsAttention (status === "failed") rather than also tracking command_execution items with status: "completed" and exitCode !== 0 / outputIndicatesFailure: true. This causes both a false negative on web (a trailing non-zero-exit work-toggle failure after an earlier recovered failure is suppressed) and a false positive (a recovered non-zero-exit work-toggle failure never marks the run recovered).

…ecovery on mobile

Treat completed commands with a failing exit code as tool failures when
tracking recovery, let a later failure undo an earlier recovery for the run,
and skip recovered work-toggle rows in the mobile activity fold.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@nullStack65

Copy link
Copy Markdown
Owner Author
{
  "schema": "closura-review-gate/v1",
  "kind": "focused_recheck",
  "review_kind": "focused_recheck",
  "reviewer": "Gemini 4 Neon, Antigravity",
  "reviewer_family": "gemini",
  "author_session": "nullStack65/t3code#235@fa07c177c6a844b5afa07c00909dbeee1982ccf6",
  "reviewer_session": "gemini-recheck-pr235-20261127T035200Z-fa07c177",
  "fresh_context": true,
  "round_id": "gemini-recheck-pr235-20261127T035200Z-fa07c177",
  "reviewed_head": "fa07c177c6a844b5afa07c00909dbeee1982ccf6",
  "reviewed_base": "b64e48d52718896b379866bfa4099dbaa908abb8",
  "previous_reviewed_head": "e59c4ebc29420047e8e3e2785c38be87304b0e93",
  "intent": [
    "R1: Recovered tool call failures followed by a clean completed call in the same run do not show Needs attention (met: works symmetrically for status=failed and completed command_execution items with non-zero exitCode or outputIndicatesFailure across chatActivityContext, web, and mobile)",
    "R2: Genuine unrecovered failures (last call failed, failed run, error items, failed notifications, pending approvals/input requests) still show Needs attention (met: trailing failures clear recoveredRuns and re-enter unrecoveredByRun, while non-tool attention items and failed runs remain unaffected)",
    "R3: Consistent behavior across shared client-runtime, web, and mobile timelines (met: mobile foldThreadFeedActivity now gates work-toggle.hasFailure on context.recoveredRuns identically to web, with regression tests covering recovered and trailing failures)"
  ],
  "verdict": "approved",
  "prior_findings": [
    {
      "id": "F1",
      "severity": "important",
      "outcome": "resolved",
      "file": "apps/mobile/src/features/threads/pending-thread-feed.ts",
      "line": 166,
      "summary": "Verified resolved: `foldThreadFeedActivity` now gates `row.type === \"work-toggle\" && row.hasFailure` on `!(row.runId && context.recoveredRuns.has(row.runId))`, matching web's `collapseTimelineActivity`, and `apps/mobile/src/features/threads/pending-thread-feed.test.ts` adds regression tests for both recovered and trailing failed `work-toggle` runs (including `exitCode !== 0`).",
      "check": "git diff e59c4ebc29420047e8e3e2785c38be87304b0e93..fa07c177c6a844b5afa07c00909dbeee1982ccf6 -- apps/mobile/src/features/threads/pending-thread-feed.ts apps/mobile/src/features/threads/pending-thread-feed.test.ts"
    },
    {
      "id": "F2",
      "severity": "important",
      "outcome": "resolved",
      "file": "packages/client-runtime/src/chatActivity.ts",
      "line": 79,
      "summary": "Verified resolved: `toolCallFailed(item)` symmetrically flags `status === \"failed\"` and `status === \"completed\" && !toolCallSucceeded(item)` (covering `command_execution` with non-zero `exitCode` or `outputIndicatesFailure: true`), and `chatActivityContext` now calls `recoveredRuns.delete(runId)` on any subsequent tool failure so trailing failures are never suppressed by an earlier recovery. Covered by new unit tests in `packages/client-runtime/src/chatActivity.test.ts`.",
      "check": "git diff e59c4ebc29420047e8e3e2785c38be87304b0e93..fa07c177c6a844b5afa07c00909dbeee1982ccf6 -- packages/client-runtime/src/chatActivity.ts packages/client-runtime/src/chatActivity.test.ts"
    }
  ],
  "findings": [],
  "skipped_nits": []
}

Focused re-check at fa07c177c6a844b5afa07c00909dbeee1982ccf6 (diff from e59c4ebc29420047e8e3e2785c38be87304b0e93):

  • F1 (resolved): apps/mobile/src/features/threads/pending-thread-feed.ts now gates work-toggle hasFailure on !(row.runId && context.recoveredRuns.has(row.runId)), matching web (MessagesTimeline.logic.ts), with regression tests in apps/mobile/src/features/threads/pending-thread-feed.test.ts for both recovered and trailing failures.
  • F2 (resolved): packages/client-runtime/src/chatActivity.ts adds toolCallFailed symmetric with toolCallSucceeded (handling command_execution with non-zero exitCode or outputIndicatesFailure: true) and clears recoveredRuns.delete(runId) when a later tool call fails, with unit test coverage in packages/client-runtime/src/chatActivity.test.ts. Non-tool attention items (error, notification, pending approval_request / user_input_request, failed runs) remain unaffected.

Verdict: approved.

@nullStack65
nullStack65 merged commit d5a3ee8 into release/native-0.1.10 Nov 27, 2026
6 checks passed
@nullStack65
nullStack65 deleted the fix/needs-attention-unresolved-only branch November 27, 2026 05:21
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