Skip to content

feat(settings): Chat settings control for idle compaction before cache expiry - #30246

Open
Pearcekieser wants to merge 1 commit into
mainfrom
pearcekieser/idle-compaction-settings-ui
Open

Pearcekieser wants to merge 1 commit into
mainfrom
pearcekieser/idle-compaction-settings-ui

Conversation

@Pearcekieser

@Pearcekieser Pearcekieser commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: a user can turn idle compaction on and set its minimum context from Settings, Chat, Advanced, without editing config.json.

session.idle_compaction and session.idle_compaction_min_context_pct shipped in #24384 as config keys only. Phase 1 of the accepted RFC (#22149) left the Settings control to Phase 2, so a user must edit config.json to turn the feature on. This PR is Phase 2.

Why it matters

The feature is opt-in and costs a model call each time it fires. A user who wants it needs a visible switch that states that cost, and a way to raise the minimum context without editing a file.

Not a goal

What changed (motivation → approach → change)

RFC section 5.1 places the control beside Auto-Compact Threshold. The Chat settings page writes each row by hand, so both rows go into the Context card on Settings, Chat, Advanced, directly below that select.

  • useIdleCompactionFields.ts (new) holds both rows' saves. The switch saves through the shared useOptimisticConfigPaths overlay, so a refetch that fails after a good save cannot flip it back. The minimum field saves on blur or Enter, writes the stored value into the config cache, and skips that write after an unmount. Both failure paths raise the panel's error banner and refetch the config, because a request can fail after the server stored the value.
  • The switch label is now "Summarize Idle Chats to Save Credits", also in sections_session.py. It changed because the UX review's blind reader did not know what "Cache Expiry" in the old label meant and left the switch off. Its row says: "Summarizes a large chat that has gone idle, so your next message in it costs less. Each summary can cost about as much as one or two messages in that chat, even if you never come back. Worth it if you often return to long chats." The size comes from the RFC's section 6 low cost bound, 2.7 to 4.6 credits per summary against 1.8 to 3.0 credits of input for a warm message at the same context.
  • The minimum field, "Minimum Context to Summarize (%)", says "Only idle chats whose context is at least this full are summarized." While the switch is off, the row is disabled and dimmed with opacity-40 cursor-not-allowed, and says "Turn on Summarize Idle Chats to Save Credits to change this." The server clamps a value outside 40 to 90 through the loader's own _safe_float. The row then shows a notice that starts with the saved value, for example "Saved 40%. The allowed range is 40% to 90%, so 20% was raised to 40%." The save worked, so the notice uses a new neutral FieldHint tone (text-muted), and every other caller keeps warn. Saves of the field share one mutation scope, so they land in the order the user made them.
  • core_config_schema.py adds both keys to _EDITABLE_CONFIG. change_card_catalog_kinds.py classes both paths as settings that cannot widen access.
  • 8 strings in en.json and the 11 translated catalogs, the regenerated en-XA pseudolocale, settings registries, UI index and config-baseline.json. settingsKeywords.ts lets Settings search find both rows by "idle compaction". The configuration.md and config.md rows name the Settings path.
  • The RFC front matter and index row record Phase 1 as shipped in feat(session): opt-in idle compaction before prompt-cache expiry #24384 (ec2e1a1609), and Phase 2 as in flight. A feature-map row covers the new page file.

Backwards compatibility

Compatible. Both keys and their defaults already exist. A config without them loads as before, and the new rows only read and write the same keys config.json holds.

Tests

SettingsChatPanelIdleCompaction.test.tsx (new, 26 cases) renders the real ChatPanel with the API mocked. It covers the default and saved states with the dimmed row, the benefit-before-cost text, the switch save while pending and after it settles, a failed switch save, a refetch failure after a good save for both rows, the banner scroll on both failure paths, the in-range save on blur and Enter, the clamp of 20 to 40 and 95 to 90 with the notice text and its neutral tone, the warn tone kept on the time limit notice, the notice cleared when another writer saves a different value, the locked reason while off, save order across a remount, the notice after a language change, an empty field, a failed field save, the refetch after it, the error cleared when that save was stored anyway, and its retry, the unmount guard, the registry entries, and a Settings search for "idle compaction". Each case added for a review finding fails without its fix. test_config_patch_idle_compaction.py (new) covers the PATCH path for both keys, and test_config_load_bounds_parity.py pins the float bounds to the loader constants.

Ran locally after the last code change: tsc -p tsconfig.app.json, eslint, black 26.10.1, I18N_BASE_REF=origin/main npm run i18n:check, I18N_BASE_REF=origin/main npx vitest run src/i18n/ (1,174 passed, all 12 locale style files), gen-ui-index.mjs --check, the settings registry and search tests, docs_lint.py, the feature-map gate and pre_push_gate.py (23 ran, 0 failed). The four full vitest shards, flake8, isort and mypy ran on the first version of the change. The 11 translations follow each locale's style guide but have no native-speaker review yet.

