feat: feed the context donut from _x.ai/session/info (control-plane, no window cost) - #80
Open
funkpopo wants to merge 4 commits into
Open
feat: feed the context donut from _x.ai/session/info (control-plane, no window cost)#80funkpopo wants to merge 4 commits into
_x.ai/session/info (control-plane, no window cost)#80funkpopo wants to merge 4 commits into
Conversation
…, no window cost)
…ng _meta.totalTokens from streaming session/update.
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.
Wire the context donut (and its popover) to the CLI’s control-plane
_x.ai/session/infoRPC so we can show an accurate, structured windowbreakdown without spending a model turn or inflating the context window.
Today the donut mostly rides turn-end
_meta.totalTokens, withsignals.json+ a hidden/session-infoprompt as backups. That worksfor a single “used / window” number, but:
/compactstill lag or need a prompt scrape on older paths;/session-infoprompt is a real inference turn on CLIs that lack the rail — wasteful and easy to get wrong.Grok CLI ≥ ~0.2.112 exposes
_x.ai/session/infoas a meter, not a prompt:repeated calls do not bill, do not append chat history, and do not grow
context.used(probe-verified). This PR prefers that path whenever themethod exists, and keeps the existing sources as an ordered fallback.
What changed
Host / ACP
AcpClient.getSessionInfo()→_x.ai/session/info; returns"unsupported"on
-32601so older CLIs (incl. the Windows pin) degrade cleanly.acp-dispatch.ts:parseSessionInfoRpcResult(flat or one-level nestedresult)sessionInfoCacheFresh+SESSION_INFO_TTL_MS(3s) so popover spamdoesn’t hammer the process
lastSessionInfoAt,sessionInfoUnsupported(reset on a fresh process)
Refresh policy (priority)
auto_compact_completed— still the live “used” path mid-session_x.ai/session/info— structured snapshot (used + window + breakdown)signals.json— cold / disk seed/session-infoprompt — legacy only when the RPC is missingCalled on:
session/load(disk first, then upgrade via session/info)refreshContextDetails, TTL-gated)/compactwhen the live rail didn’t fireWebview
contextUsagegains optional breakdown fields(
systemPromptTokens,toolDefinitionsTokens,messageTokens,freeTokens,categories[],autoCompactThresholdPercent).Skills / MCP / Free / Auto-compact at).
refreshContextDetails; an open popoverre-renders when a structured snapshot arrives.
Protocol / remote
refreshContextDetailsadded toWebviewMsg+ remote policy (view).protocol.ts.