fix(status): filter stale task rows from status cards#58810
Conversation
Greptile SummaryThis PR introduces a Key changes:
Confidence Score: 5/5Safe to merge — production logic is correct and well-tested; only a minor test-mock fidelity gap remains. All production-path changes are logically correct: expired tasks are properly gated, active tasks are prioritised, and failures surface only when no active work remains. The higher-fidelity tests in commands-status.test.ts use the real registry and lock in both key scenarios. The single P2 finding is a test-mock shortcut that does not affect any production code path. The inline mock in src/agents/openclaw-tools.session-status.test.ts (lines 219–223) diverges from the real snapshot logic; worth tightening before adding more session-status tests that rely on it. Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/agents/openclaw-tools.session-status.test.ts
Line: 219-223
Comment:
**Test mock diverges from real `buildTaskStatusSnapshot` in two ways**
The inline mock at lines 219 and 223 differs from the actual implementation in `task-status.ts` in two meaningful ways:
1. **Recency window not applied**: when `active.length === 0` the mock sets `recentTerminal = tasks` (every task, regardless of age), but the real function keeps only tasks within `TASK_STATUS_RECENT_WINDOW_MS` (5 min). A future test that sets up stale failures (>5 min old) with no active tasks will pass here but return an empty snapshot in production.
2. **`visible` is narrower than reality**: the mock uses `visible = active` when `active.length > 0`, while the real code uses `visible = [...active, ...recentTerminal]`. This means `totalCount` in the mock equals `activeCount`, while the real implementation would include any co-existing recent terminal tasks, giving a higher `totalCount`.
Neither divergence affects the two new tests (the stale task is 15 min old so it would also be excluded by the real recency filter, and the failure test has no active tasks), but they create a gap where incorrect future tests could silently pass.
Consider either: (a) importing and calling the real `buildTaskStatusSnapshot` on the mock's task list (passing a stable `now` so the age math is deterministic), or (b) adding a third test that covers the active-tasks-plus-recent-failure combination to lock in the `totalCount` behaviour.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "Merge branch 'main' into status-tasks-ma..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e6dee43112
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2025b73963
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const reconciled = tasks | ||
| .map((task) => reconcileTaskRecordForOperatorInspection(task)) | ||
| .filter((task) => !isExpiredTask(task, now)); |
There was a problem hiding this comment.
Keep status snapshots free of reconciliation side effects
buildTaskStatusSnapshot now runs every task through reconcileTaskRecordForOperatorInspection, so each /status and session_status render can execute liveness reconciliation logic that was previously limited to operator/maintenance views. For active subagent/cli tasks older than the grace period, that path calls loadSessionStore synchronously (src/tasks/task-registry.maintenance.ts:80-84), which adds O(N) blocking disk I/O to chat status rendering and can transiently project a running task to lost if the store read misses. This means status cards may become slow or briefly report false recent failures under heavier task loads.
Useful? React with 👍 / 👎.
|
Follow-up landed on This addresses the status-snapshot review concern:
I also folded in the small display-safety follow-up so task status lines truncate long unlabeled task prompts/details instead of dumping raw prompt text. |
* fix(status): filter stale task rows * test(status): use real task snapshot semantics * fix(status): prefer failure task context in recent failures
* fix(status): filter stale task rows * test(status): use real task snapshot semantics * fix(status): prefer failure task context in recent failures
* fix(status): filter stale task rows * test(status): use real task snapshot semantics * fix(status): prefer failure task context in recent failures
* fix(status): filter stale task rows * test(status): use real task snapshot semantics * fix(status): prefer failure task context in recent failures
* fix(status): filter stale task rows * test(status): use real task snapshot semantics * fix(status): prefer failure task context in recent failures
* fix(status): filter stale task rows * test(status): use real task snapshot semantics * fix(status): prefer failure task context in recent failures
Summary
/statusandsession_statuswere reading raw retained task rows, so stale completed tasks could keep showing up as if they were still the relevant session context.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
/taskscommand — User-facing task status dashboard via IM channels #54226Root Cause / Regression History (if applicable)
git blame, prior PR, issue, or refactor if known): task status surfaces were added before a dedicated status snapshot layer existed./statuschecks.Regression Test Plan (if applicable)
src/auto-reply/reply/commands-status.test.ts,src/agents/openclaw-tools.session-status.test.tsUser-visible / Behavior Changes
/statusprefers active session-linked tasks over stale completed rows.session_statusfollows the same cleanup-aware task view.Unreleased > Fixes. Thanks @vincentkoc.Diagram (if applicable)
Security Impact (required)
Yes, explain risk + mitigation: N/ARepro + Verification
Environment
/status,session_statusSteps
/statuspath or thesession_statustool.Expected
Actual
Evidence
Human Verification (required)
/statusactive-vs-stale behavior,session_statusactive-vs-recent-failure behavior.Review Conversations
Compatibility / Migration
Risks and Mitigations
openclaw tasksremains the full ledger/operator surface; this change only narrows the status summary view.AI-assisted: yes. Targeted tests and local
pnpm checkrun.