feat(web): make context window indicator opt-in (#9190)
Co-authored-by: maria-rcks <[email protected]>
This commit is contained in:
1 parent
6ff537f03c
commit
a19f01fc19
6 files changed
+45
-1
No files matched your search
@@ -23,6 +23,7 @@ const clientSettings: ClientSettings = {
|
||||
confirmThreadArchive: true,
|
||||
confirmThreadDelete: false,
|
||||
confirmThreadUnpin: false,
|
||||
contextWindowMeterEnabled: false,
|
||||
dismissedProviderUpdateNotificationKeys: [],
|
||||
diffIgnoreWhitespace: true,
|
||||
environmentIdentificationMode: "artwork",
|
||||
|
||||
@@ -4339,7 +4339,9 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
) : null}
|
||||
<ComposerFooterPrimaryActions
|
||||
compact={isComposerPrimaryActionsCompact}
|
||||
activeContextWindow={activeContextWindow}
|
||||
activeContextWindow={
|
||||
settings.contextWindowMeterEnabled ? activeContextWindow : null
|
||||
}
|
||||
activeThreadModelDisplayName={activeThreadModelDisplayName}
|
||||
pendingAction={pendingPrimaryAction}
|
||||
isRunning={phase === "running"}
|
||||
|
||||
@@ -522,6 +522,9 @@ export function useSettingsRestore(onRestored?: () => void) {
|
||||
...(settings.showSkillsInSlashMenu !== DEFAULT_UNIFIED_SETTINGS.showSkillsInSlashMenu
|
||||
? ["Show skills in slash menu"]
|
||||
: []),
|
||||
...(settings.contextWindowMeterEnabled !== DEFAULT_UNIFIED_SETTINGS.contextWindowMeterEnabled
|
||||
? ["Context window indicator"]
|
||||
: []),
|
||||
...(settings.enableLegacyTokenStreaming !==
|
||||
DEFAULT_UNIFIED_SETTINGS.enableLegacyTokenStreaming
|
||||
? ["Stream token by token"]
|
||||
@@ -576,6 +579,7 @@ export function useSettingsRestore(onRestored?: () => void) {
|
||||
settings.newWorktreesStartFromOrigin,
|
||||
settings.diffIgnoreWhitespace,
|
||||
settings.environmentIdentificationMode,
|
||||
settings.contextWindowMeterEnabled,
|
||||
settings.fontFamilyCode,
|
||||
settings.fontFamilyComposer,
|
||||
settings.fontFamilySans,
|
||||
@@ -668,6 +672,7 @@ export function useSettingsRestore(onRestored?: () => void) {
|
||||
wordWrap: DEFAULT_UNIFIED_SETTINGS.wordWrap,
|
||||
diffIgnoreWhitespace: DEFAULT_UNIFIED_SETTINGS.diffIgnoreWhitespace,
|
||||
showSkillsInSlashMenu: DEFAULT_UNIFIED_SETTINGS.showSkillsInSlashMenu,
|
||||
contextWindowMeterEnabled: DEFAULT_UNIFIED_SETTINGS.contextWindowMeterEnabled,
|
||||
environmentIdentificationMode: DEFAULT_UNIFIED_SETTINGS.environmentIdentificationMode,
|
||||
glassOpacity: DEFAULT_UNIFIED_SETTINGS.glassOpacity,
|
||||
sidebarThreadPreviewCount: DEFAULT_UNIFIED_SETTINGS.sidebarThreadPreviewCount,
|
||||
@@ -1750,6 +1755,7 @@ function AutoSettleDaysInput({
|
||||
// expand the section before its target can mount and scroll.
|
||||
const LEGACY_FEATURE_TARGET_IDS: ReadonlySet<string> = new Set([
|
||||
"legacy-plan-mode",
|
||||
"legacy-context-window-indicator",
|
||||
"legacy-token-streaming",
|
||||
"legacy-sidebar",
|
||||
]);
|
||||
@@ -1826,6 +1832,19 @@ function LegacyFeaturesSection() {
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<SettingsRow
|
||||
{...searchableSetting("legacy-context-window-indicator")}
|
||||
description="Shows context window usage as a circular indicator in the composer."
|
||||
control={
|
||||
<Switch
|
||||
checked={settings.contextWindowMeterEnabled}
|
||||
onCheckedChange={(checked) =>
|
||||
updateSettings({ contextWindowMeterEnabled: Boolean(checked) })
|
||||
}
|
||||
aria-label="Context window indicator (legacy)"
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<SettingsRow
|
||||
serverScoped
|
||||
{...searchableSetting("legacy-token-streaming")}
|
||||
|
||||
@@ -261,6 +261,12 @@ export const SETTINGS_SEARCH_ITEMS = [
|
||||
to: "/settings/general",
|
||||
searchTerms: ["build plan composer old"],
|
||||
},
|
||||
{
|
||||
id: "legacy-context-window-indicator",
|
||||
title: "Context window indicator (legacy)",
|
||||
to: "/settings/general",
|
||||
searchTerms: ["composer meter usage tokens circle old"],
|
||||
},
|
||||
{
|
||||
id: "legacy-token-streaming",
|
||||
title: "Stream token by token (legacy)",
|
||||
|
||||
@@ -191,6 +191,18 @@ describe("ClientSettings sidebar", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("ClientSettings context window meter", () => {
|
||||
it("defaults off and preserves an explicit legacy opt-in", () => {
|
||||
expect(decodeClientSettings({}).contextWindowMeterEnabled).toBe(false);
|
||||
expect(
|
||||
decodeClientSettings({ contextWindowMeterEnabled: true }).contextWindowMeterEnabled,
|
||||
).toBe(true);
|
||||
expect(
|
||||
decodeClientSettingsPatch({ contextWindowMeterEnabled: true }).contextWindowMeterEnabled,
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("ServerSettings thread settlement", () => {
|
||||
it("defaults merge settlement on and inactivity settlement to three days", () => {
|
||||
const settings = decodeServerSettings({});
|
||||
|
||||
@@ -265,6 +265,9 @@ export const ClientSettingsSchema = Schema.Struct({
|
||||
// default UI; this beta flag restores it (plus the /plan and /default slash
|
||||
// commands) for users who still rely on the old workflow.
|
||||
planModeEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
|
||||
// Legacy context window meter. The composer hides it by default; users who
|
||||
// still want the old usage indicator can restore it from Settings.
|
||||
contextWindowMeterEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
|
||||
showSkillsInSlashMenu: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
|
||||
// Legacy sidebar (the original per-project tree). Deliberately a fresh key
|
||||
// (was `sidebarV2Enabled` + `sidebarV2ConfiguredByUser`): decoding drops the
|
||||
@@ -990,6 +993,7 @@ export const ClientSettingsPatch = Schema.Struct({
|
||||
),
|
||||
),
|
||||
planModeEnabled: Schema.optionalKey(Schema.Boolean),
|
||||
contextWindowMeterEnabled: Schema.optionalKey(Schema.Boolean),
|
||||
showSkillsInSlashMenu: Schema.optionalKey(Schema.Boolean),
|
||||
legacySidebarEnabled: Schema.optionalKey(Schema.Boolean),
|
||||
sidebarProjectGroupingMode: Schema.optionalKey(SidebarProjectGroupingMode),
|
||||
|
||||
Reference in new issue
Block a user