feat: sidebar v2 is now the default sidebar (#5672)
Co-authored-by: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
31891a1a0c
commit
0de9540739
25 files changed
+7271
-7456
No files matched your search
@@ -39,8 +39,7 @@ const clientSettings: ClientSettings = {
|
||||
sidebarProjectSortOrder: "manual",
|
||||
sidebarThreadSortOrder: "created_at",
|
||||
sidebarThreadPreviewCount: 6,
|
||||
sidebarV2Enabled: false,
|
||||
sidebarV2ConfiguredByUser: false,
|
||||
legacySidebarEnabled: false,
|
||||
timestampFormat: "24-hour",
|
||||
wordWrap: true,
|
||||
};
|
||||
|
||||
@@ -131,7 +131,7 @@ function LocalSettingsRouteScreen() {
|
||||
<SettingsRow icon="paintbrush" label="Appearance" target="SettingsAppearance" />
|
||||
</SettingsSection>
|
||||
|
||||
<BetaSettingsSection />
|
||||
<LegacySettingsSection />
|
||||
|
||||
<ArchivedThreadsSettingsSection />
|
||||
|
||||
@@ -519,7 +519,7 @@ function ConfiguredSettingsRouteScreen() {
|
||||
<SettingsRow icon="paintbrush" label="Appearance" target="SettingsAppearance" />
|
||||
</SettingsSection>
|
||||
|
||||
<BetaSettingsSection />
|
||||
<LegacySettingsSection />
|
||||
|
||||
<ArchivedThreadsSettingsSection />
|
||||
|
||||
@@ -538,26 +538,27 @@ function GeneralSettingsSection() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Device-local beta toggles. Mobile has no client-settings sync, so this is
|
||||
* the counterpart of web's Settings → Beta backed by mobile preferences.
|
||||
* Device-local legacy toggles. Mobile has no client-settings sync, so this is
|
||||
* the counterpart of web's Settings → General → Legacy features backed by
|
||||
* mobile preferences.
|
||||
*/
|
||||
function BetaSettingsSection() {
|
||||
function LegacySettingsSection() {
|
||||
const savePreferences = useAtomSet(updateMobilePreferencesAtom);
|
||||
const threadListV2Enabled = useThreadListV2Enabled();
|
||||
|
||||
return (
|
||||
<View className="gap-3">
|
||||
<SettingsSection title="Beta">
|
||||
<SettingsSection title="Legacy">
|
||||
<SettingsSwitchRow
|
||||
icon="sidebar.left"
|
||||
label="Thread List v2"
|
||||
value={threadListV2Enabled}
|
||||
onValueChange={(value) => savePreferences({ threadListV2Enabled: value })}
|
||||
label="Legacy Thread List"
|
||||
value={!threadListV2Enabled}
|
||||
onValueChange={(value) => savePreferences({ legacyThreadListEnabled: value })}
|
||||
/>
|
||||
</SettingsSection>
|
||||
<Text className="px-2 text-sm text-foreground-muted">
|
||||
One flat thread list in creation order. Active work renders as cards; settled threads
|
||||
collapse to compact rows. Switch back any time.
|
||||
Brings back the original grouped thread list. The default list is flat, in creation order:
|
||||
active work renders as cards; settled threads collapse to compact rows.
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
|
||||
@@ -104,20 +104,24 @@ describe("resolveThreadListV2SnoozeMenuSelection", () => {
|
||||
|
||||
describe("resolveThreadListV2Enabled", () => {
|
||||
it("defaults on when the device has never chosen", () => {
|
||||
expect(resolveThreadListV2Enabled({ preference: undefined, preferencesLoaded: true })).toBe(
|
||||
true,
|
||||
);
|
||||
expect(
|
||||
resolveThreadListV2Enabled({ legacyPreference: undefined, preferencesLoaded: true }),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("honors an explicit device opt-out", () => {
|
||||
expect(resolveThreadListV2Enabled({ preference: false, preferencesLoaded: true })).toBe(false);
|
||||
expect(resolveThreadListV2Enabled({ preference: true, preferencesLoaded: true })).toBe(true);
|
||||
it("honors an explicit legacy opt-in", () => {
|
||||
expect(resolveThreadListV2Enabled({ legacyPreference: true, preferencesLoaded: true })).toBe(
|
||||
false,
|
||||
);
|
||||
expect(resolveThreadListV2Enabled({ legacyPreference: false, preferencesLoaded: true })).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
it("holds the default while preferences are still loading so the list does not remount", () => {
|
||||
expect(resolveThreadListV2Enabled({ preference: undefined, preferencesLoaded: false })).toBe(
|
||||
true,
|
||||
);
|
||||
expect(
|
||||
resolveThreadListV2Enabled({ legacyPreference: undefined, preferencesLoaded: false }),
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -103,23 +103,23 @@ export const THREAD_LIST_V2_SETTLED_INITIAL_COUNT = 10;
|
||||
export const THREAD_LIST_V2_SETTLED_PAGE_COUNT = 25;
|
||||
|
||||
/**
|
||||
* Thread List v2 is on by default on every app variant; the Settings → Beta
|
||||
* toggle is an opt-out. Preferences persist as sparse patches, so `undefined`
|
||||
* genuinely means "never chosen".
|
||||
* The flat Thread List v2 is the default on every app variant; the Settings →
|
||||
* Legacy toggle opts a device back into the grouped legacy list. Preferences
|
||||
* persist as sparse patches, so `undefined` genuinely means "never chosen".
|
||||
*
|
||||
* `preferencesLoaded` guards the startup window: preferences load
|
||||
* asynchronously, and rendering one list before the stored choice arrives would
|
||||
* remount the whole thing a tick later. While loading, hold the default — that
|
||||
* is where every device without an explicit opt-out lands anyway.
|
||||
* is where every device without an explicit legacy opt-in lands anyway.
|
||||
*/
|
||||
export function resolveThreadListV2Enabled(input: {
|
||||
readonly preference: boolean | undefined;
|
||||
readonly legacyPreference: boolean | undefined;
|
||||
readonly preferencesLoaded: boolean;
|
||||
}): boolean {
|
||||
if (!input.preferencesLoaded) {
|
||||
return true;
|
||||
}
|
||||
return input.preference ?? true;
|
||||
return input.legacyPreference !== true;
|
||||
}
|
||||
|
||||
export function resolveThreadListV2Status(
|
||||
|
||||
@@ -5,15 +5,15 @@ import { mobilePreferencesAtom } from "../../state/preferences";
|
||||
import { resolveThreadListV2Enabled } from "./threadListV2";
|
||||
|
||||
/**
|
||||
* Resolved Thread List v2 state: the device-local preference if the user has
|
||||
* set one, otherwise the default (on). Every consumer must read through this
|
||||
* Resolved Thread List v2 state: on unless the device opted into the legacy
|
||||
* grouped list (Settings → Legacy). Every consumer must read through this
|
||||
* rather than the raw preference, which is undefined until explicitly chosen.
|
||||
*/
|
||||
export function useThreadListV2Enabled(): boolean {
|
||||
const preferencesResult = useAtomValue(mobilePreferencesAtom);
|
||||
const loaded = AsyncResult.isSuccess(preferencesResult);
|
||||
return resolveThreadListV2Enabled({
|
||||
preference: loaded ? preferencesResult.value.threadListV2Enabled : undefined,
|
||||
legacyPreference: loaded ? preferencesResult.value.legacyThreadListEnabled : undefined,
|
||||
preferencesLoaded: loaded,
|
||||
});
|
||||
}
|
||||
@@ -27,12 +27,13 @@ export interface Preferences {
|
||||
readonly projectGroupingEnabled?: boolean;
|
||||
readonly projectGroupingMode?: SidebarProjectGroupingMode;
|
||||
/**
|
||||
* Device-local mirror of the web beta's `sidebarV2Enabled`. Mobile has no
|
||||
* client-settings sync, so the flat v2 thread list is opted out of per
|
||||
* device. Undefined means the user has never chosen, which resolves to on —
|
||||
* see `resolveThreadListV2Enabled`.
|
||||
* Device-local mirror of the web `legacySidebarEnabled` setting. Mobile has
|
||||
* no client-settings sync, so the legacy grouped thread list is opted into
|
||||
* per device. Deliberately a fresh key (was `threadListV2Enabled`, an
|
||||
* opt-out): sanitizing drops the old key, so every device resets to the
|
||||
* default flat list — see `resolveThreadListV2Enabled`.
|
||||
*/
|
||||
readonly threadListV2Enabled?: boolean;
|
||||
readonly legacyThreadListEnabled?: boolean;
|
||||
}
|
||||
|
||||
export class MobilePreferencesLoadError extends Schema.TaggedErrorClass<MobilePreferencesLoadError>()(
|
||||
@@ -84,7 +85,7 @@ function sanitizePreferences(parsed: Preferences): Preferences {
|
||||
collapsedProjectGroups?: readonly string[];
|
||||
projectGroupingEnabled?: boolean;
|
||||
projectGroupingMode?: SidebarProjectGroupingMode;
|
||||
threadListV2Enabled?: boolean;
|
||||
legacyThreadListEnabled?: boolean;
|
||||
} = {};
|
||||
|
||||
if (typeof parsed.liveActivitiesEnabled === "boolean") {
|
||||
@@ -121,8 +122,8 @@ function sanitizePreferences(parsed: Preferences): Preferences {
|
||||
) {
|
||||
preferences.projectGroupingMode = parsed.projectGroupingMode;
|
||||
}
|
||||
if (typeof parsed.threadListV2Enabled === "boolean") {
|
||||
preferences.threadListV2Enabled = parsed.threadListV2Enabled;
|
||||
if (typeof parsed.legacyThreadListEnabled === "boolean") {
|
||||
preferences.legacyThreadListEnabled = parsed.legacyThreadListEnabled;
|
||||
}
|
||||
return preferences;
|
||||
}
|
||||
|
||||
@@ -11,51 +11,6 @@ export function formatAppDisplayName(input: {
|
||||
return `${input.baseName} (${input.stageLabel})`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the sidebar v2 beta is on by default for a build stage.
|
||||
*
|
||||
* Nightly and local dev opt in; Alpha and Latest stay on v1. This is resolved
|
||||
* from the client's own stage label rather than the connected server's version:
|
||||
* v2 only exists in the client, so a stable client on a nightly server has
|
||||
* nothing to turn on.
|
||||
*/
|
||||
export function resolveSidebarV2Default(stageLabel: string): boolean {
|
||||
const stage = stageLabel.trim().toLowerCase();
|
||||
return stage === "nightly" || stage === "dev";
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolved sidebar v2 state: an explicit choice if the user has made one,
|
||||
* otherwise the default for this build stage.
|
||||
*
|
||||
* A stored `enabled: true` counts as an explicit choice even without the
|
||||
* companion flag. `true` was never the schema default, so it can only have come
|
||||
* from the Settings → Beta toggle — settings written before that flag existed
|
||||
* would otherwise lose the opt-in and drop such users back to v1 on production.
|
||||
* Mirrors how `normalizeDesktopSettingsDocument` treats a legacy stored
|
||||
* `updateChannel: "nightly"` as user-configured.
|
||||
*
|
||||
* `settingsHydrated` guards the startup window: client settings load
|
||||
* asynchronously and the pre-hydration snapshot is just the schema defaults, so
|
||||
* resolving against it would mount one sidebar and swap it out a tick later,
|
||||
* remounting the tree. While hydrating, hold v1 — where both paths already
|
||||
* start.
|
||||
*/
|
||||
export function resolveSidebarV2Enabled(input: {
|
||||
readonly enabled: boolean;
|
||||
readonly configuredByUser: boolean;
|
||||
readonly settingsHydrated: boolean;
|
||||
readonly stageLabel: string;
|
||||
}): boolean {
|
||||
if (!input.settingsHydrated) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return input.configuredByUser || input.enabled
|
||||
? input.enabled
|
||||
: resolveSidebarV2Default(input.stageLabel);
|
||||
}
|
||||
|
||||
export function resolveServerBackedAppStageLabel(input: {
|
||||
readonly primaryServerVersion: string | null | undefined;
|
||||
readonly fallbackStageLabel: string;
|
||||
|
||||
@@ -2,8 +2,6 @@ import { afterEach, describe, expect, it, vi } from "vite-plus/test";
|
||||
import {
|
||||
resolveServerBackedAppDisplayName,
|
||||
resolveServerBackedAppStageLabel,
|
||||
resolveSidebarV2Default,
|
||||
resolveSidebarV2Enabled,
|
||||
} from "./branding.logic";
|
||||
|
||||
const originalWindow = globalThis.window;
|
||||
@@ -116,74 +114,3 @@ describe("branding logic", () => {
|
||||
).toBe("T3 Code (Alpha)");
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveSidebarV2Default", () => {
|
||||
it.each(["Nightly", "Dev", "nightly", " dev "])("enables the beta for %s builds", (stage) => {
|
||||
expect(resolveSidebarV2Default(stage)).toBe(true);
|
||||
});
|
||||
|
||||
it.each(["Alpha", "Latest", ""])("leaves the beta off for %s builds", (stage) => {
|
||||
expect(resolveSidebarV2Default(stage)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveSidebarV2Enabled", () => {
|
||||
const hydrated = { settingsHydrated: true } as const;
|
||||
|
||||
it.each(["Alpha", "Latest"])(
|
||||
"keeps a legacy opt-in on %s builds even without the companion flag",
|
||||
(stageLabel) => {
|
||||
// `true` was never the schema default, so it can only be an explicit
|
||||
// opt-in from settings written before `sidebarV2ConfiguredByUser` existed.
|
||||
expect(
|
||||
resolveSidebarV2Enabled({
|
||||
...hydrated,
|
||||
enabled: true,
|
||||
configuredByUser: false,
|
||||
stageLabel,
|
||||
}),
|
||||
).toBe(true);
|
||||
},
|
||||
);
|
||||
|
||||
it("applies the stage default when the beta was never enabled or configured", () => {
|
||||
expect(
|
||||
resolveSidebarV2Enabled({
|
||||
...hydrated,
|
||||
enabled: false,
|
||||
configuredByUser: false,
|
||||
stageLabel: "Nightly",
|
||||
}),
|
||||
).toBe(true);
|
||||
expect(
|
||||
resolveSidebarV2Enabled({
|
||||
...hydrated,
|
||||
enabled: false,
|
||||
configuredByUser: false,
|
||||
stageLabel: "Latest",
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("honors an explicit opt-out over the stage default", () => {
|
||||
expect(
|
||||
resolveSidebarV2Enabled({
|
||||
...hydrated,
|
||||
enabled: false,
|
||||
configuredByUser: true,
|
||||
stageLabel: "Nightly",
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("holds v1 until settings hydrate so the sidebar does not remount", () => {
|
||||
expect(
|
||||
resolveSidebarV2Enabled({
|
||||
enabled: true,
|
||||
configuredByUser: true,
|
||||
settingsHydrated: false,
|
||||
stageLabel: "Nightly",
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -14,9 +14,11 @@ import { getLocalStorageItem } from "../hooks/useLocalStorage";
|
||||
import { resolveShortcutCommand, shortcutLabelForCommand } from "../keybindings";
|
||||
import { cn, isMacPlatform } from "../lib/utils";
|
||||
import { primaryServerKeybindingsAtom } from "../state/server";
|
||||
import { useEnvironmentIdentificationMode, useSidebarV2Enabled } from "../hooks/useSettings";
|
||||
import { useEnvironmentIdentificationMode, useLegacySidebarEnabled } from "../hooks/useSettings";
|
||||
import LegacyThreadSidebar from "./LegacySidebar";
|
||||
import ThreadSidebar from "./Sidebar";
|
||||
import ThreadSidebarV2 from "./SidebarV2";
|
||||
import { SettingsSidebarNav } from "./settings/SettingsSidebarNav";
|
||||
import { SidebarChromeHeader } from "./sidebar/SidebarChrome";
|
||||
import { useSidebarStageBackdropVariant } from "./SidebarStageBackdrop";
|
||||
import {
|
||||
resolveInitialThreadSidebarWidth,
|
||||
@@ -118,13 +120,11 @@ function SidebarControl() {
|
||||
|
||||
export function AppSidebarLayout({ children }: { children: ReactNode }) {
|
||||
const navigate = useNavigate();
|
||||
const sidebarV2Enabled = useSidebarV2Enabled();
|
||||
// Settings routes render the settings nav, which lives in the v1 component
|
||||
// and is identical for both sidebars — so v1 stays mounted there.
|
||||
const legacySidebarEnabled = useLegacySidebarEnabled();
|
||||
// Settings routes show the settings nav in place of whichever thread
|
||||
// sidebar is active.
|
||||
const pathname = useLocation({ select: (location) => location.pathname });
|
||||
const isOnSettings = pathname === "/settings" || pathname.startsWith("/settings/");
|
||||
const useSidebarV2 = sidebarV2Enabled && !isOnSettings;
|
||||
const useSidebarV2Theme = useSidebarV2 || isOnSettings;
|
||||
const isMacosDesktop = isElectron && isMacPlatform(navigator.platform);
|
||||
const [sidebarWidth, setSidebarWidth] = useState(readInitialThreadSidebarWidth);
|
||||
// Subscribed rather than read once: the clamp must track live window size,
|
||||
@@ -188,7 +188,6 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {
|
||||
side="left"
|
||||
collapsible="offcanvas"
|
||||
data-app-sidebar=""
|
||||
data-sidebar-version={useSidebarV2Theme ? "v2" : "v1"}
|
||||
className="border-r border-sidebar-border bg-sidebar text-sidebar-foreground"
|
||||
resizable={{
|
||||
maxWidth: sidebarMaximumWidth,
|
||||
@@ -200,7 +199,16 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {
|
||||
onResize: setSidebarWidth,
|
||||
}}
|
||||
>
|
||||
{useSidebarV2 ? <ThreadSidebarV2 /> : <ThreadSidebar />}
|
||||
{isOnSettings ? (
|
||||
<>
|
||||
<SidebarChromeHeader isElectron={isElectron} />
|
||||
<SettingsSidebarNav pathname={pathname} />
|
||||
</>
|
||||
) : legacySidebarEnabled ? (
|
||||
<LegacyThreadSidebar />
|
||||
) : (
|
||||
<ThreadSidebar />
|
||||
)}
|
||||
<SidebarRail />
|
||||
</Sidebar>
|
||||
{children}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -17,7 +17,7 @@ import {
|
||||
resolveProjectStatusIndicator,
|
||||
resolveSidebarStageBadgeLabel,
|
||||
resolveThreadRowClassName,
|
||||
resolveSidebarV2Status,
|
||||
resolveSidebarThreadStatus,
|
||||
resolveThreadStatusPill,
|
||||
resolveWorkingStartedAt,
|
||||
searchSidebarThreadsByTitle,
|
||||
@@ -25,11 +25,11 @@ import {
|
||||
shouldNavigateAfterProjectRemoval,
|
||||
shouldClearThreadSelectionOnMouseDown,
|
||||
sortLogicalProjectsForSidebar,
|
||||
sortSettledThreadsForSidebarV2,
|
||||
sortSettledThreadsForSidebar,
|
||||
pinOrderKeyBetween,
|
||||
planPinnedReorder,
|
||||
sortPinnedThreadsForSidebarV2,
|
||||
sortThreadsForSidebarV2,
|
||||
sortPinnedThreadsForSidebar,
|
||||
sortThreadsForSidebar,
|
||||
sortProjectsForSidebar,
|
||||
sortScopedProjectsForSidebar,
|
||||
THREAD_JUMP_HINT_SHOW_DELAY_MS,
|
||||
@@ -627,7 +627,7 @@ describe("isContextMenuPointerDown", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveSidebarV2Status", () => {
|
||||
describe("resolveSidebarThreadStatus", () => {
|
||||
const session = {
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
status: "running" as const,
|
||||
@@ -642,15 +642,17 @@ describe("resolveSidebarV2Status", () => {
|
||||
const idle = { hasPendingApprovals: false, hasPendingUserInput: false };
|
||||
|
||||
it("prioritizes approval over a running session", () => {
|
||||
expect(resolveSidebarV2Status({ ...idle, hasPendingApprovals: true, session })).toBe(
|
||||
expect(resolveSidebarThreadStatus({ ...idle, hasPendingApprovals: true, session })).toBe(
|
||||
"approval",
|
||||
);
|
||||
});
|
||||
|
||||
it("prioritizes awaiting input over a running session, below approval", () => {
|
||||
expect(resolveSidebarV2Status({ ...idle, hasPendingUserInput: true, session })).toBe("input");
|
||||
expect(resolveSidebarThreadStatus({ ...idle, hasPendingUserInput: true, session })).toBe(
|
||||
"input",
|
||||
);
|
||||
expect(
|
||||
resolveSidebarV2Status({
|
||||
resolveSidebarThreadStatus({
|
||||
...idle,
|
||||
hasPendingApprovals: true,
|
||||
hasPendingUserInput: true,
|
||||
@@ -660,9 +662,9 @@ describe("resolveSidebarV2Status", () => {
|
||||
});
|
||||
|
||||
it("reports working for running and starting sessions", () => {
|
||||
expect(resolveSidebarV2Status({ ...idle, session })).toBe("working");
|
||||
expect(resolveSidebarThreadStatus({ ...idle, session })).toBe("working");
|
||||
expect(
|
||||
resolveSidebarV2Status({
|
||||
resolveSidebarThreadStatus({
|
||||
...idle,
|
||||
session: { ...session, status: "starting" as const },
|
||||
}),
|
||||
@@ -671,19 +673,19 @@ describe("resolveSidebarV2Status", () => {
|
||||
|
||||
it("reports failed only while the session status is error", () => {
|
||||
expect(
|
||||
resolveSidebarV2Status({
|
||||
resolveSidebarThreadStatus({
|
||||
...idle,
|
||||
session: { ...session, status: "error" as const, lastError: "boom" },
|
||||
}),
|
||||
).toBe("failed");
|
||||
expect(
|
||||
resolveSidebarV2Status({
|
||||
resolveSidebarThreadStatus({
|
||||
...idle,
|
||||
session: { ...session, status: "stopped" as const, lastError: "persisted" },
|
||||
}),
|
||||
).toBe("ready");
|
||||
expect(
|
||||
resolveSidebarV2Status({
|
||||
resolveSidebarThreadStatus({
|
||||
...idle,
|
||||
session: { ...session, status: "ready" as const, lastError: "persisted" },
|
||||
}),
|
||||
@@ -691,7 +693,7 @@ describe("resolveSidebarV2Status", () => {
|
||||
});
|
||||
|
||||
it("defaults to ready with no session", () => {
|
||||
expect(resolveSidebarV2Status({ ...idle, session: null })).toBe("ready");
|
||||
expect(resolveSidebarThreadStatus({ ...idle, session: null })).toBe("ready");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -715,14 +717,14 @@ describe("searchSidebarThreadsByTitle", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("sortThreadsForSidebarV2", () => {
|
||||
describe("sortThreadsForSidebar", () => {
|
||||
const sortable = (input: { id: string; createdAt: string }) => ({
|
||||
id: input.id,
|
||||
createdAt: input.createdAt,
|
||||
});
|
||||
|
||||
it("orders by creation time, newest first, ignoring activity", () => {
|
||||
const sorted = sortThreadsForSidebarV2([
|
||||
const sorted = sortThreadsForSidebar([
|
||||
sortable({ id: "oldest", createdAt: "2026-03-09T08:00:00.000Z" }),
|
||||
sortable({ id: "newest", createdAt: "2026-03-09T12:00:00.000Z" }),
|
||||
sortable({ id: "middle", createdAt: "2026-03-09T10:00:00.000Z" }),
|
||||
@@ -732,7 +734,7 @@ describe("sortThreadsForSidebarV2", () => {
|
||||
});
|
||||
|
||||
it("breaks creation-time ties by id so the order is stable", () => {
|
||||
const sorted = sortThreadsForSidebarV2([
|
||||
const sorted = sortThreadsForSidebar([
|
||||
sortable({ id: "b", createdAt: "2026-03-09T10:00:00.000Z" }),
|
||||
sortable({ id: "a", createdAt: "2026-03-09T10:00:00.000Z" }),
|
||||
]);
|
||||
@@ -838,7 +840,7 @@ describe("planPinnedReorder", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("sortPinnedThreadsForSidebarV2", () => {
|
||||
describe("sortPinnedThreadsForSidebar", () => {
|
||||
const pinnable = (input: { id: string; createdAt: string; pinOrderKey?: string | null }) => ({
|
||||
id: input.id,
|
||||
createdAt: input.createdAt,
|
||||
@@ -846,7 +848,7 @@ describe("sortPinnedThreadsForSidebarV2", () => {
|
||||
});
|
||||
|
||||
it("sorts keyed threads by key ahead of keyless threads in creation order", () => {
|
||||
const sorted = sortPinnedThreadsForSidebarV2([
|
||||
const sorted = sortPinnedThreadsForSidebar([
|
||||
pinnable({ id: "keyless-old", createdAt: "2026-03-09T08:00:00.000Z" }),
|
||||
pinnable({ id: "second", createdAt: "2026-03-09T09:00:00.000Z", pinOrderKey: "t" }),
|
||||
pinnable({ id: "keyless-new", createdAt: "2026-03-09T12:00:00.000Z" }),
|
||||
@@ -862,7 +864,7 @@ describe("sortPinnedThreadsForSidebarV2", () => {
|
||||
});
|
||||
|
||||
it("breaks equal keys by id so raced writes render identically everywhere", () => {
|
||||
const sorted = sortPinnedThreadsForSidebarV2([
|
||||
const sorted = sortPinnedThreadsForSidebar([
|
||||
pinnable({ id: "b", createdAt: "2026-03-09T10:00:00.000Z", pinOrderKey: "m" }),
|
||||
pinnable({ id: "a", createdAt: "2026-03-09T11:00:00.000Z", pinOrderKey: "m" }),
|
||||
]);
|
||||
@@ -871,7 +873,7 @@ describe("sortPinnedThreadsForSidebarV2", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("sortSettledThreadsForSidebarV2", () => {
|
||||
describe("sortSettledThreadsForSidebar", () => {
|
||||
const settled = (input: {
|
||||
id: string;
|
||||
settledAt?: string | null;
|
||||
@@ -887,7 +889,7 @@ describe("sortSettledThreadsForSidebarV2", () => {
|
||||
});
|
||||
|
||||
it("orders by settle time, most recently settled first", () => {
|
||||
const sorted = sortSettledThreadsForSidebarV2([
|
||||
const sorted = sortSettledThreadsForSidebar([
|
||||
settled({
|
||||
id: "settled-first",
|
||||
settledAt: "2026-03-09T10:00:00.000Z",
|
||||
@@ -905,7 +907,7 @@ describe("sortSettledThreadsForSidebarV2", () => {
|
||||
});
|
||||
|
||||
it("falls back to last activity for auto-settled threads without a settledAt stamp", () => {
|
||||
const sorted = sortSettledThreadsForSidebarV2([
|
||||
const sorted = sortSettledThreadsForSidebar([
|
||||
settled({ id: "auto-old", latestUserMessageAt: "2026-03-09T08:00:00.000Z" }),
|
||||
settled({ id: "explicit", settledAt: "2026-03-09T10:00:00.000Z" }),
|
||||
settled({ id: "auto-recent", latestUserMessageAt: "2026-03-09T11:00:00.000Z" }),
|
||||
@@ -917,7 +919,7 @@ describe("sortSettledThreadsForSidebarV2", () => {
|
||||
it("counts a turn completion as activity for auto-settled threads", () => {
|
||||
// The message came in before the other thread's, but its turn finished
|
||||
// after: completion time is the real "work ended" moment.
|
||||
const sorted = sortSettledThreadsForSidebarV2([
|
||||
const sorted = sortSettledThreadsForSidebar([
|
||||
settled({ id: "message-only", latestUserMessageAt: "2026-03-09T10:04:00.000Z" }),
|
||||
settled({
|
||||
id: "completed-later",
|
||||
@@ -930,7 +932,7 @@ describe("sortSettledThreadsForSidebarV2", () => {
|
||||
});
|
||||
|
||||
it("breaks timestamp ties by id so the order is stable", () => {
|
||||
const sorted = sortSettledThreadsForSidebarV2([
|
||||
const sorted = sortSettledThreadsForSidebar([
|
||||
settled({ id: "b", settledAt: "2026-03-09T10:00:00.000Z" }),
|
||||
settled({ id: "a", settledAt: "2026-03-09T10:00:00.000Z" }),
|
||||
]);
|
||||
|
||||
@@ -423,21 +423,27 @@ export function resolveThreadRowClassName(input: {
|
||||
);
|
||||
}
|
||||
|
||||
// ── Sidebar v2 status model ─────────────────────────────────────────
|
||||
// ── Sidebar thread status model ─────────────────────────────────────
|
||||
// Five visual states, three colors: color is reserved for "act now"
|
||||
// (approval), "in motion" (working), and "broken" (failed). Ready is the
|
||||
// unlabeled resting state — the agent stopped and is waiting on the user,
|
||||
// whether it finished, asked a question, or proposed a plan.
|
||||
// Unread completion is tracked separately: it describes whether a ready
|
||||
// thread needs attention, not what the thread is currently doing.
|
||||
export type SidebarV2Status = "approval" | "input" | "working" | "monitoring" | "failed" | "ready";
|
||||
export type SidebarThreadStatus =
|
||||
| "approval"
|
||||
| "input"
|
||||
| "working"
|
||||
| "monitoring"
|
||||
| "failed"
|
||||
| "ready";
|
||||
|
||||
type SidebarV2StatusInput = Pick<
|
||||
type SidebarThreadStatusInput = Pick<
|
||||
SidebarThreadSummary,
|
||||
"hasPendingApprovals" | "hasPendingUserInput" | "session" | "backgroundLiveness"
|
||||
>;
|
||||
|
||||
export function resolveSidebarV2Status(thread: SidebarV2StatusInput): SidebarV2Status {
|
||||
export function resolveSidebarThreadStatus(thread: SidebarThreadStatusInput): SidebarThreadStatus {
|
||||
if (thread.hasPendingApprovals) {
|
||||
return "approval";
|
||||
}
|
||||
@@ -496,11 +502,11 @@ export function firstValidTimestamp(
|
||||
return null;
|
||||
}
|
||||
|
||||
// v2 sort: static creation order, newest thread on top. Activity NEVER
|
||||
// Sidebar sort: static creation order, newest thread on top. Activity NEVER
|
||||
// reorders the list — a row holds its position from open until settled, so
|
||||
// the screen only moves at lifecycle transitions. Status (including pending
|
||||
// approval) is carried by each card's edge strip, not by position.
|
||||
export function sortThreadsForSidebarV2<
|
||||
export function sortThreadsForSidebar<
|
||||
T extends { readonly id: string; readonly createdAt: string },
|
||||
>(threads: readonly T[]): T[] {
|
||||
return [...threads].toSorted(
|
||||
@@ -517,7 +523,7 @@ export {
|
||||
pinOrderKeyBetween,
|
||||
planPinnedReorder,
|
||||
} from "@t3tools/client-runtime/state/thread-sort";
|
||||
export { sortPinnedThreadsByOrderKey as sortPinnedThreadsForSidebarV2 } from "@t3tools/client-runtime/state/thread-sort";
|
||||
export { sortPinnedThreadsByOrderKey as sortPinnedThreadsForSidebar } from "@t3tools/client-runtime/state/thread-sort";
|
||||
|
||||
/**
|
||||
* Search the already-ordered sidebar thread collection by title only.
|
||||
@@ -566,7 +572,7 @@ export function resolveSettledTimestamp(thread: SettledTimestampInput): string |
|
||||
|
||||
// Settled rows are history, so they order by when the work ENDED, not when
|
||||
// the thread was created or last touched.
|
||||
export function sortSettledThreadsForSidebarV2<
|
||||
export function sortSettledThreadsForSidebar<
|
||||
T extends SettledTimestampInput & { readonly id: string },
|
||||
>(threads: readonly T[]): T[] {
|
||||
const timestampMs = (thread: T) => {
|
||||
|
||||
+3384
-3309
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,120 +0,0 @@
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import {
|
||||
useClientSettings,
|
||||
useSidebarV2Enabled,
|
||||
useUpdateClientSettings,
|
||||
} from "../../hooks/useSettings";
|
||||
import { Input } from "../ui/input";
|
||||
import { Switch } from "../ui/switch";
|
||||
import { SettingsPageContainer, SettingsRow, SettingsSection } from "./settingsLayout";
|
||||
import { searchableSetting } from "./settingsSearch";
|
||||
|
||||
const AUTO_SETTLE_MIN_DAYS = 1;
|
||||
const AUTO_SETTLE_MAX_DAYS = 90;
|
||||
const AUTO_SETTLE_DEFAULT_DAYS = 3;
|
||||
|
||||
function AutoSettleDaysInput({
|
||||
value,
|
||||
onCommit,
|
||||
}: {
|
||||
value: number;
|
||||
onCommit: (days: number) => void;
|
||||
}) {
|
||||
// Local draft so the field can be emptied mid-edit; the setting only moves
|
||||
// on valid input and snaps back to the persisted value on blur.
|
||||
const [draft, setDraft] = useState(String(value));
|
||||
useEffect(() => {
|
||||
setDraft(String(value));
|
||||
}, [value]);
|
||||
|
||||
return (
|
||||
<Input
|
||||
type="number"
|
||||
min={AUTO_SETTLE_MIN_DAYS}
|
||||
max={AUTO_SETTLE_MAX_DAYS}
|
||||
className="w-full sm:w-24"
|
||||
value={draft}
|
||||
onChange={(event) => {
|
||||
setDraft(event.target.value);
|
||||
// Number(), not parseInt: "3.5" must be rejected (not truncated to a
|
||||
// committed 3 while the field shows 3.5) — commit only when the
|
||||
// persisted value matches the displayed one.
|
||||
const parsed = Number(event.target.value);
|
||||
if (
|
||||
Number.isInteger(parsed) &&
|
||||
parsed >= AUTO_SETTLE_MIN_DAYS &&
|
||||
parsed <= AUTO_SETTLE_MAX_DAYS
|
||||
) {
|
||||
onCommit(parsed);
|
||||
}
|
||||
}}
|
||||
onBlur={() => setDraft(String(value))}
|
||||
aria-label="Days of inactivity before auto-settle"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function BetaSettingsPanel() {
|
||||
const sidebarV2Enabled = useSidebarV2Enabled();
|
||||
const sidebarAutoSettleAfterDays = useClientSettings(
|
||||
(settings) => settings.sidebarAutoSettleAfterDays,
|
||||
);
|
||||
const updateSettings = useUpdateClientSettings();
|
||||
|
||||
return (
|
||||
<SettingsPageContainer>
|
||||
<SettingsSection title="Beta features">
|
||||
<SettingsRow
|
||||
{...searchableSetting("sidebar-v2")}
|
||||
description="One flat thread list in creation order. Active work renders as rich cards; settled threads collapse to compact rows. Settling requires an up-to-date server — on older servers threads simply stay active. Switch back any time."
|
||||
control={
|
||||
<Switch
|
||||
checked={sidebarV2Enabled}
|
||||
// Touching the switch pins the choice, so a nightly build that
|
||||
// defaults v2 on does not flip it back after the user opts out.
|
||||
onCheckedChange={(checked) =>
|
||||
updateSettings({
|
||||
sidebarV2Enabled: Boolean(checked),
|
||||
sidebarV2ConfiguredByUser: true,
|
||||
})
|
||||
}
|
||||
aria-label="Enable the sidebar v2 beta"
|
||||
/>
|
||||
}
|
||||
/>
|
||||
{sidebarV2Enabled ? (
|
||||
<>
|
||||
<SettingsRow
|
||||
title={searchableSetting("auto-settle-inactive-threads").title}
|
||||
description="Threads with no activity for this long settle automatically. Threads on merged or closed PRs always settle."
|
||||
control={
|
||||
<Switch
|
||||
checked={sidebarAutoSettleAfterDays !== null}
|
||||
onCheckedChange={(checked) =>
|
||||
updateSettings({
|
||||
sidebarAutoSettleAfterDays: checked ? AUTO_SETTLE_DEFAULT_DAYS : null,
|
||||
})
|
||||
}
|
||||
aria-label="Auto-settle inactive threads"
|
||||
/>
|
||||
}
|
||||
/>
|
||||
{sidebarAutoSettleAfterDays !== null ? (
|
||||
<SettingsRow
|
||||
title="Days of inactivity before auto-settle"
|
||||
description="Any new activity un-settles a thread automatically."
|
||||
control={
|
||||
<AutoSettleDaysInput
|
||||
value={sidebarAutoSettleAfterDays}
|
||||
onCommit={(days) => updateSettings({ sidebarAutoSettleAfterDays: days })}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
</>
|
||||
) : null}
|
||||
</SettingsSection>
|
||||
</SettingsPageContainer>
|
||||
);
|
||||
}
|
||||
@@ -24,11 +24,13 @@ import {
|
||||
MAX_GLASS_OPACITY,
|
||||
MAX_INTERFACE_FONT_SIZE,
|
||||
MAX_PROMPT_FONT_SIZE,
|
||||
MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
|
||||
MAX_TERMINAL_FONT_SIZE,
|
||||
MIN_CODE_FONT_SIZE,
|
||||
MIN_GLASS_OPACITY,
|
||||
MIN_INTERFACE_FONT_SIZE,
|
||||
MIN_PROMPT_FONT_SIZE,
|
||||
MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
|
||||
MIN_TERMINAL_FONT_SIZE,
|
||||
} from "@t3tools/contracts/settings";
|
||||
import { resolveServerBackgroundActivitySettings } from "@t3tools/shared/backgroundActivitySettings";
|
||||
@@ -463,6 +465,10 @@ export function useSettingsRestore(onRestored?: () => void) {
|
||||
DEFAULT_UNIFIED_SETTINGS.sidebarProjectGroupingMode
|
||||
? ["Project Grouping"]
|
||||
: []),
|
||||
...(settings.sidebarAutoSettleAfterDays !==
|
||||
DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleAfterDays
|
||||
? ["Auto-settle inactive threads"]
|
||||
: []),
|
||||
...(settings.wordWrap !== DEFAULT_UNIFIED_SETTINGS.wordWrap ? ["Word wrap"] : []),
|
||||
...(settings.fontFamilySans !== DEFAULT_UNIFIED_SETTINGS.fontFamilySans
|
||||
? ["Interface font"]
|
||||
@@ -525,6 +531,7 @@ export function useSettingsRestore(onRestored?: () => void) {
|
||||
settings.glassOpacity,
|
||||
settings.enableLegacyTokenStreaming,
|
||||
settings.enableProviderUpdateChecks,
|
||||
settings.sidebarAutoSettleAfterDays,
|
||||
settings.sidebarProjectGroupingMode,
|
||||
settings.sidebarThreadPreviewCount,
|
||||
settings.timestampFormat,
|
||||
@@ -603,6 +610,7 @@ export function useSettingsRestore(onRestored?: () => void) {
|
||||
glassOpacity: DEFAULT_UNIFIED_SETTINGS.glassOpacity,
|
||||
sidebarThreadPreviewCount: DEFAULT_UNIFIED_SETTINGS.sidebarThreadPreviewCount,
|
||||
sidebarProjectGroupingMode: DEFAULT_UNIFIED_SETTINGS.sidebarProjectGroupingMode,
|
||||
sidebarAutoSettleAfterDays: DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleAfterDays,
|
||||
enableLegacyTokenStreaming: DEFAULT_UNIFIED_SETTINGS.enableLegacyTokenStreaming,
|
||||
enableProviderUpdateChecks: DEFAULT_UNIFIED_SETTINGS.enableProviderUpdateChecks,
|
||||
backgroundActivity: DEFAULT_UNIFIED_SETTINGS.backgroundActivity,
|
||||
@@ -1506,11 +1514,55 @@ function FontFamilySettingsRow({
|
||||
);
|
||||
}
|
||||
|
||||
// Both legacy rows sit behind the fold, so a settings-search jump has to
|
||||
const AUTO_SETTLE_DEFAULT_DAYS = DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleAfterDays ?? 3;
|
||||
|
||||
function AutoSettleDaysInput({
|
||||
value,
|
||||
onCommit,
|
||||
}: {
|
||||
value: number;
|
||||
onCommit: (days: number) => void;
|
||||
}) {
|
||||
// Local draft so the field can be emptied mid-edit; the setting only moves
|
||||
// on valid input and snaps back to the persisted value on blur.
|
||||
const [draft, setDraft] = useState(String(value));
|
||||
useEffect(() => {
|
||||
setDraft(String(value));
|
||||
}, [value]);
|
||||
|
||||
return (
|
||||
<Input
|
||||
type="number"
|
||||
min={MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS}
|
||||
max={MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS}
|
||||
className="w-full sm:w-24"
|
||||
value={draft}
|
||||
onChange={(event) => {
|
||||
setDraft(event.target.value);
|
||||
// Number(), not parseInt: "3.5" must be rejected (not truncated to a
|
||||
// committed 3 while the field shows 3.5) — commit only when the
|
||||
// persisted value matches the displayed one.
|
||||
const parsed = Number(event.target.value);
|
||||
if (
|
||||
Number.isInteger(parsed) &&
|
||||
parsed >= MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS &&
|
||||
parsed <= MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS
|
||||
) {
|
||||
onCommit(parsed);
|
||||
}
|
||||
}}
|
||||
onBlur={() => setDraft(String(value))}
|
||||
aria-label="Days of inactivity before auto-settle"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
// The legacy rows sit behind the fold, so a settings-search jump has to
|
||||
// expand the section before its target can mount and scroll.
|
||||
const LEGACY_FEATURE_TARGET_IDS: ReadonlySet<string> = new Set([
|
||||
"legacy-plan-mode",
|
||||
"legacy-token-streaming",
|
||||
"legacy-sidebar",
|
||||
]);
|
||||
|
||||
/**
|
||||
@@ -1589,6 +1641,19 @@ function LegacyFeaturesSection() {
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<SettingsRow
|
||||
{...searchableSetting("legacy-sidebar")}
|
||||
description="Brings back the original sidebar with per-project thread trees. The default sidebar shows one flat list: active work as rich cards, settled threads as compact rows."
|
||||
control={
|
||||
<Switch
|
||||
checked={settings.legacySidebarEnabled}
|
||||
onCheckedChange={(checked) =>
|
||||
updateSettings({ legacySidebarEnabled: Boolean(checked) })
|
||||
}
|
||||
aria-label="Sidebar (legacy)"
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</CollapsiblePanel>
|
||||
</Collapsible>
|
||||
@@ -1688,6 +1753,47 @@ export function GeneralSettingsPanel() {
|
||||
}
|
||||
/>
|
||||
|
||||
<SettingsRow
|
||||
{...searchableSetting("auto-settle-inactive-threads")}
|
||||
description="Sidebar threads with no activity for this long settle automatically. Threads on merged or closed PRs always settle."
|
||||
resetAction={
|
||||
settings.sidebarAutoSettleAfterDays !==
|
||||
DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleAfterDays ? (
|
||||
<SettingResetButton
|
||||
label="auto-settle"
|
||||
onClick={() =>
|
||||
updateSettings({
|
||||
sidebarAutoSettleAfterDays: DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleAfterDays,
|
||||
})
|
||||
}
|
||||
/>
|
||||
) : null
|
||||
}
|
||||
control={
|
||||
<Switch
|
||||
checked={settings.sidebarAutoSettleAfterDays !== null}
|
||||
onCheckedChange={(checked) =>
|
||||
updateSettings({
|
||||
sidebarAutoSettleAfterDays: checked ? AUTO_SETTLE_DEFAULT_DAYS : null,
|
||||
})
|
||||
}
|
||||
aria-label="Auto-settle inactive threads"
|
||||
/>
|
||||
}
|
||||
/>
|
||||
{settings.sidebarAutoSettleAfterDays !== null ? (
|
||||
<SettingsRow
|
||||
title="Days of inactivity before auto-settle"
|
||||
description="Any new activity un-settles a thread automatically."
|
||||
control={
|
||||
<AutoSettleDaysInput
|
||||
value={settings.sidebarAutoSettleAfterDays}
|
||||
onCommit={(days) => updateSettings({ sidebarAutoSettleAfterDays: days })}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
<SettingsRow
|
||||
{...searchableSetting("time-format")}
|
||||
description="System default follows your browser or OS clock preference."
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
ArchiveIcon,
|
||||
ArrowLeftIcon,
|
||||
BotIcon,
|
||||
FlaskConicalIcon,
|
||||
GitBranchIcon,
|
||||
KeyboardIcon,
|
||||
Link2Icon,
|
||||
@@ -52,7 +51,6 @@ const SETTINGS_SECTION_ICONS: Readonly<
|
||||
"/settings/providers": BotIcon,
|
||||
"/settings/source-control": GitBranchIcon,
|
||||
"/settings/connections": Link2Icon,
|
||||
"/settings/beta": FlaskConicalIcon,
|
||||
"/settings/archived": ArchiveIcon,
|
||||
};
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ export type SettingsPath =
|
||||
| "/settings/providers"
|
||||
| "/settings/source-control"
|
||||
| "/settings/connections"
|
||||
| "/settings/beta"
|
||||
| "/settings/archived";
|
||||
|
||||
export interface SettingsSearchItem {
|
||||
@@ -26,7 +25,6 @@ export const SETTINGS_SECTION_LABELS: Readonly<Record<SettingsPath, string>> = {
|
||||
"/settings/providers": "Providers",
|
||||
"/settings/source-control": "Source Control",
|
||||
"/settings/connections": "Connections",
|
||||
"/settings/beta": "Beta",
|
||||
"/settings/archived": "Archive",
|
||||
};
|
||||
|
||||
@@ -100,6 +98,11 @@ export const SETTINGS_SEARCH_ITEMS = [
|
||||
title: "Project grouping",
|
||||
to: "/settings/general",
|
||||
},
|
||||
{
|
||||
id: "auto-settle-inactive-threads",
|
||||
title: "Auto-settle inactive threads",
|
||||
to: "/settings/general",
|
||||
},
|
||||
{
|
||||
id: "time-format",
|
||||
title: "Time format",
|
||||
@@ -161,6 +164,11 @@ export const SETTINGS_SEARCH_ITEMS = [
|
||||
title: "Stream token by token (legacy)",
|
||||
to: "/settings/general",
|
||||
},
|
||||
{
|
||||
id: "legacy-sidebar",
|
||||
title: "Sidebar (legacy)",
|
||||
to: "/settings/general",
|
||||
},
|
||||
{
|
||||
id: "keybindings",
|
||||
title: "Keybindings",
|
||||
@@ -181,17 +189,6 @@ export const SETTINGS_SEARCH_ITEMS = [
|
||||
title: "Remote environments",
|
||||
to: "/settings/connections",
|
||||
},
|
||||
{
|
||||
id: "sidebar-v2",
|
||||
title: "Sidebar v2",
|
||||
to: "/settings/beta",
|
||||
},
|
||||
{
|
||||
id: "auto-settle-inactive-threads",
|
||||
title: "Auto-settle inactive threads",
|
||||
to: "/settings/beta",
|
||||
targetId: "sidebar-v2",
|
||||
},
|
||||
{
|
||||
id: "archive",
|
||||
title: "Archived threads",
|
||||
|
||||
@@ -25,8 +25,6 @@ import {
|
||||
type UnifiedSettings,
|
||||
} from "@t3tools/contracts/settings";
|
||||
import { safeErrorLogAttributes } from "@t3tools/client-runtime/errors";
|
||||
import { APP_STAGE_LABEL } from "~/branding";
|
||||
import { resolveSidebarV2Enabled } from "~/branding.logic";
|
||||
import { ensureLocalApi } from "~/localApi";
|
||||
import {
|
||||
getThemeDefinition,
|
||||
@@ -266,29 +264,18 @@ export function useEnvironmentIdentificationMode(): EnvironmentIdentificationMod
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolved sidebar v2 state: an explicit choice in Settings → Beta if the user
|
||||
* has made one, otherwise the default for this build stage (on for nightly and
|
||||
* dev, off for production). Every consumer must read through this rather than
|
||||
* `settings.sidebarV2Enabled`, which is only meaningful alongside
|
||||
* `sidebarV2ConfiguredByUser`.
|
||||
* Whether the legacy sidebar (Settings → General → Legacy features) replaces
|
||||
* the default one.
|
||||
*
|
||||
* Held at v1 until client settings hydrate. The pre-hydration snapshot is just
|
||||
* the schema defaults, so resolving against it would mount one sidebar and then
|
||||
* swap it out once persisted settings land — remounting the whole tree.
|
||||
* Held at the default sidebar until client settings hydrate: the pre-hydration
|
||||
* snapshot is just the schema defaults, so resolving against it could mount one
|
||||
* sidebar and then swap it out once persisted settings land — remounting the
|
||||
* whole tree for everyone instead of only for legacy opt-ins.
|
||||
*/
|
||||
export function useSidebarV2Enabled(): boolean {
|
||||
export function useLegacySidebarEnabled(): boolean {
|
||||
const settingsHydrated = useClientSettingsHydrated();
|
||||
const settings = useClientSettingsValue();
|
||||
return useMemo(
|
||||
() =>
|
||||
resolveSidebarV2Enabled({
|
||||
enabled: settings.sidebarV2Enabled,
|
||||
configuredByUser: settings.sidebarV2ConfiguredByUser,
|
||||
settingsHydrated,
|
||||
stageLabel: APP_STAGE_LABEL,
|
||||
}),
|
||||
[settings.sidebarV2Enabled, settings.sidebarV2ConfiguredByUser, settingsHydrated],
|
||||
);
|
||||
const legacySidebarEnabled = useClientSettingsValue().legacySidebarEnabled;
|
||||
return settingsHydrated && legacySidebarEnabled;
|
||||
}
|
||||
|
||||
/** Read current settings for one environment, merged with client-local preferences. */
|
||||
|
||||
+6
-10
@@ -995,12 +995,10 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
|
||||
}
|
||||
}
|
||||
|
||||
/* Keep both navigation implementations on the same quiet zinc hierarchy:
|
||||
zinc-50 navigation, zinc-25 hover, and white selected/raised surfaces.
|
||||
The version attribute remains useful for layout-specific styling without
|
||||
changing the color system when the beta is toggled. */
|
||||
[data-sidebar-version="v1"],
|
||||
[data-sidebar-version="v2"] {
|
||||
/* Keep both sidebar implementations (default and legacy) on the same quiet
|
||||
zinc hierarchy: zinc-50 navigation, zinc-25 hover, and white selected/raised
|
||||
surfaces. */
|
||||
[data-app-sidebar] {
|
||||
--background: var(--color-zinc-25);
|
||||
--foreground: var(--color-zinc-800);
|
||||
--card: var(--color-white);
|
||||
@@ -1023,8 +1021,7 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
|
||||
background-color: var(--sidebar);
|
||||
}
|
||||
|
||||
.dark [data-sidebar-version="v1"],
|
||||
.dark [data-sidebar-version="v2"] {
|
||||
.dark [data-app-sidebar] {
|
||||
--background: #000;
|
||||
--foreground: #f1f3f7;
|
||||
--card: #000;
|
||||
@@ -1321,8 +1318,7 @@ html[data-theme-id] .chat-markdown .chat-markdown-chrome-action[aria-pressed="tr
|
||||
color: var(--code-foreground);
|
||||
}
|
||||
|
||||
html[data-theme-id] [data-sidebar-version="v1"],
|
||||
html[data-theme-id] [data-sidebar-version="v2"] {
|
||||
html[data-theme-id] [data-app-sidebar] {
|
||||
--background: var(--app-theme-canvas);
|
||||
--foreground: var(--app-theme-text);
|
||||
--card: var(--app-theme-surface);
|
||||
|
||||
@@ -20,7 +20,6 @@ import { Route as SettingsKeybindingsRouteImport } from './routes/settings.keybi
|
||||
import { Route as SettingsGeneralRouteImport } from './routes/settings.general'
|
||||
import { Route as SettingsDiagnosticsRouteImport } from './routes/settings.diagnostics'
|
||||
import { Route as SettingsConnectionsRouteImport } from './routes/settings.connections'
|
||||
import { Route as SettingsBetaRouteImport } from './routes/settings.beta'
|
||||
import { Route as SettingsArchivedRouteImport } from './routes/settings.archived'
|
||||
import { Route as SettingsAppearanceRouteImport } from './routes/settings.appearance'
|
||||
import { Route as ConnectCallbackRouteImport } from './routes/connect_.callback'
|
||||
@@ -81,11 +80,6 @@ const SettingsConnectionsRoute = SettingsConnectionsRouteImport.update({
|
||||
path: '/connections',
|
||||
getParentRoute: () => SettingsRoute,
|
||||
} as any)
|
||||
const SettingsBetaRoute = SettingsBetaRouteImport.update({
|
||||
id: '/beta',
|
||||
path: '/beta',
|
||||
getParentRoute: () => SettingsRoute,
|
||||
} as any)
|
||||
const SettingsArchivedRoute = SettingsArchivedRouteImport.update({
|
||||
id: '/archived',
|
||||
path: '/archived',
|
||||
@@ -121,7 +115,6 @@ export interface FileRoutesByFullPath {
|
||||
'/connect/callback': typeof ConnectCallbackRoute
|
||||
'/settings/appearance': typeof SettingsAppearanceRoute
|
||||
'/settings/archived': typeof SettingsArchivedRoute
|
||||
'/settings/beta': typeof SettingsBetaRoute
|
||||
'/settings/connections': typeof SettingsConnectionsRoute
|
||||
'/settings/diagnostics': typeof SettingsDiagnosticsRoute
|
||||
'/settings/general': typeof SettingsGeneralRoute
|
||||
@@ -138,7 +131,6 @@ export interface FileRoutesByTo {
|
||||
'/connect/callback': typeof ConnectCallbackRoute
|
||||
'/settings/appearance': typeof SettingsAppearanceRoute
|
||||
'/settings/archived': typeof SettingsArchivedRoute
|
||||
'/settings/beta': typeof SettingsBetaRoute
|
||||
'/settings/connections': typeof SettingsConnectionsRoute
|
||||
'/settings/diagnostics': typeof SettingsDiagnosticsRoute
|
||||
'/settings/general': typeof SettingsGeneralRoute
|
||||
@@ -158,7 +150,6 @@ export interface FileRoutesById {
|
||||
'/connect_/callback': typeof ConnectCallbackRoute
|
||||
'/settings/appearance': typeof SettingsAppearanceRoute
|
||||
'/settings/archived': typeof SettingsArchivedRoute
|
||||
'/settings/beta': typeof SettingsBetaRoute
|
||||
'/settings/connections': typeof SettingsConnectionsRoute
|
||||
'/settings/diagnostics': typeof SettingsDiagnosticsRoute
|
||||
'/settings/general': typeof SettingsGeneralRoute
|
||||
@@ -179,7 +170,6 @@ export interface FileRouteTypes {
|
||||
| '/connect/callback'
|
||||
| '/settings/appearance'
|
||||
| '/settings/archived'
|
||||
| '/settings/beta'
|
||||
| '/settings/connections'
|
||||
| '/settings/diagnostics'
|
||||
| '/settings/general'
|
||||
@@ -196,7 +186,6 @@ export interface FileRouteTypes {
|
||||
| '/connect/callback'
|
||||
| '/settings/appearance'
|
||||
| '/settings/archived'
|
||||
| '/settings/beta'
|
||||
| '/settings/connections'
|
||||
| '/settings/diagnostics'
|
||||
| '/settings/general'
|
||||
@@ -215,7 +204,6 @@ export interface FileRouteTypes {
|
||||
| '/connect_/callback'
|
||||
| '/settings/appearance'
|
||||
| '/settings/archived'
|
||||
| '/settings/beta'
|
||||
| '/settings/connections'
|
||||
| '/settings/diagnostics'
|
||||
| '/settings/general'
|
||||
@@ -314,13 +302,6 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof SettingsConnectionsRouteImport
|
||||
parentRoute: typeof SettingsRoute
|
||||
}
|
||||
'/settings/beta': {
|
||||
id: '/settings/beta'
|
||||
path: '/beta'
|
||||
fullPath: '/settings/beta'
|
||||
preLoaderRoute: typeof SettingsBetaRouteImport
|
||||
parentRoute: typeof SettingsRoute
|
||||
}
|
||||
'/settings/archived': {
|
||||
id: '/settings/archived'
|
||||
path: '/archived'
|
||||
@@ -376,7 +357,6 @@ const ChatRouteWithChildren = ChatRoute._addFileChildren(ChatRouteChildren)
|
||||
interface SettingsRouteChildren {
|
||||
SettingsAppearanceRoute: typeof SettingsAppearanceRoute
|
||||
SettingsArchivedRoute: typeof SettingsArchivedRoute
|
||||
SettingsBetaRoute: typeof SettingsBetaRoute
|
||||
SettingsConnectionsRoute: typeof SettingsConnectionsRoute
|
||||
SettingsDiagnosticsRoute: typeof SettingsDiagnosticsRoute
|
||||
SettingsGeneralRoute: typeof SettingsGeneralRoute
|
||||
@@ -388,7 +368,6 @@ interface SettingsRouteChildren {
|
||||
const SettingsRouteChildren: SettingsRouteChildren = {
|
||||
SettingsAppearanceRoute: SettingsAppearanceRoute,
|
||||
SettingsArchivedRoute: SettingsArchivedRoute,
|
||||
SettingsBetaRoute: SettingsBetaRoute,
|
||||
SettingsConnectionsRoute: SettingsConnectionsRoute,
|
||||
SettingsDiagnosticsRoute: SettingsDiagnosticsRoute,
|
||||
SettingsGeneralRoute: SettingsGeneralRoute,
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useAtomValue } from "@effect/atom-react";
|
||||
import { useEffect, useMemo } from "react";
|
||||
|
||||
import { isCommandPaletteOpen } from "../commandPaletteBus";
|
||||
import { useClientSettings, useSidebarV2Enabled } from "../hooks/useSettings";
|
||||
import { useClientSettings, useLegacySidebarEnabled } from "../hooks/useSettings";
|
||||
import { openCommandPalette } from "../commandPaletteBus";
|
||||
import { useProjects } from "../state/entities";
|
||||
import { usePrimaryEnvironmentId } from "../state/environments";
|
||||
@@ -28,7 +28,7 @@ function ChatRouteGlobalShortcuts() {
|
||||
const { activeDraftThread, activeThread, defaultProjectRef, handleNewThread, routeThreadRef } =
|
||||
useHandleNewThread();
|
||||
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
|
||||
const sidebarV2Enabled = useSidebarV2Enabled();
|
||||
const legacySidebarEnabled = useLegacySidebarEnabled();
|
||||
const projectGroupingSettings = useClientSettings(selectProjectGroupingSettings);
|
||||
const projects = useProjects();
|
||||
const primaryEnvironmentId = usePrimaryEnvironmentId();
|
||||
@@ -92,10 +92,10 @@ function ChatRouteGlobalShortcuts() {
|
||||
if (command === "chat.new") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
// Sidebar v2 routes creation through the command palette whenever
|
||||
// there is a real choice to make; v1 (and single-project setups)
|
||||
// keep the immediate contextual create.
|
||||
if (sidebarV2Enabled && projectGroupCount > 1) {
|
||||
// The default sidebar routes creation through the command palette
|
||||
// whenever there is a real choice to make; the legacy sidebar (and
|
||||
// single-project setups) keep the immediate contextual create.
|
||||
if (!legacySidebarEnabled && projectGroupCount > 1) {
|
||||
openCommandPalette({ open: "new-thread-in" });
|
||||
return;
|
||||
}
|
||||
@@ -167,7 +167,7 @@ function ChatRouteGlobalShortcuts() {
|
||||
projectGroupCount,
|
||||
routeThreadRef,
|
||||
selectedThreadKeysSize,
|
||||
sidebarV2Enabled,
|
||||
legacySidebarEnabled,
|
||||
terminalOpen,
|
||||
]);
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
import { BetaSettingsPanel } from "../components/settings/BetaSettingsPanel";
|
||||
|
||||
function SettingsBetaRoute() {
|
||||
return <BetaSettingsPanel />;
|
||||
}
|
||||
|
||||
export const Route = createFileRoute("/settings/beta")({
|
||||
component: SettingsBetaRoute,
|
||||
});
|
||||
@@ -67,36 +67,28 @@ describe("ClientSettings environment identification", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("ClientSettings sidebar v2", () => {
|
||||
it("defaults the beta off with a three-day auto-settle threshold", () => {
|
||||
describe("ClientSettings sidebar", () => {
|
||||
it("defaults to the current sidebar with a three-day auto-settle threshold", () => {
|
||||
const settings = decodeClientSettings({});
|
||||
expect(settings.sidebarV2Enabled).toBe(false);
|
||||
expect(settings.legacySidebarEnabled).toBe(false);
|
||||
expect(settings.sidebarAutoSettleAfterDays).toBe(3);
|
||||
});
|
||||
|
||||
it("treats settings written before the beta had a per-channel default as unconfigured", () => {
|
||||
// The stored blob always carries `sidebarV2Enabled`, so only the companion
|
||||
// flag can distinguish "user opted out" from "never touched it".
|
||||
expect(decodeClientSettings({ sidebarV2Enabled: false }).sidebarV2ConfiguredByUser).toBe(false);
|
||||
expect(decodeClientSettings({ sidebarV2Enabled: true }).sidebarV2ConfiguredByUser).toBe(false);
|
||||
});
|
||||
|
||||
it("preserves an explicit beta choice", () => {
|
||||
const settings = decodeClientSettings({
|
||||
it("drops the retired sidebar v2 beta keys, resetting everyone to the default", () => {
|
||||
const decoded = decodeClientSettings({
|
||||
sidebarV2Enabled: false,
|
||||
sidebarV2ConfiguredByUser: true,
|
||||
});
|
||||
expect(settings.sidebarV2Enabled).toBe(false);
|
||||
expect(settings.sidebarV2ConfiguredByUser).toBe(true);
|
||||
expect(decoded.legacySidebarEnabled).toBe(false);
|
||||
expect(decoded).not.toHaveProperty("sidebarV2Enabled");
|
||||
expect(decoded).not.toHaveProperty("sidebarV2ConfiguredByUser");
|
||||
});
|
||||
|
||||
it("carries an explicit beta opt-out through the patch the beta toggle writes", () => {
|
||||
const patch = decodeClientSettingsPatch({
|
||||
sidebarV2Enabled: false,
|
||||
sidebarV2ConfiguredByUser: true,
|
||||
});
|
||||
expect(patch.sidebarV2Enabled).toBe(false);
|
||||
expect(patch.sidebarV2ConfiguredByUser).toBe(true);
|
||||
it("preserves an explicit legacy sidebar opt-in", () => {
|
||||
expect(decodeClientSettings({ legacySidebarEnabled: true }).legacySidebarEnabled).toBe(true);
|
||||
expect(decodeClientSettingsPatch({ legacySidebarEnabled: true }).legacySidebarEnabled).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
it("allows auto-settle by inactivity to be disabled", () => {
|
||||
|
||||
@@ -171,6 +171,11 @@ 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 sidebar (the original per-project tree). Deliberately a fresh key
|
||||
// (was `sidebarV2Enabled` + `sidebarV2ConfiguredByUser`): decoding drops the
|
||||
// old keys, so everyone, including prior beta opt-outs, resets to the new
|
||||
// default sidebar.
|
||||
legacySidebarEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
|
||||
sidebarAutoSettleAfterDays: Schema.NullOr(SidebarAutoSettleAfterDays).pipe(
|
||||
Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_AUTO_SETTLE_AFTER_DAYS)),
|
||||
),
|
||||
@@ -190,13 +195,6 @@ export const ClientSettingsSchema = Schema.Struct({
|
||||
sidebarThreadPreviewCount: SidebarThreadPreviewCount.pipe(
|
||||
Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_THREAD_PREVIEW_COUNT)),
|
||||
),
|
||||
sidebarV2Enabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
|
||||
// Whether `sidebarV2Enabled` reflects an explicit choice in Settings → Beta.
|
||||
// Client settings persist as a whole blob, so every user who has ever touched
|
||||
// any setting already has `sidebarV2Enabled: false` stored — without this bit
|
||||
// there is no way to tell that apart from "left alone", and a channel-derived
|
||||
// default could never reach them. Mirrors `updateChannelConfiguredByUser`.
|
||||
sidebarV2ConfiguredByUser: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
|
||||
timestampFormat: TimestampFormat.pipe(
|
||||
Schema.withDecodingDefault(Effect.succeed(DEFAULT_TIMESTAMP_FORMAT)),
|
||||
),
|
||||
@@ -791,6 +789,7 @@ export const ClientSettingsPatch = Schema.Struct({
|
||||
),
|
||||
),
|
||||
planModeEnabled: Schema.optionalKey(Schema.Boolean),
|
||||
legacySidebarEnabled: Schema.optionalKey(Schema.Boolean),
|
||||
sidebarAutoSettleAfterDays: Schema.optionalKey(Schema.NullOr(SidebarAutoSettleAfterDays)),
|
||||
sidebarProjectGroupingMode: Schema.optionalKey(SidebarProjectGroupingMode),
|
||||
sidebarProjectGroupingOverrides: Schema.optionalKey(
|
||||
@@ -799,8 +798,6 @@ export const ClientSettingsPatch = Schema.Struct({
|
||||
sidebarProjectSortOrder: Schema.optionalKey(SidebarProjectSortOrder),
|
||||
sidebarThreadSortOrder: Schema.optionalKey(SidebarThreadSortOrder),
|
||||
sidebarThreadPreviewCount: Schema.optionalKey(SidebarThreadPreviewCount),
|
||||
sidebarV2Enabled: Schema.optionalKey(Schema.Boolean),
|
||||
sidebarV2ConfiguredByUser: Schema.optionalKey(Schema.Boolean),
|
||||
timestampFormat: Schema.optionalKey(TimestampFormat),
|
||||
wordWrap: Schema.optionalKey(Schema.Boolean),
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user