Skip to content

feat: track context-window pressure across agent sessions - #11417

Open
raskalbass wants to merge 12 commits into
stablyai:mainfrom
raskalbass:claude/experimental-agent-cards-menu-97i7y6
Open

raskalbass wants to merge 12 commits into
stablyai:mainfrom
raskalbass:claude/experimental-agent-cards-menu-97i7y6

Conversation

@raskalbass

Copy link
Copy Markdown

Summary

  • Track provider-reported Claude and Codex context-window usage across local, SSH, and WSL sessions.
  • Add configurable global, provider, agent, and model soft limits with honest unknown-state handling.
  • Show individual and worst-child pressure across worktree cards, terminal tabs, dashboard and kanban views, automation history, terminal dialogs, AI Vault, and paired mobile clients.
  • Include exact usage, effective-limit provenance, accessible non-color states, persistence migration, relay synchronization, and defensive validation.

Testing

  • pnpm run typecheck
  • pnpm run lint
  • pnpm run check:max-lines-ratchet
  • Targeted Vitest coverage for context-pressure UI, managed hook stdin lifecycle, and mobile terminal reveal adoption.
  • git diff --check

AI Review Report

  • Cross-platform: Local POSIX and Windows statusline guards are covered; remote scripts use POSIX-safe endpoint state.
  • SSH / WSL: Context-only readings and live feature-toggle state cross the relay without forwarding remote rate-limit data.
  • Integrations: Claude statusline and Codex rollout ingestion are explicit; unsupported providers remain unknown.
  • Performance: Readings use structural equality and existing snapshot/change gates to avoid redundant fanout and rerenders.
  • UI: Existing design tokens and shared tooltip primitives are used with accessible labels and non-color state shapes.
  • Security: Relay payloads are normalized and feature-gated; provider session identity prevents stale cross-session readings.

Closes #11225

@greptile-apps

ghost commented Jul 29, 2026 •

Copy link
Copy Markdown

Too many files changed for review. (115 files found, 100 file limit)

Bypass the limit by tagging @greptile-apps to review.

@coderabbitai

ghost commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

We couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting @coderabbitai full review.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds end-to-end context-pressure tracking from Claude and Codex usage payloads through shared normalization, runtime status propagation, relay synchronization, persistence, and dashboard validation. Introduces configurable warning, critical, and soft-limit settings with migration support. Adds pressure indicators to mobile, dashboard, sidebar, tabs, automation history, agent cards, terminal dialogs, and vault sessions, with tests covering calculations, ingestion, synchronization, rendering, and settings behavior.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Some changes appear unrelated to context-pressure tracking, including manual-disconnect/web-preload-api strings and tests. Move the manual-disconnect/runtime-preload updates into a separate PR or document why they belong in this scope.
Docstring Coverage ⚠️ Warning Docstring coverage is 19.64% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: tracking context-window pressure across agent sessions.
Description check ✅ Passed The description covers summary, testing, AI review, and security audit; only non-critical template sections are missing.
Linked Issues check ✅ Passed The PR implements context-pressure tracking, configurable soft limits, aggregate worst-state rendering, and consistent support across local, SSH, WSL, and paired clients.

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

ghost 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: 14

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/renderer/src/store/slices/agent-status.ts (1)

1841-1890: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Clear cached context usage when the provider session changes.

Line 1845 only checks agentType. A new Claude provider session whose hook ping omits contextUsage retains the old session’s pressure reading even though providerSessionChanged is already known. Gate reuse on !providerSessionChanged and add a same-agent/session-switch regression test.

Proposed fix
-        const previousContextUsage =
-          existing?.agentType === identity.agentType ? existing.contextUsage : undefined
+        const previousContextUsage =
+          existing?.agentType === identity.agentType && !providerSessionChanged
+            ? existing.contextUsage
+            : undefined
src/main/ssh/ssh-relay-session.ts (1)

517-529: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

detach() leaks the context-pressure settings listener.

detach() sets _state = 'disposed' (same terminal state as dispose()), so establish() can never be called again on this instance and a fresh SshRelaySession is expected for future reconnects. But unlike dispose() (Lines 505-506), detach() never calls this.settingsCleanup?.(). Because a later dispose() on the same object early-returns (if (this._state === 'disposed') return), the onSettingsChanged listener registered in bindContextPressureSettings() is never removed — every detach leaks one listener + closure over the orphaned session object, growing unbounded across SSH disconnect/reattach cycles.

🔧 Proposed fix: clean up settingsCleanup in detach() too
   detach(): void {
     if (this._state === 'disposed') {
       return
     }
     this.abortController?.abort()
+    this.settingsCleanup?.()
+    this.settingsCleanup = null
     this.stopPortScanning()
     this.broadcastEmptyLists()
     // Why: window disconnect is non-destructive — unregister local providers but keep PTY ownership so reattach works (relay owns the grace timer).
     this.teardownProviders('connection_lost')
     this.store.markSshRemotePtyLeases(this.targetId, 'detached')
     this.currentConnection = null
     this._state = 'disposed'
   }
🧹 Nitpick comments (7)
src/main/claude/statusline-script.ts (1)

14-19: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Condense the new generated-script comments.

  • src/main/claude/statusline-script.ts#L14-L19: reduce the header to one brief non-obvious rationale.
  • src/main/claude/statusline-script.ts#L50-L54: retain only the essential reason for quoted-key matching.

As per coding guidelines, “Comments must be concise, limited to non-obvious information, and preferably one line.”

Source: Coding guidelines

mobile/src/components/ContextPressureDot.tsx (1)

6-11: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Condense the new implementation comments.

  • mobile/src/components/ContextPressureDot.tsx#L6-L11: reduce this to one short domain-specific note or remove it.
  • mobile/src/components/WorktreeAgentRow.tsx#L37-L39: retain only the non-obvious aggregate-policy rationale.
  • mobile/src/components/WorktreeListRow.tsx#L81-L83: retain only the alert-only rollup rule.

As per coding guidelines, comments must be concise and avoid walking through obvious implementation details.

Source: Coding guidelines

src/shared/agent-context-pressure.ts (1)

200-232: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Optional: avoid rebuilding the lowercased entries array on every call.

resolveSoftCap runs per agent row per snapshot/render and re-allocates a normalized copy of softLimits each time. Since the caps are already sanitized/normalized at the persistence boundary, you could pre-normalize once alongside the memoized ContextPressureConfig (see getContextPressureConfig in src/renderer/src/components/sidebar/context-pressure-selection.ts) and index by key.

src/shared/agent-context-pressure.test.ts (1)

16-227: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider covering resolveContextPressureConfigFromSettings.

The suite is thorough on resolveContextPressure and the normalizers, but the settings gate (experimentalContextPressure !== true → null, plus default threshold hydration) is the shared entry point for both renderer and main and is currently untested here.

src/shared/model-context-windows.ts (1)

89-96: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Precompile the two family regexes as module constants.

family is a closed literal union, so the new RegExp per call buys nothing and is what triggers the ast-grep "regex from variable" warning (a false positive here — no untrusted input reaches the pattern; the OpenGrep exec-js command-injection hit is also a false positive, this is RegExp.prototype.exec). Two precompiled constants remove the per-call compile and the lint noise.

♻️ Proposed refactor
+const CANONICAL_MODEL_SEGMENT_PATTERNS = {
+  claude: /(?:^|[./])(claude(?:[-.][a-z0-9[\]:]+)*)$/i,
+  'gpt-5': /(?:^|[./])(gpt-5(?:[-.][a-z0-9[\]:]+)*)$/i
+} as const
+
 function extractCanonicalModelSegment(
   value: string,
   family: 'claude' | 'gpt-5'
 ): string | undefined {
-  const escaped = family.replace('-', '\\-')
-  const match = new RegExp(`(?:^|[./])(${escaped}(?:[-.][a-z0-9[\\]:]+)*)$`, 'i').exec(value)
-  return match?.[1]
+  return CANONICAL_MODEL_SEGMENT_PATTERNS[family].exec(value)?.[1]
 }

Source: Linters/SAST tools

src/shared/runtime-types.ts (1)

707-712: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Condense this type comment.

Keep the public absence semantics and the 0–100 invariant; move polling/UI rationale to implementation code if needed.

