agent-host: log subscribe + state replay in IPC output channel#314916
Draft
roblourens wants to merge 2 commits intomainfrom
Draft
agent-host: log subscribe + state replay in IPC output channel#314916roblourens wants to merge 2 commits intomainfrom
roblourens wants to merge 2 commits intomainfrom
Conversation
The LoggingAgentConnection wrapper was passing getSubscription through unwrapped, so neither the subscribe call nor the snapshot/state replay that the server sends back surfaced in the per-host output channel. Wrap the returned subscription with a logger that emits a one-shot .current line (if already hydrated) and an .onDidChange line per state change. Refcount the logger per inner subscription instance so multiple wrappers (e.g. chat + terminal) sharing the same underlying sub still only log once, and tear it down with the last ref. Also log >> subscribe and >> unsubscribe at the call sites. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Base:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the agent-host IPC tracing wrapper (LoggingAgentConnection) so that getSubscription(...) calls are logged to the per-host output channel, including initial hydration/current state and subsequent state replay via onDidChange.
Changes:
- Wrap
getSubscription(...)to logsubscribe/unsubscribecalls and state changes (current+onDidChange). - Deduplicate per-subscription
onDidChangelogging across multiple wrappers via a staticWeakMaprefcount.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/loggingAgentConnection.ts | Adds logging + deduped refcounted listeners for state subscriptions to surface snapshot/state replay in the output channel. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 2
| * onDidChange logger per inner subscription and dispose it when the last | ||
| * wrapper goes away. | ||
| */ | ||
| private static readonly _subscriptionLoggers = new WeakMap<IAgentSubscription<unknown>, { refCount: number; store: DisposableStore }>(); |
Comment on lines
+232
to
+237
| const store = new DisposableStore(); | ||
| const label = `${kind}(${resource.toString()})`; | ||
| if (sub.value !== undefined) { | ||
| this._log('**', `${label}.current`, sub.value); | ||
| } | ||
| store.add(sub.onDidChange(value => this._log('**', `${label}.onDidChange`, value))); |
Map StateComponents (numeric const enum) to 'root'/'session'/'terminal' strings before logging, and widen the static WeakMap key type to `object` so it accepts subscriptions with any `T` parameter. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
449a32e to
69e3c70
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
LoggingAgentConnectionwrapper was passinggetSubscriptionthrough unwrapped, so neither the subscribe call nor the snapshot/state replay the server sends back surfaced in the per-host output channel. When opening a session, the channel showed nothing for the subscription handshake.Wrap the returned subscription with a logger that emits:
>> subscribe { kind, resource }whengetSubscriptionis called** <kind>(<resource>).currentif the inner sub is already hydrated** <kind>(<resource>).onDidChangeon each value change (this is what surfaces the server snapshot / state replay)>> unsubscribe { kind, resource }on ref disposeRefcount the logger per inner
IAgentSubscriptioninstance via a staticWeakMapso multiple wrappers (e.g. chat + terminal) sharing the same underlying sub still only log once, and the listener is torn down with the last ref.No-op when
agentHost.ipcLoggingis disabled.