Skip to content

The agent that grows with you

fix(tui): drop the stale context meter when /compress commits

xxxigm5c6660eaf54c
diff --git a/ui-tui/src/app/slash/canonicalSessionControls.ts b/ui-tui/src/app/slash/canonicalSessionControls.ts
index 5c57b1d3157..023fea43a9b 100644
--- a/ui-tui/src/app/slash/canonicalSessionControls.ts
+++ b/ui-tui/src/app/slash/canonicalSessionControls.ts
@@ -206,8 +206,10 @@ function askModelConfirmation(refusal: ModelConfirmation, arg: string, ctx: Slas
throw new Error(`${refusal.confirm_message ?? ''}\n\n${t('slashCmd.session.model.confirmStale')}`.trim())
}
- openModelConfirmation(refusal.confirm_message, refusal.target_model ?? arg.trim().split(/\s+/)[0] ?? '', () =>
- void runCanonicalSessionControl('model', arg, ctx, refusal.confirm)
+ openModelConfirmation(
+ refusal.confirm_message,
+ refusal.target_model ?? arg.trim().split(/\s+/)[0] ?? '',
+ () => void runCanonicalSessionControl('model', arg, ctx, refusal.confirm)
)
}
@@ -342,9 +344,27 @@ export async function switchCanonicalModel(
type CompressSummary = { headline?: string; noop?: boolean; note?: string; token_line?: string } | null
+/** The bar's prompt size is the previous reply. Manual /compress does not call the
+ * chat model, and nothing publishes `session.usage` for it, so that size would
+ * stay on screen. The classic CLI parks the reading at -1 and paints 0 until
+ * the next reply, and counts the compaction immediately. */
+function usageAfterManualCompress<U extends { compressions?: null | number }>(usage: U): U {
+ const prior = usage.compressions
+
+ return {
+ ...usage,
+ compressions: (typeof prior === 'number' ? prior : 0) + 1,
+ context_estimated: false,
+ context_percent: 0,
+ context_used: 0
+ }
+}
+
/** The authority's report (headline, token line, note), as the native /compress prints it. */
function printCompressSummary(summary: CompressSummary, ctx: SlashRunCtx) {
- ctx.transcript.sys(summary?.headline ? `${summary.noop ? '' : '✓ '}${summary.headline}` : t('canonical.controls.compressed'))
+ ctx.transcript.sys(
+ summary?.headline ? `${summary.noop ? '' : '✓ '}${summary.headline}` : t('canonical.controls.compressed')
+ )
for (const line of [summary?.token_line, summary?.note]) {
if (line) {
@@ -375,7 +395,7 @@ async function applyCompressResult(gw: MutationGateway, sid: string, result: Can
}
ctx.transcript.setHistoryItems([introMsg(info), ...toTranscriptMessages(snapshot.messages)])
- patchUiState({ info })
+ patchUiState(state => ({ ...state, info, usage: usageAfterManualCompress(state.usage) }))
printCompressSummary(result.summary as CompressSummary, ctx)
}