Manual verification

A pod on this branch, Settings, Chat, Advanced.

Off, the default. The switch row states what it does, what one summary costs and when it pays. The minimum row is dimmed, disabled and says how to unlock it:

settings-idle-off-v4

On, then 20 typed and Enter pressed. The server saved 40, and the notice starts with the saved value, in neutral text:

settings-idle-clamp-v4

Related Issues

Fixes #30245

Part of #22148

Implements Phase 2 of #22149 (merged RFC).

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@Pearcekieser
Pearcekieser requested review from a team and KiroCrewCaptain as code owners November 5, 2026 08:45
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of c85953dc3a200f4c4012358e57b8dae8b63a3878 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] c85953d

False positive or not applicable? A repository writer can comment:
/ai-review override gpt c85953dc3a200f4c4012358e57b8dae8b63a3878 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of c85953dc3a200f4c4012358e57b8dae8b63a3878 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the PR adds Settings rows for two existing keys. The write path clamps values the same way the loader does, the idle trigger reads the live config, and both states are shown in screenshots.

Notes

  • The frontend hardcodes IDLE_COMPACTION_MIN_PCT_MIN/MAX as 40/90, a copy of the bounds in sections_limits.py. The backend parity test only checks the bounds on the backend side. If the backend bounds change, the field's min/max and its description will drift until the server's clamp notice shows the mismatch. This is reversible.

[DESIGN-REVIEWED] c85953d

Description read

[DESCRIPTION-READ] 4262e864c7b37df072068514a8c93deedd511321076e7027a4c03b28fb3d243c

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of c85953dc3a200f4c4012358e57b8dae8b63a3878 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. The base RFC (in-progress) covers Phase 2, the setting stays off by default, and the one rider is small enough to delete.

Notes

  • Item 5 — one consumer, generalized: FieldHint's new tone?: 'warn' | 'neutral' has exactly one tone="neutral" caller (ChatPanel.tsx:876). Its stated reason, "The save worked, so the notice uses a new neutral FieldHint tone", also applies to the 3 sibling clamp notices that stay warn: compactClampNotice (ChatPanel.tsx:833), waitClampNotice (ChatPanel.tsx:908) and SessionsPerCreatorSetting.tsx:102. I grepped FieldHint|clamp_notice under pages/settings. Subtraction: delete the tone prop and keep the idle notice on the default warn tone, like its 3 siblings.

What this change ships

Inventory (7 items) — 6 justified

Intent: let a user turn idle compaction on and set its minimum context from Settings, without editing config.json. This is an ADDITION (RFC #22149, Phase 2).

  1. Settings → Chat → Advanced → Context gets a "Summarize Idle Chats to Save Credits" switch, off by default — justified
  2. A "Minimum Context to Summarize (%)" field, disabled while the switch is off — justified
  3. Both keys become writable through PATCH, and out-of-range values are clamped to 40–90 — justified
  4. The setting's label is renamed from "Compact Idle Chats Before Cache Expiry" in the schema and the RFC — justified
  5. The clamp notice uses a new neutral (muted) colour instead of warn — one consumer, generalized
  6. Settings search finds both rows by "idle compaction" — justified
  7. The RFC front matter records Phase 1 as shipped, and both keys are classed as unable to widen access — justified

[FIRST-PRINCIPLES-REVIEWED] c85953d

Description read

[DESCRIPTION-READ] 7a6902941b521cea97d45bac37bf20949fc0b25741509ca84cfc72be25a29042

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of c85953dc3a200f4c4012358e57b8dae8b63a3878 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing blocks: the blind reader correctly understood the new switch and the minimum field, would use them, and saw both states.

Notes

  • The new labels say "Summarize", but the controls next to them ("Auto-Compact Threshold", "Compaction Time Limit") and the idle_compaction_hint tooltip say "compact". The reader "can't tell whether 'compact' and 'summarize' are the same thing" and couldn't tell how the 70% threshold relates to the 50% minimum. Use one verb for both. If the label stays "Summarize", start the description with "Summarizing (compacting) …", and add one sentence saying this happens before the Auto-Compact Threshold is reached.
  • The idle_compaction_hint tooltip runs to eight sentences. "The summary loses detail from earlier in the conversation" affects the user's decision, so move it into the description that is always visible, and cut the rest of the tooltip down.
  • The reader said the "Saved 40% … raised to 40%" notice "looks just like the plain explanation text", so they might miss that their number was changed. The neutral tone is fine, but put the notice right under the input, or add a small info icon, so it reads as a reply to what they typed.

[UX-REVIEWED] c85953d

Description read

[DESCRIPTION-READ] 9fb1d87fd74a90f328944a8ad33f6dd23e982c4606fa27ab582053b190da6f9f

That sha256 names everything this verdict read: the PR description, plus the 5 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed c85953dc3a200f4c4012358e57b8dae8b63a3878 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] c85953d