Proposed cleanup
-/** Host-computed context-window pressure for one agent row. Present only when
- *  the host's experimental context-pressure flag is on AND the session has
- *  provider-reported usage; absent = gate off or unknown — clients render
- *  nothing (honest fallback; also degrades gracefully on hosts that predate
- *  the field). usedPercent is pre-clamped to an integer 0-100 so the 3s
- *  worktree.ps poll doesn't churn client-side diffs on sub-percent drift. */
+/** Context pressure for one agent row; absent when disabled or unknown.
+ *  `usedPercent` is a pre-clamped integer from 0–100. */

As per coding guidelines, “Comments must be concise, limited to non-obvious information, and preferably one line.”

Source: Coding guidelines

src/main/persistence.ts (1)

5443-5460: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Normalize context-pressure settings on load too.

updateSettings clamps these fields, but load() restores settings without sanitizing the context-pressure keys, so hand-edited or downgraded profiles can retain contextPressureWarnPercent: 0 or malformed/non-object contextPressureSoftLimits; resolveContextPressureConfigFromSettings() only uses ?? for defaults and leaves the object unbounded. Apply the same load-time sanitizer for these fields unless they are explicitly saved to default after every startup.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1505795c-d130-4fe5-b8a9-b4c2d0b2ce77

📥 Commits

Reviewing files that changed from the base of the PR and between 8272077 and 78066866438098f36e2d831fa6e1a9f7f287eb5b.

📒 Files selected for processing (109)
  • config/tsconfig.cli.json
  • mobile/src/components/ContextPressureDot.tsx
  • mobile/src/components/WorktreeAgentRow.tsx
  • mobile/src/components/WorktreeListRow.test.ts
  • mobile/src/components/WorktreeListRow.tsx
  • mobile/src/worktree/context-pressure-display.test.ts
  • mobile/src/worktree/context-pressure-display.ts
  • mobile/src/worktree/worktree-list-snapshot.test.ts
  • mobile/src/worktree/worktree-list-snapshot.ts
  • src/main/agent-hooks/managed-hook-stdin-lifecycle.test.ts
  • src/main/agent-hooks/server-codex-context-usage.test.ts
  • src/main/agent-hooks/server-context-usage.test.ts
  • src/main/agent-hooks/server.ts
  • src/main/agent-hooks/wsl-hook-relay-manager.test.ts
  • src/main/agent-hooks/wsl-hook-relay-manager.ts
  • src/main/agent-hooks/wsl-hook-relay-state.ts
  • src/main/claude/hook-service.test.ts
  • src/main/claude/hook-service.ts
  • src/main/claude/statusline-script.test.ts
  • src/main/claude/statusline-script.ts
  • src/main/claude/statusline-toggle.ts
  • src/main/index.ts
  • src/main/ipc/dashboard-payload-validation.test.ts
  • src/main/ipc/dashboard-payload-validation.ts
  • src/main/persistence.test.ts
  • src/main/persistence.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/ui-state-schema-parity-checks.ts
  • src/main/ssh/ssh-relay-session-agent-hooks.integration.test.ts
  • src/main/ssh/ssh-relay-session.ts
  • src/relay/agent-hook-server-codex-subagent-transcript.test.ts
  • src/relay/agent-hook-server.test.ts
  • src/relay/agent-hook-server.ts
  • src/relay/relay.ts
  • src/renderer/src/components/ContextPressureIndicator.test.tsx
  • src/renderer/src/components/ContextPressureIndicator.tsx
  • src/renderer/src/components/automations/AutomationRunContextPressure.test.tsx
  • src/renderer/src/components/automations/AutomationRunContextPressure.tsx
  • src/renderer/src/components/automations/AutomationRunHistory.tsx
  • src/renderer/src/components/dashboard-popout/AgentKanbanCard.test.tsx
  • src/renderer/src/components/dashboard-popout/AgentKanbanCard.tsx
  • src/renderer/src/components/dashboard-popout/AgentTerminalDialog.tsx
  • src/renderer/src/components/dashboard/DashboardAgentRow.context-pressure.test.tsx
  • src/renderer/src/components/dashboard/DashboardAgentRow.tsx
  • src/renderer/src/components/dashboard/build-dashboard-snapshot.test.ts
  • src/renderer/src/components/dashboard/build-dashboard-snapshot.ts
  • src/renderer/src/components/dashboard/dashboard-card-context-pressure.ts
  • src/renderer/src/components/dashboard/dashboard-snapshot-card-fields.ts
  • src/renderer/src/components/right-sidebar/AiVaultPanel.tsx
  • src/renderer/src/components/right-sidebar/AiVaultSessionRow.tsx
  • src/renderer/src/components/right-sidebar/AiVaultSessionVirtualList.tsx
  • src/renderer/src/components/right-sidebar/ai-vault-original-pane-actions.ts
  • src/renderer/src/components/right-sidebar/ai-vault-original-pane-index.ts
  • src/renderer/src/components/settings/ContextPressureExperimentalSetting.tsx
  • src/renderer/src/components/settings/ContextPressureSoftLimitsEditor.tsx
  • src/renderer/src/components/settings/ExperimentalPane.test.tsx
  • src/renderer/src/components/settings/ExperimentalPane.tsx
  • src/renderer/src/components/settings/context-pressure-search-entry.ts
  • src/renderer/src/components/settings/experimental-search.ts
  • src/renderer/src/components/sidebar/WorktreeCard.context-pressure.test.tsx
  • src/renderer/src/components/sidebar/WorktreeCard.tsx
  • src/renderer/src/components/sidebar/WorktreeCardDisplayMenuSection.tsx
  • src/renderer/src/components/sidebar/context-pressure-selection.test.ts
  • src/renderer/src/components/sidebar/context-pressure-selection.ts
  • src/renderer/src/components/sidebar/sidebar-workspace-option-items.test.ts
  • src/renderer/src/components/sidebar/sidebar-workspace-option-items.ts
  • src/renderer/src/components/sidebar/worktree-card-compact-agent-row.context-pressure.test.tsx
  • src/renderer/src/components/sidebar/worktree-card-compact-agent-row.tsx
  • src/renderer/src/components/sidebar/worktree-card-display-property-options.ts
  • src/renderer/src/components/tab-bar/SortableTab.context-pressure.test.tsx
  • src/renderer/src/components/tab-bar/SortableTab.tsx
  • src/renderer/src/components/tab-bar/TerminalTabContextPressure.tsx
  • src/renderer/src/hooks/useIpcEvents.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/runtime/sync-runtime-graph-agent-status-projection.test.ts
  • src/renderer/src/runtime/sync-runtime-graph.ts
  • src/renderer/src/runtime/web-session-tabs-sync.test.ts
  • src/renderer/src/runtime/web-session-tabs-sync.ts
  • src/renderer/src/store/slices/agent-status.test.ts
  • src/renderer/src/store/slices/agent-status.ts
  • src/renderer/src/web/web-preload-api.test.ts
  • src/shared/agent-context-pressure.test.ts
  • src/shared/agent-context-pressure.ts
  • src/shared/agent-hook-listener.ts
  • src/shared/agent-hook-relay.test.ts
  • src/shared/agent-hook-relay.ts
  • src/shared/agent-status-types.test.ts
  • src/shared/agent-status-types.ts
  • src/shared/claude-statusline-context-window.test.ts
  • src/shared/claude-statusline-context-window.ts
  • src/shared/codex-rollout-context-usage.test.ts
  • src/shared/codex-rollout-context-usage.ts
  • src/shared/codex-subagent-transcript.test.ts
  • src/shared/codex-subagent-transcript.ts
  • src/shared/constants.test.ts
  • src/shared/constants.ts
  • src/shared/dashboard-snapshot.ts
  • src/shared/model-context-windows.test.ts
  • src/shared/model-context-windows.ts
  • src/shared/runtime-types.ts
  • src/shared/telemetry-events.ts
  • src/shared/types.ts
  • src/shared/worktree-card-properties.test.ts
  • src/shared/worktree-card-properties.ts

Comment thread src/main/agent-hooks/server.ts Resolved
Comment thread src/main/index.ts Resolved
Comment thread src/renderer/src/i18n/locales/ja.json Resolved
Comment thread src/renderer/src/i18n/locales/ko.json Resolved
Comment thread src/renderer/src/i18n/locales/zh.json Resolved
Comment thread src/shared/agent-context-pressure.ts Resolved
Comment thread src/shared/types.ts Resolved
@raskalbass
raskalbass force-pushed the claude/experimental-agent-cards-menu-97i7y6 branch from 7806686 to 1324598 Compare July 30, 2026 01:51
@raskalbass
raskalbass requested a review from brennanb2025 as a code owner July 30, 2026 01:51
@raskalbass
raskalbass force-pushed the claude/experimental-agent-cards-menu-97i7y6 branch from 1324598 to 74e2dee Compare July 30, 2026 01:57

