Skip to content

fix(tui): hide background hint when all work is already backgrounded - #39242

Open
aakankshaduggal wants to merge 1 commit into
anomalyco:devfrom
aakankshaduggal:background-hint-fix
Open

fix(tui): hide background hint when all work is already backgrounded#39242
aakankshaduggal wants to merge 1 commit into
anomalyco:devfrom
aakankshaduggal:background-hint-fix

Conversation

@aakankshaduggal

Copy link
Copy Markdown

Issue for this PR

Fixes #36940

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The ctrl+b background hint checked state.metadata.background but metadata is set asynchronously via ctx.metadata(). There's a window where metadata is undefined even for tasks launched with background: true. This adds a check on state.input.background which is available immediately from the tool call parameters.

Extracts isForegroundRunningTask to deduplicate the filter in foregroundTasks memo and the inline <Show> condition.

How did you verify your code works?

  • bun test --cwd packages/tui — 197 pass, 1 skip, 0 fail
  • bun run --cwd packages/tui typecheck — clean
  • bun turbo typecheck — 30/30 packages pass (ran via pre-push hook)
  • Added 6 targeted tests covering: foreground task, background via input, background via metadata, both set, non-task tools, completed task

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Check state.input.background in addition to state.metadata.background
so the hint is suppressed immediately, before the async metadata update
arrives.

Fixes anomalyco#36940
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found:

This appears to be a related or potentially duplicate fix addressing the same background hint visibility issue in the TUI. You should review PR #37088 to determine if it already addresses the issue or if your PR #39242 provides an improved/alternative solution.

@aakankshaduggal

Copy link
Copy Markdown
Author

Note: PR #37088 addresses the same issue on the v2 branch. This PR targets dev (the default branch), which has different TUI code — dev uses an inline <Show> condition in AssistantMessage and a foregroundTasks memo, while v2 has a separate BackgroundToolHint component with toolDisplay() checks. The two PRs don't overlap.

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.

tui: background hint appears when child work is already backgrounded

1 participant