DeepSeek-Reasonix icon indicating copy to clipboard operation
DeepSeek-Reasonix copied to clipboard

Expose configurable context compaction threshold in Desktop and CLI / 在桌面端和 CLI 配置上下文压缩阈值

Open SivanCola opened this issue 4 months ago • 0 comments

Summary

  • Expose the automatic context-compaction threshold directly in Desktop Settings.
  • Keep guarded 70%, 80%, and 85% presets, with 80% remaining the default.
  • Allow an explicit custom value from 65% to 85% in 0.1% increments.
  • Add reasonix config compact-ratio for effective-value/source queries, user-global writes, and --local project overrides.
  • Show the approximate token threshold for the default model and disclose project or Remote Workbench scope overrides.
  • Update English and Chinese CLI/spec documentation, localized CLI help, and the public website docs.
  • Persist changes through the existing guarded, failure-atomic config update and controller rebuild paths.

Why

The threshold already exists in TOML, but users could not discover or safely tune it from Desktop or CLI. Presets keep the common path simple, while explicit custom input lets advanced users choose an intermediate tradeoff without editing configuration files. Earlier compaction preserves context headroom; later compaction retains the provider-visible prefix and prompt-cache reuse longer.

Desktop custom input is draft-only until the user clicks Apply or presses Enter, so typing does not repeatedly rebuild the active session. Escape restores the persisted value, and out-of-range values cannot be submitted. CLI input uses percentages (75 means 0.75 in TOML) and reports whether the effective value came from the built-in default, user config, or project config.

Safety and compatibility

Surface Compatibility behavior
Existing TOML A missing compact_ratio still defaults to 0.8; existing custom values remain readable.
Wails settings view New fields are additive and use omitempty; older frontends can ignore them.
New frontend with older backend An absent ratio is normalized to 0.8.
Manual input Only finite values from 65% to 85% can be submitted; the backend also enforces configured snip/force guard rails.
CLI writes Existing config locks and atomic saves preserve unrelated concurrent Desktop/CLI fields.
Project overrides The UI and CLI query show the effective project threshold instead of implying the global value is active.
Remote Workbench The UI states that the setting updates the local host default only.
Running CLI sessions New sessions load the updated setting; an existing process keeps its startup value.
Initial bundle Control-specific CSS loads with the lazy Settings panel; the feature stays within existing bundle budgets.
Concurrent runtime work Existing active-work guards reject unsafe Desktop controller rebuilds before saving.

Cache-impact: medium - Selecting a value below 80%, including the 65% custom minimum, can compact earlier and reset the provider-visible prefix more often; the default remains 80%, and no request serialization changes until the user chooses another value.

Cache-guard: ./scripts/cache-guard.sh passed all release cache-hit scenarios.

Verification

  • go test ./...
  • go test ./internal/cli ./internal/config
  • (cd desktop && go test ./...)
  • pnpm --dir desktop/frontend build (typecheck, CSS checks, production build, and bundle budgets passed)
  • pnpm --dir desktop/frontend test:typecheck
  • pnpm --dir desktop/frontend exec tsx src/__tests__/settings-refresh-snapshot.test.tsx (83 passed)
  • pnpm --dir desktop/frontend exec tsx src/__tests__/typography-overflow-contract.test.ts (136 passed)
  • ./scripts/cache-guard.sh
  • npm --prefix site test (48 passed)
  • npm --prefix site run build (38 pages built)
  • git diff --check

SivanCola avatar Aug 02 '26 16:08 SivanCola