Verdict parsed from the review's SHA-scoped output markers for commit c85953dc3a200f4c4012358e57b8dae8b63a3878.

False positive or not applicable? A repository writer can comment:
/ai-review override fable c85953dc3a200f4c4012358e57b8dae8b63a3878 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: checking Automated validation is still running labels Nov 5, 2026
@Pearcekieser
Pearcekieser force-pushed the pearcekieser/idle-compaction-settings-ui branch from db84eef to dc74631 Compare November 5, 2026 10:15
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 5, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • fixed: The "Compact Idle Chats Before Cache Expiry" switch hides its benefit in a tooltip span=bdaf28480e2c

fixed in dc74631: the visible line under the switch now states the benefit first and the cost second: "Summarizes a large idle chat just before the backend's cached copy of its history expires, so your next message costs less. Each summary is an extra model call that costs credits, even if you never come back." The label stays "Compact Idle Chats Before Cache Expiry", the same as the config field label, and the description explains the cache. All 11 translated catalogs carry the new text. The test says on the row that each idle compaction costs credits now also requires the benefit sentence to come before the cost sentence.

The three notes are fixed in the same push. The minimum row is dimmed with opacity-40 cursor-not-allowed while the switch is off, the same classes a disabled toggle row uses. The label is now "Idle Compaction Minimum Context (%)". The clamp notice leads with the limit: "The allowed range is 40% to 90%, so 40% was saved instead of 20%." The new screenshots in the description show the dimmed row and the new notice.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 5, 2026
@Pearcekieser
Pearcekieser force-pushed the pearcekieser/idle-compaction-settings-ui branch from dc74631 to 60a4e8f Compare November 5, 2026 11:15
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/feature-map/README.md and 34 other files this PR touches since this head went green (942ab8b -> 59e91f2); CI re-running.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Nov 5, 2026
@Pearcekieser
Pearcekieser force-pushed the pearcekieser/idle-compaction-settings-ui branch from 60a4e8f to 527726d Compare November 5, 2026 12:15
@github-actions github-actions Bot added merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 5, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Backend Lint & Type Check on 5e16c3d fails on main's own flake8 F821 (was_installed in src/kiro_crew/apps/routes_registry.py, from #30628 and #30584 merging minutes apart), not on this diff. The fix is #30762 (issue #30761). This PR waits for it, then rebases.

@Pearcekieser
Pearcekieser force-pushed the pearcekieser/idle-compaction-settings-ui branch from 5e16c3d to 54e3b8d Compare November 5, 2026 22:15
@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • fixed: An explicit revert is dropped while an earlier save is pending span=85e72f6d77f0

fixed in 54e3b8d: the minimum field skipped a value equal to the cached one, also while an earlier save to the same path was still pending. Thus a revert to the cached value never reached the server, and the earlier save decided the stored value. The save mutation now has its own mutation key. commitIdleMinPct skips an equal value only when qc.isMutating reports no pending save for that key. Otherwise the revert is queued in the same MIN_PATH scope behind the earlier save, so it lands last. The new test "sends a revert to the cached value while an earlier save from a previous mount is pending" covers this case, and the idle test file passes 23 of 23.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 5, 2026
@Pearcekieser
Pearcekieser force-pushed the pearcekieser/idle-compaction-settings-ui branch from 54e3b8d to 14efc70 Compare November 6, 2026 00:44
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 6, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • fixed: The main switch reads as a risk the user cannot size span=eab6a7fb684a

fixed in 14efc70: the switch is now labelled "Summarize Idle Chats to Save Credits", in the config metadata and in all 12 catalogs, so the label no longer ends in "Cache Expiry". The row now gives the cost a size: "Each summary can cost about as much as one or two messages in that chat, even if you never come back." The figure comes from the RFC section 6 low cost bound, 2.7 to 4.6 credits per summary against 1.8 to 3.0 credits of input for a warm message at the same context. The test for the row pins the full description.

The two notes are fixed in the same push. The minimum field is now "Minimum Context to Summarize (%)" and says "Only idle chats whose context is at least this full are summarized.", which tells it apart from Auto-Compact Threshold. The clamp notice now uses a neutral FieldHint tone (text-muted), because the save worked. Every other FieldHint keeps the warn tone. The new screenshots in the description show both.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 6, 2026
@Pearcekieser
Pearcekieser force-pushed the pearcekieser/idle-compaction-settings-ui branch from 14efc70 to caef2b6 Compare November 6, 2026 01:45
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 6, 2026
@Pearcekieser
Pearcekieser force-pushed the pearcekieser/idle-compaction-settings-ui branch from caef2b6 to 1e0eb29 Compare November 6, 2026 04:00
@github-actions github-actions Bot removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention labels Nov 6, 2026
@KiroCrewCaptain

