From 417ddc01aeecd1bf5c720b7b60ed356c380dc74d Mon Sep 17 00:00:00 2001 From: cyue Date: Tue, 11 Aug 2026 18:01:25 +0800 Subject: [PATCH] feat(desktop): over-threshold resume guard and compaction_done live refresh Keeps the review-endorsed parts of the original four-threshold PR #8256, rescaled to the single compact_ratio architecture of #8244: - over-threshold resume guard, asked BEFORE the mutating ResumeSessionPageForTab / OpenChannelSessionPageForTab calls via a read-only PreviewSession estimate, so cancelling leaves the session untouched - immediate context + balance refresh on compaction_done (the coalesced BalanceForTab query is invalidated first so the refresh reads fresh data) Drops everything tied to the multi-threshold model removed by #8244 (soft/snip/force ratios, the four-thumb slider, thresholdLayout, SetCompactionThresholds, CLI snip-ratio, the widened compact-ratio range) and does not reintroduce the ContextPanel maintenance block removed by #8265. The live capacity visualization already aligns with the single Compact threshold on current main-v2 (#8329/#8307), so the gauge is unchanged. --- desktop/frontend/src/App.tsx | 2 + .../__tests__/new-session-load-race.test.tsx | 1 + .../src/__tests__/resume-guard.test.tsx | 312 ++++++++++++++++++ .../use-controller-live-context.test.tsx | 33 ++ desktop/frontend/src/lib/useController.ts | 41 ++- desktop/frontend/src/lib/useResumeGuard.ts | 49 +++ desktop/frontend/src/locales/en.ts | 4 + desktop/frontend/src/locales/zh-TW.ts | 4 + desktop/frontend/src/locales/zh.ts | 4 + docs/SPEC.md | 5 + docs/SPEC.zh-CN.md | 3 + tools/repolint/baseline.json | 6 +- 12 files changed, 459 insertions(+), 5 deletions(-) create mode 100644 desktop/frontend/src/__tests__/resume-guard.test.tsx create mode 100644 desktop/frontend/src/lib/useResumeGuard.ts diff --git a/desktop/frontend/src/App.tsx b/desktop/frontend/src/App.tsx index a4edf9f482..a50f9c9c88 100644 --- a/desktop/frontend/src/App.tsx +++ b/desktop/frontend/src/App.tsx @@ -1135,6 +1135,7 @@ export default function App() { syncActiveTab, ensureBlankTab, ensureBlankSurface, + resumeGuardDialog, } = useController(); const { locale, setPref: setLocalePref } = useI18n(); const t = useT(); @@ -4906,6 +4907,7 @@ export default function App() { )} + {resumeGuardDialog} {!sidebarImDetailConnection && (