ghost 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

♻️ Duplicate comments (1)
src/renderer/src/components/settings/ContextPressureSoftLimitsEditor.tsx (1)

219-242: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Collision branch still doesn't revert stale draft values.

On a key collision, commit() sets duplicate but returns without restoring keyDraft/tokensDraft to the persisted entryKey/tokens — unlike the invalid-input branch just below, which does revert. The row keeps showing the un-persisted duplicate value after blur, and the "already exists" alert can persist even after the user moves on, giving the impression the edit was saved when it wasn't.

🔧 Proposed fix
     if (collision) {
       setDuplicate(true)
+      setKeyDraft(entryKey)
+      setTokensDraft(String(tokens))
       return
     }

This was flagged in a previous review on this same file/range without being addressed.

🧹 Nitpick comments (4)
src/main/claude/hook-service.ts (1)

127-135: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Inconsistent Claude-only gating for the statusline rewrite.

install(), installRemote(), and remove() all guard statusline work behind this.options.agent === 'claude' ("the statusline usage feed is Claude-only"), but setContextPressureEnabled calls rewriteManagedClaudeStatusLine unconditionally. It's likely a harmless no-op for non-Claude agents (the helper only rewrites when the slot is already 'managed'), but the inconsistency invites confusion and an unnecessary config read for other agent types.

♻️ Optional consistency fix
     this.contextPressureEnabled = enabled
