Skip to content

Commit 4feddb6

Browse files
committed
Fix settings routing and remove duplicate migration helpers
1 parent a3b9af5 commit 4feddb6

File tree

13 files changed

+173
-189
lines changed

13 files changed

+173
-189
lines changed

apps/server/src/persistence/Migrations.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import Migration0015 from "./Migrations/015_ProjectionTurnsSourceProposedPlan.ts
3131
import Migration0016 from "./Migrations/016_CanonicalizeModelSelections.ts";
3232
import Migration0017 from "./Migrations/017_ProjectionThreadsArchivedAt.ts";
3333
import Migration0018 from "./Migrations/018_ProjectionThreadsArchivedAtIndex.ts";
34-
import Migration0019 from "./Migrations/019_FixProjectDefaultModelSelection.ts";
3534

3635
/**
3736
* Migration loader with all migrations defined inline.
@@ -62,7 +61,6 @@ export const migrationEntries = [
6261
[16, "CanonicalizeModelSelections", Migration0016],
6362
[17, "ProjectionThreadsArchivedAt", Migration0017],
6463
[18, "ProjectionThreadsArchivedAtIndex", Migration0018],
65-
[19, "FixProjectDefaultModelSelection", Migration0019],
6664
] as const;
6765

6866
export const makeMigrationLoader = (throughId?: number) =>

apps/server/src/persistence/Migrations/016_CanonicalizeModelSelections.test.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,20 @@ layer("016_CanonicalizeModelSelections", (it) => {
128128
'{"projectId":"project-2","title":"Fallback Project","workspaceRoot":"/tmp/project-2","defaultModel":"claude-opus-4-6","defaultModelOptions":{"codex":{"reasoningEffort":"low"}},"scripts":[],"createdAt":"2026-01-01T00:00:00.000Z","updatedAt":"2026-01-01T00:00:00.000Z"}',
129129
'{}'
130130
),
131+
(
132+
'event-project-created-null-model',
133+
'project',
134+
'project-3',
135+
1,
136+
'project.created',
137+
'2026-01-01T00:00:00.000Z',
138+
'command-project-created-null-model',
139+
NULL,
140+
'correlation-project-created-null-model',
141+
'user',
142+
'{"projectId":"project-3","title":"Null Model Project","workspaceRoot":"/tmp/project-3","defaultModel":null,"scripts":[],"createdAt":"2026-01-01T00:00:00.000Z","updatedAt":"2026-01-01T00:00:00.000Z"}',
143+
'{}'
144+
),
131145
(
132146
'event-thread-created',
133147
'thread',
@@ -284,6 +298,16 @@ layer("016_CanonicalizeModelSelections", (it) => {
284298
});
285299

286300
assert.deepStrictEqual(JSON.parse(eventRows[2]!.payloadJson), {
301+
projectId: "project-3",
302+
title: "Null Model Project",
303+
workspaceRoot: "/tmp/project-3",
304+
defaultModelSelection: null,
305+
scripts: [],
306+
createdAt: "2026-01-01T00:00:00.000Z",
307+
updatedAt: "2026-01-01T00:00:00.000Z",
308+
});
309+
310+
assert.deepStrictEqual(JSON.parse(eventRows[3]!.payloadJson), {
287311
threadId: "thread-1",
288312
projectId: "project-1",
289313
title: "Thread",
@@ -303,7 +327,7 @@ layer("016_CanonicalizeModelSelections", (it) => {
303327
updatedAt: "2026-01-01T00:00:00.000Z",
304328
});
305329

306-
assert.deepStrictEqual(JSON.parse(eventRows[3]!.payloadJson), {
330+
assert.deepStrictEqual(JSON.parse(eventRows[4]!.payloadJson), {
307331
threadId: "thread-2",
308332
projectId: "project-1",
309333
title: "Fallback Thread",
@@ -322,7 +346,7 @@ layer("016_CanonicalizeModelSelections", (it) => {
322346
updatedAt: "2026-01-01T00:00:00.000Z",
323347
});
324348

325-
assert.deepStrictEqual(JSON.parse(eventRows[4]!.payloadJson), {
349+
assert.deepStrictEqual(JSON.parse(eventRows[5]!.payloadJson), {
326350
threadId: "thread-1",
327351
turnId: "turn-1",
328352
input: "hi",
@@ -336,7 +360,7 @@ layer("016_CanonicalizeModelSelections", (it) => {
336360
deliveryMode: "buffered",
337361
});
338362

339-
assert.deepStrictEqual(JSON.parse(eventRows[5]!.payloadJson), {
363+
assert.deepStrictEqual(JSON.parse(eventRows[6]!.payloadJson), {
340364
threadId: "thread-3",
341365
projectId: "project-1",
342366
title: "Ancient Thread",

apps/server/src/persistence/Migrations/019_FixProjectDefaultModelSelection.ts

Lines changed: 0 additions & 53 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { useEffect, type ReactNode } from "react";
2+
import { useNavigate } from "@tanstack/react-router";
3+
4+
import ThreadSidebar from "./Sidebar";
5+
import { Sidebar, SidebarProvider, SidebarRail } from "./ui/sidebar";
6+
7+
const THREAD_SIDEBAR_WIDTH_STORAGE_KEY = "chat_thread_sidebar_width";
8+
const THREAD_SIDEBAR_MIN_WIDTH = 13 * 16;
9+
const THREAD_MAIN_CONTENT_MIN_WIDTH = 40 * 16;
10+
11+
export function AppSidebarLayout({ children }: { children: ReactNode }) {
12+
const navigate = useNavigate();
13+
14+
useEffect(() => {
15+
const onMenuAction = window.desktopBridge?.onMenuAction;
16+
if (typeof onMenuAction !== "function") {
17+
return;
18+
}
19+
20+
const unsubscribe = onMenuAction((action) => {
21+
if (action !== "open-settings") return;
22+
void navigate({ to: "/settings" });
23+
});
24+
25+
return () => {
26+
unsubscribe?.();
27+
};
28+
}, [navigate]);
29+
30+
return (
31+
<SidebarProvider defaultOpen>
32+
<Sidebar
33+
side="left"
34+
collapsible="offcanvas"
35+
className="border-r border-border bg-card text-foreground"
36+
resizable={{
37+
minWidth: THREAD_SIDEBAR_MIN_WIDTH,
38+
shouldAcceptWidth: ({ nextWidth, wrapper }) =>
39+
wrapper.clientWidth - nextWidth >= THREAD_MAIN_CONTENT_MIN_WIDTH,
40+
storageKey: THREAD_SIDEBAR_WIDTH_STORAGE_KEY,
41+
}}
42+
>
43+
<ThreadSidebar />
44+
<SidebarRail />
45+
</Sidebar>
46+
{children}
47+
</SidebarProvider>
48+
);
49+
}

apps/web/src/components/Sidebar.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import { useHandleNewThread } from "../hooks/useHandleNewThread";
5757
import { useThreadActions } from "../hooks/useThreadActions";
5858
import { selectThreadTerminalState, useTerminalStateStore } from "../terminalStateStore";
5959
import { toastManager } from "./ui/toast";
60-
import { formatRelativeTime } from "../formatRelativeTime";
60+
import { formatRelativeTimeLabel } from "../timestampFormat";
6161
import { SettingsSidebarNav } from "./settings/SettingsSidebarNav";
6262
import {
6363
getArm64IntelBuildWarningDescription,
@@ -194,9 +194,6 @@ function T3Wordmark() {
194194
);
195195
}
196196

197-
/**
198-
*/
199-
200197
type SortableProjectHandleProps = Pick<
201198
ReturnType<typeof useSortable>,
202199
"attributes" | "listeners" | "setActivatorNodeRef"
@@ -1206,7 +1203,7 @@ export default function Sidebar() {
12061203
: "text-muted-foreground/40"
12071204
}`}
12081205
>
1209-
{formatRelativeTime(thread.updatedAt ?? thread.createdAt)}
1206+
{formatRelativeTimeLabel(thread.updatedAt ?? thread.createdAt)}
12101207
</span>
12111208
)}
12121209
</div>

apps/web/src/components/settings/SettingsPanels.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ import {
3636
} from "../../modelSelection";
3737
import { ensureNativeApi, readNativeApi } from "../../nativeApi";
3838
import { useStore } from "../../store";
39-
import { formatRelativeTime as formatArchivedRelativeTime } from "../../formatRelativeTime";
40-
import { formatRelativeTime } from "../../timestampFormat";
39+
import { formatRelativeTime, formatRelativeTimeLabel } from "../../timestampFormat";
4140
import { cn } from "../../lib/utils";
4241
import { Button } from "../ui/button";
4342
import { Collapsible, CollapsibleContent } from "../ui/collapsible";
@@ -1352,9 +1351,9 @@ export function ArchivedThreadsPanel() {
13521351
<div className="min-w-0 flex-1">
13531352
<h3 className="truncate text-sm font-medium text-foreground">{thread.title}</h3>
13541353
<p className="text-xs text-muted-foreground">
1355-
Archived {formatArchivedRelativeTime(thread.archivedAt ?? thread.createdAt)}
1354+
Archived {formatRelativeTimeLabel(thread.archivedAt ?? thread.createdAt)}
13561355
{" \u00b7 Created "}
1357-
{formatArchivedRelativeTime(thread.createdAt)}
1356+
{formatRelativeTimeLabel(thread.createdAt)}
13581357
</p>
13591358
</div>
13601359
<Button

apps/web/src/formatRelativeTime.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)