Repository navigation
feat: show how full Claude's context is on the session page - #224
Merged
kalaspuff merged 4 commits intoOct 23, 2026
Merged
Conversation
fctl-agent asks Claude Code for a summary of its context (get_context_usage) once Claude has started and after each turn, and reports the window and the auto-compact threshold in the session state. SessionDO keeps them in the session's stats, with the context the conversation's latest API call had (its input, cached or not, as Claude Code's status line counts it) and the compactions Claude made.
The Work section of the session page shows the context against the window, a meter split where Claude compacts the conversation, amber nine tenths of the way there, and how often it compacted; fctl show says the same. fake-claude grows its context with each call, compacts at 167K of its 200K window or on 'compact', fills it on 'context <tokens>' and answers get_context_usage.
…section-in-the-right-sidebar # Conflicts: # crates/fake-claude/src/main.rs # docs/development.md
kalaspuff
approved these changes
Oct 23, 2026
kalaspuff
deleted the
fctl/149-in-the-work-section-in-the-right-sidebar
branch
October 23, 2026 06:21
fctl-sh Bot
added a commit
that referenced
this pull request
Oct 23, 2026
#226 posts a review's summary as a comment before the review that holds its findings on their lines. The findings fctl passes on to the session that opened the pull request now link that summary, and say that findings on lines the diff doesn't show are in it; the review's id, for finding each comment, comes from the review posted after the summary.
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 Work section of the session page now shows how much of Claude's context window the conversation fills, where Claude compacts it on its own, and how often it has, so people can see a session closing in on the limit or on a compaction.
fctl showsays the same.What changed
fctl_domain::events): the input of the conversation's latest API call, cached or not (input_tokens + cache_creation_input_tokens + cache_read_input_tokens), which is how Claude Code's status line counts it. Subagents' calls have contexts of their own and don't count. It moves with each call, as the response starts (message_start) or with the call's first stored message. A compaction (system/compact_boundary) sets it to what the compaction left (post_tokens) until the next call reports, and adds to a count of compactions.get_context_usagecontrol request once Claude has started and after each turn, as it already does for the effort level. It passesdetail: "summary", so Claude answers from the last call's usage and its own estimates, with no token-count API calls. fctl-agent reportsmaxTokensandautoCompactThresholdin the session state (ContextWindow). It reports no threshold when auto-compact is off, or when Claude leaves compaction to the API (autocompactSource: "auto", where Claude's own/contextshows no buffer either). SessionDO keeps them in the session's stats (context_tokens,context_window,compact_at,compactions), so D1 has them without a migration.135K / 200K) under the Work section's counters, with a meter split where Claude compacts. The meter turns amber nine tenths of the way to the threshold (or to the end of the window, when there is no threshold). A line under it says where Claude compacts and how often it has. Hovering the numbers shows them exactly. The phone details sheet shows the same.fctl showhas acontext:line:135k of 200k tokens (67%) · compacts at 167k.compact(or/compact),context <tokens>fills its context, and it answersget_context_usage.docs/architecture.md(how the context is counted and reported),docs/development.md(fake-claude's new words) anddocs/getting-started.md.Compatibility:
SessionState.contextis optional, and the new stats fields are optional or default to 0. Agents from before this change report no window, so the page shows the token count alone, without the meter. A Claude Code from beforeget_context_usageanswers it with an error, which fctl-agent ignores.Verification
autocases give no threshold, the session state carries the window, and a turn's end now sendsget_context_usageafterget_settings.context:line, fake-claude'scontextword, and the web helpers (contextUse,contextNote).get_context_usagewithdetail: "summary"answered in 0.01–0.4 s withmaxTokens: 1000000,autoCompactThreshold: 967000andautocompactSource: "model-default"for Opus 5.5. Withoutdetailit calls the token-count API, so the agent always passes it.cargo xtask dev:context 120k, then exploreshowed135k of 200k tokens (67%) · compacts at 167kinfctl showand on the page.context 160kpushed it past the threshold. fake-claude compacted mid-turn (compacted once, back to 31.5K), andcompactcompacted it again (compacted twice).cargo xtask check, and a session through the standalone control plane (cargo xtask serve, thencargo xtask dev --smoke --server http://localhost:8787): the smoke test passed, andfctl showthere sayscontext: 42k of 200k tokens (21%) · compacts at 167k.Screenshots
At 3018dbc, against
cargo xtask dev: the Work section of the session page, 1440 px wide.The 1M shot sets the stats in the page (fake-claude's window is 200K) to what a session on Opus 5.5 reports.
At 390 px, in the details sheet, dark:
Session: https://app.fctl.sh/s/ses_01M5JWQSGV55Z5F2CS1YYF67BF