-    if (reinstall) {
+    if (reinstall && this.options.agent === 'claude') {
       rewriteManagedClaudeStatusLine(this.options.settings, enabled)
     }
src/main/persistence.ts (1)

3138-3148: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

No cross-validation between contextPressureWarnPercent and contextPressureCriticalPercent.

Both percents are normalized independently (1–100 clamp each), so a caller can persist contextPressureWarnPercent > contextPressureCriticalPercent (e.g. warn=95, critical=90). If the level-computation checks critical first, the "warning" band becomes unreachable for that range — a silently confusing config rather than a crash. Consider clamping contextPressureCriticalPercent to be >= contextPressureWarnPercent (or vice versa) at the same normalization boundary.

💡 Example clamp at the `updateSettings` boundary
     if ('contextPressureCriticalPercent' in updates) {
-      sanitizedUpdates.contextPressureCriticalPercent = normalizeContextPressurePercent(
-        updates.contextPressureCriticalPercent,
-        DEFAULT_CONTEXT_PRESSURE_CRITICAL_PERCENT
-      )
+      const warnPercent =
+        sanitizedUpdates.contextPressureWarnPercent ?? this.state.settings.contextPressureWarnPercent
+      sanitizedUpdates.contextPressureCriticalPercent = Math.max(
+        warnPercent,
+        normalizeContextPressurePercent(
+          updates.contextPressureCriticalPercent,
+          DEFAULT_CONTEXT_PRESSURE_CRITICAL_PERCENT
+        )
+      )
     }

Also applies to: 5454-5465

src/renderer/src/components/sidebar/sidebar-workspace-option-items.ts (1)

207-221: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the new conditional option paths with tests.

Add assertions for enabled and disabled contextPressureEnabled in both newCardStyle branches, verifying that context-pressure appears only when enabled. This protects the menu contract from exposing an inert checkbox or omitting the option.

src/renderer/src/components/ContextPressureIndicator.tsx (1)

14-18: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Condense this component rationale.

This restates behavior visible from the component and is longer than needed; retain only a concise, non-obvious note if one is necessary. As per coding guidelines, “Comments must be concise, limited to non-obvious information, and preferably one line.”

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e3d9dff3-ed1f-4954-8dd0-8ff7eef017d3

📥 Commits

Reviewing files that changed from the base of the PR and between 78066866438098f36e2d831fa6e1a9f7f287eb5b and 1324598502ecb903bc346fd6f61196937352ff03.

📒 Files selected for processing (110)
  • config/tsconfig.cli.json
  • mobile/src/components/ContextPressureDot.tsx
  • mobile/src/components/WorktreeAgentRow.tsx
  • mobile/src/components/WorktreeListRow.test.ts
  • mobile/src/components/WorktreeListRow.tsx
  • mobile/src/worktree/context-pressure-display.test.ts
  • mobile/src/worktree/context-pressure-display.ts
  • mobile/src/worktree/worktree-list-snapshot.test.ts
  • mobile/src/worktree/worktree-list-snapshot.ts
  • src/main/agent-hooks/managed-hook-stdin-lifecycle.test.ts
  • src/main/agent-hooks/server-codex-context-usage.test.ts
  • src/main/agent-hooks/server-context-usage.test.ts
  • src/main/agent-hooks/server.ts
  • src/main/agent-hooks/wsl-hook-relay-manager.test.ts
  • src/main/agent-hooks/wsl-hook-relay-manager.ts
  • src/main/agent-hooks/wsl-hook-relay-state.ts
  • src/main/claude/hook-service.test.ts
  • src/main/claude/hook-service.ts
  • src/main/claude/statusline-script.test.ts
  • src/main/claude/statusline-script.ts
  • src/main/claude/statusline-toggle.ts
  • src/main/index.ts
  • src/main/ipc/dashboard-payload-validation.test.ts
  • src/main/ipc/dashboard-payload-validation.ts
  • src/main/persistence.test.ts
  • src/main/persistence.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/ui-state-schema-parity-checks.ts
  • src/main/ssh/ssh-relay-session-agent-hooks.integration.test.ts
  • src/main/ssh/ssh-relay-session.test.ts
  • src/main/ssh/ssh-relay-session.ts
  • src/relay/agent-hook-server-codex-subagent-transcript.test.ts
  • src/relay/agent-hook-server.test.ts
  • src/relay/agent-hook-server.ts
  • src/relay/relay.ts
  • src/renderer/src/components/ContextPressureIndicator.test.tsx
  • src/renderer/src/components/ContextPressureIndicator.tsx
  • src/renderer/src/components/automations/AutomationRunContextPressure.test.tsx
  • src/renderer/src/components/automations/AutomationRunContextPressure.tsx
  • src/renderer/src/components/automations/AutomationRunHistory.tsx
  • src/renderer/src/components/dashboard-popout/AgentKanbanCard.test.tsx
  • src/renderer/src/components/dashboard-popout/AgentKanbanCard.tsx
  • src/renderer/src/components/dashboard-popout/AgentTerminalDialog.tsx
  • src/renderer/src/components/dashboard/DashboardAgentRow.context-pressure.test.tsx
  • src/renderer/src/components/dashboard/DashboardAgentRow.tsx
  • src/renderer/src/components/dashboard/build-dashboard-snapshot.test.ts
  • src/renderer/src/components/dashboard/build-dashboard-snapshot.ts
  • src/renderer/src/components/dashboard/dashboard-card-context-pressure.ts
  • src/renderer/src/components/dashboard/dashboard-snapshot-card-fields.ts
  • src/renderer/src/components/right-sidebar/AiVaultPanel.tsx
  • src/renderer/src/components/right-sidebar/AiVaultSessionRow.tsx
  • src/renderer/src/components/right-sidebar/AiVaultSessionVirtualList.tsx
  • src/renderer/src/components/right-sidebar/ai-vault-original-pane-actions.ts
  • src/renderer/src/components/right-sidebar/ai-vault-original-pane-index.ts
  • src/renderer/src/components/settings/ContextPressureExperimentalSetting.tsx
  • src/renderer/src/components/settings/ContextPressureSoftLimitsEditor.tsx
  • src/renderer/src/components/settings/ExperimentalPane.test.tsx
  • src/renderer/src/components/settings/ExperimentalPane.tsx
  • src/renderer/src/components/settings/context-pressure-search-entry.ts
  • src/renderer/src/components/settings/experimental-search.ts
  • src/renderer/src/components/sidebar/WorktreeCard.context-pressure.test.tsx
  • src/renderer/src/components/sidebar/WorktreeCard.tsx
  • src/renderer/src/components/sidebar/WorktreeCardDisplayMenuSection.tsx
  • src/renderer/src/components/sidebar/context-pressure-selection.test.ts
  • src/renderer/src/components/sidebar/context-pressure-selection.ts
  • src/renderer/src/components/sidebar/sidebar-workspace-option-items.test.ts
  • src/renderer/src/components/sidebar/sidebar-workspace-option-items.ts
  • src/renderer/src/components/sidebar/worktree-card-compact-agent-row.context-pressure.test.tsx
  • src/renderer/src/components/sidebar/worktree-card-compact-agent-row.tsx
  • src/renderer/src/components/sidebar/worktree-card-display-property-options.ts
  • src/renderer/src/components/tab-bar/SortableTab.context-pressure.test.tsx
  • src/renderer/src/components/tab-bar/SortableTab.tsx
  • src/renderer/src/components/tab-bar/TerminalTabContextPressure.tsx
  • src/renderer/src/hooks/useIpcEvents.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/runtime/sync-runtime-graph-agent-status-projection.test.ts
  • src/renderer/src/runtime/sync-runtime-graph.ts
  • src/renderer/src/runtime/web-session-tabs-sync.test.ts
  • src/renderer/src/runtime/web-session-tabs-sync.ts
  • src/renderer/src/store/slices/agent-status.test.ts
  • src/renderer/src/store/slices/agent-status.ts
  • src/renderer/src/web/web-preload-api.test.ts
  • src/shared/agent-context-pressure.test.ts
  • src/shared/agent-context-pressure.ts
  • src/shared/agent-hook-listener.ts
  • src/shared/agent-hook-relay.test.ts
  • src/shared/agent-hook-relay.ts
  • src/shared/agent-status-types.test.ts
  • src/shared/agent-status-types.ts
  • src/shared/claude-statusline-context-window.test.ts
  • src/shared/claude-statusline-context-window.ts
  • src/shared/codex-rollout-context-usage.test.ts
  • src/shared/codex-rollout-context-usage.ts
  • src/shared/codex-subagent-transcript.test.ts
  • src/shared/codex-subagent-transcript.ts
  • src/shared/constants.test.ts
  • src/shared/constants.ts
  • src/shared/dashboard-snapshot.ts
  • src/shared/model-context-windows.test.ts
  • src/shared/model-context-windows.ts
  • src/shared/runtime-types.ts
  • src/shared/telemetry-events.ts
  • src/shared/types.ts
  • src/shared/worktree-card-properties.test.ts
  • src/shared/worktree-card-properties.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/shared/agent-hook-relay.test.ts
  • src/renderer/src/web/web-preload-api.test.ts
  • src/renderer/src/components/sidebar/worktree-card-compact-agent-row.context-pressure.test.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/components/automations/AutomationRunHistory.tsx
  • src/renderer/src/i18n/locales/es.json

Comment thread src/main/claude/hook-service.ts Resolved

ghost 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

🧹 Nitpick comments (2)
src/main/claude/statusline-script.ts (1)

90-117: 📐 Maintainability & Code Quality | 🔵 Trivial

contextPressureEnabled is a no-op for target === 'posix'.

The POSIX case-guard (Lines 101-102) always emits both rate_limits/context_window matches with the runtime $ORCA_CONTEXT_PRESSURE_ENABLED check, regardless of the contextPressureEnabled argument — only the target !== 'posix' branch (Lines 105-108) and the Windows findstr branch honor it. Since installRemoteClaudeStatusLine passes this.contextPressureEnabled into getManagedStatusLineScript('posix', enabled), that argument currently has no effect on the generated remote script. This is likely intentional (remote toggling is meant to be live via the env var), but a short comment noting why the parameter is ignored for posix would prevent future confusion.

mobile/src/worktree/context-pressure-display.ts (1)

6-9: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Condense the new implementation comments.

Several comments restate direct control flow or implementation details and exceed the concise-comment rule.

  • mobile/src/worktree/context-pressure-display.ts#L6-L9: reduce to one concise contract comment.
  • mobile/src/worktree/context-pressure-display.ts#L17-L18: remove or condense the desktop-parity explanation.
  • mobile/src/worktree/context-pressure-display.ts#L27-L31: shorten the JSDoc to the exported behavior.
  • mobile/src/worktree/context-pressure-display.ts#L48-L49: reduce to a single-line defensive-formatting note.
  • src/main/index.ts#L774-L778: summarize the liveness-reap rationale in one line.
  • src/main/index.ts#L2811-L2813: condense the serve-path cleanup rationale.
  • src/main/index.ts#L2940-L2941: condense the shutdown-flush rationale.

As per coding guidelines, “Comments must be concise, limited to non-obvious information, and preferably one line.”

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 06ee6951-dbdb-4a72-a77a-555bfc17acce

📥 Commits

Reviewing files that changed from the base of the PR and between 1324598502ecb903bc346fd6f61196937352ff03 and 74e2deeea8bf4cec78432cbdfea7b5c9f5e47e44.

📒 Files selected for processing (35)
  • config/tsconfig.cli.json
  • mobile/src/components/ContextPressureDot.tsx
  • mobile/src/components/WorktreeAgentRow.tsx
  • mobile/src/components/WorktreeListRow.test.ts
  • mobile/src/components/WorktreeListRow.tsx
  • mobile/src/worktree/context-pressure-display.test.ts
  • mobile/src/worktree/context-pressure-display.ts
  • mobile/src/worktree/worktree-list-snapshot.test.ts
  • mobile/src/worktree/worktree-list-snapshot.ts
  • src/main/agent-hooks/managed-hook-stdin-lifecycle.test.ts
  • src/main/agent-hooks/server-codex-context-usage.test.ts
  • src/main/agent-hooks/server-context-usage.test.ts
  • src/main/agent-hooks/server.ts
  • src/main/agent-hooks/wsl-hook-relay-manager.test.ts
  • src/main/agent-hooks/wsl-hook-relay-manager.ts
  • src/main/agent-hooks/wsl-hook-relay-state.ts
  • src/main/claude/hook-service.test.ts
  • src/main/claude/hook-service.ts
  • src/main/claude/statusline-script.test.ts
  • src/main/claude/statusline-script.ts
  • src/main/claude/statusline-toggle.ts
  • src/main/index.ts
  • src/main/ipc/dashboard-payload-validation.test.ts
  • src/main/ipc/dashboard-payload-validation.ts
  • src/main/persistence.test.ts
  • src/main/persistence.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/ui-state-schema-parity-checks.ts
  • src/main/ssh/ssh-relay-session-agent-hooks.integration.test.ts
  • src/main/ssh/ssh-relay-session.test.ts
  • src/main/ssh/ssh-relay-session.ts
  • src/relay/agent-hook-server-codex-subagent-transcript.test.ts
  • src/relay/agent-hook-server.test.ts
  • src/relay/agent-hook-server.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/ssh/ssh-relay-session.test.ts

@raskalbass
raskalbass force-pushed the claude/experimental-agent-cards-menu-97i7y6 branch 4 times, most recently from 55a1e13 to 6f8200c Compare July 30, 2026 03:05

ghost 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: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/runtime/orca-runtime.ts (1)

32073-32076: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Remove the unused duplicate jiraReadStatus method.

jiraReadStatus is not referenced elsewhere and duplicates jiraStatus; removing it avoids stale API surface and future drift.

♻️ Duplicate comments (1)
src/main/claude/hook-service.ts (1)

244-250: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Remote statusline filename still gated by the local box's process.platform, not the remote host.

getStatusLineScriptFileName() branches on process.platform === 'win32' (the local box, per its own definition), yet it's used here to name a file being written to a POSIX remote via SFTP — mirroring the sibling remoteScriptFileName line right above it, which correctly calls the POSIX-specific getPosixManagedScriptFileName. A Windows client managing an SSH remote would compute …statusline.cmd for a POSIX shell script, while a Mac/Linux client managing the same remote would compute …statusline.sh; getStatusLineSlotState/removeManagedStatusLine then can't recognize either client's file as the "managed" slot the other created, risking duplicate or orphaned managed statuslines. This is the same defect flagged in a prior review of this file (previously marked addressed), so please confirm whether the intended fix was reverted or never landed.

🐛 Proposed fix (pending export verification below)
-    const remoteStatusLineFileName = getStatusLineScriptFileName(this.options.settings)
+    // Why: POSIX-only remote install; local process.platform can't gate the remote host's shell.
+    const remoteStatusLineFileName = getPosixStatusLineScriptFileName(this.options.settings)
#!/bin/bash
# Verify getPosixStatusLineScriptFileName is exported and check test coverage for the remote-install filename contract.
rg -n "getPosixStatusLineScriptFileName" src/main/claude
rg -n -A5 "locks in the remote-install contract" src/main/claude/hook-service.test.ts

Also applies to: 275-283

🧹 Nitpick comments (1)
src/main/claude/statusline-script.ts (1)

90-118: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

contextPressureEnabled parameter is a no-op when target === 'posix'.

The posix branch never reads contextPressureEnabled; it always emits both case patterns and defers to the runtime $ORCA_CONTEXT_PRESSURE_ENABLED env var instead. That's a reasonable design (remote reads a live flag), but installRemoteClaudeStatusLine (statusline-toggle.ts) still threads a real boolean into getManagedStatusLineScript('posix', enabled) as if it mattered, which can mislead future maintainers into thinking toggling it changes remote script content. Consider dropping the parameter for the posix path (or documenting in the signature/JSDoc that it's ignored for target === 'posix').


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 81da754e-ea95-421c-b316-3c576df36c98

