Track pin timestamps for projects and threads
- replace boolean pin state with pinnedAt timestamps - update orchestration, persistence, and sidebar sorting
This commit is contained in:
1 parent
f48fcb8afe
commit
3a199bc719
31 files changed
+200
-127
No files matched your search
@@ -31,7 +31,7 @@ function makeSnapshot(input: {
|
||||
id: input.projectId,
|
||||
title: "Project",
|
||||
workspaceRoot: input.workspaceRoot,
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: "2026-01-01T00:00:00.000Z",
|
||||
@@ -44,7 +44,7 @@ function makeSnapshot(input: {
|
||||
id: input.threadId,
|
||||
projectId: input.projectId,
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
|
||||
@@ -383,7 +383,7 @@ const makeOrchestrationProjectionPipeline = Effect.fn("makeOrchestrationProjecti
|
||||
projectId: event.payload.projectId,
|
||||
title: event.payload.title,
|
||||
workspaceRoot: event.payload.workspaceRoot,
|
||||
pinned: event.payload.pinned,
|
||||
pinnedAt: event.payload.pinnedAt,
|
||||
defaultModelSelection: event.payload.defaultModelSelection,
|
||||
scripts: event.payload.scripts,
|
||||
createdAt: event.payload.createdAt,
|
||||
@@ -405,7 +405,7 @@ const makeOrchestrationProjectionPipeline = Effect.fn("makeOrchestrationProjecti
|
||||
...(event.payload.workspaceRoot !== undefined
|
||||
? { workspaceRoot: event.payload.workspaceRoot }
|
||||
: {}),
|
||||
...(event.payload.pinned !== undefined ? { pinned: event.payload.pinned } : {}),
|
||||
...(event.payload.pinnedAt !== undefined ? { pinnedAt: event.payload.pinnedAt } : {}),
|
||||
...(event.payload.defaultModelSelection !== undefined
|
||||
? { defaultModelSelection: event.payload.defaultModelSelection }
|
||||
: {}),
|
||||
@@ -444,7 +444,7 @@ const makeOrchestrationProjectionPipeline = Effect.fn("makeOrchestrationProjecti
|
||||
threadId: event.payload.threadId,
|
||||
projectId: event.payload.projectId,
|
||||
title: event.payload.title,
|
||||
pinned: event.payload.pinned,
|
||||
pinnedAt: event.payload.pinnedAt,
|
||||
modelSelection: event.payload.modelSelection,
|
||||
runtimeMode: event.payload.runtimeMode,
|
||||
interactionMode: event.payload.interactionMode,
|
||||
@@ -498,7 +498,7 @@ const makeOrchestrationProjectionPipeline = Effect.fn("makeOrchestrationProjecti
|
||||
yield* projectionThreadRepository.upsert({
|
||||
...existingRow.value,
|
||||
...(event.payload.title !== undefined ? { title: event.payload.title } : {}),
|
||||
...(event.payload.pinned !== undefined ? { pinned: event.payload.pinned } : {}),
|
||||
...(event.payload.pinnedAt !== undefined ? { pinnedAt: event.payload.pinnedAt } : {}),
|
||||
...(event.payload.modelSelection !== undefined
|
||||
? { modelSelection: event.payload.modelSelection }
|
||||
: {}),
|
||||
|
||||
@@ -234,7 +234,7 @@ projectionSnapshotLayer("ProjectionSnapshotQuery", (it) => {
|
||||
id: asProjectId("project-1"),
|
||||
title: "Project 1",
|
||||
workspaceRoot: "/tmp/project-1",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -258,7 +258,7 @@ projectionSnapshotLayer("ProjectionSnapshotQuery", (it) => {
|
||||
id: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread 1",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
|
||||
@@ -46,7 +46,7 @@ import {
|
||||
const decodeReadModel = Schema.decodeUnknownEffect(OrchestrationReadModel);
|
||||
const ProjectionProjectDbRowSchema = ProjectionProject.mapFields(
|
||||
Struct.assign({
|
||||
pinned: Schema.BooleanFromBit,
|
||||
pinnedAt: Schema.NullOr(IsoDateTime),
|
||||
defaultModelSelection: Schema.NullOr(Schema.fromJsonString(ModelSelection)),
|
||||
scripts: Schema.fromJsonString(Schema.Array(ProjectScript)),
|
||||
}),
|
||||
@@ -60,7 +60,7 @@ const ProjectionThreadMessageDbRowSchema = ProjectionThreadMessage.mapFields(
|
||||
const ProjectionThreadProposedPlanDbRowSchema = ProjectionThreadProposedPlan;
|
||||
const ProjectionThreadDbRowSchema = ProjectionThread.mapFields(
|
||||
Struct.assign({
|
||||
pinned: Schema.BooleanFromBit,
|
||||
pinnedAt: Schema.NullOr(IsoDateTime),
|
||||
modelSelection: Schema.fromJsonString(ModelSelection),
|
||||
}),
|
||||
);
|
||||
@@ -149,7 +149,7 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
project_id AS "projectId",
|
||||
title,
|
||||
workspace_root AS "workspaceRoot",
|
||||
pinned,
|
||||
pinned_at AS "pinnedAt",
|
||||
default_model_selection_json AS "defaultModelSelection",
|
||||
scripts_json AS "scripts",
|
||||
created_at AS "createdAt",
|
||||
@@ -169,7 +169,7 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
thread_id AS "threadId",
|
||||
project_id AS "projectId",
|
||||
title,
|
||||
pinned,
|
||||
pinned_at AS "pinnedAt",
|
||||
model_selection_json AS "modelSelection",
|
||||
runtime_mode AS "runtimeMode",
|
||||
interaction_mode AS "interactionMode",
|
||||
@@ -546,7 +546,7 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
id: row.projectId,
|
||||
title: row.title,
|
||||
workspaceRoot: row.workspaceRoot,
|
||||
pinned: row.pinned,
|
||||
pinnedAt: row.pinnedAt,
|
||||
defaultModelSelection: row.defaultModelSelection,
|
||||
scripts: row.scripts,
|
||||
createdAt: row.createdAt,
|
||||
@@ -558,7 +558,7 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
id: row.threadId,
|
||||
projectId: row.projectId,
|
||||
title: row.title,
|
||||
pinned: row.pinned,
|
||||
pinnedAt: row.pinnedAt,
|
||||
modelSelection: row.modelSelection,
|
||||
runtimeMode: row.runtimeMode,
|
||||
interactionMode: row.interactionMode,
|
||||
|
||||
@@ -28,7 +28,7 @@ const readModel: OrchestrationReadModel = {
|
||||
id: ProjectId.makeUnsafe("project-a"),
|
||||
title: "Project A",
|
||||
workspaceRoot: "/tmp/project-a",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -42,7 +42,7 @@ const readModel: OrchestrationReadModel = {
|
||||
id: ProjectId.makeUnsafe("project-b"),
|
||||
title: "Project B",
|
||||
workspaceRoot: "/tmp/project-b",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -58,7 +58,7 @@ const readModel: OrchestrationReadModel = {
|
||||
id: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: ProjectId.makeUnsafe("project-a"),
|
||||
title: "Thread A",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -82,7 +82,7 @@ const readModel: OrchestrationReadModel = {
|
||||
id: ThreadId.makeUnsafe("thread-2"),
|
||||
projectId: ProjectId.makeUnsafe("project-b"),
|
||||
title: "Thread B",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
|
||||
@@ -39,7 +39,7 @@ describe("decider project scripts", () => {
|
||||
const event = Array.isArray(result) ? result[0] : result;
|
||||
expect(event.type).toBe("project.created");
|
||||
expect(event.payload).toMatchObject({
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
scripts: [],
|
||||
});
|
||||
});
|
||||
@@ -63,7 +63,7 @@ describe("decider project scripts", () => {
|
||||
projectId: asProjectId("project-scripts"),
|
||||
title: "Scripts",
|
||||
workspaceRoot: "/tmp/scripts",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: now,
|
||||
@@ -118,7 +118,7 @@ describe("decider project scripts", () => {
|
||||
projectId: asProjectId("project-pin"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/project-pin",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: now,
|
||||
@@ -151,7 +151,7 @@ describe("decider project scripts", () => {
|
||||
);
|
||||
const createdEvent = Array.isArray(created) ? created[0] : created;
|
||||
expect(createdEvent.type).toBe("thread.created");
|
||||
expect(createdEvent.payload).toMatchObject({ pinned: true });
|
||||
expect(createdEvent.payload).toMatchObject({ pinnedAt: now });
|
||||
|
||||
const withThread = await Effect.runPromise(
|
||||
projectEvent(withProject, {
|
||||
@@ -172,7 +172,7 @@ describe("decider project scripts", () => {
|
||||
);
|
||||
const updatedEvent = Array.isArray(updated) ? updated[0] : updated;
|
||||
expect(updatedEvent.type).toBe("thread.meta-updated");
|
||||
expect(updatedEvent.payload).toMatchObject({ pinned: false });
|
||||
expect(updatedEvent.payload).toMatchObject({ pinnedAt: null });
|
||||
});
|
||||
|
||||
it("emits user message and turn-start-requested events for thread.turn.start", async () => {
|
||||
@@ -194,7 +194,7 @@ describe("decider project scripts", () => {
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/project",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: now,
|
||||
@@ -218,7 +218,7 @@ describe("decider project scripts", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -305,7 +305,7 @@ describe("decider project scripts", () => {
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/project",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: now,
|
||||
@@ -329,7 +329,7 @@ describe("decider project scripts", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -389,7 +389,7 @@ describe("decider project scripts", () => {
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/project",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: now,
|
||||
@@ -413,7 +413,7 @@ describe("decider project scripts", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
|
||||
@@ -77,7 +77,7 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
projectId: command.projectId,
|
||||
title: command.title,
|
||||
workspaceRoot: command.workspaceRoot,
|
||||
pinned: command.pinned ?? false,
|
||||
pinnedAt: command.pinned ? command.createdAt : null,
|
||||
defaultModelSelection: command.defaultModelSelection ?? null,
|
||||
scripts: [],
|
||||
createdAt: command.createdAt,
|
||||
@@ -105,7 +105,7 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
projectId: command.projectId,
|
||||
...(command.title !== undefined ? { title: command.title } : {}),
|
||||
...(command.workspaceRoot !== undefined ? { workspaceRoot: command.workspaceRoot } : {}),
|
||||
...(command.pinned !== undefined ? { pinned: command.pinned } : {}),
|
||||
...(command.pinned !== undefined ? { pinnedAt: command.pinned ? occurredAt : null } : {}),
|
||||
...(command.defaultModelSelection !== undefined
|
||||
? { defaultModelSelection: command.defaultModelSelection }
|
||||
: {}),
|
||||
@@ -160,7 +160,7 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
threadId: command.threadId,
|
||||
projectId: command.projectId,
|
||||
title: command.title,
|
||||
pinned: command.pinned ?? false,
|
||||
pinnedAt: command.pinned ? command.createdAt : null,
|
||||
modelSelection: command.modelSelection,
|
||||
runtimeMode: command.runtimeMode,
|
||||
interactionMode: command.interactionMode,
|
||||
@@ -257,7 +257,7 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
...(command.title !== undefined ? { title: command.title } : {}),
|
||||
...(command.pinned !== undefined ? { pinned: command.pinned } : {}),
|
||||
...(command.pinned !== undefined ? { pinnedAt: command.pinned ? occurredAt : null } : {}),
|
||||
...(command.modelSelection !== undefined
|
||||
? { modelSelection: command.modelSelection }
|
||||
: {}),
|
||||
|
||||
@@ -76,7 +76,7 @@ describe("orchestration projector", () => {
|
||||
id: "thread-1",
|
||||
projectId: "project-1",
|
||||
title: "demo",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -136,13 +136,13 @@ describe("orchestration projector", () => {
|
||||
commandId: "cmd-project-pin",
|
||||
payload: {
|
||||
projectId: "project-1",
|
||||
pinned: true,
|
||||
pinnedAt: later,
|
||||
updatedAt: later,
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(withPinnedProject.projects[0]?.pinned).toBe(true);
|
||||
expect(withPinnedProject.projects[0]?.pinnedAt).toBe(later);
|
||||
|
||||
const withThread = await Effect.runPromise(
|
||||
projectEvent(
|
||||
@@ -183,13 +183,13 @@ describe("orchestration projector", () => {
|
||||
commandId: "cmd-thread-pin",
|
||||
payload: {
|
||||
threadId: "thread-1",
|
||||
pinned: true,
|
||||
pinnedAt: later,
|
||||
updatedAt: later,
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(withPinnedThread.threads[0]?.pinned).toBe(true);
|
||||
expect(withPinnedThread.threads[0]?.pinnedAt).toBe(later);
|
||||
});
|
||||
|
||||
it("fails when event payload cannot be decoded by runtime schema", async () => {
|
||||
|
||||
@@ -183,7 +183,7 @@ export function projectEvent(
|
||||
id: payload.projectId,
|
||||
title: payload.title,
|
||||
workspaceRoot: payload.workspaceRoot,
|
||||
pinned: payload.pinned,
|
||||
pinnedAt: payload.pinnedAt,
|
||||
defaultModelSelection: payload.defaultModelSelection,
|
||||
scripts: payload.scripts,
|
||||
createdAt: payload.createdAt,
|
||||
@@ -214,7 +214,7 @@ export function projectEvent(
|
||||
...(payload.workspaceRoot !== undefined
|
||||
? { workspaceRoot: payload.workspaceRoot }
|
||||
: {}),
|
||||
...(payload.pinned !== undefined ? { pinned: payload.pinned } : {}),
|
||||
...(payload.pinnedAt !== undefined ? { pinnedAt: payload.pinnedAt } : {}),
|
||||
...(payload.defaultModelSelection !== undefined
|
||||
? { defaultModelSelection: payload.defaultModelSelection }
|
||||
: {}),
|
||||
@@ -256,7 +256,7 @@ export function projectEvent(
|
||||
id: payload.threadId,
|
||||
projectId: payload.projectId,
|
||||
title: payload.title,
|
||||
pinned: payload.pinned,
|
||||
pinnedAt: payload.pinnedAt,
|
||||
modelSelection: payload.modelSelection,
|
||||
runtimeMode: payload.runtimeMode,
|
||||
interactionMode: payload.interactionMode,
|
||||
@@ -323,7 +323,7 @@ export function projectEvent(
|
||||
...nextBase,
|
||||
threads: updateThread(nextBase.threads, payload.threadId, {
|
||||
...(payload.title !== undefined ? { title: payload.title } : {}),
|
||||
...(payload.pinned !== undefined ? { pinned: payload.pinned } : {}),
|
||||
...(payload.pinnedAt !== undefined ? { pinnedAt: payload.pinnedAt } : {}),
|
||||
...(payload.modelSelection !== undefined
|
||||
? { modelSelection: payload.modelSelection }
|
||||
: {}),
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
|
||||
const ProjectionProjectDbRow = ProjectionProject.mapFields(
|
||||
Struct.assign({
|
||||
pinned: Schema.BooleanFromBit,
|
||||
pinnedAt: Schema.NullOr(Schema.String),
|
||||
defaultModelSelection: Schema.NullOr(Schema.fromJsonString(ModelSelection)),
|
||||
scripts: Schema.fromJsonString(Schema.Array(ProjectScript)),
|
||||
}),
|
||||
@@ -33,6 +33,7 @@ const makeProjectionProjectRepository = Effect.gen(function* () {
|
||||
title,
|
||||
workspace_root,
|
||||
pinned,
|
||||
pinned_at,
|
||||
default_model_selection_json,
|
||||
scripts_json,
|
||||
created_at,
|
||||
@@ -43,7 +44,8 @@ const makeProjectionProjectRepository = Effect.gen(function* () {
|
||||
${row.projectId},
|
||||
${row.title},
|
||||
${row.workspaceRoot},
|
||||
${row.pinned ? 1 : 0},
|
||||
${row.pinnedAt !== null ? 1 : 0},
|
||||
${row.pinnedAt},
|
||||
${row.defaultModelSelection !== null ? JSON.stringify(row.defaultModelSelection) : null},
|
||||
${JSON.stringify(row.scripts)},
|
||||
${row.createdAt},
|
||||
@@ -55,6 +57,7 @@ const makeProjectionProjectRepository = Effect.gen(function* () {
|
||||
title = excluded.title,
|
||||
workspace_root = excluded.workspace_root,
|
||||
pinned = excluded.pinned,
|
||||
pinned_at = excluded.pinned_at,
|
||||
default_model_selection_json = excluded.default_model_selection_json,
|
||||
scripts_json = excluded.scripts_json,
|
||||
created_at = excluded.created_at,
|
||||
@@ -72,7 +75,7 @@ const makeProjectionProjectRepository = Effect.gen(function* () {
|
||||
project_id AS "projectId",
|
||||
title,
|
||||
workspace_root AS "workspaceRoot",
|
||||
pinned,
|
||||
pinned_at AS "pinnedAt",
|
||||
default_model_selection_json AS "defaultModelSelection",
|
||||
scripts_json AS "scripts",
|
||||
created_at AS "createdAt",
|
||||
@@ -92,7 +95,7 @@ const makeProjectionProjectRepository = Effect.gen(function* () {
|
||||
project_id AS "projectId",
|
||||
title,
|
||||
workspace_root AS "workspaceRoot",
|
||||
pinned,
|
||||
pinned_at AS "pinnedAt",
|
||||
default_model_selection_json AS "defaultModelSelection",
|
||||
scripts_json AS "scripts",
|
||||
created_at AS "createdAt",
|
||||
|
||||
@@ -27,7 +27,7 @@ projectionRepositoriesLayer("Projection repositories", (it) => {
|
||||
projectId: ProjectId.makeUnsafe("project-null-options"),
|
||||
title: "Null options project",
|
||||
workspaceRoot: "/tmp/project-null-options",
|
||||
pinned: true,
|
||||
pinnedAt: "2026-03-24T00:00:00.000Z",
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.4",
|
||||
@@ -61,7 +61,7 @@ projectionRepositoriesLayer("Projection repositories", (it) => {
|
||||
const persisted = yield* projects.getById({
|
||||
projectId: ProjectId.makeUnsafe("project-null-options"),
|
||||
});
|
||||
assert.strictEqual(Option.getOrNull(persisted)?.pinned, true);
|
||||
assert.strictEqual(Option.getOrNull(persisted)?.pinnedAt, "2026-03-24T00:00:00.000Z");
|
||||
assert.deepStrictEqual(Option.getOrNull(persisted)?.defaultModelSelection, {
|
||||
provider: "codex",
|
||||
model: "gpt-5.4",
|
||||
@@ -78,7 +78,7 @@ projectionRepositoriesLayer("Projection repositories", (it) => {
|
||||
threadId: ThreadId.makeUnsafe("thread-null-options"),
|
||||
projectId: ProjectId.makeUnsafe("project-null-options"),
|
||||
title: "Null options thread",
|
||||
pinned: true,
|
||||
pinnedAt: "2026-03-24T00:00:00.000Z",
|
||||
modelSelection: {
|
||||
provider: "claudeAgent",
|
||||
model: "claude-opus-4-6",
|
||||
@@ -117,7 +117,7 @@ projectionRepositoriesLayer("Projection repositories", (it) => {
|
||||
const persisted = yield* threads.getById({
|
||||
threadId: ThreadId.makeUnsafe("thread-null-options"),
|
||||
});
|
||||
assert.strictEqual(Option.getOrNull(persisted)?.pinned, true);
|
||||
assert.strictEqual(Option.getOrNull(persisted)?.pinnedAt, "2026-03-24T00:00:00.000Z");
|
||||
assert.deepStrictEqual(Option.getOrNull(persisted)?.modelSelection, {
|
||||
provider: "claudeAgent",
|
||||
model: "claude-opus-4-6",
|
||||
|
||||
@@ -15,7 +15,7 @@ import { ModelSelection } from "@t3tools/contracts";
|
||||
|
||||
const ProjectionThreadDbRow = ProjectionThread.mapFields(
|
||||
Struct.assign({
|
||||
pinned: Schema.BooleanFromBit,
|
||||
pinnedAt: Schema.NullOr(Schema.String),
|
||||
modelSelection: Schema.fromJsonString(ModelSelection),
|
||||
}),
|
||||
);
|
||||
@@ -33,6 +33,7 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
project_id,
|
||||
title,
|
||||
pinned,
|
||||
pinned_at,
|
||||
model_selection_json,
|
||||
runtime_mode,
|
||||
interaction_mode,
|
||||
@@ -48,7 +49,8 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
${row.threadId},
|
||||
${row.projectId},
|
||||
${row.title},
|
||||
${row.pinned ? 1 : 0},
|
||||
${row.pinnedAt !== null ? 1 : 0},
|
||||
${row.pinnedAt},
|
||||
${JSON.stringify(row.modelSelection)},
|
||||
${row.runtimeMode},
|
||||
${row.interactionMode},
|
||||
@@ -65,6 +67,7 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
project_id = excluded.project_id,
|
||||
title = excluded.title,
|
||||
pinned = excluded.pinned,
|
||||
pinned_at = excluded.pinned_at,
|
||||
model_selection_json = excluded.model_selection_json,
|
||||
runtime_mode = excluded.runtime_mode,
|
||||
interaction_mode = excluded.interaction_mode,
|
||||
@@ -87,7 +90,7 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
thread_id AS "threadId",
|
||||
project_id AS "projectId",
|
||||
title,
|
||||
pinned,
|
||||
pinned_at AS "pinnedAt",
|
||||
model_selection_json AS "modelSelection",
|
||||
runtime_mode AS "runtimeMode",
|
||||
interaction_mode AS "interactionMode",
|
||||
@@ -112,7 +115,7 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
thread_id AS "threadId",
|
||||
project_id AS "projectId",
|
||||
title,
|
||||
pinned,
|
||||
pinned_at AS "pinnedAt",
|
||||
model_selection_json AS "modelSelection",
|
||||
runtime_mode AS "runtimeMode",
|
||||
interaction_mode AS "interactionMode",
|
||||
|
||||
@@ -32,6 +32,7 @@ import Migration0016 from "./Migrations/016_CanonicalizeModelSelections.ts";
|
||||
import Migration0017 from "./Migrations/017_ProjectionThreadsArchivedAt.ts";
|
||||
import Migration0018 from "./Migrations/018_ProjectionThreadsArchivedAtIndex.ts";
|
||||
import Migration0019 from "./Migrations/019_ProjectionPins.ts";
|
||||
import Migration0020 from "./Migrations/020_ProjectionPinTimestamps.ts";
|
||||
|
||||
/**
|
||||
* Migration loader with all migrations defined inline.
|
||||
@@ -63,6 +64,7 @@ export const migrationEntries = [
|
||||
[17, "ProjectionThreadsArchivedAt", Migration0017],
|
||||
[18, "ProjectionThreadsArchivedAtIndex", Migration0018],
|
||||
[19, "ProjectionPins", Migration0019],
|
||||
[20, "ProjectionPinTimestamps", Migration0020],
|
||||
] as const;
|
||||
|
||||
export const makeMigrationLoader = (throughId?: number) =>
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
||||
|
||||
export default Effect.gen(function* () {
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
|
||||
const projectColumns = yield* sql<{ readonly name: string }>`
|
||||
PRAGMA table_info(projection_projects)
|
||||
`;
|
||||
if (!projectColumns.some((column) => column.name === "pinned_at")) {
|
||||
yield* sql`
|
||||
ALTER TABLE projection_projects
|
||||
ADD COLUMN pinned_at TEXT
|
||||
`;
|
||||
}
|
||||
|
||||
yield* sql`
|
||||
UPDATE projection_projects
|
||||
SET pinned_at = CASE WHEN pinned != 0 THEN updated_at ELSE NULL END
|
||||
WHERE pinned_at IS NULL
|
||||
`;
|
||||
|
||||
const threadColumns = yield* sql<{ readonly name: string }>`
|
||||
PRAGMA table_info(projection_threads)
|
||||
`;
|
||||
if (!threadColumns.some((column) => column.name === "pinned_at")) {
|
||||
yield* sql`
|
||||
ALTER TABLE projection_threads
|
||||
ADD COLUMN pinned_at TEXT
|
||||
`;
|
||||
}
|
||||
|
||||
yield* sql`
|
||||
UPDATE projection_threads
|
||||
SET pinned_at = CASE WHEN pinned != 0 THEN updated_at ELSE NULL END
|
||||
WHERE pinned_at IS NULL
|
||||
`;
|
||||
});
|
||||
@@ -16,7 +16,7 @@ export const ProjectionProject = Schema.Struct({
|
||||
projectId: ProjectId,
|
||||
title: Schema.String,
|
||||
workspaceRoot: Schema.String,
|
||||
pinned: Schema.Boolean,
|
||||
pinnedAt: Schema.NullOr(IsoDateTime),
|
||||
defaultModelSelection: Schema.NullOr(ModelSelection),
|
||||
scripts: Schema.Array(ProjectScript),
|
||||
createdAt: IsoDateTime,
|
||||
|
||||
@@ -24,7 +24,7 @@ export const ProjectionThread = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
projectId: ProjectId,
|
||||
title: Schema.String,
|
||||
pinned: Schema.Boolean,
|
||||
pinnedAt: Schema.NullOr(IsoDateTime),
|
||||
modelSelection: ModelSelection,
|
||||
runtimeMode: RuntimeMode,
|
||||
interactionMode: ProviderInteractionMode,
|
||||
|
||||
@@ -237,7 +237,7 @@ function createSnapshotForTargetUser(options: {
|
||||
id: PROJECT_ID,
|
||||
title: "Project",
|
||||
workspaceRoot: "/repo/project",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5",
|
||||
@@ -253,7 +253,7 @@ function createSnapshotForTargetUser(options: {
|
||||
id: THREAD_ID,
|
||||
projectId: PROJECT_ID,
|
||||
title: "Browser test thread",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5",
|
||||
@@ -312,7 +312,7 @@ function addThreadToSnapshot(
|
||||
id: threadId,
|
||||
projectId: PROJECT_ID,
|
||||
title: "New thread",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5",
|
||||
@@ -360,7 +360,7 @@ function createThreadCreatedEvent(threadId: ThreadId, sequence: number): Orchest
|
||||
threadId,
|
||||
projectId: PROJECT_ID,
|
||||
title: "New thread",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5",
|
||||
|
||||
@@ -89,7 +89,7 @@ const makeThread = (input?: {
|
||||
codexThreadId: null,
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
modelSelection: { provider: "codex" as const, model: "gpt-5.4" },
|
||||
runtimeMode: "full-access" as const,
|
||||
interactionMode: "default" as const,
|
||||
@@ -248,7 +248,7 @@ describe("hasServerAcknowledgedLocalDispatch", () => {
|
||||
codexThreadId: null,
|
||||
projectId,
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
modelSelection: { provider: "codex", model: "gpt-5.4" },
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
@@ -285,7 +285,7 @@ describe("hasServerAcknowledgedLocalDispatch", () => {
|
||||
codexThreadId: null,
|
||||
projectId,
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
modelSelection: { provider: "codex", model: "gpt-5.4" },
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
@@ -331,7 +331,7 @@ describe("hasServerAcknowledgedLocalDispatch", () => {
|
||||
codexThreadId: null,
|
||||
projectId,
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
modelSelection: { provider: "codex", model: "gpt-5.4" },
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
|
||||
@@ -26,7 +26,7 @@ export function buildLocalDraftThread(
|
||||
codexThreadId: null,
|
||||
projectId: draftThread.projectId,
|
||||
title: "New thread",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
modelSelection: fallbackModelSelection,
|
||||
runtimeMode: draftThread.runtimeMode,
|
||||
interactionMode: draftThread.interactionMode,
|
||||
|
||||
@@ -76,7 +76,7 @@ function createMinimalSnapshot(): OrchestrationReadModel {
|
||||
id: PROJECT_ID,
|
||||
title: "Project",
|
||||
workspaceRoot: "/repo/project",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5",
|
||||
@@ -92,7 +92,7 @@ function createMinimalSnapshot(): OrchestrationReadModel {
|
||||
id: THREAD_ID,
|
||||
projectId: PROJECT_ID,
|
||||
title: "Test thread",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5",
|
||||
|
||||
@@ -592,7 +592,7 @@ function makeProject(overrides: Partial<Project> = {}): Project {
|
||||
id: ProjectId.makeUnsafe("project-1"),
|
||||
name: "Project",
|
||||
cwd: "/tmp/project",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.4",
|
||||
@@ -611,7 +611,7 @@ function makeThread(overrides: Partial<Thread> = {}): Thread {
|
||||
codexThreadId: null,
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.4",
|
||||
@@ -770,7 +770,7 @@ describe("sortThreadsForSidebar", () => {
|
||||
createdAt: "2026-03-09T10:00:00.000Z",
|
||||
updatedAt: "2026-03-09T10:01:00.000Z",
|
||||
}),
|
||||
pinned: true,
|
||||
pinnedAt: "2026-03-09T10:20:00.000Z",
|
||||
},
|
||||
{
|
||||
...makeThread({
|
||||
@@ -778,7 +778,7 @@ describe("sortThreadsForSidebar", () => {
|
||||
createdAt: "2026-03-09T10:05:00.000Z",
|
||||
updatedAt: "2026-03-09T10:05:00.000Z",
|
||||
}),
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
},
|
||||
],
|
||||
"updated_at",
|
||||
@@ -790,7 +790,7 @@ describe("sortThreadsForSidebar", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("still auto-sorts within the pinned thread bucket", () => {
|
||||
it("sorts pinned threads by latest pin timestamp before activity recency", () => {
|
||||
const sorted = sortThreadsForSidebar(
|
||||
[
|
||||
{
|
||||
@@ -799,7 +799,7 @@ describe("sortThreadsForSidebar", () => {
|
||||
createdAt: "2026-03-09T10:01:00.000Z",
|
||||
updatedAt: "2026-03-09T10:01:00.000Z",
|
||||
}),
|
||||
pinned: true,
|
||||
pinnedAt: "2026-03-09T10:10:00.000Z",
|
||||
},
|
||||
{
|
||||
...makeThread({
|
||||
@@ -807,7 +807,7 @@ describe("sortThreadsForSidebar", () => {
|
||||
createdAt: "2026-03-09T10:05:00.000Z",
|
||||
updatedAt: "2026-03-09T10:05:00.000Z",
|
||||
}),
|
||||
pinned: true,
|
||||
pinnedAt: "2026-03-09T10:20:00.000Z",
|
||||
},
|
||||
{
|
||||
...makeThread({
|
||||
@@ -815,7 +815,7 @@ describe("sortThreadsForSidebar", () => {
|
||||
createdAt: "2026-03-09T10:10:00.000Z",
|
||||
updatedAt: "2026-03-09T10:10:00.000Z",
|
||||
}),
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
},
|
||||
],
|
||||
"updated_at",
|
||||
@@ -874,7 +874,7 @@ describe("getFallbackThreadIdAfterDelete", () => {
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
updatedAt: "2026-03-09T10:05:00.000Z",
|
||||
}),
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
},
|
||||
{
|
||||
...makeThread({
|
||||
@@ -882,7 +882,7 @@ describe("getFallbackThreadIdAfterDelete", () => {
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
updatedAt: "2026-03-09T10:03:00.000Z",
|
||||
}),
|
||||
pinned: true,
|
||||
pinnedAt: "2026-03-09T10:20:00.000Z",
|
||||
},
|
||||
{
|
||||
...makeThread({
|
||||
@@ -890,7 +890,7 @@ describe("getFallbackThreadIdAfterDelete", () => {
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
updatedAt: "2026-03-09T10:10:00.000Z",
|
||||
}),
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
},
|
||||
],
|
||||
deletedThreadId: ThreadId.makeUnsafe("thread-active"),
|
||||
@@ -1010,13 +1010,13 @@ describe("sortProjectsForSidebar", () => {
|
||||
makeProject({
|
||||
id: ProjectId.makeUnsafe("project-1"),
|
||||
name: "Pinned older project",
|
||||
pinned: true,
|
||||
pinnedAt: "2026-03-09T10:20:00.000Z",
|
||||
updatedAt: "2026-03-09T10:01:00.000Z",
|
||||
}),
|
||||
makeProject({
|
||||
id: ProjectId.makeUnsafe("project-2"),
|
||||
name: "Unpinned newer project",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
updatedAt: "2026-03-09T10:05:00.000Z",
|
||||
}),
|
||||
],
|
||||
@@ -1030,25 +1030,25 @@ describe("sortProjectsForSidebar", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("still auto-sorts within the pinned bucket", () => {
|
||||
it("sorts pinned projects by latest pin timestamp before project recency", () => {
|
||||
const sorted = sortProjectsForSidebar(
|
||||
[
|
||||
makeProject({
|
||||
id: ProjectId.makeUnsafe("project-1"),
|
||||
name: "Pinned older project",
|
||||
pinned: true,
|
||||
pinnedAt: "2026-03-09T10:10:00.000Z",
|
||||
updatedAt: "2026-03-09T10:01:00.000Z",
|
||||
}),
|
||||
makeProject({
|
||||
id: ProjectId.makeUnsafe("project-2"),
|
||||
name: "Pinned newer project",
|
||||
pinned: true,
|
||||
pinnedAt: "2026-03-09T10:20:00.000Z",
|
||||
updatedAt: "2026-03-09T10:05:00.000Z",
|
||||
}),
|
||||
makeProject({
|
||||
id: ProjectId.makeUnsafe("project-3"),
|
||||
name: "Unpinned project",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
updatedAt: "2026-03-09T10:10:00.000Z",
|
||||
}),
|
||||
],
|
||||
|
||||
@@ -16,12 +16,12 @@ type SidebarProject = {
|
||||
name: string;
|
||||
createdAt?: string | undefined;
|
||||
updatedAt?: string | undefined;
|
||||
pinned?: boolean | undefined;
|
||||
pinnedAt?: string | null | undefined;
|
||||
};
|
||||
type SidebarThreadSortInput = Pick<Thread, "createdAt" | "updatedAt"> & {
|
||||
latestUserMessageAt?: string | null;
|
||||
messages?: Pick<Thread["messages"][number], "createdAt" | "role">[];
|
||||
pinned?: boolean | undefined;
|
||||
pinnedAt?: string | null | undefined;
|
||||
};
|
||||
|
||||
export type ThreadTraversalDirection = "previous" | "next";
|
||||
@@ -450,15 +450,24 @@ function getThreadSortTimestamp(
|
||||
return getLatestUserMessageTimestamp(thread);
|
||||
}
|
||||
|
||||
function getPinnedSortTimestamp(input: { pinnedAt?: string | null | undefined }): number | null {
|
||||
return toSortableTimestamp(input.pinnedAt ?? undefined);
|
||||
}
|
||||
|
||||
export function sortThreadsForSidebar<
|
||||
T extends Pick<Thread, "id" | "createdAt" | "updatedAt"> & SidebarThreadSortInput,
|
||||
>(threads: readonly T[], sortOrder: SidebarThreadSortOrder): T[] {
|
||||
return threads.toSorted((left, right) => {
|
||||
const leftPinned = left.pinned === true;
|
||||
const rightPinned = right.pinned === true;
|
||||
const leftPinnedAt = getPinnedSortTimestamp(left);
|
||||
const rightPinnedAt = getPinnedSortTimestamp(right);
|
||||
const leftPinned = leftPinnedAt !== null;
|
||||
const rightPinned = rightPinnedAt !== null;
|
||||
if (leftPinned !== rightPinned) {
|
||||
return rightPinned ? 1 : -1;
|
||||
}
|
||||
if (leftPinnedAt !== null && rightPinnedAt !== null && leftPinnedAt !== rightPinnedAt) {
|
||||
return rightPinnedAt > leftPinnedAt ? 1 : -1;
|
||||
}
|
||||
const rightTimestamp = getThreadSortTimestamp(right, sortOrder);
|
||||
const leftTimestamp = getThreadSortTimestamp(left, sortOrder);
|
||||
const byTimestamp =
|
||||
@@ -533,11 +542,16 @@ export function sortProjectsForSidebar<
|
||||
}
|
||||
|
||||
return [...projects].toSorted((left, right) => {
|
||||
const leftPinned = left.pinned === true;
|
||||
const rightPinned = right.pinned === true;
|
||||
const leftPinnedAt = getPinnedSortTimestamp(left);
|
||||
const rightPinnedAt = getPinnedSortTimestamp(right);
|
||||
const leftPinned = leftPinnedAt !== null;
|
||||
const rightPinned = rightPinnedAt !== null;
|
||||
if (leftPinned !== rightPinned) {
|
||||
return rightPinned ? 1 : -1;
|
||||
}
|
||||
if (leftPinnedAt !== null && rightPinnedAt !== null && leftPinnedAt !== rightPinnedAt) {
|
||||
return rightPinnedAt > leftPinnedAt ? 1 : -1;
|
||||
}
|
||||
const rightTimestamp = getProjectSortTimestamp(
|
||||
right,
|
||||
threadsByProjectId.get(right.id) ?? [],
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
ChevronRightIcon,
|
||||
FolderIcon,
|
||||
GitPullRequestIcon,
|
||||
PinIcon,
|
||||
PlusIcon,
|
||||
SettingsIcon,
|
||||
SquarePenIcon,
|
||||
@@ -152,7 +153,7 @@ type SidebarThreadSnapshot = Pick<
|
||||
| "id"
|
||||
| "interactionMode"
|
||||
| "latestTurn"
|
||||
| "pinned"
|
||||
| "pinnedAt"
|
||||
| "projectId"
|
||||
| "proposedPlans"
|
||||
| "session"
|
||||
@@ -205,7 +206,7 @@ function toSidebarThreadSnapshot(
|
||||
updatedAt: thread.updatedAt,
|
||||
archivedAt: thread.archivedAt,
|
||||
latestTurn: thread.latestTurn,
|
||||
pinned: thread.pinned,
|
||||
pinnedAt: thread.pinnedAt,
|
||||
lastVisitedAt,
|
||||
branch: thread.branch,
|
||||
worktreePath: thread.worktreePath,
|
||||
@@ -879,7 +880,10 @@ export default function Sidebar() {
|
||||
thread.worktreePath ?? projectCwdById.get(thread.projectId) ?? null;
|
||||
const clicked = await api.contextMenu.show(
|
||||
[
|
||||
{ id: "toggle-pin", label: thread.pinned ? "Unpin thread" : "Pin thread" },
|
||||
{
|
||||
id: "toggle-pin",
|
||||
label: thread.pinnedAt !== null ? "Unpin thread" : "Pin thread",
|
||||
},
|
||||
{ id: "rename", label: "Rename thread" },
|
||||
{ id: "mark-unread", label: "Mark unread" },
|
||||
{ id: "copy-path", label: "Copy Path" },
|
||||
@@ -890,7 +894,7 @@ export default function Sidebar() {
|
||||
);
|
||||
|
||||
if (clicked === "toggle-pin") {
|
||||
await setThreadPinned(thread, !thread.pinned);
|
||||
await setThreadPinned(thread, thread.pinnedAt === null);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1064,7 +1068,7 @@ export default function Sidebar() {
|
||||
[
|
||||
{
|
||||
id: "toggle-pin",
|
||||
label: project.pinned ? "Unpin project" : "Pin project",
|
||||
label: project.pinnedAt !== null ? "Unpin project" : "Pin project",
|
||||
},
|
||||
{ id: "copy-path", label: "Copy Project Path" },
|
||||
{ id: "delete", label: "Remove project", destructive: true },
|
||||
@@ -1072,7 +1076,7 @@ export default function Sidebar() {
|
||||
position,
|
||||
);
|
||||
if (clicked === "toggle-pin") {
|
||||
await setProjectPinned(project, !project.pinned);
|
||||
await setProjectPinned(project, project.pinnedAt === null);
|
||||
return;
|
||||
}
|
||||
if (clicked === "copy-path") {
|
||||
@@ -1230,7 +1234,7 @@ export default function Sidebar() {
|
||||
const globalPinnedThreads = useMemo(
|
||||
() =>
|
||||
sortThreadsForSidebar(
|
||||
visibleThreads.filter((thread) => thread.pinned),
|
||||
visibleThreads.filter((thread) => thread.pinnedAt !== null),
|
||||
appSettings.sidebarThreadSortOrder,
|
||||
),
|
||||
[appSettings.sidebarThreadSortOrder, visibleThreads],
|
||||
@@ -1252,7 +1256,7 @@ export default function Sidebar() {
|
||||
visibleThreads.filter((thread) => thread.projectId === project.id),
|
||||
appSettings.sidebarThreadSortOrder,
|
||||
);
|
||||
const projectThreads = allProjectThreads.filter((thread) => !thread.pinned);
|
||||
const projectThreads = allProjectThreads.filter((thread) => thread.pinnedAt === null);
|
||||
const projectStatus = resolveProjectStatusIndicator(
|
||||
allProjectThreads.map((thread) => threadStatusById.get(thread.id) ?? null),
|
||||
);
|
||||
@@ -1734,6 +1738,15 @@ export default function Sidebar() {
|
||||
{project.name}
|
||||
</span>
|
||||
</SidebarMenuButton>
|
||||
{project.pinnedAt !== null ? (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
title="Pinned project"
|
||||
className="pointer-events-none absolute top-1 right-1.5 inline-flex size-5 items-center justify-center text-muted-foreground/65 transition-opacity duration-150 group-hover/project-header:opacity-0 group-focus-within/project-header:opacity-0"
|
||||
>
|
||||
<PinIcon className="size-3.5" />
|
||||
</span>
|
||||
) : null}
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
|
||||
@@ -48,7 +48,7 @@ describe("deriveOrchestrationBatchEffects", () => {
|
||||
threadId: createdThreadId,
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Created thread",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
modelSelection: { provider: "codex", model: "gpt-5-codex" },
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
@@ -81,7 +81,7 @@ describe("deriveOrchestrationBatchEffects", () => {
|
||||
threadId,
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Recreated thread",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
modelSelection: { provider: "codex", model: "gpt-5-codex" },
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
|
||||
@@ -25,7 +25,7 @@ function makeThread(overrides: Partial<Thread> = {}): Thread {
|
||||
codexThreadId: null,
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -54,7 +54,7 @@ function makeState(thread: Thread): AppState {
|
||||
id: ProjectId.makeUnsafe("project-1"),
|
||||
name: "Project",
|
||||
cwd: "/tmp/project",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -99,7 +99,7 @@ function makeReadModelThread(overrides: Partial<OrchestrationReadModel["threads"
|
||||
id: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.3-codex",
|
||||
@@ -131,7 +131,7 @@ function makeReadModel(thread: OrchestrationReadModel["threads"][number]): Orche
|
||||
id: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/project",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.3-codex",
|
||||
@@ -153,7 +153,7 @@ function makeReadModelProject(
|
||||
id: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/project",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.3-codex",
|
||||
@@ -258,7 +258,7 @@ describe("store read model sync", () => {
|
||||
id: project2,
|
||||
name: "Project 2",
|
||||
cwd: "/tmp/project-2",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: DEFAULT_MODEL_BY_PROVIDER.codex,
|
||||
@@ -269,7 +269,7 @@ describe("store read model sync", () => {
|
||||
id: project1,
|
||||
name: "Project 1",
|
||||
cwd: "/tmp/project-1",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: DEFAULT_MODEL_BY_PROVIDER.codex,
|
||||
@@ -360,7 +360,7 @@ describe("incremental orchestration updates", () => {
|
||||
id: originalProjectId,
|
||||
name: "Project",
|
||||
cwd: "/tmp/project",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: DEFAULT_MODEL_BY_PROVIDER.codex,
|
||||
@@ -378,7 +378,7 @@ describe("incremental orchestration updates", () => {
|
||||
projectId: recreatedProjectId,
|
||||
title: "Project Recreated",
|
||||
workspaceRoot: "/tmp/project",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: DEFAULT_MODEL_BY_PROVIDER.codex,
|
||||
|
||||
@@ -147,7 +147,7 @@ function mapThread(thread: OrchestrationThread): Thread {
|
||||
codexThreadId: null,
|
||||
projectId: thread.projectId,
|
||||
title: thread.title,
|
||||
pinned: thread.pinned,
|
||||
pinnedAt: thread.pinnedAt,
|
||||
modelSelection: normalizeModelSelection(thread.modelSelection),
|
||||
runtimeMode: thread.runtimeMode,
|
||||
interactionMode: thread.interactionMode,
|
||||
@@ -172,7 +172,7 @@ function mapProject(project: OrchestrationReadModel["projects"][number]): Projec
|
||||
id: project.id,
|
||||
name: project.title,
|
||||
cwd: project.workspaceRoot,
|
||||
pinned: project.pinned,
|
||||
pinnedAt: project.pinnedAt,
|
||||
defaultModelSelection: project.defaultModelSelection
|
||||
? normalizeModelSelection(project.defaultModelSelection)
|
||||
: null,
|
||||
@@ -426,7 +426,7 @@ export function applyOrchestrationEvent(state: AppState, event: OrchestrationEve
|
||||
id: event.payload.projectId,
|
||||
title: event.payload.title,
|
||||
workspaceRoot: event.payload.workspaceRoot,
|
||||
pinned: event.payload.pinned,
|
||||
pinnedAt: event.payload.pinnedAt,
|
||||
defaultModelSelection: event.payload.defaultModelSelection,
|
||||
scripts: event.payload.scripts,
|
||||
createdAt: event.payload.createdAt,
|
||||
@@ -447,7 +447,7 @@ export function applyOrchestrationEvent(state: AppState, event: OrchestrationEve
|
||||
...project,
|
||||
...(event.payload.title !== undefined ? { name: event.payload.title } : {}),
|
||||
...(event.payload.workspaceRoot !== undefined ? { cwd: event.payload.workspaceRoot } : {}),
|
||||
...(event.payload.pinned !== undefined ? { pinned: event.payload.pinned } : {}),
|
||||
...(event.payload.pinnedAt !== undefined ? { pinnedAt: event.payload.pinnedAt } : {}),
|
||||
...(event.payload.defaultModelSelection !== undefined
|
||||
? {
|
||||
defaultModelSelection: event.payload.defaultModelSelection
|
||||
@@ -474,7 +474,7 @@ export function applyOrchestrationEvent(state: AppState, event: OrchestrationEve
|
||||
id: event.payload.threadId,
|
||||
projectId: event.payload.projectId,
|
||||
title: event.payload.title,
|
||||
pinned: event.payload.pinned,
|
||||
pinnedAt: event.payload.pinnedAt,
|
||||
modelSelection: event.payload.modelSelection,
|
||||
runtimeMode: event.payload.runtimeMode,
|
||||
interactionMode: event.payload.interactionMode,
|
||||
@@ -524,7 +524,7 @@ export function applyOrchestrationEvent(state: AppState, event: OrchestrationEve
|
||||
const threads = updateThread(state.threads, event.payload.threadId, (thread) => ({
|
||||
...thread,
|
||||
...(event.payload.title !== undefined ? { title: event.payload.title } : {}),
|
||||
...(event.payload.pinned !== undefined ? { pinned: event.payload.pinned } : {}),
|
||||
...(event.payload.pinnedAt !== undefined ? { pinnedAt: event.payload.pinnedAt } : {}),
|
||||
...(event.payload.modelSelection !== undefined
|
||||
? { modelSelection: normalizeModelSelection(event.payload.modelSelection) }
|
||||
: {}),
|
||||
|
||||
@@ -82,7 +82,7 @@ export interface Project {
|
||||
id: ProjectId;
|
||||
name: string;
|
||||
cwd: string;
|
||||
pinned: boolean;
|
||||
pinnedAt: string | null;
|
||||
defaultModelSelection: ModelSelection | null;
|
||||
createdAt?: string | undefined;
|
||||
updatedAt?: string | undefined;
|
||||
@@ -94,7 +94,7 @@ export interface Thread {
|
||||
codexThreadId: string | null;
|
||||
projectId: ProjectId;
|
||||
title: string;
|
||||
pinned: boolean;
|
||||
pinnedAt: string | null;
|
||||
modelSelection: ModelSelection;
|
||||
runtimeMode: RuntimeMode;
|
||||
interactionMode: ProviderInteractionMode;
|
||||
|
||||
@@ -10,7 +10,7 @@ function makeThread(overrides: Partial<Thread> = {}): Thread {
|
||||
codexThreadId: null,
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.3-codex",
|
||||
|
||||
@@ -289,7 +289,7 @@ describe("wsNativeApi", () => {
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/workspace",
|
||||
pinned: false,
|
||||
pinnedAt: null,
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: "2026-02-24T00:00:00.000Z",
|
||||
|
||||
@@ -118,7 +118,7 @@ it.effect("decodes historical project.created payloads with a default provider",
|
||||
updatedAt: "2026-01-01T00:00:00.000Z",
|
||||
});
|
||||
assert.strictEqual(parsed.defaultModelSelection?.provider, "codex");
|
||||
assert.strictEqual(parsed.pinned, false);
|
||||
assert.strictEqual(parsed.pinnedAt, null);
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -216,7 +216,7 @@ it.effect("decodes thread.created runtime mode for historical events", () =>
|
||||
|
||||
assert.strictEqual(parsed.runtimeMode, DEFAULT_RUNTIME_MODE);
|
||||
assert.strictEqual(parsed.modelSelection.provider, "codex");
|
||||
assert.strictEqual(parsed.pinned, false);
|
||||
assert.strictEqual(parsed.pinnedAt, null);
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ export const OrchestrationProject = Schema.Struct({
|
||||
id: ProjectId,
|
||||
title: TrimmedNonEmptyString,
|
||||
workspaceRoot: TrimmedNonEmptyString,
|
||||
pinned: Schema.Boolean.pipe(Schema.withDecodingDefault(() => false)),
|
||||
pinnedAt: Schema.NullOr(IsoDateTime).pipe(Schema.withDecodingDefault(() => null)),
|
||||
defaultModelSelection: Schema.NullOr(ModelSelection),
|
||||
scripts: Schema.Array(ProjectScript),
|
||||
createdAt: IsoDateTime,
|
||||
@@ -275,7 +275,7 @@ export const OrchestrationThread = Schema.Struct({
|
||||
id: ThreadId,
|
||||
projectId: ProjectId,
|
||||
title: TrimmedNonEmptyString,
|
||||
pinned: Schema.Boolean.pipe(Schema.withDecodingDefault(() => false)),
|
||||
pinnedAt: Schema.NullOr(IsoDateTime).pipe(Schema.withDecodingDefault(() => null)),
|
||||
modelSelection: ModelSelection,
|
||||
runtimeMode: RuntimeMode,
|
||||
interactionMode: ProviderInteractionMode.pipe(
|
||||
@@ -630,7 +630,7 @@ export const ProjectCreatedPayload = Schema.Struct({
|
||||
projectId: ProjectId,
|
||||
title: TrimmedNonEmptyString,
|
||||
workspaceRoot: TrimmedNonEmptyString,
|
||||
pinned: Schema.Boolean.pipe(Schema.withDecodingDefault(() => false)),
|
||||
pinnedAt: Schema.NullOr(IsoDateTime).pipe(Schema.withDecodingDefault(() => null)),
|
||||
defaultModelSelection: Schema.NullOr(ModelSelection),
|
||||
scripts: Schema.Array(ProjectScript),
|
||||
createdAt: IsoDateTime,
|
||||
@@ -641,7 +641,7 @@ export const ProjectMetaUpdatedPayload = Schema.Struct({
|
||||
projectId: ProjectId,
|
||||
title: Schema.optional(TrimmedNonEmptyString),
|
||||
workspaceRoot: Schema.optional(TrimmedNonEmptyString),
|
||||
pinned: Schema.optional(Schema.Boolean),
|
||||
pinnedAt: Schema.optional(Schema.NullOr(IsoDateTime)),
|
||||
defaultModelSelection: Schema.optional(Schema.NullOr(ModelSelection)),
|
||||
scripts: Schema.optional(Schema.Array(ProjectScript)),
|
||||
updatedAt: IsoDateTime,
|
||||
@@ -656,7 +656,7 @@ export const ThreadCreatedPayload = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
projectId: ProjectId,
|
||||
title: TrimmedNonEmptyString,
|
||||
pinned: Schema.Boolean.pipe(Schema.withDecodingDefault(() => false)),
|
||||
pinnedAt: Schema.NullOr(IsoDateTime).pipe(Schema.withDecodingDefault(() => null)),
|
||||
modelSelection: ModelSelection,
|
||||
runtimeMode: RuntimeMode.pipe(Schema.withDecodingDefault(() => DEFAULT_RUNTIME_MODE)),
|
||||
interactionMode: ProviderInteractionMode.pipe(
|
||||
@@ -687,7 +687,7 @@ export const ThreadUnarchivedPayload = Schema.Struct({
|
||||
export const ThreadMetaUpdatedPayload = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
title: Schema.optional(TrimmedNonEmptyString),
|
||||
pinned: Schema.optional(Schema.Boolean),
|
||||
pinnedAt: Schema.optional(Schema.NullOr(IsoDateTime)),
|
||||
modelSelection: Schema.optional(ModelSelection),
|
||||
branch: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
||||
worktreePath: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
||||
|
||||
Reference in new issue
Block a user