Skip to content

feat(threads): show pending agent questions - #9583

Open
lastobelus wants to merge 4 commits into
pingdotgg:mainfrom
lastobelus:feat/thread-question-attention
Open

feat(threads): show pending agent questions#9583
lastobelus wants to merge 4 commits into
pingdotgg:mainfrom
lastobelus:feat/thread-question-attention

Conversation

@lastobelus

@lastobelus lastobelus commented Sep 4, 2026

Copy link
Copy Markdown

What Changed

  • Adds a typed thread attention record with an initial question kind.
  • Adds authenticated, thread-scoped set_thread_attention and clear_thread_attention tools to the existing t3-code MCP server.
  • Shows a bare violet ? in compact sidebars and ? Question where long labels fit, across web/desktop and mobile.
  • Clears the marker on the user's next reply or an explicit settle; automatic settlement waits for it to clear.
  • Keeps structured approval and provider input prompts at higher priority.

Why

Interview-style agent workflows can end on a blocking question while looking indistinguishable from completed threads. The explicit MCP signal is reliable and authenticated to the current thread, unlike parsing provider terminal output. A discriminated attention record keeps the initial UI narrow while allowing additional user-actionable kinds later without another persistence redesign.

UI Changes

Before: a blocking agent question fell back to the thread timestamp.

After: the row shows a bare violet ?, plus Question in layouts with long status labels. Native input continues to show Input / Awaiting Input.

Live web QA covered both desktop and responsive sidebar layouts in dark mode. The visual artifact is intentionally not committed to the repository.

Validation

  • 16 focused test files, 345 tests passed
  • Server, web, mobile, contracts, and client-runtime typechecks passed
  • Focused lint passed with no errors
  • Changed-file formatting check passed

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • No animation or interaction video is needed

Implemented with GPT-5.6-Sol in the T3 Code Codex harness.


Note

Medium Risk
Touches orchestration lifecycle, MCP auth/capabilities, and settlement/snooze invariants; behavior changes when preview is disabled (attention MCP remains available).

Overview
Adds a question thread attention marker agents can raise when a blocking question would otherwise look like a finished thread. Contracts, orchestration commands/events, projection (attention_json migration), and shell snapshots all carry optional attention.

Agents set or clear it through new MCP tools set_thread_attention / clear_thread_attention, bound to the authenticated thread. Preview tools stay on /mcp; attention-only credentials use /mcp/thread when agent browser access is off—sessions still get MCP, but without preview capability instead of withholding credentials entirely.

Orchestration treats attention like other “needs you” work: setting it wakes settled/snoozed threads; snooze and auto-settle are blocked; manual settle clears it; a user reply clears it before turn start. Web, mobile, and client-runtime status/snooze logic show a violet ? / Question below approval and native input priority.

User-facing docs in thread-sidebar.md describe the marker and how it differs from provider approval/input prompts.

Reviewed by Cursor Bugbot for commit bb2bc1a. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add pending agent question attention to threads with thread.attention.set and thread.attention.clear

  • Adds a ThreadAttention contract type with a question kind and raisedAt timestamp, plus attention fields on OrchestrationThread and OrchestrationThreadShell, internal set/clear commands, and thread.attention-set/thread.attention-cleared events in orchestration.ts
  • The orchestration command decider in decider.ts manages the full attention lifecycle: raising attention wakes settled/snoozed threads, auto-settlement and snoozing are blocked while attention is raised, and attention clears on user reply, interrupt, revert, manual settle, and terminal session errors
  • Persists attention in the projection table via migration 0048 (attention_json nullable column) and returns it through snapshot queries and the projector in ProjectionSnapshotQuery.ts and projector.ts
  • Exposes set_thread_attention and clear_thread_attention MCP tools through a new /mcp/thread endpoint that accepts attention-only credentials without the preview capability, while the existing /mcp endpoint now serves both preview and attention toolkits in McpHttpServer.ts
  • Web sidebar and mobile thread list show a violet Question status pill with a question-mark icon when a thread has question attention, ranked below pending approval/user-input but above active work, in Sidebar.logic.ts and threadListV2.ts
  • Risk: canSnooze in threadSettled.ts now returns false for threads with question attention; prepareMcpSession in ProviderService.ts always requests an MCP credential instead of revoking one when agent-browser-access is disabled

Macroscope summarized bb2bc1a.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-04T03:49:32.372513Z bbd8995 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XL 500-999 changed lines (additions + deletions). labels Sep 4, 2026
Comment thread apps/server/src/orchestration/projector.ts
@macroscopeapp