📥 Commits

Reviewing files that changed from the base of the PR and between 74e2deeea8bf4cec78432cbdfea7b5c9f5e47e44 and 6f8200ce568d07c90221e9683714143c489eb8e0.

📒 Files selected for processing (112)
  • config/tsconfig.cli.json
  • mobile/src/components/ContextPressureDot.tsx
  • mobile/src/components/WorktreeAgentRow.tsx
  • mobile/src/components/WorktreeListRow.test.ts
  • mobile/src/components/WorktreeListRow.tsx
  • mobile/src/components/context-pressure-copy.test.ts
  • mobile/src/components/context-pressure-copy.ts
  • mobile/src/worktree/context-pressure-display.test.ts
  • mobile/src/worktree/context-pressure-display.ts
  • mobile/src/worktree/worktree-list-snapshot.test.ts
  • mobile/src/worktree/worktree-list-snapshot.ts
  • src/main/agent-hooks/managed-hook-stdin-lifecycle.test.ts
  • src/main/agent-hooks/server-codex-context-usage.test.ts
  • src/main/agent-hooks/server-context-usage.test.ts
  • src/main/agent-hooks/server.ts
  • src/main/agent-hooks/wsl-hook-relay-manager.test.ts
  • src/main/agent-hooks/wsl-hook-relay-manager.ts
  • src/main/agent-hooks/wsl-hook-relay-state.ts
  • src/main/claude/hook-service.test.ts
  • src/main/claude/hook-service.ts
  • src/main/claude/statusline-script.test.ts
  • src/main/claude/statusline-script.ts
  • src/main/claude/statusline-toggle.ts
  • src/main/index.ts
  • src/main/ipc/dashboard-payload-validation.test.ts
  • src/main/ipc/dashboard-payload-validation.ts
  • src/main/persistence.test.ts
  • src/main/persistence.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/ui-state-schema-parity-checks.ts
  • src/main/ssh/ssh-relay-session-agent-hooks.integration.test.ts
  • src/main/ssh/ssh-relay-session.test.ts
  • src/main/ssh/ssh-relay-session.ts
  • src/relay/agent-hook-server-codex-subagent-transcript.test.ts
  • src/relay/agent-hook-server.test.ts
  • src/relay/agent-hook-server.ts
  • src/relay/relay.ts
  • src/renderer/src/components/ContextPressureIndicator.test.tsx
  • src/renderer/src/components/ContextPressureIndicator.tsx
  • src/renderer/src/components/automations/AutomationRunContextPressure.test.tsx
  • src/renderer/src/components/automations/AutomationRunContextPressure.tsx
  • src/renderer/src/components/automations/AutomationRunHistory.tsx
  • src/renderer/src/components/dashboard-popout/AgentKanbanCard.test.tsx
  • src/renderer/src/components/dashboard-popout/AgentKanbanCard.tsx
  • src/renderer/src/components/dashboard-popout/AgentTerminalDialog.tsx
  • src/renderer/src/components/dashboard/DashboardAgentRow.context-pressure.test.tsx
  • src/renderer/src/components/dashboard/DashboardAgentRow.tsx
  • src/renderer/src/components/dashboard/build-dashboard-snapshot.test.ts
  • src/renderer/src/components/dashboard/build-dashboard-snapshot.ts
  • src/renderer/src/components/dashboard/dashboard-card-context-pressure.ts
  • src/renderer/src/components/dashboard/dashboard-snapshot-card-fields.ts
  • src/renderer/src/components/right-sidebar/AiVaultPanel.tsx
  • src/renderer/src/components/right-sidebar/AiVaultSessionRow.tsx
  • src/renderer/src/components/right-sidebar/AiVaultSessionVirtualList.tsx
  • src/renderer/src/components/right-sidebar/ai-vault-original-pane-actions.ts
  • src/renderer/src/components/right-sidebar/ai-vault-original-pane-index.ts
  • src/renderer/src/components/settings/ContextPressureExperimentalSetting.tsx
  • src/renderer/src/components/settings/ContextPressureSoftLimitsEditor.tsx
  • src/renderer/src/components/settings/ExperimentalPane.test.tsx
  • src/renderer/src/components/settings/ExperimentalPane.tsx
  • src/renderer/src/components/settings/context-pressure-search-entry.ts
  • src/renderer/src/components/settings/experimental-search.ts
  • src/renderer/src/components/sidebar/WorktreeCard.context-pressure.test.tsx
  • src/renderer/src/components/sidebar/WorktreeCard.tsx
  • src/renderer/src/components/sidebar/WorktreeCardDisplayMenuSection.tsx
  • src/renderer/src/components/sidebar/context-pressure-selection.test.ts
  • src/renderer/src/components/sidebar/context-pressure-selection.ts
  • src/renderer/src/components/sidebar/sidebar-workspace-option-items.test.ts
  • src/renderer/src/components/sidebar/sidebar-workspace-option-items.ts
  • src/renderer/src/components/sidebar/worktree-card-compact-agent-row.context-pressure.test.tsx
  • src/renderer/src/components/sidebar/worktree-card-compact-agent-row.tsx
  • src/renderer/src/components/sidebar/worktree-card-display-property-options.ts
  • src/renderer/src/components/tab-bar/SortableTab.context-pressure.test.tsx
  • src/renderer/src/components/tab-bar/SortableTab.tsx
  • src/renderer/src/components/tab-bar/TerminalTabContextPressure.tsx
  • src/renderer/src/hooks/useIpcEvents.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/runtime/sync-runtime-graph-agent-status-projection.test.ts
  • src/renderer/src/runtime/sync-runtime-graph.ts
  • src/renderer/src/runtime/web-session-tabs-sync.test.ts
  • src/renderer/src/runtime/web-session-tabs-sync.ts
  • src/renderer/src/store/slices/agent-status.test.ts
  • src/renderer/src/store/slices/agent-status.ts
  • src/renderer/src/web/web-preload-api.test.ts
  • src/shared/agent-context-pressure.test.ts
  • src/shared/agent-context-pressure.ts
  • src/shared/agent-hook-listener.ts
  • src/shared/agent-hook-relay.test.ts
  • src/shared/agent-hook-relay.ts
  • src/shared/agent-status-types.test.ts
  • src/shared/agent-status-types.ts
  • src/shared/claude-statusline-context-window.test.ts
  • src/shared/claude-statusline-context-window.ts
  • src/shared/codex-rollout-context-usage.test.ts
  • src/shared/codex-rollout-context-usage.ts
  • src/shared/codex-subagent-transcript.test.ts
  • src/shared/codex-subagent-transcript.ts
  • src/shared/constants.test.ts
  • src/shared/constants.ts
  • src/shared/dashboard-snapshot.ts
  • src/shared/model-context-windows.test.ts
  • src/shared/model-context-windows.ts
  • src/shared/runtime-types.ts
  • src/shared/telemetry-events.ts
  • src/shared/types.ts
  • src/shared/worktree-card-properties.test.ts
  • src/shared/worktree-card-properties.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/main/runtime/rpc/methods/ui-state-schema-parity-checks.ts
  • src/shared/agent-hook-relay.test.ts
  • src/renderer/src/runtime/web-session-tabs-sync.test.ts
  • src/renderer/src/components/ContextPressureIndicator.test.tsx
  • src/shared/runtime-types.ts
  • src/renderer/src/i18n/locales/zh.json