KiroCrewCaptain commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: the decider estimates a 12% chance that this change introduces a defect, within the 12% limit for approving on its own, but it changes 1214 lines, more than the 400 it may approve on its own.

This PR adds Phase 2 of the idle-compaction RFC: a Settings switch and a minimum-context field for two config keys that already exist. I found nothing that blocks it.

Backend. core_config_patch.py already enforces what the PR adds:

  • session.idle_compaction must be a real boolean. Anything else gets a 400.
  • session.idle_compaction_min_context_pct goes through the float branch. Booleans, non-numbers and NaN are rejected. Out-of-range values are clamped by the loader's own _safe_float with the 40/90 constants from sections_limits.py, and the response carries a clamp_notice.
  • A saved value therefore matches what a later config load produces. The new PATCH tests check this against the real load path, and the bounds-parity test now pins both bounds to the loader constants.
  • Both keys go in _CANNOT_WIDEN_SETTINGS. That is accurate: they spend credits but grant no access.

Frontend.

  • The switch saves through the shared useOptimisticConfigPaths overlay, the same pattern its sibling rows use.
  • The minimum field saves on blur or Enter, in order within one mutation scope.
  • It writes the saved value into the config cache only while the panel is mounted.
  • After a

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit c85953dc3a · 1214 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

…e expiry

Settings > Chat > Advanced, Context card, gains the Summarize Idle Chats to Save Credits switch (session.idle_compaction) and the Minimum Context to Summarize (%) field (session.idle_compaction_min_context_pct) below Auto-Compact Threshold. The switch row says that the next message costs less, that each summary can cost about as much as one or two messages in that chat even if you never come back, and that it is worth it if you often return to long chats. The field says that only idle chats at least this full are summarized. It is disabled and dimmed while the switch is off, and its row then says to turn on the switch to change it.

The switch saves through the shared optimistic config overlay, so a refetch that fails after a good save cannot flip it back. The field writes the stored value into the config cache, skips that write after an unmount, raises the panel's error banner on failure and then refetches the config, because a request can fail after the server stored the value. The PATCH path accepts both keys: the switch takes a boolean only, and the minimum clamps to 40-90 through the loader's own _safe_float and returns a clamp_notice. The field shows a notice that opens with the saved value and says whether the typed value was raised or lowered. The notice uses a new neutral FieldHint tone, because the save worked. Every other FieldHint keeps the warn tone. Both paths are classified as cannot-widen settings for change cards.

Strings are in all 12 catalogs, and the settings registry, the agent-facing registry, the UI index and config-baseline.json are regenerated. Settings search keeps finding both rows by "idle compaction". The RFC record and the feature map name Phase 1 as shipped and Phase 2 as in flight.
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

The design for this change is signed off: a maintainer accepted the RFC when #22149 merged. This PR also edits the RFC index and the feature map, so it now waits for a maintainer to approve it.

Review result on c85953: no blocking findings. Here is what the review checked:

  • The new PATCH rows for session.idle_compaction and session.idle_compaction_min_context_pct clamp through the loader's own _safe_float with the same bounds. The new backend test loads the stored value back through KiroCrewConfig.load() and gets the same value.
  • Both keys stay owner-gated and are listed in _CANNOT_WIDEN_SETTINGS, like their sibling rows.
  • Each branch of useIdleCompactionFields.ts has its own test: save order across a remount, no cache write after unmount, refetch after a failed save, and the error cleared when the server stored the value anyway. Removing any one of these branches makes a test fail.
  • All 13 locale catalogs carry the same keys with matching placeholders. The label renames keep the old wording as search keywords.
  • PR Readiness is green on this head, and the branch merges cleanly with main.

A note for the maintainer: on #30245, a maintainer said on 2026-11-13 that they would carry this change onto a fresh branch. No such PR is open, and this branch has since been rebased. Please pick one of the two paths.

Optional:

  • FieldHint gets a tone prop with one caller. The result is that the new clamp notice is muted, while the two sibling clamp notices in the same Context card stay in the warn colour. Consider dropping the prop and reusing the siblings' single "Saved X. Y is outside the allowed range" string. If neutral is the right colour, change all three rows together in a separate PR.
  • The body says en.json gains 8 strings. The diff adds 11 per catalog.
  • The save-order test asserts that a call did not happen right after a 5-microtask flush. Waiting for the second mutation to show as paused before that assertion would make the test sturdier against a react-query upgrade.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(settings): Chat settings control for idle compaction before cache expiry

2 participants