Repository navigation
feat: track context-window pressure across agent sessions - #11417
raskalbass wants to merge 12 commits into
Conversation
|
Too many files changed for review. ( Bypass the limit by tagging |
|
Important Review skippedWe 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 You can disable this status message by setting the Use the checkbox below for a quick retry:
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds 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)
✅ Passed checks (3 passed)
Comment |
left a comment
There was a problem hiding this comment.
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 winClear cached context usage when the provider session changes.
Line 1845 only checks
agentType. A new Claude provider session whose hook ping omitscontextUsageretains the old session’s pressure reading even thoughproviderSessionChangedis already known. Gate reuse on!providerSessionChangedand 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 + : undefinedsrc/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 asdispose()), soestablish()can never be called again on this instance and a freshSshRelaySessionis expected for future reconnects. But unlikedispose()(Lines 505-506),detach()never callsthis.settingsCleanup?.(). Because a laterdispose()on the same object early-returns (if (this._state === 'disposed') return), theonSettingsChangedlistener registered inbindContextPressureSettings()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 valueCondense 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 winCondense 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 valueOptional: avoid rebuilding the lowercased entries array on every call.
resolveSoftCapruns per agent row per snapshot/render and re-allocates a normalized copy ofsoftLimitseach time. Since the caps are already sanitized/normalized at the persistence boundary, you could pre-normalize once alongside the memoizedContextPressureConfig(seegetContextPressureConfiginsrc/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 valueConsider covering
resolveContextPressureConfigFromSettings.The suite is thorough on
resolveContextPressureand 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 winPrecompile the two family regexes as module constants.
familyis a closed literal union, so thenew RegExpper 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 OpenGrepexec-jscommand-injection hit is also a false positive, this isRegExp.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 winCondense 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 winNormalize context-pressure settings on load too.
updateSettingsclamps these fields, butload()restoressettingswithout sanitizing the context-pressure keys, so hand-edited or downgraded profiles can retaincontextPressureWarnPercent: 0or malformed/non-objectcontextPressureSoftLimits;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.jsonmobile/src/components/ContextPressureDot.tsxmobile/src/components/WorktreeAgentRow.tsxmobile/src/components/WorktreeListRow.test.tsmobile/src/components/WorktreeListRow.tsxmobile/src/worktree/context-pressure-display.test.tsmobile/src/worktree/context-pressure-display.tsmobile/src/worktree/worktree-list-snapshot.test.tsmobile/src/worktree/worktree-list-snapshot.tssrc/main/agent-hooks/managed-hook-stdin-lifecycle.test.tssrc/main/agent-hooks/server-codex-context-usage.test.tssrc/main/agent-hooks/server-context-usage.test.tssrc/main/agent-hooks/server.tssrc/main/agent-hooks/wsl-hook-relay-manager.test.tssrc/main/agent-hooks/wsl-hook-relay-manager.tssrc/main/agent-hooks/wsl-hook-relay-state.tssrc/main/claude/hook-service.test.tssrc/main/claude/hook-service.tssrc/main/claude/statusline-script.test.tssrc/main/claude/statusline-script.tssrc/main/claude/statusline-toggle.tssrc/main/index.tssrc/main/ipc/dashboard-payload-validation.test.tssrc/main/ipc/dashboard-payload-validation.tssrc/main/persistence.test.tssrc/main/persistence.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/ui-state-schema-parity-checks.tssrc/main/ssh/ssh-relay-session-agent-hooks.integration.test.tssrc/main/ssh/ssh-relay-session.tssrc/relay/agent-hook-server-codex-subagent-transcript.test.tssrc/relay/agent-hook-server.test.tssrc/relay/agent-hook-server.tssrc/relay/relay.tssrc/renderer/src/components/ContextPressureIndicator.test.tsxsrc/renderer/src/components/ContextPressureIndicator.tsxsrc/renderer/src/components/automations/AutomationRunContextPressure.test.tsxsrc/renderer/src/components/automations/AutomationRunContextPressure.tsxsrc/renderer/src/components/automations/AutomationRunHistory.tsxsrc/renderer/src/components/dashboard-popout/AgentKanbanCard.test.tsxsrc/renderer/src/components/dashboard-popout/AgentKanbanCard.tsxsrc/renderer/src/components/dashboard-popout/AgentTerminalDialog.tsxsrc/renderer/src/components/dashboard/DashboardAgentRow.context-pressure.test.tsxsrc/renderer/src/components/dashboard/DashboardAgentRow.tsxsrc/renderer/src/components/dashboard/build-dashboard-snapshot.test.tssrc/renderer/src/components/dashboard/build-dashboard-snapshot.tssrc/renderer/src/components/dashboard/dashboard-card-context-pressure.tssrc/renderer/src/components/dashboard/dashboard-snapshot-card-fields.tssrc/renderer/src/components/right-sidebar/AiVaultPanel.tsxsrc/renderer/src/components/right-sidebar/AiVaultSessionRow.tsxsrc/renderer/src/components/right-sidebar/AiVaultSessionVirtualList.tsxsrc/renderer/src/components/right-sidebar/ai-vault-original-pane-actions.tssrc/renderer/src/components/right-sidebar/ai-vault-original-pane-index.tssrc/renderer/src/components/settings/ContextPressureExperimentalSetting.tsxsrc/renderer/src/components/settings/ContextPressureSoftLimitsEditor.tsxsrc/renderer/src/components/settings/ExperimentalPane.test.tsxsrc/renderer/src/components/settings/ExperimentalPane.tsxsrc/renderer/src/components/settings/context-pressure-search-entry.tssrc/renderer/src/components/settings/experimental-search.tssrc/renderer/src/components/sidebar/WorktreeCard.context-pressure.test.tsxsrc/renderer/src/components/sidebar/WorktreeCard.tsxsrc/renderer/src/components/sidebar/WorktreeCardDisplayMenuSection.tsxsrc/renderer/src/components/sidebar/context-pressure-selection.test.tssrc/renderer/src/components/sidebar/context-pressure-selection.tssrc/renderer/src/components/sidebar/sidebar-workspace-option-items.test.tssrc/renderer/src/components/sidebar/sidebar-workspace-option-items.tssrc/renderer/src/components/sidebar/worktree-card-compact-agent-row.context-pressure.test.tsxsrc/renderer/src/components/sidebar/worktree-card-compact-agent-row.tsxsrc/renderer/src/components/sidebar/worktree-card-display-property-options.tssrc/renderer/src/components/tab-bar/SortableTab.context-pressure.test.tsxsrc/renderer/src/components/tab-bar/SortableTab.tsxsrc/renderer/src/components/tab-bar/TerminalTabContextPressure.tsxsrc/renderer/src/hooks/useIpcEvents.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/runtime/sync-runtime-graph-agent-status-projection.test.tssrc/renderer/src/runtime/sync-runtime-graph.tssrc/renderer/src/runtime/web-session-tabs-sync.test.tssrc/renderer/src/runtime/web-session-tabs-sync.tssrc/renderer/src/store/slices/agent-status.test.tssrc/renderer/src/store/slices/agent-status.tssrc/renderer/src/web/web-preload-api.test.tssrc/shared/agent-context-pressure.test.tssrc/shared/agent-context-pressure.tssrc/shared/agent-hook-listener.tssrc/shared/agent-hook-relay.test.tssrc/shared/agent-hook-relay.tssrc/shared/agent-status-types.test.tssrc/shared/agent-status-types.tssrc/shared/claude-statusline-context-window.test.tssrc/shared/claude-statusline-context-window.tssrc/shared/codex-rollout-context-usage.test.tssrc/shared/codex-rollout-context-usage.tssrc/shared/codex-subagent-transcript.test.tssrc/shared/codex-subagent-transcript.tssrc/shared/constants.test.tssrc/shared/constants.tssrc/shared/dashboard-snapshot.tssrc/shared/model-context-windows.test.tssrc/shared/model-context-windows.tssrc/shared/runtime-types.tssrc/shared/telemetry-events.tssrc/shared/types.tssrc/shared/worktree-card-properties.test.tssrc/shared/worktree-card-properties.ts
7806686 to
1324598
Compare
1324598 to
74e2dee
Compare
left a comment
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
src/renderer/src/components/settings/ContextPressureSoftLimitsEditor.tsx (1)
219-242: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winCollision branch still doesn't revert stale draft values.
On a key collision,
commit()setsduplicatebut returns without restoringkeyDraft/tokensDraftto the persistedentryKey/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 valueInconsistent Claude-only gating for the statusline rewrite.
install(),installRemote(), andremove()all guard statusline work behindthis.options.agent === 'claude'("the statusline usage feed is Claude-only"), butsetContextPressureEnabledcallsrewriteManagedClaudeStatusLineunconditionally. 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 winNo cross-validation between
contextPressureWarnPercentandcontextPressureCriticalPercent.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 clampingcontextPressureCriticalPercentto 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 winCover the new conditional option paths with tests.
Add assertions for enabled and disabled
contextPressureEnabledin bothnewCardStylebranches, verifying thatcontext-pressureappears 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 winCondense 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.jsonmobile/src/components/ContextPressureDot.tsxmobile/src/components/WorktreeAgentRow.tsxmobile/src/components/WorktreeListRow.test.tsmobile/src/components/WorktreeListRow.tsxmobile/src/worktree/context-pressure-display.test.tsmobile/src/worktree/context-pressure-display.tsmobile/src/worktree/worktree-list-snapshot.test.tsmobile/src/worktree/worktree-list-snapshot.tssrc/main/agent-hooks/managed-hook-stdin-lifecycle.test.tssrc/main/agent-hooks/server-codex-context-usage.test.tssrc/main/agent-hooks/server-context-usage.test.tssrc/main/agent-hooks/server.tssrc/main/agent-hooks/wsl-hook-relay-manager.test.tssrc/main/agent-hooks/wsl-hook-relay-manager.tssrc/main/agent-hooks/wsl-hook-relay-state.tssrc/main/claude/hook-service.test.tssrc/main/claude/hook-service.tssrc/main/claude/statusline-script.test.tssrc/main/claude/statusline-script.tssrc/main/claude/statusline-toggle.tssrc/main/index.tssrc/main/ipc/dashboard-payload-validation.test.tssrc/main/ipc/dashboard-payload-validation.tssrc/main/persistence.test.tssrc/main/persistence.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/ui-state-schema-parity-checks.tssrc/main/ssh/ssh-relay-session-agent-hooks.integration.test.tssrc/main/ssh/ssh-relay-session.test.tssrc/main/ssh/ssh-relay-session.tssrc/relay/agent-hook-server-codex-subagent-transcript.test.tssrc/relay/agent-hook-server.test.tssrc/relay/agent-hook-server.tssrc/relay/relay.tssrc/renderer/src/components/ContextPressureIndicator.test.tsxsrc/renderer/src/components/ContextPressureIndicator.tsxsrc/renderer/src/components/automations/AutomationRunContextPressure.test.tsxsrc/renderer/src/components/automations/AutomationRunContextPressure.tsxsrc/renderer/src/components/automations/AutomationRunHistory.tsxsrc/renderer/src/components/dashboard-popout/AgentKanbanCard.test.tsxsrc/renderer/src/components/dashboard-popout/AgentKanbanCard.tsxsrc/renderer/src/components/dashboard-popout/AgentTerminalDialog.tsxsrc/renderer/src/components/dashboard/DashboardAgentRow.context-pressure.test.tsxsrc/renderer/src/components/dashboard/DashboardAgentRow.tsxsrc/renderer/src/components/dashboard/build-dashboard-snapshot.test.tssrc/renderer/src/components/dashboard/build-dashboard-snapshot.tssrc/renderer/src/components/dashboard/dashboard-card-context-pressure.tssrc/renderer/src/components/dashboard/dashboard-snapshot-card-fields.tssrc/renderer/src/components/right-sidebar/AiVaultPanel.tsxsrc/renderer/src/components/right-sidebar/AiVaultSessionRow.tsxsrc/renderer/src/components/right-sidebar/AiVaultSessionVirtualList.tsxsrc/renderer/src/components/right-sidebar/ai-vault-original-pane-actions.tssrc/renderer/src/components/right-sidebar/ai-vault-original-pane-index.tssrc/renderer/src/components/settings/ContextPressureExperimentalSetting.tsxsrc/renderer/src/components/settings/ContextPressureSoftLimitsEditor.tsxsrc/renderer/src/components/settings/ExperimentalPane.test.tsxsrc/renderer/src/components/settings/ExperimentalPane.tsxsrc/renderer/src/components/settings/context-pressure-search-entry.tssrc/renderer/src/components/settings/experimental-search.tssrc/renderer/src/components/sidebar/WorktreeCard.context-pressure.test.tsxsrc/renderer/src/components/sidebar/WorktreeCard.tsxsrc/renderer/src/components/sidebar/WorktreeCardDisplayMenuSection.tsxsrc/renderer/src/components/sidebar/context-pressure-selection.test.tssrc/renderer/src/components/sidebar/context-pressure-selection.tssrc/renderer/src/components/sidebar/sidebar-workspace-option-items.test.tssrc/renderer/src/components/sidebar/sidebar-workspace-option-items.tssrc/renderer/src/components/sidebar/worktree-card-compact-agent-row.context-pressure.test.tsxsrc/renderer/src/components/sidebar/worktree-card-compact-agent-row.tsxsrc/renderer/src/components/sidebar/worktree-card-display-property-options.tssrc/renderer/src/components/tab-bar/SortableTab.context-pressure.test.tsxsrc/renderer/src/components/tab-bar/SortableTab.tsxsrc/renderer/src/components/tab-bar/TerminalTabContextPressure.tsxsrc/renderer/src/hooks/useIpcEvents.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/runtime/sync-runtime-graph-agent-status-projection.test.tssrc/renderer/src/runtime/sync-runtime-graph.tssrc/renderer/src/runtime/web-session-tabs-sync.test.tssrc/renderer/src/runtime/web-session-tabs-sync.tssrc/renderer/src/store/slices/agent-status.test.tssrc/renderer/src/store/slices/agent-status.tssrc/renderer/src/web/web-preload-api.test.tssrc/shared/agent-context-pressure.test.tssrc/shared/agent-context-pressure.tssrc/shared/agent-hook-listener.tssrc/shared/agent-hook-relay.test.tssrc/shared/agent-hook-relay.tssrc/shared/agent-status-types.test.tssrc/shared/agent-status-types.tssrc/shared/claude-statusline-context-window.test.tssrc/shared/claude-statusline-context-window.tssrc/shared/codex-rollout-context-usage.test.tssrc/shared/codex-rollout-context-usage.tssrc/shared/codex-subagent-transcript.test.tssrc/shared/codex-subagent-transcript.tssrc/shared/constants.test.tssrc/shared/constants.tssrc/shared/dashboard-snapshot.tssrc/shared/model-context-windows.test.tssrc/shared/model-context-windows.tssrc/shared/runtime-types.tssrc/shared/telemetry-events.tssrc/shared/types.tssrc/shared/worktree-card-properties.test.tssrc/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
left a comment
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/main/claude/statusline-script.ts (1)
90-117: 📐 Maintainability & Code Quality | 🔵 Trivial
contextPressureEnabledis a no-op fortarget === 'posix'.The POSIX case-guard (Lines 101-102) always emits both
rate_limits/context_windowmatches with the runtime$ORCA_CONTEXT_PRESSURE_ENABLEDcheck, regardless of thecontextPressureEnabledargument — only thetarget !== 'posix'branch (Lines 105-108) and the Windows findstr branch honor it. SinceinstallRemoteClaudeStatusLinepassesthis.contextPressureEnabledintogetManagedStatusLineScript('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 forposixwould prevent future confusion.mobile/src/worktree/context-pressure-display.ts (1)
6-9: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCondense 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.jsonmobile/src/components/ContextPressureDot.tsxmobile/src/components/WorktreeAgentRow.tsxmobile/src/components/WorktreeListRow.test.tsmobile/src/components/WorktreeListRow.tsxmobile/src/worktree/context-pressure-display.test.tsmobile/src/worktree/context-pressure-display.tsmobile/src/worktree/worktree-list-snapshot.test.tsmobile/src/worktree/worktree-list-snapshot.tssrc/main/agent-hooks/managed-hook-stdin-lifecycle.test.tssrc/main/agent-hooks/server-codex-context-usage.test.tssrc/main/agent-hooks/server-context-usage.test.tssrc/main/agent-hooks/server.tssrc/main/agent-hooks/wsl-hook-relay-manager.test.tssrc/main/agent-hooks/wsl-hook-relay-manager.tssrc/main/agent-hooks/wsl-hook-relay-state.tssrc/main/claude/hook-service.test.tssrc/main/claude/hook-service.tssrc/main/claude/statusline-script.test.tssrc/main/claude/statusline-script.tssrc/main/claude/statusline-toggle.tssrc/main/index.tssrc/main/ipc/dashboard-payload-validation.test.tssrc/main/ipc/dashboard-payload-validation.tssrc/main/persistence.test.tssrc/main/persistence.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/ui-state-schema-parity-checks.tssrc/main/ssh/ssh-relay-session-agent-hooks.integration.test.tssrc/main/ssh/ssh-relay-session.test.tssrc/main/ssh/ssh-relay-session.tssrc/relay/agent-hook-server-codex-subagent-transcript.test.tssrc/relay/agent-hook-server.test.tssrc/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
55a1e13 to
6f8200c
Compare
left a comment
There was a problem hiding this comment.
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 winRemove the unused duplicate
jiraReadStatusmethod.
jiraReadStatusis not referenced elsewhere and duplicatesjiraStatus; 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 winRemote statusline filename still gated by the local box's
process.platform, not the remote host.
getStatusLineScriptFileName()branches onprocess.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 siblingremoteScriptFileNameline right above it, which correctly calls the POSIX-specificgetPosixManagedScriptFileName. A Windows client managing an SSH remote would compute…statusline.cmdfor a POSIX shell script, while a Mac/Linux client managing the same remote would compute…statusline.sh;getStatusLineSlotState/removeManagedStatusLinethen 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.tsAlso applies to: 275-283
🧹 Nitpick comments (1)
src/main/claude/statusline-script.ts (1)
90-118: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
contextPressureEnabledparameter is a no-op whentarget === 'posix'.The posix branch never reads
contextPressureEnabled; it always emits both case patterns and defers to the runtime$ORCA_CONTEXT_PRESSURE_ENABLEDenv var instead. That's a reasonable design (remote reads a live flag), butinstallRemoteClaudeStatusLine(statusline-toggle.ts) still threads a real boolean intogetManagedStatusLineScript('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 fortarget === '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.jsonmobile/src/components/ContextPressureDot.tsxmobile/src/components/WorktreeAgentRow.tsxmobile/src/components/WorktreeListRow.test.tsmobile/src/components/WorktreeListRow.tsxmobile/src/components/context-pressure-copy.test.tsmobile/src/components/context-pressure-copy.tsmobile/src/worktree/context-pressure-display.test.tsmobile/src/worktree/context-pressure-display.tsmobile/src/worktree/worktree-list-snapshot.test.tsmobile/src/worktree/worktree-list-snapshot.tssrc/main/agent-hooks/managed-hook-stdin-lifecycle.test.tssrc/main/agent-hooks/server-codex-context-usage.test.tssrc/main/agent-hooks/server-context-usage.test.tssrc/main/agent-hooks/server.tssrc/main/agent-hooks/wsl-hook-relay-manager.test.tssrc/main/agent-hooks/wsl-hook-relay-manager.tssrc/main/agent-hooks/wsl-hook-relay-state.tssrc/main/claude/hook-service.test.tssrc/main/claude/hook-service.tssrc/main/claude/statusline-script.test.tssrc/main/claude/statusline-script.tssrc/main/claude/statusline-toggle.tssrc/main/index.tssrc/main/ipc/dashboard-payload-validation.test.tssrc/main/ipc/dashboard-payload-validation.tssrc/main/persistence.test.tssrc/main/persistence.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/ui-state-schema-parity-checks.tssrc/main/ssh/ssh-relay-session-agent-hooks.integration.test.tssrc/main/ssh/ssh-relay-session.test.tssrc/main/ssh/ssh-relay-session.tssrc/relay/agent-hook-server-codex-subagent-transcript.test.tssrc/relay/agent-hook-server.test.tssrc/relay/agent-hook-server.tssrc/relay/relay.tssrc/renderer/src/components/ContextPressureIndicator.test.tsxsrc/renderer/src/components/ContextPressureIndicator.tsxsrc/renderer/src/components/automations/AutomationRunContextPressure.test.tsxsrc/renderer/src/components/automations/AutomationRunContextPressure.tsxsrc/renderer/src/components/automations/AutomationRunHistory.tsxsrc/renderer/src/components/dashboard-popout/AgentKanbanCard.test.tsxsrc/renderer/src/components/dashboard-popout/AgentKanbanCard.tsxsrc/renderer/src/components/dashboard-popout/AgentTerminalDialog.tsxsrc/renderer/src/components/dashboard/DashboardAgentRow.context-pressure.test.tsxsrc/renderer/src/components/dashboard/DashboardAgentRow.tsxsrc/renderer/src/components/dashboard/build-dashboard-snapshot.test.tssrc/renderer/src/components/dashboard/build-dashboard-snapshot.tssrc/renderer/src/components/dashboard/dashboard-card-context-pressure.tssrc/renderer/src/components/dashboard/dashboard-snapshot-card-fields.tssrc/renderer/src/components/right-sidebar/AiVaultPanel.tsxsrc/renderer/src/components/right-sidebar/AiVaultSessionRow.tsxsrc/renderer/src/components/right-sidebar/AiVaultSessionVirtualList.tsxsrc/renderer/src/components/right-sidebar/ai-vault-original-pane-actions.tssrc/renderer/src/components/right-sidebar/ai-vault-original-pane-index.tssrc/renderer/src/components/settings/ContextPressureExperimentalSetting.tsxsrc/renderer/src/components/settings/ContextPressureSoftLimitsEditor.tsxsrc/renderer/src/components/settings/ExperimentalPane.test.tsxsrc/renderer/src/components/settings/ExperimentalPane.tsxsrc/renderer/src/components/settings/context-pressure-search-entry.tssrc/renderer/src/components/settings/experimental-search.tssrc/renderer/src/components/sidebar/WorktreeCard.context-pressure.test.tsxsrc/renderer/src/components/sidebar/WorktreeCard.tsxsrc/renderer/src/components/sidebar/WorktreeCardDisplayMenuSection.tsxsrc/renderer/src/components/sidebar/context-pressure-selection.test.tssrc/renderer/src/components/sidebar/context-pressure-selection.tssrc/renderer/src/components/sidebar/sidebar-workspace-option-items.test.tssrc/renderer/src/components/sidebar/sidebar-workspace-option-items.tssrc/renderer/src/components/sidebar/worktree-card-compact-agent-row.context-pressure.test.tsxsrc/renderer/src/components/sidebar/worktree-card-compact-agent-row.tsxsrc/renderer/src/components/sidebar/worktree-card-display-property-options.tssrc/renderer/src/components/tab-bar/SortableTab.context-pressure.test.tsxsrc/renderer/src/components/tab-bar/SortableTab.tsxsrc/renderer/src/components/tab-bar/TerminalTabContextPressure.tsxsrc/renderer/src/hooks/useIpcEvents.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/runtime/sync-runtime-graph-agent-status-projection.test.tssrc/renderer/src/runtime/sync-runtime-graph.tssrc/renderer/src/runtime/web-session-tabs-sync.test.tssrc/renderer/src/runtime/web-session-tabs-sync.tssrc/renderer/src/store/slices/agent-status.test.tssrc/renderer/src/store/slices/agent-status.tssrc/renderer/src/web/web-preload-api.test.tssrc/shared/agent-context-pressure.test.tssrc/shared/agent-context-pressure.tssrc/shared/agent-hook-listener.tssrc/shared/agent-hook-relay.test.tssrc/shared/agent-hook-relay.tssrc/shared/agent-status-types.test.tssrc/shared/agent-status-types.tssrc/shared/claude-statusline-context-window.test.tssrc/shared/claude-statusline-context-window.tssrc/shared/codex-rollout-context-usage.test.tssrc/shared/codex-rollout-context-usage.tssrc/shared/codex-subagent-transcript.test.tssrc/shared/codex-subagent-transcript.tssrc/shared/constants.test.tssrc/shared/constants.tssrc/shared/dashboard-snapshot.tssrc/shared/model-context-windows.test.tssrc/shared/model-context-windows.tssrc/shared/runtime-types.tssrc/shared/telemetry-events.tssrc/shared/types.tssrc/shared/worktree-card-properties.test.tssrc/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
6f8200c to
9b83854
Compare
left a comment
There was a problem hiding this comment.
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 winTwo aggregation points blank a known
contextUsagereading when a fresher status ping omits it. Both sites pick the "freshest" status/hook entry and copy itscontextUsageverbatim, but neither falls back to the previously known value when the new one isundefined— unlikeretainAgentRowSnapshot(L9795-L9804), which explicitly carriescontextUsageforward across such gaps for the same data.
src/main/runtime/orca-runtime.ts#L15887-L15893: inconsider(getFreshExplicitAgentStatusForHandle), fall back to the previousbestContextUsagewhen the winning entry'scontextUsageisundefined.src/main/runtime/orca-runtime.ts#L16723-L16737: in the hook-merge loop (attachAgentRowsToSummaries), fall back toexisting?.contextUsagewhenentry.contextUsageisundefined.
3130-3130: 🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick winScope terminal side-effect availability to terminal-side-effect listeners only.
runtime.clientEvents.subscribesubscribes once per RPC stream and dispatches allRuntimeClientEventtypes on that singleclientEventListenerssink, including client-surface repo/worktree/SSH events. That keepsterminalSideEffectConsumerAvailabletrue and rebuilds per-PTY scanners even when no subscriber needsterminalSideEffects. 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 winUse a semantic localization key.
Replace
search.0d24759f14with a descriptivecontextPressure-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 valueTest name overstates what the
posixtarget honors.
getManagedStatusLineScript('posix', false)ignores the second argument (remote scripts readORCA_CONTEXT_PRESSURE_ENABLEDat 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 valueHoist the repeated settings read.
The same
store.getSettings().experimentalContextPressure === trueexpression 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 valueShorten 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 winAssert that the context-only envelope omits
payload.
rate_limitsis submitted inside the statusline body, so this top-level assertion passes even if raw statusline data is incorrectly forwarded throughpayload.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
contextPressureEnabledhas no effect on the generatedposixscript.For
target === 'posix', the case body always includes thecontext_windowbranch gated by the liveORCA_CONTEXT_PRESSURE_ENABLEDenv var; thecontextPressureEnabledparameter is only consulted in theelse(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 likeinstallRemoteClaudeStatusLine(..., enabled)pass a value that is silently ignored for posix output. A short comment near thegetManagedStatusLineScriptsignature (or on the posix ternary) noting thatcontextPressureEnabledonly 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 winNo test-reset hooks for the three module-level caches.
configCache,worstSnapshotByEntries, andtabPressureIndexCacheare module-scoped singletons with no exported reset function, unlike the siblingcachedAgentStatusProjectioninsync-runtime-graph.ts, which exposesresetRuntimeMobileAgentStatusProjectionCacheForTests()for exactly this purpose. Without an equivalent here, tests in the companioncontext-pressure-selection.test.tscan 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 +}(
worstSnapshotByEntriesis aWeakMap, 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 winConsider covering
sessionIdandproviderIdextraction.Every case here omits
session_idandmodel.provider, yet both drive downstream behavior:sessionIdgatesapplyPaneContextUsage(src/main/agent-hooks/server.ts) and is forwarded ascontextSessionIdby the relay, andproviderIdfeedsprovider:<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.jsonmobile/src/components/ContextPressureDot.tsxmobile/src/components/WorktreeAgentRow.tsxmobile/src/components/WorktreeListRow.test.tsmobile/src/components/WorktreeListRow.tsxmobile/src/components/context-pressure-copy.test.tsmobile/src/components/context-pressure-copy.tsmobile/src/worktree/context-pressure-display.test.tsmobile/src/worktree/context-pressure-display.tsmobile/src/worktree/worktree-list-snapshot.test.tsmobile/src/worktree/worktree-list-snapshot.tssrc/main/agent-hooks/managed-hook-stdin-lifecycle.test.tssrc/main/agent-hooks/server-codex-context-usage.test.tssrc/main/agent-hooks/server-context-usage.test.tssrc/main/agent-hooks/server.tssrc/main/agent-hooks/wsl-hook-relay-manager.test.tssrc/main/agent-hooks/wsl-hook-relay-manager.tssrc/main/agent-hooks/wsl-hook-relay-state.tssrc/main/claude/hook-service.test.tssrc/main/claude/hook-service.tssrc/main/claude/statusline-script.test.tssrc/main/claude/statusline-script.tssrc/main/claude/statusline-toggle.tssrc/main/index.tssrc/main/ipc/dashboard-payload-validation.test.tssrc/main/ipc/dashboard-payload-validation.tssrc/main/persistence.test.tssrc/main/persistence.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/ui-state-schema-parity-checks.tssrc/main/ssh/ssh-relay-session-agent-hooks.integration.test.tssrc/main/ssh/ssh-relay-session.test.tssrc/main/ssh/ssh-relay-session.tssrc/relay/agent-hook-server-codex-subagent-transcript.test.tssrc/relay/agent-hook-server.test.tssrc/relay/agent-hook-server.tssrc/relay/relay.tssrc/renderer/src/components/ContextPressureIndicator.test.tsxsrc/renderer/src/components/ContextPressureIndicator.tsxsrc/renderer/src/components/automations/AutomationRunContextPressure.test.tsxsrc/renderer/src/components/automations/AutomationRunContextPressure.tsxsrc/renderer/src/components/automations/AutomationRunHistory.tsxsrc/renderer/src/components/dashboard-popout/AgentKanbanCard.test.tsxsrc/renderer/src/components/dashboard-popout/AgentKanbanCard.tsxsrc/renderer/src/components/dashboard-popout/AgentTerminalDialog.tsxsrc/renderer/src/components/dashboard/DashboardAgentRow.context-pressure.test.tsxsrc/renderer/src/components/dashboard/DashboardAgentRow.tsxsrc/renderer/src/components/dashboard/build-dashboard-snapshot.test.tssrc/renderer/src/components/dashboard/build-dashboard-snapshot.tssrc/renderer/src/components/dashboard/dashboard-card-context-pressure.tssrc/renderer/src/components/dashboard/dashboard-snapshot-card-fields.tssrc/renderer/src/components/right-sidebar/AiVaultPanel.tsxsrc/renderer/src/components/right-sidebar/AiVaultSessionRow.tsxsrc/renderer/src/components/right-sidebar/AiVaultSessionVirtualList.tsxsrc/renderer/src/components/right-sidebar/ai-vault-original-pane-actions.tssrc/renderer/src/components/right-sidebar/ai-vault-original-pane-index.tssrc/renderer/src/components/settings/ContextPressureExperimentalSetting.tsxsrc/renderer/src/components/settings/ContextPressureSoftLimitsEditor.tsxsrc/renderer/src/components/settings/ExperimentalPane.test.tsxsrc/renderer/src/components/settings/ExperimentalPane.tsxsrc/renderer/src/components/settings/context-pressure-search-entry.tssrc/renderer/src/components/settings/experimental-search.tssrc/renderer/src/components/sidebar/WorktreeCard.context-pressure.test.tsxsrc/renderer/src/components/sidebar/WorktreeCard.tsxsrc/renderer/src/components/sidebar/WorktreeCardDisplayMenuSection.tsxsrc/renderer/src/components/sidebar/context-pressure-selection.test.tssrc/renderer/src/components/sidebar/context-pressure-selection.tssrc/renderer/src/components/sidebar/sidebar-workspace-option-items.test.tssrc/renderer/src/components/sidebar/sidebar-workspace-option-items.tssrc/renderer/src/components/sidebar/worktree-card-compact-agent-row.context-pressure.test.tsxsrc/renderer/src/components/sidebar/worktree-card-compact-agent-row.tsxsrc/renderer/src/components/sidebar/worktree-card-display-property-options.tssrc/renderer/src/components/tab-bar/SortableTab.context-pressure.test.tsxsrc/renderer/src/components/tab-bar/SortableTab.tsxsrc/renderer/src/components/tab-bar/TerminalTabContextPressure.tsxsrc/renderer/src/hooks/useIpcEvents.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/runtime/sync-runtime-graph-agent-status-projection.test.tssrc/renderer/src/runtime/sync-runtime-graph.tssrc/renderer/src/runtime/web-session-tabs-sync.test.tssrc/renderer/src/runtime/web-session-tabs-sync.tssrc/renderer/src/store/slices/agent-status.test.tssrc/renderer/src/store/slices/agent-status.tssrc/renderer/src/web/web-preload-api.test.tssrc/shared/agent-context-pressure.test.tssrc/shared/agent-context-pressure.tssrc/shared/agent-hook-listener.tssrc/shared/agent-hook-relay.test.tssrc/shared/agent-hook-relay.tssrc/shared/agent-status-types.test.tssrc/shared/agent-status-types.tssrc/shared/claude-statusline-context-window.test.tssrc/shared/claude-statusline-context-window.tssrc/shared/codex-rollout-context-usage.test.tssrc/shared/codex-rollout-context-usage.tssrc/shared/codex-subagent-transcript.test.tssrc/shared/codex-subagent-transcript.tssrc/shared/constants.test.tssrc/shared/constants.tssrc/shared/dashboard-snapshot.tssrc/shared/model-context-windows.test.tssrc/shared/model-context-windows.tssrc/shared/runtime-types.tssrc/shared/telemetry-events.tssrc/shared/types.tssrc/shared/worktree-card-properties.test.tssrc/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
| 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' }) |
There was a problem hiding this comment.
🎯 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.
9d89459 to
c47a823
Compare
cc4c828 to
356b8e6
Compare
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.
356b8e6 to
5f5ddf9
Compare
commented
Aug 1, 2026
|
Taking a look! |
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.
- 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.
commented
Aug 1, 2026
|
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):
Known accepted behaviors (documented, by design):
Verification (exact head 9fad190 = your commit + 7 maintainer commits, fast-forward):
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). |
















Summary
Testing
pnpm run typecheckpnpm run lintpnpm run check:max-lines-ratchetgit diff --checkAI Review Report
Closes #11225