Comment thread src/main/agent-hooks/server.ts Resolved
Comment thread src/shared/worktree-card-properties.ts Resolved
@raskalbass
raskalbass force-pushed the claude/experimental-agent-cards-menu-97i7y6 branch from 6f8200c to 9b83854 Compare July 30, 2026 04:15

ghost 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: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/main/runtime/orca-runtime.ts (2)

15887-15893: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Two aggregation points blank a known contextUsage reading when a fresher status ping omits it. Both sites pick the "freshest" status/hook entry and copy its contextUsage verbatim, but neither falls back to the previously known value when the new one is undefined — unlike retainAgentRowSnapshot (L9795-L9804), which explicitly carries contextUsage forward across such gaps for the same data.

  • src/main/runtime/orca-runtime.ts#L15887-L15893: in consider (getFreshExplicitAgentStatusForHandle), fall back to the previous bestContextUsage when the winning entry's contextUsage is undefined.
  • src/main/runtime/orca-runtime.ts#L16723-L16737: in the hook-merge loop (attachAgentRowsToSummaries), fall back to existing?.contextUsage when entry.contextUsage is undefined.

3130-3130: 🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win

Scope terminal side-effect availability to terminal-side-effect listeners only.

runtime.clientEvents.subscribe subscribes once per RPC stream and dispatches all RuntimeClientEvent types on that single clientEventListeners sink, including client-surface repo/worktree/SSH events. That keeps terminalSideEffectConsumerAvailable true and rebuilds per-PTY scanners even when no subscriber needs terminalSideEffects. Use a dedicated listener set/counter for terminal side effects instead of the generic client-event set.

🧹 Nitpick comments (8)
src/renderer/src/components/settings/context-pressure-search-entry.ts (1)

16-19: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use a semantic localization key.

Replace search.0d24759f14 with a descriptive contextPressure-scoped key and update localization catalogs. Based on learnings, prefer semantic locale keys when they match neighboring namespaces.

Source: Learnings

src/main/claude/statusline-script.test.ts (1)

41-50: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Test name overstates what the posix target honors.

getManagedStatusLineScript('posix', false) ignores the second argument (remote scripts read ORCA_CONTEXT_PRESSURE_ENABLED at runtime), so this case really asserts flag-independence. Consider naming it accordingly to avoid implying the build-time flag gates remote scripts.

src/main/index.ts (1)

1997-2016: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Hoist the repeated settings read.

The same store.getSettings().experimentalContextPressure === true expression is evaluated three times; a single local keeps the three services provably in sync with one snapshot (as the change handler already does).

♻️ Proposed refactor
   wslHookRelayManager.setManagedHookSettingsResolver(() => store?.getSettings() ?? null)
-  agentHookServer.setContextPressureEnabled(
-    store.getSettings().experimentalContextPressure === true
-  )
-  claudeHookService.setContextPressureEnabled(
-    store.getSettings().experimentalContextPressure === true
-  )
-  wslHookRelayManager.setContextPressureEnabled(
-    store.getSettings().experimentalContextPressure === true
-  )
+  const contextPressureEnabled = store.getSettings().experimentalContextPressure === true
+  agentHookServer.setContextPressureEnabled(contextPressureEnabled)
+  claudeHookService.setContextPressureEnabled(contextPressureEnabled)
+  wslHookRelayManager.setContextPressureEnabled(contextPressureEnabled)
src/shared/codex-rollout-context-usage.test.ts (1)

1-3: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Shorten the test contract comment.

This restates parser mechanics across three lines; retain a one-line intent comment instead.

As per coding guidelines, comments must be concise, limited to non-obvious information, and preferably one line.

Source: Coding guidelines

src/relay/agent-hook-server.test.ts (1)

114-114: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert that the context-only envelope omits payload.

rate_limits is submitted inside the statusline body, so this top-level assertion passes even if raw statusline data is incorrectly forwarded through payload.

Proposed test fix
-      expect(forward.mock.calls[0][0]).not.toHaveProperty('rate_limits')
+      expect(forward.mock.calls[0][0].payload).toBeUndefined()
src/main/claude/statusline-script.ts (1)

100-109: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

contextPressureEnabled has no effect on the generated posix script.

For target === 'posix', the case body always includes the context_window branch gated by the live ORCA_CONTEXT_PRESSURE_ENABLED env var; the contextPressureEnabled parameter is only consulted in the else (non-posix/local) branch. That's consistent with the "Remote POSIX reads the live relay flag; local scripts bake in the setting" comment above, but it means callers like installRemoteClaudeStatusLine(..., enabled) pass a value that is silently ignored for posix output. A short comment near the getManagedStatusLineScript signature (or on the posix ternary) noting that contextPressureEnabled only affects the non-posix/local branch would prevent a future reader from assuming it also gates the remote script.

src/renderer/src/components/sidebar/context-pressure-selection.ts (1)

39-39: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

No test-reset hooks for the three module-level caches.

configCache, worstSnapshotByEntries, and tabPressureIndexCache are module-scoped singletons with no exported reset function, unlike the sibling cachedAgentStatusProjection in sync-runtime-graph.ts, which exposes resetRuntimeMobileAgentStatusProjectionCacheForTests() for exactly this purpose. Without an equivalent here, tests in the companion context-pressure-selection.test.ts can only rely on Vitest's default per-file module isolation to avoid cross-test cache bleed-through, which is more fragile than an explicit reset.

♻️ Suggested addition
+export function resetContextPressureSelectionCachesForTests(): void {
+  configCache = null
+  tabPressureIndexCache = null
+}

