Skip to content

Enhance session handling and update provider limit logic#9

Merged
koltyakov merged 5 commits into
mainfrom
dev
May 9, 2026
Merged

Enhance session handling and update provider limit logic#9
koltyakov merged 5 commits into
mainfrom
dev

Conversation

@koltyakov
Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings May 9, 2026 00:08
@koltyakov koltyakov merged commit d0651ee into main May 9, 2026
5 checks passed
@koltyakov koltyakov deleted the dev branch May 9, 2026 00:08
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the webview’s session/thread rendering and provider-limit polling/visibility logic, while also adding targeted performance improvements (virtualization rebuilds, sanitization caching) and enhancing Anthropic provider-limit status aggregation.

Changes:

  • Scope message rendering and sticky-preview behavior to the active session thread (including special handling for child/subagent sessions) and refine assistant final-answer highlighting behavior.
  • Adjust provider-limit defaults/threshold behavior (default threshold → 100%) and refine polling behavior based on whether the active session thread is “working”.
  • Add caching/partial-rebuild optimizations in the webview (virtualization metrics reuse, HTML sanitization cache) and merge Anthropic limit windows across sources.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/webview/perf/session-effects.perf.test.ts Updates perf-guard deps for renamed active-session predicate.
src/webview/lib/state.ts Adds messageInfoVersion, refines message-index callbacks, adjusts session marker writes, permission inheritance lookup, and per-session preference persistence.
src/webview/lib/state-helpers.test.ts Adds tests for permission-mode inheritance and updates provider-limit default threshold assertion.
src/webview/lib/message-index.ts Introduces split callbacks (onInvalidate vs onPartChange) and legacy API compatibility.
src/webview/lib/message-index.test.ts Adds coverage for split-callback behavior and retains legacy single-callback test.
src/webview/lib/format.ts Treats 100% threshold as “show any available limit”.
src/webview/lib/format.test.ts Adds test for 100% threshold behavior.
src/webview/index.css Moves/adjusts overflow-anchor: none to reduce scroll anchoring issues.
src/webview/hooks/session/session-effects.ts Renames hasActiveSessionsisActiveSessionWorking and updates polling interval selection.
src/webview/hooks/session-effects.test.ts Updates tests for renamed dependency and working-session polling behavior.
src/webview/hooks/runtime/open-code-runtime-instance.ts Computes “active session working” across the active session’s tree (root + descendants).
src/webview/components/MessageList.tsx Adds thread-scoped message filtering, introduces messageInfoVersion usage, and optimizes virtualization metrics recomputation.
src/webview/components/MessageList.test.ts Adds tests for session scoping and aborted assistant final-answer formatting behavior.
src/webview/components/message/AssistantMessageContent.tsx Adjusts final-answer container variant logic when structured parts/subagent content is present.
src/webview/components/Message.test.ts Adds regression tests for container variant and final-answer rendering in mixed tool/text cases.
src/webview/components/message-list/virtualization.ts Adds partial rebuild support using cached metrics + dirty index hints.
src/webview/components/message-list/sticky-preview.ts Skips child-session prompts in sticky preview/top map logic.
src/webview/components/message-list/MessageRows.tsx Prevents highlighting final answers for aborted assistant turns.
src/webview/components/MarkdownRenderer.tsx Adds a bounded cache for sanitized HTML output and resets it in test helper.
src/webview/components/MarkdownRenderer.test.ts Updates test to assert sanitization reuse across remounts.
src/shared/provider-limit-config.ts Changes default provider-limit threshold percent from 40 → 100.
src/extension/provider-limits/adapters/anthropic.ts Merges statusline/local-proxy/OAuth statuses and windows; adds helper merge logic.
src/extension/provider-limits/adapters/anthropic.test.ts Adds test for merged statusline + OAuth windows behavior.
package.json Bumps version and updates config default/description for provider-limit threshold.
docs/usage.md Updates provider-limit threshold docs to match new semantics/default.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 371 to +465
@@ -428,6 +451,18 @@ export function MessageList() {

const measuredHeights = new Map<string, number>();
let lastTrackHeight = 0;
let cachedVirtualMetrics: VirtualMetrics | null = null;
let cachedVirtualMetricsItemIds: string[] | null = null;
let dirtyVirtualMetricsFromIndex = Number.POSITIVE_INFINITY;

function markVirtualMetricsDirty(messageId: string) {
if (dirtyVirtualMetricsFromIndex === 0) return;
const index = messageIndexById().get(messageId);
if (typeof index !== 'number') return;
if (index < dirtyVirtualMetricsFromIndex) {
dirtyVirtualMetricsFromIndex = index;
}
}
Comment on lines 22 to 35
for (let i = firstVisibleMessageIndex; i >= 0; i--) {
const entry = messages[i];
if (!entry) continue;
if (entry.info.role !== 'user') continue;
const session = entry.info.sessionID;
const isChildSessionPrompt = messages.some(
(candidate) =>
candidate.info.sessionID === session &&
candidate.info.role === 'assistant' &&
'mode' in candidate.info &&
candidate.info.mode === 'subagent'
);
if (isChildSessionPrompt) continue;
const text = getUserMessagePreviewText(entry.parts);
Comment on lines 54 to +68
for (let index = messages.length - 1; index >= 0; index -= 1) {
const entry = messages[index];
result.set(entry.info.id, nextVisibleUserMessageTop);
if (entry.info.role !== 'user') continue;

const session = entry.info.sessionID;
const isChildSessionPrompt = messages.some(
(candidate) =>
candidate.info.sessionID === session &&
candidate.info.role === 'assistant' &&
'mode' in candidate.info &&
candidate.info.mode === 'subagent'
);
if (isChildSessionPrompt) continue;

Comment on lines +206 to +216
if (primary.status !== 'available') return secondary;
if (secondary.status !== 'available') return primary;

const windows = mergeAnthropicWindows(primary.windows, secondary.windows);
const note = [primary.note, secondary.note].filter(Boolean).join(' + ') || undefined;
return {
...primary,
checkedAt: Math.max(primary.checkedAt, secondary.checkedAt),
windows,
...(note ? { note } : {}),
};
sanitizeHtmlCache.set(html, result);
if (sanitizeHtmlCache.size > SANITIZE_CACHE_LIMIT) {
const oldest = sanitizeHtmlCache.keys().next().value;
if (oldest) sanitizeHtmlCache.delete(oldest);
Comment on lines +189 to +203
function shouldHideThreadMessage(
entry: { info: Message; parts: Part[] },
activeSessionId: string | null
) {
if (!activeSessionId) return false;

const activeTreeIds = new Set(getSessionTreeIds(activeSessionId));
if (!activeTreeIds.has(entry.info.sessionID)) return true;

if (entry.info.role !== 'user') return false;
if (entry.info.sessionID === activeSessionId) return false;

const session = state.sessions.find((item) => item.id === entry.info.sessionID);
return !!session?.parentID;
}
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.

2 participants