Skip to content

refactor(vscode): extract task background detection helper - #14107

Merged
marius-kilocode merged 1 commit into
mainfrom
quality/complexity-prs-0914
Sep 14, 2026
Merged

marius-kilocode merged 1 commit into
mainfrom
quality/complexity-prs-0914

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

What Problem This Solves

The Task card renderer decided whether a Task part was a background job with an inline expression that nested a ?? fallback and two as Record<string, unknown> casts. The same component also re-encoded the auto-open condition (status === "running" && !background) in its open-state effect, duplicating the existing auto() predicate.

Why This Change Was Made

Both spots are small readability and maintenance hazards in code added by #14104. Moving the background lookup into task-tool-state.ts, beside the existing Task card predicates, gives it a name, a documented precedence rule, and a direct unit test. Reusing auto() in the effect removes the duplicated status check.

Behavior is unchanged:

  • taskBackground is the same expression as before, preserving the part-metadata-over-state-metadata precedence.
  • The effect now tests auto() then taskBackground(), which is equivalent in all background x running combinations.

User Impact

None. Internal refactor with no behavior change.

Evidence

  • bun test tests/unit/task-tool-state.test.ts from packages/kilo-vscode/: 4 pass, 0 fail.
  • bun test tests/unit/task-tool-state.test.ts tests/unit/background-agents.test.ts tests/unit/task-tool-hydration.test.ts: 33 pass, 0 fail.
  • bunx eslint on the changed files: clean.

Move the background-flag lookup for Task cards into task-tool-state so the component no longer nests the metadata fallback, and reuse the auto() predicate in the open-state effect instead of re-testing status.
@kilo-code-bot

kilo-code-bot Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • packages/kilo-vscode/tests/unit/task-tool-state.test.ts
  • packages/kilo-vscode/webview-ui/src/components/chat/TaskToolExpanded.tsx
  • packages/kilo-vscode/webview-ui/src/components/chat/task-tool-state.ts

Reviewed by deepseek-v4.1-flash · Input: 0 · Output: 0 · Cached: 0

Review guidance: REVIEW.md from base branch main

@marius-kilocode
marius-kilocode merged commit 38ee3e6 into main Sep 14, 2026
24 checks passed
@marius-kilocode
marius-kilocode deleted the quality/complexity-prs-0914 branch September 14, 2026 09:15
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.

2 participants