(worstSnapshotByEntries is a WeakMap, so it self-clears once entry arrays are unreferenced and doesn't need explicit resetting.)

Also applies to: 131-134, 163-163

src/shared/claude-statusline-context-window.test.ts (1)

15-143: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider covering sessionId and providerId extraction.

Every case here omits session_id and model.provider, yet both drive downstream behavior: sessionId gates applyPaneContextUsage (src/main/agent-hooks/server.ts) and is forwarded as contextSessionId by the relay, and providerId feeds provider:<id> soft-limit resolution. A single payload with both would lock those paths in.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6c9a55e9-01f3-4324-b058-0561a9435a7b

📥 Commits

Reviewing files that changed from the base of the PR and between 6f8200ce568d07c90221e9683714143c489eb8e0 and 9b83854b72d354a44f726405c9e123e1d217810b.

📒 Files selected for processing (112)
  • config/tsconfig.cli.json
  • mobile/src/components/ContextPressureDot.tsx
  • mobile/src/components/WorktreeAgentRow.tsx
  • mobile/src/components/WorktreeListRow.test.ts
  • mobile/src/components/WorktreeListRow.tsx
  • mobile/src/components/context-pressure-copy.test.ts
  • mobile/src/components/context-pressure-copy.ts
  • mobile/src/worktree/context-pressure-display.test.ts
  • mobile/src/worktree/context-pressure-display.ts
  • mobile/src/worktree/worktree-list-snapshot.test.ts
  • mobile/src/worktree/worktree-list-snapshot.ts
  • src/main/agent-hooks/managed-hook-stdin-lifecycle.test.ts
  • src/main/agent-hooks/server-codex-context-usage.test.ts
  • src/main/agent-hooks/server-context-usage.test.ts
  • src/main/agent-hooks/server.ts
  • src/main/agent-hooks/wsl-hook-relay-manager.test.ts
  • src/main/agent-hooks/wsl-hook-relay-manager.ts
  • src/main/agent-hooks/wsl-hook-relay-state.ts
  • src/main/claude/hook-service.test.ts
  • src/main/claude/hook-service.ts
  • src/main/claude/statusline-script.test.ts
  • src/main/claude/statusline-script.ts
  • src/main/claude/statusline-toggle.ts
  • src/main/index.ts
  • src/main/ipc/dashboard-payload-validation.test.ts
  • src/main/ipc/dashboard-payload-validation.ts
  • src/main/persistence.test.ts
  • src/main/persistence.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/ui-state-schema-parity-checks.ts
  • src/main/ssh/ssh-relay-session-agent-hooks.integration.test.ts
  • src/main/ssh/ssh-relay-session.test.ts
  • src/main/ssh/ssh-relay-session.ts
  • src/relay/agent-hook-server-codex-subagent-transcript.test.ts
  • src/relay/agent-hook-server.test.ts
  • src/relay/agent-hook-server.ts
  • src/relay/relay.ts
  • src/renderer/src/components/ContextPressureIndicator.test.tsx
  • src/renderer/src/components/ContextPressureIndicator.tsx
  • src/renderer/src/components/automations/AutomationRunContextPressure.test.tsx
  • src/renderer/src/components/automations/AutomationRunContextPressure.tsx
  • src/renderer/src/components/automations/AutomationRunHistory.tsx
  • src/renderer/src/components/dashboard-popout/AgentKanbanCard.test.tsx
  • src/renderer/src/components/dashboard-popout/AgentKanbanCard.tsx
  • src/renderer/src/components/dashboard-popout/AgentTerminalDialog.tsx
  • src/renderer/src/components/dashboard/DashboardAgentRow.context-pressure.test.tsx
  • src/renderer/src/components/dashboard/DashboardAgentRow.tsx
  • src/renderer/src/components/dashboard/build-dashboard-snapshot.test.ts
  • src/renderer/src/components/dashboard/build-dashboard-snapshot.ts
  • src/renderer/src/components/dashboard/dashboard-card-context-pressure.ts
  • src/renderer/src/components/dashboard/dashboard-snapshot-card-fields.ts
  • src/renderer/src/components/right-sidebar/AiVaultPanel.tsx
  • src/renderer/src/components/right-sidebar/AiVaultSessionRow.tsx
  • src/renderer/src/components/right-sidebar/AiVaultSessionVirtualList.tsx
  • src/renderer/src/components/right-sidebar/ai-vault-original-pane-actions.ts
  • src/renderer/src/components/right-sidebar/ai-vault-original-pane-index.ts
  • src/renderer/src/components/settings/ContextPressureExperimentalSetting.tsx
  • src/renderer/src/components/settings/ContextPressureSoftLimitsEditor.tsx
  • src/renderer/src/components/settings/ExperimentalPane.test.tsx
  • src/renderer/src/components/settings/ExperimentalPane.tsx
  • src/renderer/src/components/settings/context-pressure-search-entry.ts
  • src/renderer/src/components/settings/experimental-search.ts
  • src/renderer/src/components/sidebar/WorktreeCard.context-pressure.test.tsx
  • src/renderer/src/components/sidebar/WorktreeCard.tsx
  • src/renderer/src/components/sidebar/WorktreeCardDisplayMenuSection.tsx
  • src/renderer/src/components/sidebar/context-pressure-selection.test.ts
  • src/renderer/src/components/sidebar/context-pressure-selection.ts
  • src/renderer/src/components/sidebar/sidebar-workspace-option-items.test.ts
  • src/renderer/src/components/sidebar/sidebar-workspace-option-items.ts
  • src/renderer/src/components/sidebar/worktree-card-compact-agent-row.context-pressure.test.tsx
  • src/renderer/src/components/sidebar/worktree-card-compact-agent-row.tsx
  • src/renderer/src/components/sidebar/worktree-card-display-property-options.ts
  • src/renderer/src/components/tab-bar/SortableTab.context-pressure.test.tsx
  • src/renderer/src/components/tab-bar/SortableTab.tsx
  • src/renderer/src/components/tab-bar/TerminalTabContextPressure.tsx
  • src/renderer/src/hooks/useIpcEvents.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/runtime/sync-runtime-graph-agent-status-projection.test.ts
  • src/renderer/src/runtime/sync-runtime-graph.ts
  • src/renderer/src/runtime/web-session-tabs-sync.test.ts
  • src/renderer/src/runtime/web-session-tabs-sync.ts
  • src/renderer/src/store/slices/agent-status.test.ts
  • src/renderer/src/store/slices/agent-status.ts
  • src/renderer/src/web/web-preload-api.test.ts
  • src/shared/agent-context-pressure.test.ts
  • src/shared/agent-context-pressure.ts
  • src/shared/agent-hook-listener.ts
  • src/shared/agent-hook-relay.test.ts
  • src/shared/agent-hook-relay.ts
  • src/shared/agent-status-types.test.ts
  • src/shared/agent-status-types.ts
  • src/shared/claude-statusline-context-window.test.ts
  • src/shared/claude-statusline-context-window.ts
  • src/shared/codex-rollout-context-usage.test.ts
  • src/shared/codex-rollout-context-usage.ts
  • src/shared/codex-subagent-transcript.test.ts
  • src/shared/codex-subagent-transcript.ts
  • src/shared/constants.test.ts
  • src/shared/constants.ts
  • src/shared/dashboard-snapshot.ts
  • src/shared/model-context-windows.test.ts
  • src/shared/model-context-windows.ts
  • src/shared/runtime-types.ts
  • src/shared/telemetry-events.ts
  • src/shared/types.ts
  • src/shared/worktree-card-properties.test.ts
  • src/shared/worktree-card-properties.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/shared/agent-hook-relay.test.ts
  • src/renderer/src/components/dashboard-popout/AgentTerminalDialog.tsx
  • src/renderer/src/components/dashboard/build-dashboard-snapshot.test.ts
  • src/renderer/src/components/sidebar/worktree-card-display-property-options.ts
  • src/renderer/src/i18n/locales/ko.json
  • src/main/claude/hook-service.test.ts

Comment thread src/main/agent-hooks/server.ts Resolved
Comment thread src/main/agent-hooks/server.ts Resolved
Comment thread src/main/claude/statusline-script.ts Resolved
Comment on lines +54 to +59
for (const window of [0, -1, Number.NaN, '272000', null]) {
expect(
readCodexRolloutContextUsage(
parse(tokenCountLine({ ...base, model_context_window: window }))
)
).toEqual({ usedTokens: 10_500, providerId: 'openai' })

ghost Jul 30, 2026

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

Test NaN without JSON serialization.

At Line 54, JSON.stringify(Number.NaN) becomes null, so the loop tests null twice and never verifies rejection of non-finite numeric input. Pass a constructed record directly for the NaN case.

@raskalbass
raskalbass force-pushed the claude/experimental-agent-cards-menu-97i7y6 branch 2 times, most recently from 9d89459 to c47a823 Compare July 30, 2026 22:39
@raskalbass
raskalbass force-pushed the claude/experimental-agent-cards-menu-97i7y6 branch 4 times, most recently from cc4c828 to 356b8e6 Compare August 1, 2026 00:12
Ingest provider-reported Claude and Codex context usage across local, SSH, and WSL sessions. Add configurable global, provider, agent, and model soft limits with honest unknown-state handling.

Surface individual and worst-child pressure across desktop, dashboard, automation, terminal, AI Vault, and paired mobile views. Include exact usage, effective-limit provenance, accessible states, persistence migration, relay synchronization, and regression coverage.
@raskalbass
raskalbass force-pushed the claude/experimental-agent-cards-menu-97i7y6 branch from 356b8e6 to 5f5ddf9 Compare August 1, 2026 00:18
@brennanb2025

ghost commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Taking a look!

Brennan Benson added 4 commits August 1, 2026 04:16
Resolves the single conflict in src/main/ssh/ssh-relay-session.ts:
keep main's claimSshPtyConsumerRecovery(targetId, store) and the PR's
bindContextPressureSettings() constructor hook.
- Restore load-bearing comments compressed in src/main/index.ts and in the
  dashboard/WSL move-extractions (max-lines skips comments, so the
  compression bought nothing).
- Remote statusline: never POST rate_limits from SSH remotes (the relay
  drops them by design; account identity stays host-local), and mirror the
  local slot policy — a user-owned remote statusLine slot is never claimed
  and an empty slot after a prior install (remote marker) is a respected
  opt-out.
- Drop a session-tagged context reading until the row has an established
  provider session identity, closing the pre-identity stale-post window.
- Mobile: strip the 5-locale copy table to English constants; mobile has
  no i18n layer and the rest of its UI is English.
- Soft limits: require explicitly scoped keys (global, provider:<id>,
  agent:<type>, model:<id>) — unprefixed keys ambiguously matched both a
  model family and an agent type; settings editor now validates inline.
- Delete an unused duplicate distro-key helper from the WSL extraction.
Both written contracts — issue stablyai#11225 ('use the harness's reported
context-window size whenever available') and model-context-windows.ts
('used only when the provider does not report its own context max') —
say provider truth wins; min() let a stale curated entry override a live
provider-reported window and inflate pressure. The table now fills in
only when the provider reports no max; soft caps still bind below
either. Isolated commit for a one-step revert if min() was intended.
persistence, ExperimentalPane, and sidebar-selection fixtures now use
explicitly scoped keys; the editor test also covers the inline
unprefixed-key rejection.
Brennan Benson added 3 commits August 1, 2026 05:16
- Runtime OSC retention no longer carries a context reading across an
  agentType change (mirrors the hook server's guard); pinned by a
  red/green OSC-path test.
- Correct the GlobalSettings soft-limits doc to the enforced scoped-key
  contract.
- Restore the MSVC findstr-escape rationale and the no-stdout contract
  comment in statusline-script.ts.
- Refresh stale inline i18n fallbacks and drop the dead
  ContextPressureIndicator.ariaLabel catalog key in all five locales.
- Skip re-emit/re-persist for already-cleared rows on toggle-off; hoist
  mobile NumberFormat to module scope.
- worktree.ps cross-source merge: a fresher OSC row now inherits the hook
  row's known contextUsage/model for the same agentType instead of
  erasing it (mobile dot no longer flaps between statusline posts).
- Pressure level now follows the ROUNDED percent every surface displays,
  so an '90%' label never wears a warning dot under 'critical at 90'.
- AiVault: document why the pressure lookup resolves ambiguity to null
  while the state chip takes first-match; pin both rules with tests.
- Soft-limits editor: aria-invalid on all four inputs per STYLEGUIDE;
  align draft error-span placement with rows.
- Mobile dot: guard unknown limitSource values from a newer desktop
  (never prints 'undefined'); detail-string test per source.
- Popout payload validation: integer + shared 1e9 clamp parity for token
  counts; enum-rejection tests for level/limitSource/usedTokensSource.
- Parse-count test pinning the feature-off statusline parse gate.
@brennanb2025

ghost commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Thanks @raskalbass — this is a well-architected submission and we want to land it. It rides the existing seams end to end (statusline POST, rollout tail, relay envelope, status-row upsert) with no new transports, honest "unknown" fallbacks, and full feature-flag inertness. We reviewed it as a maintainer patch series on top of your head commit; your commit and attribution are preserved untouched.

What we changed on top (maintainer commits):

  • De-staled against current main; resolved the one conflict in ssh-relay-session.ts (kept main's PTY-consumer recovery helper plus your bindContextPressureSettings() hook).
  • Effective limit is now provider-first: the curated model table only fills in when the harness reports no max (per [Feature]: Show context-window pressure and configurable soft limits across agent views #11225 and the table's own contract), so a stale table entry can never inflate pressure. Isolated commit for easy revert if min() was intended.
  • Remote statusline hardening: SSH remotes never POST rate_limits (the relay drops them by design — account identity stays host-local), a user-owned remote statusLine slot is never claimed, and a deleted managed entry is a respected opt-out (marker on the remote box).
  • Session-identity: a session-tagged reading is dropped until the row's provider session id is established (closes a stale-post window before identity lands).
  • Runtime/mobile: OSC retention and the worktree.ps cross-source merge never carry a reading across an agentType change, and the merge no longer drops a known reading when a fresher OSC ping wins (no dot flap).
  • Level now follows the rounded percent every surface displays ("90%" never wears a warning dot under "critical at 90").
  • Soft-limit keys require an explicit scope (global, provider:<id>, agent:<type>, model:<id>) with inline editor validation — the unprefixed shorthand was ambiguous between model and agent.
  • Mobile copy is plain English constants (mobile has no i18n layer yet); unknown limitSource values from a newer desktop degrade gracefully.
  • Restored the load-bearing comments that were compressed for the (comment-exempt) max-lines cap; verified both extractions are move-pure; small a11y (aria-invalid), validation-bound, and feature-off-cost cleanups.

Known accepted behaviors (documented, by design):

  • After an SSH reconnect an idle remote session shows no reading (never a stale one) until its next statusline tick; readings replay across app restarts from persisted last-status.
  • SSH remotes and WSL guests get the managed statusline installed so the toggle propagates live without reconnect; with the feature off the script exits via shell builtins before any subprocess (one sh spawn per statusline tick).
  • Nested mobile dot semantics are flattened into the row for screen readers (pre-existing pattern with the lineage toggle) — follow-up candidate.

Verification (exact head 9fad190 = your commit + 7 maintainer commits, fast-forward):

  • 38 affected desktop suites (2,050 tests) + full mobile suite (386 files, 2,873 tests) green; typecheck, oxlint chain, max-lines ratchet, localization catalog/extraction/coverage all pass; changed-code quality gate (including React Doctor) clean vs main: 0 new findings across 108 changed files.
  • Two independent tracked review lanes ran three rounds to CLEAN-same-round, plus a dedicated perf audit (no regression; per-tick costs quantified) and red/green sampling on 10+ behaviors (tests fail when each fix or core behavior is reverted).
  • Electron validation: PASS. Isolated dev instance (temp profile); readings driven end-to-end through the real local hook-server HTTP boundary (real Claude statusline JSON, incl. session ids), not store injection. 12 full-page screenshots (light + dark) below cover sidebar/tab-strip/dashboard/kanban dots, the settings editor (invalid soft-limit key → inline role=alert error + aria-invalid ring), feature-off inertness (a11y tree empty of any pressure label), the live endpoint-file toggle (no restart), and folder-workspace (non-git) parity. Not exercised live: automations run-history surface (unit-covered) and the separate popout window (same kanban card component captured in-window; popout payload validation unit-tested).
  • SSH (throwaway Linux container): relay-contract legs PASS with physical evidence — real build:relay deploy to an Ubuntu 22.04 arm64 container; user-owned remote statusLine slot never claimed across three connect attempts (remote settings.json byte-identical after); the exact remote script bytes under real sh: flag-off → zero subprocess posts, flag-on → exactly one context_window POST, and rate_limits never posts from the remote regardless of flag. The desktop-connect leg hit a dev-mode ssh2/Docker-for-Mac wedge that reproduces identically on an identity-verified pinned-main build in the same container (A/B), so it is environmental, not introduced by this PR; the legs not proven live on that rig (relay→desktop envelope crossing, live remote toggle, reconnect-absence) are pinned by the green relay/integration suites on this exact head.
  • Mobile emulator: PASS, full matrix against a desktop running this exact head — pairing/session flow, 75% warning (orange diamond, "approaching limit") and 95% critical (red square, "near limit") per-agent rows, worst-of worktree rollup, "Effective limit: provider-reported" a11y labels, press-for-detail alert, and feature-off vanish; mobile rows matched the desktop store exactly (screenshots below).
  • Windows .bat checkpoint: PASS (A–F) on real cmd.exe via a tracked worker on a real Windows host — the generated .bat ran under Claude-statusline stdin in both flag states: payload capture, two-probe findstr split (rate_limits posts in both states; context_window only when enabled), throttle-stamp behavior, temp-file cleanup, no stray stdout (statusline visually unchanged), no window flash. One Medium finding — a trailing backslash in CLAUDE_CONFIG_DIR mangles the curl argument — is byte-identical on main (pre-existing, out of scope here); we recommend a separate follow-up issue.
Electron screenshots (12 — dark + light, feature on/off, folder workspace)

01-sidebar-worktree-dot-warning-critical.png
02-sidebar-agent-rows-expanded.png
03-dashboard-agent-rows.png
04-tasks-dashboard-rows.png
05-workspace-board.png
06-settings-softlimit-invalid-key.png
07-settings-softlimit-committed.png
08-settings-feature-off.png
09-sidebar-feature-off-no-dots.png
10-folder-workspace-tab-dot.png
11-light-theme-folder-tab.png
12-light-theme-sidebar-tabs.png

Mobile screenshots (4 — rollup, per-agent rows, detail alert, feature off)

mobile-01-worktree-critical-rollup.png
mobile-02-agent-rows-warning-critical.png
mobile-03-dot-detail-alert.png
mobile-04-feature-off-no-dots.png

One open product question for the maintainers before merge: provider-reported max vs. curated table precedence (we shipped provider-first per the written contracts; commit 349c4c1 reverts cleanly if min() was the intent).

@nwparker nwparker removed the P2 label Aug 19, 2026

This branch has not been deployed

No deployments
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.

[Feature]: Show context-window pressure and configurable soft limits across agent views

4 participants