macroscopeapp Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This PR introduces a cross-cutting agent-question workflow with new authenticated MCP mutation tools, persistent orchestration state, and changes to snoozing, settlement, credential routing, and web/mobile status behavior. Unresolved lifecycle concerns include stale attention updates and question markers being cleared after later session failures.

Not approved because:

  • 1 blocking correctness issue found at or above your repo's Minimum Blocking Severity

Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more.

@lastobelus

Copy link
Copy Markdown
Author

Follow-up commit 9993263aee addresses the two automated edge-case findings: attention-only credentials are now rejected by the full MCP endpoint, and question-driven snooze wakes use attention.raisedAt. LastCode port: lastobelus#191

type: "thread.attention-set",
payload: {
threadId: command.threadId,
attention: unchanged ? thread.attention! : command.attention,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium orchestration/decider.ts:1530

A delayed thread.attention.set can restore an old question after a newer thread.turn.start already cleared it, so the thread is incorrectly marked as awaiting input and is blocked from snoozing or automatic settlement. Likewise, thread.attention.clear and thread.revert.complete unconditionally clear the current marker, allowing stale clears (including zero-turn reverts) to hide a newer unanswered question. Add request/turn generation checks to all three paths so they only modify the attention marker they correspond to.

🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/server/src/orchestration/decider.ts around line 1530:

A delayed `thread.attention.set` can restore an old `question` after a newer `thread.turn.start` already cleared it, so the thread is incorrectly marked as awaiting input and is blocked from snoozing or automatic settlement. Likewise, `thread.attention.clear` and `thread.revert.complete` unconditionally clear the current marker, allowing stale clears (including zero-turn reverts) to hide a newer unanswered question. Add request/turn generation checks to all three paths so they only modify the attention marker they correspond to.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit bb2bc1a. Configure here.

threadId: command.threadId,
updatedAt: command.createdAt,
},
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Errors wipe delivered question markers

Medium Severity

A thread.session.set to error or interrupted always clears attention, even after the question was delivered and the session had already gone ready. A later provider runtime.error or session crash therefore drops the sidebar marker and leaves the unanswered thread eligible for auto-settle.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit bb2bc1a. Configure here.

lastobelus added a commit to lastobelus/lastCode that referenced this pull request Sep 4, 2026
## What Changed

- Ports [upstream PR
pingdotgg#9583](pingdotgg#9583), including
upstream commits `bbd8995b3c` and `9993263aee`.
- Adds authenticated, thread-scoped `set_thread_attention` and
`clear_thread_attention` tools to the existing `t3-code` MCP server.
- Shows a bare violet `?` in compact sidebars and `? Question` where
long labels fit, across web/desktop and mobile.
- Clears the marker on the user's next reply or explicit settlement;
automatic settlement waits for it to clear.
- Enforces the attention-only MCP endpoint when agent browser access is
disabled and records the real question timestamp for snooze wake
indicators.

## LastCode Adaptations

- Preserves LastCode's action-resume MCP tools and its existing
`Waiting` status priority.
- Preserves thread annotations, persistent threads, latest-user-message
tracking, and worktree-cleanup projections.
- Uses migration 57 because LastCode already owns migrations 48–56.
- Keeps the full MCP endpoint limited to preview-capable credentials
while exposing only thread-attention tools on `/mcp/thread`.

## Why

Interview-style agent workflows can end on a blocking question while
looking indistinguishable from completed threads. The explicit MCP
signal is reliable and authenticated to the current thread, unlike
parsing provider terminal output. A discriminated attention record keeps
the initial UI narrow while allowing additional user-actionable kinds
later without another persistence redesign.

## UI Changes

Before: a blocking agent question fell back to the thread timestamp.

After: the row shows a bare violet `?`, plus `Question` in layouts with
long status labels. Native input continues to show `Input` / `Awaiting
Input`.

Live web QA covered desktop and responsive sidebar layouts in dark mode.
The visual artifact is intentionally not committed to the repository.

## Validation

- 14 affected test files passed; the final MCP/snooze follow-up added 39
passing tests in its focused run.
- LastCode Quick CI passed at `d3df114d24` (format, lint with no errors,
and all 15 workspace typechecks).
- Live web QA passed for desktop and responsive layouts.

Implemented with GPT-5.6-Sol in the T3 Code Codex harness.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500-999 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant