Skip to content

fix(attention): count both terminal and chat siblings when clearing workspace unread - #21274

Merged
brennanb2025 merged 2 commits into
mainfrom
brennanb2025/fix-mixed-workspace-attention
Sep 18, 2026
Merged

brennanb2025 merged 2 commits into
mainfrom
brennanb2025/fix-mixed-workspace-attention

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​445 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​439
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​403 $\color{#cf222e}{\Huge{\mathbf{−}}}$​118 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​285

ELI5

A project shows one "there's something new here" dot, and looking at the thing
that raised it turns the dot off. The code deciding "is anything else here still
waiting?" only ever counted terminals. It had no idea an AI chat tab could be
waiting too.

Two consequences. Today, opening a chat tab makes the app think you looked at a
terminal you cannot even see, and it clears that terminal's dot. And once chats
can raise the dot themselves, looking at the terminal would wipe the chat's mark
with nothing left to bring it back.

Now the question is asked of both kinds, so the dot only goes off when nothing
in that project is still waiting for you — and looking at a chat counts as
looking at the chat, not at some terminal behind it.

What the dot means is unchanged. Nothing about what raises it moved; only
the check that decides when it is safe to turn off, and that check can now only
ever keep it lit longer, never light it when it wasn't.

What Changed

Before: in a workspace holding both a terminal pane and a structured chat
tab, acknowledging the visible terminal cleared the workspace's unread flag even
while the chat still had an unread completion marker. The workspace dot went
dark and the chat's unread was silently lost. The reverse case was worse still:
with a chat tab on screen, nothing acknowledged it at all, and the workspace
instead acknowledged whichever terminal happened to have been visible last —
clearing a hidden terminal's unread.

After: acknowledging either kind of surface keeps the workspace lit while the
other kind still owns attention, and a visible chat is acknowledged as itself.

What is live on main today, and what is pre-positioning. Worth knowing before
you look for a repro. The second half above is reachable right now: with a chat
tab on screen, auto-ack really does acknowledge a hidden terminal today, and this
PR stops it. The first half is not yet reachable — nothing can currently write a
chat completion marker at all, because the only writer is
dispatchTerminalNotification, which asks the terminal surface, and a structured
chat tab has no tabsByWorktree row, so admission rejects it as
superseded-surface. So a chat can neither light the workspace dot nor hold it
lit today. That half lands the inventory the structured completion producer needs
before it can activate, which is why this has to go in ahead of it.

Likewise, widening markTerminalTabUnread to accept a structured chat's unified
tab id is capability, not behaviour: no caller writes a container marker for a
chat today, so no new dot appears anywhere.

The mechanism. Acknowledgement asks a surface adapter "what else in this
workspace still wants attention?" and clears the workspace flag only if the
answer is empty. The only adapter was the terminal one, and it builds that
remainder exclusively from tabsByWorktree. A chat tab lives in
unifiedTabsByWorktree, so it was invisible to the question being asked — the
inventory was the bug, not the decision made from it.

Three pieces, all reusing the provider-neutral attention abstraction rather than
adding a second one:

  • structured-attention-surface.ts implements the existing
    AgentAttentionSurface contract for structured chats.
  • mergeAgentAttentionRemainders unions every surface kind's remainder, and
    acknowledgement now asks the union. Workspace unread belongs to the workspace,
    not to one surface kind.
  • resolveAutoAckTabTargets resolves what is actually on screen through the
    unified tab model, so a visible chat produces a structured target instead of a
    stale terminal one, and each target is handed to the adapter that owns its
    address.

The addressing decision, and why. A structured session's subject key is
structuredAgentSessionPaneKey(unifiedTabId, sessionId) — the pane key the
structured status producer already publishes into the agent-status store, and
which worktree ps, the hook server and the sidebar all key on. Reusing it was
the only choice that keeps one session named one way across the process
boundary. Its container id (groupId in the neutral contract) is therefore the
unified tab id that prefixes that key — not the split-layout group the tab sits
in. Two existing readers already resolve a structured tab exactly this way:
SortableTab reads unreadTerminalTabs[<unified tab id>] for an agent-session
tab, and hasUnreadAgentCompletionForTerminalTab maps a pane key's prefix to
that same id.

That made markTerminalTabUnread an asymmetry worth removing rather than
working around: the readers accept a structured tab's unified id, but the writer
rejected any id absent from tabsByWorktree, silently dropping the write. Its
existence check now consults both indexes — the same pair findRenamableUnifiedTab
already resolves for rename and colour.

One staleness note: the structured remainder is read per live tab rather than by
scanning the marker maps, so a marker left behind by a closed tab or a superseded
session cannot hold workspace unread lit with nothing able to clear it. This
mirrors the terminal adapter, where the tabsByWorktree membership filter serves
the same purpose.

Why

The alternative was to fix "which subject is viewed" and leave the inventory
alone. That does not fix this: the clear is permitted because the sibling was
never counted, so any correct viewed-subject would still clear a workspace whose
chat was unread.

The other alternative was a second suppression path for structured surfaces. The
provider-neutral boundary in src/renderer/src/attention/ exists precisely so a
non-terminal surface can supply an adapter without touching the policy, and it
already had every seam needed. The decision policy
(agent-attention-policy.ts) and the terminal evidence arbitration in
use-notification-dispatch.ts are unchanged, and no new workspace-clear call
was added.

Linked Issue

Fixes #

Visual Proof

N/A — no rendered change. The change is in which unread markers survive an
acknowledgement; the marker's own presentation (the workspace dot, the tab dot)
is untouched. The observable difference is a dot that stays lit where it
previously went dark, covered by the tests below.

Testing

Both directions are covered, and each was verified to fail when the
corresponding production change is reverted (ablated one at a time, re-proven at
the final rebased head):

  • useAutoAckViewedAgent.mixed-workspace.test.ts — one workspace holding a
    terminal pane and a chat tab in the same layout group:
    • acknowledging the visible terminal keeps the hidden chat unread
    • acknowledging the visible chat keeps the hidden terminal unread
    • the workspace does clear when the visible surface held the only unread (both
      directions), so the tests are not passing by never clearing
    • a hidden chat holding only container unread also keeps the workspace lit
    • markTerminalTabUnread accepts a structured chat's unified tab id, and
      still refuses an id no open tab owns
  • structured-attention-surface.test.ts — the adapter: addressing, superseded
    sessions, foreign surface keys, viewed resolution, and workspace scoping.

Existing suites: src/renderer/src/hooks, src/renderer/src/attention,
src/renderer/src/components/native-chat, src/renderer/src/store/terminals,
src/renderer/src/components/tab-bar, src/renderer/src/store/slices/tabs —
411 files / 3394 tests green. use-notification-dispatch.test.ts's distinction
between a viewed surface suppressing unread while still requesting delivery is
unchanged and still passes.

pnpm tc clean. pnpm run check:code-quality:changed clean (0 new findings
across 11 files). oxfmt --check clean.

Platforms: macOS. No platform-dependent code paths are touched — this is
renderer store logic with no shell, path, or keyboard handling. SSH/remote:
unaffected; the structured session's execution host is not consulted, and the
adapter reads only renderer tab state. Mobile: unaffected; the unread maps it
reads are unchanged.

Pre-existing failure, not from this PR:
terminal-pane-hook-order-parity.test.ts fails (expects 209 flattened hooks,
finds 211). Its inputs are the 20 TerminalPane/use-terminal-pane-* sources,
none of which this PR touches, and all 20 are byte-identical between this branch
and origin/main. #9035 added two hooks in use-terminal-pane-foundation.ts and
use-terminal-pane-global-listeners.ts without bumping the baseline. Left alone.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • Backwards compatibility: the acknowledgement guard only ever becomes more
    conservative — it withholds a clear it previously allowed. Terminal-only
    workspaces have an empty structured remainder and behave exactly as before.
  • Performance: the structured remainder is O(structured tabs in the
    workspace) with a direct map lookup per tab, not a scan of the marker maps. It
    runs inside the auto-ack target loop, which is already gated by the hook's
    reference-equality guard. That guard gained groupsByWorktree, needed because
    activating a chat tab moves only its layout group's activeTabId and touches
    no terminal slice — without it the scan that clears the chat's attention would
    be skipped.
  • Folder workspaces: the adapter is keyed on workspace id throughout and
    reads unifiedTabsByWorktree, which folder workspaces populate the same way;
    nothing assumes a git worktree.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…orkspace unread

A workspace holding a terminal pane and a structured chat tab built its
"anything still unread here?" inventory from the terminal tab list alone, so
acknowledging the visible terminal cleared the workspace's unread flag while
the chat's completion marker was still outstanding. The chat's unread was lost
with nothing left to relight it.

Structured chats now have their own attention-surface adapter, addressed by the
pane key the status producer already publishes — `<unifiedTabId>:<sessionLeaf>`
— with the unified tab id as its container id. Acknowledgement unions both
surface kinds' remainders, so either kind's hidden sibling holds the workspace
lit.
@coderabbitai

coderabbitai Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: aaa46287-e1e3-4724-8bd7-08e1ae9b01dc

📥 Commits

Reviewing files that changed from the base of the PR and between 99794fb and afcd7cd.

📒 Files selected for processing (2)
  • src/renderer/src/hooks/useAutoAckViewedAgent.focus-group.test.ts
  • src/renderer/src/hooks/useAutoAckViewedAgent.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

The change adds structured chat tabs as an agent attention surface. It validates live sessions, viewed state, and unread markers. Auto-acknowledgement now selects terminal or structured targets and combines their workspace attention remainders. Unified structured tabs can receive terminal unread markers. Tests cover structured surfaces, mixed workspaces, focus changes, target resolution, acknowledgement, and unread-state behavior.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to afcd7

Viewing a structured chat can leave its completion unread indicator active when no pane-level unread record exists. This is a bounded UI-state regression that should be addressed before relying on the new acknowledgement flow.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 69.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 23 functions across 12 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the primary change: preserving workspace unread state when terminal and structured chat surfaces coexist.
Description check ✅ Passed The description is detailed and covers the user impact, implementation, rationale, testing, compatibility, and checklist. The Linked Issue field is still empty despite the template requiring an issue …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: f2b8d293-0fc9-4e3e-905c-3a4ded1aaf50

📥 Commits

Reviewing files that changed from the base of the PR and between 09622f0 and 99794fb.

📒 Files selected for processing (11)
  • src/renderer/src/attention/agent-attention-acknowledgement.ts
  • src/renderer/src/components/native-chat/StructuredAgentSessionStatusBridge.tsx
  • src/renderer/src/components/native-chat/structured-agent-session-tabs.ts
  • src/renderer/src/components/native-chat/structured-attention-surface.test.ts
  • src/renderer/src/components/native-chat/structured-attention-surface.ts
  • src/renderer/src/hooks/agent-auto-ack-surfaces.ts
  • src/renderer/src/hooks/agent-auto-ack-targets.ts
  • src/renderer/src/hooks/useAutoAckViewedAgent.mixed-workspace.test.ts
  • src/renderer/src/hooks/useAutoAckViewedAgent.test.ts
  • src/renderer/src/hooks/useAutoAckViewedAgent.ts
  • src/renderer/src/store/terminals/terminal-tab-attention.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.

Comment on lines +76 to +77
if (toAck.length === 0 && !viewedUnreadSubjectKey) {
return

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '1,180p' src/renderer/src/hooks/agent-auto-ack-surfaces.ts
sed -n '1,190p' src/renderer/src/hooks/useAutoAckViewedAgent.ts
sed -n '1,130p' src/renderer/src/store/terminals/terminal-tab-attention.ts
rg -n 'markTerminalTabUnread|unreadTerminalTabs|applyAgentAttentionAcknowledgement|clear.*Terminal.*Unread|unreadGroupIds|shouldClearWorkspaceAttention' src/renderer/src

Repository: stablyai/orca

Length of output: 50369


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- attention acknowledgement ---'
sed -n '1,230p' src/renderer/src/attention/agent-attention-acknowledgement.ts
printf '%s\n' '--- structured attention surface ---'
sed -n '1,180p' src/renderer/src/components/native-chat/structured-attention-surface.ts
printf '%s\n' '--- terminal attention surface ---'
sed -n '1,130p' src/renderer/src/components/terminal-pane/terminal-attention-surface.ts
printf '%s\n' '--- auto-ack target resolver ---'
sed -n '1,220p' src/renderer/src/hooks/agent-auto-ack-targets.ts
printf '%s\n' '--- structured/tab focus mutations ---'
sed -n '1,140p' src/renderer/src/store/slices/tabs/tabs-focus-actions.ts
sed -n '1,130p' src/renderer/src/store/slices/tabs/tabs-group-actions.ts
sed -n '1,115p' src/renderer/src/store/terminals/terminal-tab-navigation.ts
printf '%s\n' '--- agent-completion tab marking callers ---'
rg -n -C 5 "markTerminalTabUnread\\([^\\n]*agent-completion|markTerminalTabUnread" src/renderer/src/components src/renderer/src/hooks src/renderer/src/store | grep -B5 -A8 "agent-completion"
printf '%s\n' '--- focused tests for group-only auto-ack ---'
rg -n -C 8 "unreadTerminalTabs|group-only|group unread|agent-completion" src/renderer/src/hooks/useAutoAckViewedAgent*.test.ts src/renderer/src/components/native-chat/structured-attention-surface.test.ts

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- attention acknowledgement ---'
sed -n '1,230p' src/renderer/src/attention/agent-attention-acknowledgement.ts
printf '%s\n' '--- structured attention surface ---'
sed -n '1,180p' src/renderer/src/components/native-chat/structured-attention-surface.ts
printf '%s\n' '--- terminal attention surface ---'
sed -n '1,130p' src/renderer/src/components/terminal-pane/terminal-attention-surface.ts
printf '%s\n' '--- auto-ack target resolver ---'
sed -n '1,220p' src/renderer/src/hooks/agent-auto-ack-targets.ts
printf '%s\n' '--- structured/tab focus mutations ---'
sed -n '1,140p' src/renderer/src/store/slices/tabs/tabs-focus-actions.ts
sed -n '1,130p' src/renderer/src/store/slices/tabs/tabs-group-actions.ts
sed -n '1,115p' src/renderer/src/store/terminals/terminal-tab-navigation.ts
printf '%s\n' '--- agent-completion tab marking callers ---'
rg -n -C 5 "markTerminalTabUnread" src/renderer/src/components src/renderer/src/hooks src/renderer/src/store | grep -B5 -A8 "agent-completion"
printf '%s\n' '--- focused tests for group-only auto-ack ---'
rg -n -C 8 "unreadTerminalTabs|group-only|group unread|agent-completion" src/renderer/src/hooks/useAutoAckViewedAgent*.test.ts src/renderer/src/components/native-chat/structured-attention-surface.test.ts

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- unread reason contract ---'
sed -n '1,150p' src/renderer/src/attention/agent-attention-contract.ts
printf '%s\n' '--- structured completion and notification producers ---'
rg -n -C 8 "markTerminalTabUnread|agent-completion|markAgentCompletionPaneUnread" src/renderer/src/components/native-chat src/renderer/src/attention src/renderer/src/hooks | head -n 240
printf '%s\n' '--- focused auto-ack tests ---'
sed -n '1,210p' src/renderer/src/hooks/useAutoAckViewedAgent.mixed-workspace.test.ts

Repository: stablyai/orca

Length of output: 34590


Model structured agent-completion group unread as an auto-ack trigger.

A structured tab can store an agent-completion marker only in unreadTerminalTabs. The auto-ack guard does not watch this map, and its presence check does not detect the marker. If another update triggers a scan, acknowledgeViewedAutoAckTarget returns when no subject marker exists. The group and workspace unread markers therefore remain set. Filter this path to agent-completion; unreadTerminalTabs also stores terminal-bell, manual-mark-unread, and legacy markers that auto-ack must not clear.

  • Track s.unreadTerminalTabs in the store-change guard.
  • Include the viewed structured target's agent-completion group marker in the presence check.
  • Treat that marker as an acknowledgement target so group and workspace unread can clear without a subject marker.

@pullfrog pullfrog 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.

Important

The reverse direction of this fix is sound, but the forward direction — "acknowledging the visible terminal keeps the hidden chat unread" — cannot fire in production: no code path writes a structured chat's unreadAgentCompletionPanes / unreadTerminalTabs marker, and shouldClearWorkspaceAttention never reads the chat's live turn. Details inline.

Reviewed changes

  • Provider-neutral remainder union — mergeAgentAttentionRemainders unions each surface kind's hasSurfaces / unreadSubjectKeys / unreadGroupIds, and acknowledgement now asks the union before clearing workspace unread.
  • Structured attention surface — new createStructuredAttentionSurface adapter binds AgentAttentionSurface to the store, addressing a session by its published structuredAgentSessionPaneKey(unifiedTabId, sessionId).
  • Surface-kind target resolution — resolveAutoAckTabTargets now resolves the active unified tab, so a visible chat produces a structured target instead of a stale terminal one; AutoAckTabTarget carries surfaceKind.
  • markTerminalTabUnread acceptance — the write guard now also accepts a unified agent-session tab id, not only a tabsByWorktree id.
  • Extracted structured-tab projection — StructuredTab / isStructuredTab / getStructuredAgentSessionTabs moved to structured-agent-session-tabs.ts; the bridge re-exports the getter.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment on lines +97 to +104
for (const tab of tabs) {
const subjectKey = structuredAgentSessionPaneKey(tab.id, tab.entityId)
if (state.unreadAgentCompletionPanes[subjectKey]) {
unreadSubjectKeys.push(subjectKey)
}
if (state.unreadTerminalTabs[tab.id]) {
unreadGroupIds.push(tab.id)
}

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.

The structured remainder only counts markers in unreadAgentCompletionPanes / unreadTerminalTabs, but no production path writes either map for a structured chat, so this returns empty for a hidden unread chat and shouldClearWorkspaceAttention still clears the workspace. The forward direction this PR targets stays broken in production.

Technical details
# Structured remainder reads maps no structured writer populates

## Affected sites
- `src/renderer/src/components/native-chat/structured-attention-surface.ts:99` — reads `unreadAgentCompletionPanes[subjectKey]`; `:102` reads `unreadTerminalTabs[tab.id]`.
- `src/renderer/src/store/terminals/terminal-tab-attention.ts:20,51` — the only additive writers of those maps.
- `src/renderer/src/components/terminal-pane/use-notification-dispatch.ts:195-196` — the only production caller (`markSubjectUnread` / `markGroupUnread`), reached with `createTerminalAttentionSurface`, whose `admitTerminalPane` requires a `tabsByWorktree` / `ptyIdsByTabId` record a structured chat does not have.
- `src/renderer/src/store/slices/agent-status-live-actions.ts:40-86` — `setAgentStatus` writes only `agentStatusByPaneKey`, never the unread maps.
- `src/renderer/src/hooks/agent-hook-completion-notifications.ts:228-233` — `paneCanReceiveHookCompletion` rejects structured pane keys (needs a `tabsByWorktree` row or a `ptyIdsByTabId` entry).

## Required outcome
- The clear decision must also count the hidden chat's live/retained turn (`agentStatusByPaneKey` / `retainedAgentsByPaneKey`) as workspace attention, or a producer must write a structured unread marker before the union can observe it.

## Open questions for the human
- Is a structured unread-marker producer planned separately? If so, this direction is inert until it lands; the new `markTerminalTabUnread` acceptance has no production caller today either.

@pullfrog pullfrog 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.

ℹ️ No new issues in this delta. The prior review's open thread on the structured remainder is unchanged by these commits, so this is not an approval.

Reviewed changes

Changes since the prior pullfrog review (99794fb):

  • Focused-group rescan — the auto-ack ref-equality guard now compares activeWorktreeId, the focused group id, and the active workspace's group slice (plus the floating workspace's equivalents) instead of the whole groupsByWorktree map, so focusing a split group onto a structured chat re-runs the scan.
  • Regression test — useAutoAckViewedAgent.focus-group.test.ts mounts the hook with a hidden unread chat and asserts that focusGroup onto its group clears the marker.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: reviewed, fixed, and clean

Verdict: land after fixes.

The review found one concrete regression: focusing a different split group containing a structured chat could change the visible session without invalidating the auto-ack scan, leaving that session unread. Commit afcd7cd418 fixes the subscription inputs and adds a regression test using the real focus-group action. The test was ablated and fails without the fix.

Judgments

  • Functional correctness: Clean after the fix and an independent re-review. Mixed terminal and structured-chat attention remains surface-owned and is aggregated at the workspace boundary.
  • Architecture and performance: The mechanism fits the existing ownership/lifecycle model. The fix watches the active worktree/group identity and only the active/floating group snapshots; it adds no polling, retry loop, durable latch, or unbounded resource growth. No material architectural deviation remains.
  • Validation: 44 relevant tests passed, along with pnpm tc, pnpm tc:web, pnpm run check:code-quality:changed, git diff --check, both readiness passes, and the full PR workflow. One unrelated SSH relay-reset test failed transiently on the first CI attempt and passed on the isolated rerun; aggregate CI is green.
  • Remaining dependency: Production structured-completion events are owned by separate planned work. This PR provides the structured attention surface and remainder plumbing, but does not by itself generate that completion marker.

Electron evidence

A dedicated Electron validation worker launched this exact worktree in the background through hidden CDP and verified the rendered mixed terminal/structured-chat surface:

mixed-attention-visible.png

The screenshot is rendered-surface evidence, not full end-to-end proof of the unread transition. During that interaction Playwright switched renderer targets, so the worker could not deterministically exercise and capture the unread-to-read transition. The transition itself is covered by the focused regression tests.

@brennanb2025
brennanb2025 merged commit 0b57ce0 into main Sep 18, 2026
52 of 54 checks passed
husseincak added a commit to husseincak/orca that referenced this pull request Sep 19, 2026
Upstream stablyai#21274 split auto-ack into per-surface adapters (terminal and
structured chat). The grid target now carries surfaceKind: 'terminal',
the parked-card BEL check (group-level unread) moves into
acknowledgeViewedAutoAckTarget, and the sessions view branch no longer
sits behind the terminal-view early return.

stablyai#21659 chains .finally on ensureRemoteDetectedAgents; the launch picker
test stubs it with a resolved promise like upstream's own tests.
brennanb2025 added a commit that referenced this pull request Sep 21, 2026
… finishes

A structured native chat had no attention producer. The PTY lane reaches the
unread markers through use-notification-dispatch, whose liveness reads PTY
state and whose admission requires terminal panes, so a structured session —
which runs on the execution host with no renderer PTY — could finish a turn
with nothing lighting anywhere. A backgrounded chat was the worst case: with
no mounted pane there was no reader to notice at all.

The host derives the completion, because only the host can. The journal keeps
committing whether or not a renderer holds a reader, so the new feed observes
each commit at StructuredAgentSessionClientDelivery.publishJournal and emits on
every running -> settled transition. That edge runs after the subscriber loop
and independent of it, which is exactly why a chat nobody is watching can still
complete. It is a separate capability-gated stream rather than a field on the
status summary: the summary carries no turn identity and no outcome, and is
re-broadcast on every status change, so folding a completion into it would make
every status consumer a completion consumer.

ONLY `success` LIGHTS ANYTHING. Outcome is A0's provider verdict and is never
inferred: a turn the host merely watched stop carries no outcome and produces
no event, because absent means UNKNOWN. `completed` alone proves nothing — a
provider reports its own API error as a finished turn — so the host emits
nothing for it and the renderer filters again on the way in.

RECOVERY IS LIVE-ONLY. Nothing is retained, queued or replayed on either side.
A subscriber learns what settles while it is subscribed and nothing else; on
reconnect it re-opens an empty stream and whatever landed during the gap is
gone. A retained completion would be a durable "unread is owed" obligation with
nothing to retire it, and a reconnect would then light the dot for work the
user already read. Tests on both sides pin this so a later refactor cannot
quietly turn it into catch-up.

The dot itself reuses the neutral policy in attention/agent-attention-policy
and #21274's structured surface adapter, so suppression, acknowledgement and
addressing keep exactly one implementation and the surface key is never omitted
to evade a check. No second suppression rule is introduced. OS delivery is
deliberately not wired: this calls applyAgentAttentionUnread, not
applyAgentAttention.

Also narrows the completion feed's journal dependency to the newest-turn reader
it actually uses, and adds journal.newestTurn() beside the existing
activeTurnId() on the one shared by-sequence scan rather than a second scan.
brennanb2025 added a commit that referenced this pull request Sep 21, 2026
… finishes (#21924)

* feat(native-chat): light the unread indicators when a structured chat finishes

A structured native chat had no attention producer. The PTY lane reaches the
unread markers through use-notification-dispatch, whose liveness reads PTY
state and whose admission requires terminal panes, so a structured session —
which runs on the execution host with no renderer PTY — could finish a turn
with nothing lighting anywhere. A backgrounded chat was the worst case: with
no mounted pane there was no reader to notice at all.

The host derives the completion, because only the host can. The journal keeps
committing whether or not a renderer holds a reader, so the new feed observes
each commit at StructuredAgentSessionClientDelivery.publishJournal and emits on
every running -> settled transition. That edge runs after the subscriber loop
and independent of it, which is exactly why a chat nobody is watching can still
complete. It is a separate capability-gated stream rather than a field on the
status summary: the summary carries no turn identity and no outcome, and is
re-broadcast on every status change, so folding a completion into it would make
every status consumer a completion consumer.

ONLY `success` LIGHTS ANYTHING. Outcome is A0's provider verdict and is never
inferred: a turn the host merely watched stop carries no outcome and produces
no event, because absent means UNKNOWN. `completed` alone proves nothing — a
provider reports its own API error as a finished turn — so the host emits
nothing for it and the renderer filters again on the way in.

RECOVERY IS LIVE-ONLY. Nothing is retained, queued or replayed on either side.
A subscriber learns what settles while it is subscribed and nothing else; on
reconnect it re-opens an empty stream and whatever landed during the gap is
gone. A retained completion would be a durable "unread is owed" obligation with
nothing to retire it, and a reconnect would then light the dot for work the
user already read. Tests on both sides pin this so a later refactor cannot
quietly turn it into catch-up.

The dot itself reuses the neutral policy in attention/agent-attention-policy
and #21274's structured surface adapter, so suppression, acknowledgement and
addressing keep exactly one implementation and the surface key is never omitted
to evade a check. No second suppression rule is introduced. OS delivery is
deliberately not wired: this calls applyAgentAttentionUnread, not
applyAgentAttention.

Also narrows the completion feed's journal dependency to the newest-turn reader
it actually uses, and adds journal.newestTurn() beside the existing
activeTurnId() on the one shared by-sequence scan rather than a second scan.

* test(cross-version): register the turn-completion subscribe on the wire manifest

The cross-version gate asserts the structured surface's method list by name and
count, so an additive method has to be declared there deliberately. Adding the
entry makes the suite call it in both skew directions and stubs the host side,
which is the statement the gate exists to force.

* fix(native-chat): rebaseline completion feed after rewinds
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