Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a48356137 | ||
|
|
6723507c00 | ||
|
|
c09e21da38 | ||
|
|
3083d30b1c | ||
|
|
d32da3cb9a | ||
|
|
835d693a92 |
No files matched your search
@@ -116,6 +116,7 @@ const seedProjectAndThread = (harness: OrchestrationIntegrationHarness) =>
|
||||
projectId: PROJECT_ID,
|
||||
title: "Integration Project",
|
||||
workspaceRoot: harness.workspaceDir,
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider,
|
||||
model: defaultModel,
|
||||
@@ -129,6 +130,7 @@ const seedProjectAndThread = (harness: OrchestrationIntegrationHarness) =>
|
||||
threadId: THREAD_ID,
|
||||
projectId: PROJECT_ID,
|
||||
title: "Integration Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider,
|
||||
model: defaultModel,
|
||||
@@ -265,6 +267,7 @@ it.live.skipIf(!process.env.CODEX_BINARY_PATH)(
|
||||
projectId: PROJECT_ID,
|
||||
title: "Integration Project",
|
||||
workspaceRoot: harness.workspaceDir,
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.3-codex",
|
||||
@@ -278,6 +281,7 @@ it.live.skipIf(!process.env.CODEX_BINARY_PATH)(
|
||||
threadId: THREAD_ID,
|
||||
projectId: PROJECT_ID,
|
||||
title: "Integration Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.3-codex",
|
||||
|
||||
@@ -31,6 +31,7 @@ function makeSnapshot(input: {
|
||||
id: input.projectId,
|
||||
title: "Project",
|
||||
workspaceRoot: input.workspaceRoot,
|
||||
pinned: false,
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: "2026-01-01T00:00:00.000Z",
|
||||
@@ -43,6 +44,7 @@ function makeSnapshot(input: {
|
||||
id: input.threadId,
|
||||
projectId: input.projectId,
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
|
||||
@@ -282,6 +282,7 @@ describe("CheckpointReactor", () => {
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Test Project",
|
||||
workspaceRoot: options?.projectWorkspaceRoot ?? cwd,
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -296,6 +297,7 @@ describe("CheckpointReactor", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
|
||||
@@ -72,6 +72,7 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Project 1",
|
||||
workspaceRoot: "/tmp/project-1",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -86,6 +87,7 @@ describe("OrchestrationEngine", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -132,6 +134,7 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-archive"),
|
||||
title: "Project Archive",
|
||||
workspaceRoot: "/tmp/project-archive",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -146,6 +149,7 @@ describe("OrchestrationEngine", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-archive"),
|
||||
projectId: asProjectId("project-archive"),
|
||||
title: "Archive me",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -199,6 +203,7 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-replay"),
|
||||
title: "Replay Project",
|
||||
workspaceRoot: "/tmp/project-replay",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -213,6 +218,7 @@ describe("OrchestrationEngine", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-replay"),
|
||||
projectId: asProjectId("project-replay"),
|
||||
title: "replay",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -257,6 +263,7 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-stream"),
|
||||
title: "Stream Project",
|
||||
workspaceRoot: "/tmp/project-stream",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -281,6 +288,7 @@ describe("OrchestrationEngine", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-stream"),
|
||||
projectId: asProjectId("project-stream"),
|
||||
title: "domain-stream",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -318,6 +326,7 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-turn-diff"),
|
||||
title: "Turn Diff Project",
|
||||
workspaceRoot: "/tmp/project-turn-diff",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -332,6 +341,7 @@ describe("OrchestrationEngine", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-turn-diff"),
|
||||
projectId: asProjectId("project-turn-diff"),
|
||||
title: "Turn diff thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -435,6 +445,7 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-flaky"),
|
||||
title: "Flaky Project",
|
||||
workspaceRoot: "/tmp/project-flaky",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -451,6 +462,7 @@ describe("OrchestrationEngine", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-flaky-fail"),
|
||||
projectId: asProjectId("project-flaky"),
|
||||
title: "flaky-fail",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -471,6 +483,7 @@ describe("OrchestrationEngine", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-flaky-ok"),
|
||||
projectId: asProjectId("project-flaky"),
|
||||
title: "flaky-ok",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -528,6 +541,7 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-atomic"),
|
||||
title: "Atomic Project",
|
||||
workspaceRoot: "/tmp/project-atomic",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -542,6 +556,7 @@ describe("OrchestrationEngine", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-atomic"),
|
||||
projectId: asProjectId("project-atomic"),
|
||||
title: "atomic",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -669,6 +684,7 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-sync"),
|
||||
title: "Sync Project",
|
||||
workspaceRoot: "/tmp/project-sync",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -683,6 +699,7 @@ describe("OrchestrationEngine", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-sync"),
|
||||
projectId: asProjectId("project-sync"),
|
||||
title: "sync-before",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -754,6 +771,7 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-duplicate"),
|
||||
title: "Duplicate Project",
|
||||
workspaceRoot: "/tmp/project-duplicate",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -769,6 +787,7 @@ describe("OrchestrationEngine", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-duplicate"),
|
||||
projectId: asProjectId("project-duplicate"),
|
||||
title: "duplicate",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -789,6 +808,7 @@ describe("OrchestrationEngine", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-duplicate"),
|
||||
projectId: asProjectId("project-duplicate"),
|
||||
title: "duplicate",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
|
||||
@@ -1867,6 +1867,7 @@ engineLayer("OrchestrationProjectionPipeline via engine dispatch", (it) => {
|
||||
projectId: ProjectId.makeUnsafe("project-live"),
|
||||
title: "Live Project",
|
||||
workspaceRoot: "/tmp/project-live",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -1905,6 +1906,7 @@ engineLayer("OrchestrationProjectionPipeline via engine dispatch", (it) => {
|
||||
projectId: ProjectId.makeUnsafe("project-scripts"),
|
||||
title: "Scripts Project",
|
||||
workspaceRoot: "/tmp/project-scripts",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
|
||||
@@ -383,6 +383,7 @@ const makeOrchestrationProjectionPipeline = Effect.fn("makeOrchestrationProjecti
|
||||
projectId: event.payload.projectId,
|
||||
title: event.payload.title,
|
||||
workspaceRoot: event.payload.workspaceRoot,
|
||||
pinned: event.payload.pinned,
|
||||
defaultModelSelection: event.payload.defaultModelSelection,
|
||||
scripts: event.payload.scripts,
|
||||
createdAt: event.payload.createdAt,
|
||||
@@ -404,6 +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.defaultModelSelection !== undefined
|
||||
? { defaultModelSelection: event.payload.defaultModelSelection }
|
||||
: {}),
|
||||
@@ -442,6 +444,7 @@ const makeOrchestrationProjectionPipeline = Effect.fn("makeOrchestrationProjecti
|
||||
threadId: event.payload.threadId,
|
||||
projectId: event.payload.projectId,
|
||||
title: event.payload.title,
|
||||
pinned: event.payload.pinned,
|
||||
modelSelection: event.payload.modelSelection,
|
||||
runtimeMode: event.payload.runtimeMode,
|
||||
interactionMode: event.payload.interactionMode,
|
||||
@@ -495,6 +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.modelSelection !== undefined
|
||||
? { modelSelection: event.payload.modelSelection }
|
||||
: {}),
|
||||
|
||||
@@ -234,6 +234,7 @@ projectionSnapshotLayer("ProjectionSnapshotQuery", (it) => {
|
||||
id: asProjectId("project-1"),
|
||||
title: "Project 1",
|
||||
workspaceRoot: "/tmp/project-1",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -257,6 +258,7 @@ projectionSnapshotLayer("ProjectionSnapshotQuery", (it) => {
|
||||
id: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread 1",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
|
||||
@@ -46,6 +46,7 @@ import {
|
||||
const decodeReadModel = Schema.decodeUnknownEffect(OrchestrationReadModel);
|
||||
const ProjectionProjectDbRowSchema = ProjectionProject.mapFields(
|
||||
Struct.assign({
|
||||
pinned: Schema.BooleanFromBit,
|
||||
defaultModelSelection: Schema.NullOr(Schema.fromJsonString(ModelSelection)),
|
||||
scripts: Schema.fromJsonString(Schema.Array(ProjectScript)),
|
||||
}),
|
||||
@@ -59,6 +60,7 @@ const ProjectionThreadMessageDbRowSchema = ProjectionThreadMessage.mapFields(
|
||||
const ProjectionThreadProposedPlanDbRowSchema = ProjectionThreadProposedPlan;
|
||||
const ProjectionThreadDbRowSchema = ProjectionThread.mapFields(
|
||||
Struct.assign({
|
||||
pinned: Schema.BooleanFromBit,
|
||||
modelSelection: Schema.fromJsonString(ModelSelection),
|
||||
}),
|
||||
);
|
||||
@@ -147,6 +149,7 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
project_id AS "projectId",
|
||||
title,
|
||||
workspace_root AS "workspaceRoot",
|
||||
pinned,
|
||||
default_model_selection_json AS "defaultModelSelection",
|
||||
scripts_json AS "scripts",
|
||||
created_at AS "createdAt",
|
||||
@@ -166,6 +169,7 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
thread_id AS "threadId",
|
||||
project_id AS "projectId",
|
||||
title,
|
||||
pinned,
|
||||
model_selection_json AS "modelSelection",
|
||||
runtime_mode AS "runtimeMode",
|
||||
interaction_mode AS "interactionMode",
|
||||
@@ -542,6 +546,7 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
id: row.projectId,
|
||||
title: row.title,
|
||||
workspaceRoot: row.workspaceRoot,
|
||||
pinned: row.pinned,
|
||||
defaultModelSelection: row.defaultModelSelection,
|
||||
scripts: row.scripts,
|
||||
createdAt: row.createdAt,
|
||||
@@ -553,6 +558,7 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
id: row.threadId,
|
||||
projectId: row.projectId,
|
||||
title: row.title,
|
||||
pinned: row.pinned,
|
||||
modelSelection: row.modelSelection,
|
||||
runtimeMode: row.runtimeMode,
|
||||
interactionMode: row.interactionMode,
|
||||
|
||||
@@ -245,6 +245,7 @@ describe("ProviderCommandReactor", () => {
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Provider Project",
|
||||
workspaceRoot: "/tmp/provider-project",
|
||||
pinned: false,
|
||||
defaultModelSelection: modelSelection,
|
||||
createdAt: now,
|
||||
}),
|
||||
@@ -256,6 +257,7 @@ describe("ProviderCommandReactor", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: modelSelection,
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
|
||||
@@ -225,6 +225,7 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Provider Project",
|
||||
workspaceRoot,
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -239,6 +240,7 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -768,6 +770,7 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
threadId: sourceThreadId,
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Plan Source",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -803,6 +806,7 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
threadId: targetThreadId,
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Plan Target",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -955,6 +959,7 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
threadId: sourceThreadId,
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Plan Source",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -1108,6 +1113,7 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
threadId: sourceThreadId,
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Plan Source",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -1143,6 +1149,7 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
threadId: targetThreadId,
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Plan Target",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
|
||||
@@ -28,6 +28,7 @@ const readModel: OrchestrationReadModel = {
|
||||
id: ProjectId.makeUnsafe("project-a"),
|
||||
title: "Project A",
|
||||
workspaceRoot: "/tmp/project-a",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -41,6 +42,7 @@ const readModel: OrchestrationReadModel = {
|
||||
id: ProjectId.makeUnsafe("project-b"),
|
||||
title: "Project B",
|
||||
workspaceRoot: "/tmp/project-b",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -56,6 +58,7 @@ const readModel: OrchestrationReadModel = {
|
||||
id: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: ProjectId.makeUnsafe("project-a"),
|
||||
title: "Thread A",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -79,6 +82,7 @@ const readModel: OrchestrationReadModel = {
|
||||
id: ThreadId.makeUnsafe("thread-2"),
|
||||
projectId: ProjectId.makeUnsafe("project-b"),
|
||||
title: "Thread B",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -158,6 +162,7 @@ describe("commandInvariants", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-3"),
|
||||
projectId: ProjectId.makeUnsafe("project-a"),
|
||||
title: "new",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -182,6 +187,7 @@ describe("commandInvariants", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: ProjectId.makeUnsafe("project-a"),
|
||||
title: "dup",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
|
||||
@@ -29,6 +29,7 @@ describe("decider project scripts", () => {
|
||||
projectId: asProjectId("project-scripts"),
|
||||
title: "Scripts",
|
||||
workspaceRoot: "/tmp/scripts",
|
||||
pinned: false,
|
||||
createdAt: now,
|
||||
},
|
||||
readModel,
|
||||
@@ -37,7 +38,10 @@ describe("decider project scripts", () => {
|
||||
|
||||
const event = Array.isArray(result) ? result[0] : result;
|
||||
expect(event.type).toBe("project.created");
|
||||
expect((event.payload as { scripts: unknown[] }).scripts).toEqual([]);
|
||||
expect(event.payload).toMatchObject({
|
||||
pinned: false,
|
||||
scripts: [],
|
||||
});
|
||||
});
|
||||
|
||||
it("propagates scripts in project.meta.update payload", async () => {
|
||||
@@ -59,6 +63,7 @@ describe("decider project scripts", () => {
|
||||
projectId: asProjectId("project-scripts"),
|
||||
title: "Scripts",
|
||||
workspaceRoot: "/tmp/scripts",
|
||||
pinned: false,
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: now,
|
||||
@@ -94,6 +99,82 @@ describe("decider project scripts", () => {
|
||||
expect((event.payload as { scripts?: unknown[] }).scripts).toEqual(scripts);
|
||||
});
|
||||
|
||||
it("propagates pin state through thread create and meta update", async () => {
|
||||
const now = new Date().toISOString();
|
||||
const initial = createEmptyReadModel(now);
|
||||
const withProject = await Effect.runPromise(
|
||||
projectEvent(initial, {
|
||||
sequence: 1,
|
||||
eventId: asEventId("evt-project-create-pin"),
|
||||
aggregateKind: "project",
|
||||
aggregateId: asProjectId("project-pin"),
|
||||
type: "project.created",
|
||||
occurredAt: now,
|
||||
commandId: CommandId.makeUnsafe("cmd-project-create-pin"),
|
||||
causationEventId: null,
|
||||
correlationId: CommandId.makeUnsafe("cmd-project-create-pin"),
|
||||
metadata: {},
|
||||
payload: {
|
||||
projectId: asProjectId("project-pin"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/project-pin",
|
||||
pinned: false,
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
const created = await Effect.runPromise(
|
||||
decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.create",
|
||||
commandId: CommandId.makeUnsafe("cmd-thread-create-pin"),
|
||||
threadId: ThreadId.makeUnsafe("thread-pin"),
|
||||
projectId: asProjectId("project-pin"),
|
||||
title: "Pinned thread",
|
||||
pinned: true,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
},
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
},
|
||||
readModel: withProject,
|
||||
}),
|
||||
);
|
||||
const createdEvent = Array.isArray(created) ? created[0] : created;
|
||||
expect(createdEvent.type).toBe("thread.created");
|
||||
expect(createdEvent.payload).toMatchObject({ pinned: true });
|
||||
|
||||
const withThread = await Effect.runPromise(
|
||||
projectEvent(withProject, {
|
||||
...createdEvent,
|
||||
sequence: 2,
|
||||
}),
|
||||
);
|
||||
const updated = await Effect.runPromise(
|
||||
decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.meta.update",
|
||||
commandId: CommandId.makeUnsafe("cmd-thread-update-pin"),
|
||||
threadId: ThreadId.makeUnsafe("thread-pin"),
|
||||
pinned: false,
|
||||
},
|
||||
readModel: withThread,
|
||||
}),
|
||||
);
|
||||
const updatedEvent = Array.isArray(updated) ? updated[0] : updated;
|
||||
expect(updatedEvent.type).toBe("thread.meta-updated");
|
||||
expect(updatedEvent.payload).toMatchObject({ pinned: false });
|
||||
});
|
||||
|
||||
it("emits user message and turn-start-requested events for thread.turn.start", async () => {
|
||||
const now = new Date().toISOString();
|
||||
const initial = createEmptyReadModel(now);
|
||||
@@ -113,6 +194,7 @@ describe("decider project scripts", () => {
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/project",
|
||||
pinned: false,
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: now,
|
||||
@@ -136,6 +218,7 @@ describe("decider project scripts", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -222,6 +305,7 @@ describe("decider project scripts", () => {
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/project",
|
||||
pinned: false,
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: now,
|
||||
@@ -245,6 +329,7 @@ describe("decider project scripts", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -304,6 +389,7 @@ describe("decider project scripts", () => {
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/project",
|
||||
pinned: false,
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: now,
|
||||
@@ -327,6 +413,7 @@ describe("decider project scripts", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
|
||||
@@ -77,6 +77,7 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
projectId: command.projectId,
|
||||
title: command.title,
|
||||
workspaceRoot: command.workspaceRoot,
|
||||
pinned: command.pinned ?? false,
|
||||
defaultModelSelection: command.defaultModelSelection ?? null,
|
||||
scripts: [],
|
||||
createdAt: command.createdAt,
|
||||
@@ -104,6 +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.defaultModelSelection !== undefined
|
||||
? { defaultModelSelection: command.defaultModelSelection }
|
||||
: {}),
|
||||
@@ -158,6 +160,7 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
threadId: command.threadId,
|
||||
projectId: command.projectId,
|
||||
title: command.title,
|
||||
pinned: command.pinned ?? false,
|
||||
modelSelection: command.modelSelection,
|
||||
runtimeMode: command.runtimeMode,
|
||||
interactionMode: command.interactionMode,
|
||||
@@ -254,6 +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.modelSelection !== undefined
|
||||
? { modelSelection: command.modelSelection }
|
||||
: {}),
|
||||
|
||||
@@ -76,6 +76,7 @@ describe("orchestration projector", () => {
|
||||
id: "thread-1",
|
||||
projectId: "project-1",
|
||||
title: "demo",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -98,6 +99,99 @@ describe("orchestration projector", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("applies pin updates for projects and threads", async () => {
|
||||
const now = new Date().toISOString();
|
||||
const later = new Date(Date.parse(now) + 1_000).toISOString();
|
||||
const withProject = await Effect.runPromise(
|
||||
projectEvent(
|
||||
createEmptyReadModel(now),
|
||||
makeEvent({
|
||||
sequence: 1,
|
||||
type: "project.created",
|
||||
aggregateKind: "project",
|
||||
aggregateId: "project-1",
|
||||
occurredAt: now,
|
||||
commandId: "cmd-project-create",
|
||||
payload: {
|
||||
projectId: "project-1",
|
||||
title: "demo",
|
||||
workspaceRoot: "/tmp/project-1",
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
const withPinnedProject = await Effect.runPromise(
|
||||
projectEvent(
|
||||
withProject,
|
||||
makeEvent({
|
||||
sequence: 2,
|
||||
type: "project.meta-updated",
|
||||
aggregateKind: "project",
|
||||
aggregateId: "project-1",
|
||||
occurredAt: later,
|
||||
commandId: "cmd-project-pin",
|
||||
payload: {
|
||||
projectId: "project-1",
|
||||
pinned: true,
|
||||
updatedAt: later,
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(withPinnedProject.projects[0]?.pinned).toBe(true);
|
||||
|
||||
const withThread = await Effect.runPromise(
|
||||
projectEvent(
|
||||
withPinnedProject,
|
||||
makeEvent({
|
||||
sequence: 3,
|
||||
type: "thread.created",
|
||||
aggregateKind: "thread",
|
||||
aggregateId: "thread-1",
|
||||
occurredAt: now,
|
||||
commandId: "cmd-thread-create",
|
||||
payload: {
|
||||
threadId: "thread-1",
|
||||
projectId: "project-1",
|
||||
title: "demo",
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
},
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
const withPinnedThread = await Effect.runPromise(
|
||||
projectEvent(
|
||||
withThread,
|
||||
makeEvent({
|
||||
sequence: 4,
|
||||
type: "thread.meta-updated",
|
||||
aggregateKind: "thread",
|
||||
aggregateId: "thread-1",
|
||||
occurredAt: later,
|
||||
commandId: "cmd-thread-pin",
|
||||
payload: {
|
||||
threadId: "thread-1",
|
||||
pinned: true,
|
||||
updatedAt: later,
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(withPinnedThread.threads[0]?.pinned).toBe(true);
|
||||
});
|
||||
|
||||
it("fails when event payload cannot be decoded by runtime schema", async () => {
|
||||
const now = new Date().toISOString();
|
||||
const model = createEmptyReadModel(now);
|
||||
|
||||
@@ -183,6 +183,7 @@ export function projectEvent(
|
||||
id: payload.projectId,
|
||||
title: payload.title,
|
||||
workspaceRoot: payload.workspaceRoot,
|
||||
pinned: payload.pinned,
|
||||
defaultModelSelection: payload.defaultModelSelection,
|
||||
scripts: payload.scripts,
|
||||
createdAt: payload.createdAt,
|
||||
@@ -213,6 +214,7 @@ export function projectEvent(
|
||||
...(payload.workspaceRoot !== undefined
|
||||
? { workspaceRoot: payload.workspaceRoot }
|
||||
: {}),
|
||||
...(payload.pinned !== undefined ? { pinned: payload.pinned } : {}),
|
||||
...(payload.defaultModelSelection !== undefined
|
||||
? { defaultModelSelection: payload.defaultModelSelection }
|
||||
: {}),
|
||||
@@ -254,6 +256,7 @@ export function projectEvent(
|
||||
id: payload.threadId,
|
||||
projectId: payload.projectId,
|
||||
title: payload.title,
|
||||
pinned: payload.pinned,
|
||||
modelSelection: payload.modelSelection,
|
||||
runtimeMode: payload.runtimeMode,
|
||||
interactionMode: payload.interactionMode,
|
||||
@@ -320,6 +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.modelSelection !== undefined
|
||||
? { modelSelection: payload.modelSelection }
|
||||
: {}),
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
|
||||
const ProjectionProjectDbRow = ProjectionProject.mapFields(
|
||||
Struct.assign({
|
||||
pinned: Schema.BooleanFromBit,
|
||||
defaultModelSelection: Schema.NullOr(Schema.fromJsonString(ModelSelection)),
|
||||
scripts: Schema.fromJsonString(Schema.Array(ProjectScript)),
|
||||
}),
|
||||
@@ -31,6 +32,7 @@ const makeProjectionProjectRepository = Effect.gen(function* () {
|
||||
project_id,
|
||||
title,
|
||||
workspace_root,
|
||||
pinned,
|
||||
default_model_selection_json,
|
||||
scripts_json,
|
||||
created_at,
|
||||
@@ -41,6 +43,7 @@ const makeProjectionProjectRepository = Effect.gen(function* () {
|
||||
${row.projectId},
|
||||
${row.title},
|
||||
${row.workspaceRoot},
|
||||
${row.pinned ? 1 : 0},
|
||||
${row.defaultModelSelection !== null ? JSON.stringify(row.defaultModelSelection) : null},
|
||||
${JSON.stringify(row.scripts)},
|
||||
${row.createdAt},
|
||||
@@ -51,6 +54,7 @@ const makeProjectionProjectRepository = Effect.gen(function* () {
|
||||
DO UPDATE SET
|
||||
title = excluded.title,
|
||||
workspace_root = excluded.workspace_root,
|
||||
pinned = excluded.pinned,
|
||||
default_model_selection_json = excluded.default_model_selection_json,
|
||||
scripts_json = excluded.scripts_json,
|
||||
created_at = excluded.created_at,
|
||||
@@ -68,6 +72,7 @@ const makeProjectionProjectRepository = Effect.gen(function* () {
|
||||
project_id AS "projectId",
|
||||
title,
|
||||
workspace_root AS "workspaceRoot",
|
||||
pinned,
|
||||
default_model_selection_json AS "defaultModelSelection",
|
||||
scripts_json AS "scripts",
|
||||
created_at AS "createdAt",
|
||||
@@ -87,6 +92,7 @@ const makeProjectionProjectRepository = Effect.gen(function* () {
|
||||
project_id AS "projectId",
|
||||
title,
|
||||
workspace_root AS "workspaceRoot",
|
||||
pinned,
|
||||
default_model_selection_json AS "defaultModelSelection",
|
||||
scripts_json AS "scripts",
|
||||
created_at AS "createdAt",
|
||||
|
||||
@@ -27,6 +27,7 @@ projectionRepositoriesLayer("Projection repositories", (it) => {
|
||||
projectId: ProjectId.makeUnsafe("project-null-options"),
|
||||
title: "Null options project",
|
||||
workspaceRoot: "/tmp/project-null-options",
|
||||
pinned: true,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.4",
|
||||
@@ -60,6 +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.deepStrictEqual(Option.getOrNull(persisted)?.defaultModelSelection, {
|
||||
provider: "codex",
|
||||
model: "gpt-5.4",
|
||||
@@ -76,6 +78,7 @@ projectionRepositoriesLayer("Projection repositories", (it) => {
|
||||
threadId: ThreadId.makeUnsafe("thread-null-options"),
|
||||
projectId: ProjectId.makeUnsafe("project-null-options"),
|
||||
title: "Null options thread",
|
||||
pinned: true,
|
||||
modelSelection: {
|
||||
provider: "claudeAgent",
|
||||
model: "claude-opus-4-6",
|
||||
@@ -114,6 +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.deepStrictEqual(Option.getOrNull(persisted)?.modelSelection, {
|
||||
provider: "claudeAgent",
|
||||
model: "claude-opus-4-6",
|
||||
|
||||
@@ -15,6 +15,7 @@ import { ModelSelection } from "@t3tools/contracts";
|
||||
|
||||
const ProjectionThreadDbRow = ProjectionThread.mapFields(
|
||||
Struct.assign({
|
||||
pinned: Schema.BooleanFromBit,
|
||||
modelSelection: Schema.fromJsonString(ModelSelection),
|
||||
}),
|
||||
);
|
||||
@@ -31,6 +32,7 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
thread_id,
|
||||
project_id,
|
||||
title,
|
||||
pinned,
|
||||
model_selection_json,
|
||||
runtime_mode,
|
||||
interaction_mode,
|
||||
@@ -46,6 +48,7 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
${row.threadId},
|
||||
${row.projectId},
|
||||
${row.title},
|
||||
${row.pinned ? 1 : 0},
|
||||
${JSON.stringify(row.modelSelection)},
|
||||
${row.runtimeMode},
|
||||
${row.interactionMode},
|
||||
@@ -61,6 +64,7 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
DO UPDATE SET
|
||||
project_id = excluded.project_id,
|
||||
title = excluded.title,
|
||||
pinned = excluded.pinned,
|
||||
model_selection_json = excluded.model_selection_json,
|
||||
runtime_mode = excluded.runtime_mode,
|
||||
interaction_mode = excluded.interaction_mode,
|
||||
@@ -83,6 +87,7 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
thread_id AS "threadId",
|
||||
project_id AS "projectId",
|
||||
title,
|
||||
pinned,
|
||||
model_selection_json AS "modelSelection",
|
||||
runtime_mode AS "runtimeMode",
|
||||
interaction_mode AS "interactionMode",
|
||||
@@ -107,6 +112,7 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
thread_id AS "threadId",
|
||||
project_id AS "projectId",
|
||||
title,
|
||||
pinned,
|
||||
model_selection_json AS "modelSelection",
|
||||
runtime_mode AS "runtimeMode",
|
||||
interaction_mode AS "interactionMode",
|
||||
|
||||
@@ -31,6 +31,7 @@ import Migration0015 from "./Migrations/015_ProjectionTurnsSourceProposedPlan.ts
|
||||
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";
|
||||
|
||||
/**
|
||||
* Migration loader with all migrations defined inline.
|
||||
@@ -61,6 +62,7 @@ export const migrationEntries = [
|
||||
[16, "CanonicalizeModelSelections", Migration0016],
|
||||
[17, "ProjectionThreadsArchivedAt", Migration0017],
|
||||
[18, "ProjectionThreadsArchivedAtIndex", Migration0018],
|
||||
[19, "ProjectionPins", Migration0019],
|
||||
] as const;
|
||||
|
||||
export const makeMigrationLoader = (throughId?: number) =>
|
||||
|
||||
@@ -9,6 +9,7 @@ export default Effect.gen(function* () {
|
||||
project_id TEXT PRIMARY KEY,
|
||||
title TEXT NOT NULL,
|
||||
workspace_root TEXT NOT NULL,
|
||||
pinned INTEGER NOT NULL DEFAULT 0,
|
||||
default_model TEXT,
|
||||
scripts_json TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL,
|
||||
@@ -22,6 +23,7 @@ export default Effect.gen(function* () {
|
||||
thread_id TEXT PRIMARY KEY,
|
||||
project_id TEXT NOT NULL,
|
||||
title TEXT NOT NULL,
|
||||
pinned INTEGER NOT NULL DEFAULT 0,
|
||||
model TEXT NOT NULL,
|
||||
branch TEXT,
|
||||
worktree_path TEXT,
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
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")) {
|
||||
yield* sql`
|
||||
ALTER TABLE projection_projects
|
||||
ADD COLUMN pinned INTEGER NOT NULL DEFAULT 0
|
||||
`;
|
||||
}
|
||||
|
||||
const threadColumns = yield* sql<{ readonly name: string }>`
|
||||
PRAGMA table_info(projection_threads)
|
||||
`;
|
||||
if (!threadColumns.some((column) => column.name === "pinned")) {
|
||||
yield* sql`
|
||||
ALTER TABLE projection_threads
|
||||
ADD COLUMN pinned INTEGER NOT NULL DEFAULT 0
|
||||
`;
|
||||
}
|
||||
});
|
||||
@@ -16,6 +16,7 @@ export const ProjectionProject = Schema.Struct({
|
||||
projectId: ProjectId,
|
||||
title: Schema.String,
|
||||
workspaceRoot: Schema.String,
|
||||
pinned: Schema.Boolean,
|
||||
defaultModelSelection: Schema.NullOr(ModelSelection),
|
||||
scripts: Schema.Array(ProjectScript),
|
||||
createdAt: IsoDateTime,
|
||||
|
||||
@@ -24,6 +24,7 @@ export const ProjectionThread = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
projectId: ProjectId,
|
||||
title: Schema.String,
|
||||
pinned: Schema.Boolean,
|
||||
modelSelection: ModelSelection,
|
||||
runtimeMode: RuntimeMode,
|
||||
interactionMode: ProviderInteractionMode,
|
||||
|
||||
@@ -1221,6 +1221,7 @@ describe("WebSocket Server", () => {
|
||||
projectId: "project-diff",
|
||||
title: "Diff Project",
|
||||
workspaceRoot,
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -1234,6 +1235,7 @@ describe("WebSocket Server", () => {
|
||||
threadId: "thread-diff",
|
||||
projectId: "project-diff",
|
||||
title: "Diff Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -1306,6 +1308,7 @@ describe("WebSocket Server", () => {
|
||||
projectId: "project-1",
|
||||
title: "WS Project",
|
||||
workspaceRoot,
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -1319,6 +1322,7 @@ describe("WebSocket Server", () => {
|
||||
threadId: "thread-1",
|
||||
projectId: "project-1",
|
||||
title: "Thread 1",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
|
||||
@@ -675,6 +675,7 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return<
|
||||
projectId: bootstrapProjectId,
|
||||
title: bootstrapProjectTitle,
|
||||
workspaceRoot: cwd,
|
||||
pinned: false,
|
||||
defaultModelSelection: bootstrapProjectDefaultModelSelection,
|
||||
createdAt,
|
||||
});
|
||||
@@ -698,6 +699,7 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return<
|
||||
threadId,
|
||||
projectId: bootstrapProjectId,
|
||||
title: "New thread",
|
||||
pinned: false,
|
||||
modelSelection: bootstrapProjectDefaultModelSelection,
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "full-access",
|
||||
|
||||
@@ -237,6 +237,7 @@ function createSnapshotForTargetUser(options: {
|
||||
id: PROJECT_ID,
|
||||
title: "Project",
|
||||
workspaceRoot: "/repo/project",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5",
|
||||
@@ -252,6 +253,7 @@ function createSnapshotForTargetUser(options: {
|
||||
id: THREAD_ID,
|
||||
projectId: PROJECT_ID,
|
||||
title: "Browser test thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5",
|
||||
@@ -310,6 +312,7 @@ function addThreadToSnapshot(
|
||||
id: threadId,
|
||||
projectId: PROJECT_ID,
|
||||
title: "New thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5",
|
||||
@@ -357,6 +360,7 @@ function createThreadCreatedEvent(threadId: ThreadId, sequence: number): Orchest
|
||||
threadId,
|
||||
projectId: PROJECT_ID,
|
||||
title: "New thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5",
|
||||
|
||||
@@ -89,6 +89,7 @@ const makeThread = (input?: {
|
||||
codexThreadId: null,
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: { provider: "codex" as const, model: "gpt-5.4" },
|
||||
runtimeMode: "full-access" as const,
|
||||
interactionMode: "default" as const,
|
||||
@@ -247,6 +248,7 @@ describe("hasServerAcknowledgedLocalDispatch", () => {
|
||||
codexThreadId: null,
|
||||
projectId,
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: { provider: "codex", model: "gpt-5.4" },
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
@@ -283,6 +285,7 @@ describe("hasServerAcknowledgedLocalDispatch", () => {
|
||||
codexThreadId: null,
|
||||
projectId,
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: { provider: "codex", model: "gpt-5.4" },
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
@@ -328,6 +331,7 @@ describe("hasServerAcknowledgedLocalDispatch", () => {
|
||||
codexThreadId: null,
|
||||
projectId,
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: { provider: "codex", model: "gpt-5.4" },
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
|
||||
@@ -26,6 +26,7 @@ export function buildLocalDraftThread(
|
||||
codexThreadId: null,
|
||||
projectId: draftThread.projectId,
|
||||
title: "New thread",
|
||||
pinned: false,
|
||||
modelSelection: fallbackModelSelection,
|
||||
runtimeMode: draftThread.runtimeMode,
|
||||
interactionMode: draftThread.interactionMode,
|
||||
|
||||
@@ -2774,6 +2774,7 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
threadId: threadIdForSend,
|
||||
projectId: activeProject.id,
|
||||
title,
|
||||
pinned: false,
|
||||
modelSelection: threadCreateModelSelection,
|
||||
runtimeMode,
|
||||
interactionMode,
|
||||
@@ -3221,6 +3222,7 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
threadId: nextThreadId,
|
||||
projectId: activeProject.id,
|
||||
title: nextThreadTitle,
|
||||
pinned: false,
|
||||
modelSelection: nextThreadModelSelection,
|
||||
runtimeMode,
|
||||
interactionMode: "default",
|
||||
|
||||
@@ -76,6 +76,7 @@ function createMinimalSnapshot(): OrchestrationReadModel {
|
||||
id: PROJECT_ID,
|
||||
title: "Project",
|
||||
workspaceRoot: "/repo/project",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5",
|
||||
@@ -91,6 +92,7 @@ function createMinimalSnapshot(): OrchestrationReadModel {
|
||||
id: THREAD_ID,
|
||||
projectId: PROJECT_ID,
|
||||
title: "Test thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5",
|
||||
|
||||
@@ -592,6 +592,7 @@ function makeProject(overrides: Partial<Project> = {}): Project {
|
||||
id: ProjectId.makeUnsafe("project-1"),
|
||||
name: "Project",
|
||||
cwd: "/tmp/project",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.4",
|
||||
@@ -610,6 +611,7 @@ function makeThread(overrides: Partial<Thread> = {}): Thread {
|
||||
codexThreadId: null,
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.4",
|
||||
@@ -758,6 +760,73 @@ describe("sortThreadsForSidebar", () => {
|
||||
ThreadId.makeUnsafe("thread-2"),
|
||||
]);
|
||||
});
|
||||
|
||||
it("puts pinned threads ahead of unpinned threads in auto-sort modes", () => {
|
||||
const sorted = sortThreadsForSidebar(
|
||||
[
|
||||
{
|
||||
...makeThread({
|
||||
id: ThreadId.makeUnsafe("thread-1"),
|
||||
createdAt: "2026-03-09T10:00:00.000Z",
|
||||
updatedAt: "2026-03-09T10:01:00.000Z",
|
||||
}),
|
||||
pinned: true,
|
||||
},
|
||||
{
|
||||
...makeThread({
|
||||
id: ThreadId.makeUnsafe("thread-2"),
|
||||
createdAt: "2026-03-09T10:05:00.000Z",
|
||||
updatedAt: "2026-03-09T10:05:00.000Z",
|
||||
}),
|
||||
pinned: false,
|
||||
},
|
||||
],
|
||||
"updated_at",
|
||||
);
|
||||
|
||||
expect(sorted.map((thread) => thread.id)).toEqual([
|
||||
ThreadId.makeUnsafe("thread-1"),
|
||||
ThreadId.makeUnsafe("thread-2"),
|
||||
]);
|
||||
});
|
||||
|
||||
it("still auto-sorts within the pinned thread bucket", () => {
|
||||
const sorted = sortThreadsForSidebar(
|
||||
[
|
||||
{
|
||||
...makeThread({
|
||||
id: ThreadId.makeUnsafe("thread-1"),
|
||||
createdAt: "2026-03-09T10:01:00.000Z",
|
||||
updatedAt: "2026-03-09T10:01:00.000Z",
|
||||
}),
|
||||
pinned: true,
|
||||
},
|
||||
{
|
||||
...makeThread({
|
||||
id: ThreadId.makeUnsafe("thread-2"),
|
||||
createdAt: "2026-03-09T10:05:00.000Z",
|
||||
updatedAt: "2026-03-09T10:05:00.000Z",
|
||||
}),
|
||||
pinned: true,
|
||||
},
|
||||
{
|
||||
...makeThread({
|
||||
id: ThreadId.makeUnsafe("thread-3"),
|
||||
createdAt: "2026-03-09T10:10:00.000Z",
|
||||
updatedAt: "2026-03-09T10:10:00.000Z",
|
||||
}),
|
||||
pinned: false,
|
||||
},
|
||||
],
|
||||
"updated_at",
|
||||
);
|
||||
|
||||
expect(sorted.map((thread) => thread.id)).toEqual([
|
||||
ThreadId.makeUnsafe("thread-2"),
|
||||
ThreadId.makeUnsafe("thread-1"),
|
||||
ThreadId.makeUnsafe("thread-3"),
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getFallbackThreadIdAfterDelete", () => {
|
||||
@@ -796,6 +865,41 @@ describe("getFallbackThreadIdAfterDelete", () => {
|
||||
expect(fallbackThreadId).toBe(ThreadId.makeUnsafe("thread-newest"));
|
||||
});
|
||||
|
||||
it("respects pinning when choosing the fallback thread after delete", () => {
|
||||
const fallbackThreadId = getFallbackThreadIdAfterDelete({
|
||||
threads: [
|
||||
{
|
||||
...makeThread({
|
||||
id: ThreadId.makeUnsafe("thread-active"),
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
updatedAt: "2026-03-09T10:05:00.000Z",
|
||||
}),
|
||||
pinned: false,
|
||||
},
|
||||
{
|
||||
...makeThread({
|
||||
id: ThreadId.makeUnsafe("thread-pinned"),
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
updatedAt: "2026-03-09T10:03:00.000Z",
|
||||
}),
|
||||
pinned: true,
|
||||
},
|
||||
{
|
||||
...makeThread({
|
||||
id: ThreadId.makeUnsafe("thread-newer"),
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
updatedAt: "2026-03-09T10:10:00.000Z",
|
||||
}),
|
||||
pinned: false,
|
||||
},
|
||||
],
|
||||
deletedThreadId: ThreadId.makeUnsafe("thread-active"),
|
||||
sortOrder: "updated_at",
|
||||
});
|
||||
|
||||
expect(fallbackThreadId).toBe(ThreadId.makeUnsafe("thread-pinned"));
|
||||
});
|
||||
|
||||
it("skips other threads being deleted in the same action", () => {
|
||||
const fallbackThreadId = getFallbackThreadIdAfterDelete({
|
||||
threads: [
|
||||
@@ -900,6 +1004,65 @@ describe("sortProjectsForSidebar", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("puts pinned projects ahead of unpinned projects in auto-sort modes", () => {
|
||||
const sorted = sortProjectsForSidebar(
|
||||
[
|
||||
makeProject({
|
||||
id: ProjectId.makeUnsafe("project-1"),
|
||||
name: "Pinned older project",
|
||||
pinned: true,
|
||||
updatedAt: "2026-03-09T10:01:00.000Z",
|
||||
}),
|
||||
makeProject({
|
||||
id: ProjectId.makeUnsafe("project-2"),
|
||||
name: "Unpinned newer project",
|
||||
pinned: false,
|
||||
updatedAt: "2026-03-09T10:05:00.000Z",
|
||||
}),
|
||||
],
|
||||
[],
|
||||
"updated_at",
|
||||
);
|
||||
|
||||
expect(sorted.map((project) => project.id)).toEqual([
|
||||
ProjectId.makeUnsafe("project-1"),
|
||||
ProjectId.makeUnsafe("project-2"),
|
||||
]);
|
||||
});
|
||||
|
||||
it("still auto-sorts within the pinned bucket", () => {
|
||||
const sorted = sortProjectsForSidebar(
|
||||
[
|
||||
makeProject({
|
||||
id: ProjectId.makeUnsafe("project-1"),
|
||||
name: "Pinned older project",
|
||||
pinned: true,
|
||||
updatedAt: "2026-03-09T10:01:00.000Z",
|
||||
}),
|
||||
makeProject({
|
||||
id: ProjectId.makeUnsafe("project-2"),
|
||||
name: "Pinned newer project",
|
||||
pinned: true,
|
||||
updatedAt: "2026-03-09T10:05:00.000Z",
|
||||
}),
|
||||
makeProject({
|
||||
id: ProjectId.makeUnsafe("project-3"),
|
||||
name: "Unpinned project",
|
||||
pinned: false,
|
||||
updatedAt: "2026-03-09T10:10:00.000Z",
|
||||
}),
|
||||
],
|
||||
[],
|
||||
"updated_at",
|
||||
);
|
||||
|
||||
expect(sorted.map((project) => project.id)).toEqual([
|
||||
ProjectId.makeUnsafe("project-2"),
|
||||
ProjectId.makeUnsafe("project-1"),
|
||||
ProjectId.makeUnsafe("project-3"),
|
||||
]);
|
||||
});
|
||||
|
||||
it("falls back to name and id ordering when projects have no sortable timestamps", () => {
|
||||
const sorted = sortProjectsForSidebar(
|
||||
[
|
||||
|
||||
@@ -16,10 +16,12 @@ type SidebarProject = {
|
||||
name: string;
|
||||
createdAt?: string | undefined;
|
||||
updatedAt?: string | undefined;
|
||||
pinned?: boolean | undefined;
|
||||
};
|
||||
type SidebarThreadSortInput = Pick<Thread, "createdAt" | "updatedAt"> & {
|
||||
latestUserMessageAt?: string | null;
|
||||
messages?: Pick<Thread["messages"][number], "createdAt" | "role">[];
|
||||
pinned?: boolean | undefined;
|
||||
};
|
||||
|
||||
export type ThreadTraversalDirection = "previous" | "next";
|
||||
@@ -452,6 +454,11 @@ 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;
|
||||
if (leftPinned !== rightPinned) {
|
||||
return rightPinned ? 1 : -1;
|
||||
}
|
||||
const rightTimestamp = getThreadSortTimestamp(right, sortOrder);
|
||||
const leftTimestamp = getThreadSortTimestamp(left, sortOrder);
|
||||
const byTimestamp =
|
||||
@@ -526,6 +533,11 @@ export function sortProjectsForSidebar<
|
||||
}
|
||||
|
||||
return [...projects].toSorted((left, right) => {
|
||||
const leftPinned = left.pinned === true;
|
||||
const rightPinned = right.pinned === true;
|
||||
if (leftPinned !== rightPinned) {
|
||||
return rightPinned ? 1 : -1;
|
||||
}
|
||||
const rightTimestamp = getProjectSortTimestamp(
|
||||
right,
|
||||
threadsByProjectId.get(right.id) ?? [],
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
ChevronRightIcon,
|
||||
FolderIcon,
|
||||
GitPullRequestIcon,
|
||||
PinIcon,
|
||||
PlusIcon,
|
||||
SettingsIcon,
|
||||
SquarePenIcon,
|
||||
@@ -152,6 +153,7 @@ type SidebarThreadSnapshot = Pick<
|
||||
| "id"
|
||||
| "interactionMode"
|
||||
| "latestTurn"
|
||||
| "pinned"
|
||||
| "projectId"
|
||||
| "proposedPlans"
|
||||
| "session"
|
||||
@@ -163,9 +165,7 @@ type SidebarThreadSnapshot = Pick<
|
||||
latestUserMessageAt: string | null;
|
||||
};
|
||||
|
||||
type SidebarProjectSnapshot = Project & {
|
||||
expanded: boolean;
|
||||
};
|
||||
type SidebarProjectSnapshot = Project & { expanded: boolean };
|
||||
|
||||
const sidebarThreadSnapshotCache = new WeakMap<
|
||||
Thread,
|
||||
@@ -206,6 +206,7 @@ function toSidebarThreadSnapshot(
|
||||
updatedAt: thread.updatedAt,
|
||||
archivedAt: thread.archivedAt,
|
||||
latestTurn: thread.latestTurn,
|
||||
pinned: thread.pinned,
|
||||
lastVisitedAt,
|
||||
branch: thread.branch,
|
||||
worktreePath: thread.worktreePath,
|
||||
@@ -675,6 +676,7 @@ export default function Sidebar() {
|
||||
projectId,
|
||||
title,
|
||||
workspaceRoot: cwd,
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: DEFAULT_MODEL_BY_PROVIDER.codex,
|
||||
@@ -832,6 +834,42 @@ export default function Sidebar() {
|
||||
});
|
||||
},
|
||||
});
|
||||
const setThreadPinned = useCallback(async (thread: SidebarThreadSnapshot, pinned: boolean) => {
|
||||
const api = readNativeApi();
|
||||
if (!api) return;
|
||||
try {
|
||||
await api.orchestration.dispatchCommand({
|
||||
type: "thread.meta.update",
|
||||
commandId: newCommandId(),
|
||||
threadId: thread.id,
|
||||
pinned,
|
||||
});
|
||||
} catch (error) {
|
||||
toastManager.add({
|
||||
type: "error",
|
||||
title: `${pinned ? "Pin" : "Unpin"} thread failed`,
|
||||
description: error instanceof Error ? error.message : "An error occurred.",
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
const setProjectPinned = useCallback(async (project: Project, pinned: boolean) => {
|
||||
const api = readNativeApi();
|
||||
if (!api) return;
|
||||
try {
|
||||
await api.orchestration.dispatchCommand({
|
||||
type: "project.meta.update",
|
||||
commandId: newCommandId(),
|
||||
projectId: project.id,
|
||||
pinned,
|
||||
});
|
||||
} catch (error) {
|
||||
toastManager.add({
|
||||
type: "error",
|
||||
title: `${pinned ? "Pin" : "Unpin"} project failed`,
|
||||
description: error instanceof Error ? error.message : "An error occurred.",
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
const handleThreadContextMenu = useCallback(
|
||||
async (threadId: ThreadId, position: { x: number; y: number }) => {
|
||||
const api = readNativeApi();
|
||||
@@ -842,6 +880,7 @@ 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: "rename", label: "Rename thread" },
|
||||
{ id: "mark-unread", label: "Mark unread" },
|
||||
{ id: "copy-path", label: "Copy Path" },
|
||||
@@ -851,6 +890,11 @@ export default function Sidebar() {
|
||||
position,
|
||||
);
|
||||
|
||||
if (clicked === "toggle-pin") {
|
||||
await setThreadPinned(thread, !thread.pinned);
|
||||
return;
|
||||
}
|
||||
|
||||
if (clicked === "rename") {
|
||||
setRenamingThreadId(threadId);
|
||||
setRenamingTitle(thread.title);
|
||||
@@ -900,6 +944,7 @@ export default function Sidebar() {
|
||||
markThreadUnread,
|
||||
projectCwdById,
|
||||
threads,
|
||||
setThreadPinned,
|
||||
],
|
||||
);
|
||||
|
||||
@@ -1018,11 +1063,19 @@ export default function Sidebar() {
|
||||
|
||||
const clicked = await api.contextMenu.show(
|
||||
[
|
||||
{
|
||||
id: "toggle-pin",
|
||||
label: project.pinned ? "Unpin project" : "Pin project",
|
||||
},
|
||||
{ id: "copy-path", label: "Copy Project Path" },
|
||||
{ id: "delete", label: "Remove project", destructive: true },
|
||||
],
|
||||
position,
|
||||
);
|
||||
if (clicked === "toggle-pin") {
|
||||
await setProjectPinned(project, !project.pinned);
|
||||
return;
|
||||
}
|
||||
if (clicked === "copy-path") {
|
||||
copyPathToClipboard(project.cwd, { path: project.cwd });
|
||||
return;
|
||||
@@ -1069,6 +1122,7 @@ export default function Sidebar() {
|
||||
copyPathToClipboard,
|
||||
getDraftThreadByProjectId,
|
||||
projects,
|
||||
setProjectPinned,
|
||||
threads,
|
||||
],
|
||||
);
|
||||
@@ -1385,9 +1439,12 @@ export default function Sidebar() {
|
||||
const isConfirmingArchive = confirmingArchiveThreadId === thread.id && !isThreadRunning;
|
||||
const threadMetaClassName = isConfirmingArchive
|
||||
? "pointer-events-none opacity-0"
|
||||
: !isThreadRunning
|
||||
? "pointer-events-none transition-opacity duration-150 group-hover/menu-sub-item:opacity-0 group-focus-within/menu-sub-item:opacity-0"
|
||||
: "pointer-events-none";
|
||||
: "pointer-events-none transition-opacity duration-150 group-hover/menu-sub-item:opacity-0 group-focus-within/menu-sub-item:opacity-0";
|
||||
const hoverActionClassName =
|
||||
"inline-flex size-5 cursor-pointer items-center justify-center text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring";
|
||||
const hoverActionGroupClassName =
|
||||
"pointer-events-none absolute top-1/2 right-1 flex -translate-y-1/2 items-center gap-0.5 opacity-0 transition-opacity duration-150 group-hover/menu-sub-item:pointer-events-auto group-hover/menu-sub-item:opacity-100 group-focus-within/menu-sub-item:pointer-events-auto group-focus-within/menu-sub-item:opacity-100";
|
||||
const pinActionLabel = thread.pinned ? "Unpin" : "Pin";
|
||||
|
||||
return (
|
||||
<SidebarMenuSubItem
|
||||
@@ -1443,6 +1500,11 @@ export default function Sidebar() {
|
||||
}}
|
||||
>
|
||||
<div className="flex min-w-0 flex-1 items-center gap-1.5 text-left">
|
||||
{thread.pinned ? (
|
||||
<span className="inline-flex shrink-0" title="Pinned thread">
|
||||
<PinIcon className="size-3 text-muted-foreground/55" />
|
||||
</span>
|
||||
) : null}
|
||||
{prStatus && (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
@@ -1540,58 +1602,69 @@ export default function Sidebar() {
|
||||
>
|
||||
Confirm
|
||||
</button>
|
||||
) : !isThreadRunning ? (
|
||||
appSettings.confirmThreadArchive ? (
|
||||
<div className="pointer-events-none absolute top-1/2 right-1 -translate-y-1/2 opacity-0 transition-opacity duration-150 group-hover/menu-sub-item:pointer-events-auto group-hover/menu-sub-item:opacity-100 group-focus-within/menu-sub-item:pointer-events-auto group-focus-within/menu-sub-item:opacity-100">
|
||||
<button
|
||||
type="button"
|
||||
data-thread-selection-safe
|
||||
data-testid={`thread-archive-${thread.id}`}
|
||||
aria-label={`Archive ${thread.title}`}
|
||||
className="inline-flex size-5 cursor-pointer items-center justify-center text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring"
|
||||
onPointerDown={(event) => {
|
||||
event.stopPropagation();
|
||||
}}
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
setConfirmingArchiveThreadId(thread.id);
|
||||
requestAnimationFrame(() => {
|
||||
confirmArchiveButtonRefs.current.get(thread.id)?.focus();
|
||||
});
|
||||
}}
|
||||
>
|
||||
<ArchiveIcon className="size-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
) : null}
|
||||
{!isConfirmingArchive ? (
|
||||
<div className={hoverActionGroupClassName}>
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<div className="pointer-events-none absolute top-1/2 right-1 -translate-y-1/2 opacity-0 transition-opacity duration-150 group-hover/menu-sub-item:pointer-events-auto group-hover/menu-sub-item:opacity-100 group-focus-within/menu-sub-item:pointer-events-auto group-focus-within/menu-sub-item:opacity-100">
|
||||
<button
|
||||
type="button"
|
||||
data-thread-selection-safe
|
||||
data-testid={`thread-pin-${thread.id}`}
|
||||
aria-label={`${pinActionLabel} ${thread.title}`}
|
||||
className={hoverActionClassName}
|
||||
onPointerDown={(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}}
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
void setThreadPinned(thread, !thread.pinned);
|
||||
}}
|
||||
>
|
||||
<PinIcon className="size-3.5" />
|
||||
</button>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">{pinActionLabel}</TooltipPopup>
|
||||
</Tooltip>
|
||||
{!isThreadRunning ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<button
|
||||
type="button"
|
||||
data-thread-selection-safe
|
||||
data-testid={`thread-archive-${thread.id}`}
|
||||
aria-label={`Archive ${thread.title}`}
|
||||
className="inline-flex size-5 cursor-pointer items-center justify-center text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring"
|
||||
className={hoverActionClassName}
|
||||
onPointerDown={(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}}
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (appSettings.confirmThreadArchive) {
|
||||
setConfirmingArchiveThreadId(thread.id);
|
||||
requestAnimationFrame(() => {
|
||||
confirmArchiveButtonRefs.current.get(thread.id)?.focus();
|
||||
});
|
||||
return;
|
||||
}
|
||||
void attemptArchiveThread(thread.id);
|
||||
}}
|
||||
>
|
||||
<ArchiveIcon className="size-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">Archive</TooltipPopup>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">Archive</TooltipPopup>
|
||||
</Tooltip>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
<span className={threadMetaClassName}>
|
||||
{showThreadJumpHints && jumpLabel ? (
|
||||
@@ -1666,6 +1739,18 @@ export default function Sidebar() {
|
||||
/>
|
||||
)}
|
||||
<ProjectFavicon cwd={project.cwd} />
|
||||
{project.pinned ? (
|
||||
<span
|
||||
className="inline-flex shrink-0"
|
||||
title={
|
||||
isManualProjectSorting
|
||||
? "Pinned project (inactive in manual sorting)"
|
||||
: "Pinned project"
|
||||
}
|
||||
>
|
||||
<PinIcon className="size-3 text-muted-foreground/55" />
|
||||
</span>
|
||||
) : null}
|
||||
<span className="flex-1 truncate text-xs font-medium text-foreground/90">
|
||||
{project.name}
|
||||
</span>
|
||||
@@ -1683,6 +1768,10 @@ export default function Sidebar() {
|
||||
}
|
||||
showOnHover
|
||||
className="top-1 right-1.5 size-5 rounded-md p-0 text-muted-foreground/70 hover:bg-secondary hover:text-foreground"
|
||||
onPointerDown={(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}}
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
@@ -48,6 +48,7 @@ describe("deriveOrchestrationBatchEffects", () => {
|
||||
threadId: createdThreadId,
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Created thread",
|
||||
pinned: false,
|
||||
modelSelection: { provider: "codex", model: "gpt-5-codex" },
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
@@ -80,6 +81,7 @@ describe("deriveOrchestrationBatchEffects", () => {
|
||||
threadId,
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Recreated thread",
|
||||
pinned: false,
|
||||
modelSelection: { provider: "codex", model: "gpt-5-codex" },
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
|
||||
@@ -25,6 +25,7 @@ function makeThread(overrides: Partial<Thread> = {}): Thread {
|
||||
codexThreadId: null,
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -53,6 +54,7 @@ function makeState(thread: Thread): AppState {
|
||||
id: ProjectId.makeUnsafe("project-1"),
|
||||
name: "Project",
|
||||
cwd: "/tmp/project",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -97,6 +99,7 @@ function makeReadModelThread(overrides: Partial<OrchestrationReadModel["threads"
|
||||
id: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.3-codex",
|
||||
@@ -128,6 +131,7 @@ function makeReadModel(thread: OrchestrationReadModel["threads"][number]): Orche
|
||||
id: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/project",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.3-codex",
|
||||
@@ -149,6 +153,7 @@ function makeReadModelProject(
|
||||
id: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/project",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.3-codex",
|
||||
@@ -253,6 +258,7 @@ describe("store read model sync", () => {
|
||||
id: project2,
|
||||
name: "Project 2",
|
||||
cwd: "/tmp/project-2",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: DEFAULT_MODEL_BY_PROVIDER.codex,
|
||||
@@ -263,6 +269,7 @@ describe("store read model sync", () => {
|
||||
id: project1,
|
||||
name: "Project 1",
|
||||
cwd: "/tmp/project-1",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: DEFAULT_MODEL_BY_PROVIDER.codex,
|
||||
@@ -353,6 +360,7 @@ describe("incremental orchestration updates", () => {
|
||||
id: originalProjectId,
|
||||
name: "Project",
|
||||
cwd: "/tmp/project",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: DEFAULT_MODEL_BY_PROVIDER.codex,
|
||||
@@ -370,6 +378,7 @@ describe("incremental orchestration updates", () => {
|
||||
projectId: recreatedProjectId,
|
||||
title: "Project Recreated",
|
||||
workspaceRoot: "/tmp/project",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: DEFAULT_MODEL_BY_PROVIDER.codex,
|
||||
|
||||
@@ -147,6 +147,7 @@ function mapThread(thread: OrchestrationThread): Thread {
|
||||
codexThreadId: null,
|
||||
projectId: thread.projectId,
|
||||
title: thread.title,
|
||||
pinned: thread.pinned,
|
||||
modelSelection: normalizeModelSelection(thread.modelSelection),
|
||||
runtimeMode: thread.runtimeMode,
|
||||
interactionMode: thread.interactionMode,
|
||||
@@ -171,6 +172,7 @@ function mapProject(project: OrchestrationReadModel["projects"][number]): Projec
|
||||
id: project.id,
|
||||
name: project.title,
|
||||
cwd: project.workspaceRoot,
|
||||
pinned: project.pinned,
|
||||
defaultModelSelection: project.defaultModelSelection
|
||||
? normalizeModelSelection(project.defaultModelSelection)
|
||||
: null,
|
||||
@@ -424,6 +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,
|
||||
defaultModelSelection: event.payload.defaultModelSelection,
|
||||
scripts: event.payload.scripts,
|
||||
createdAt: event.payload.createdAt,
|
||||
@@ -444,6 +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.defaultModelSelection !== undefined
|
||||
? {
|
||||
defaultModelSelection: event.payload.defaultModelSelection
|
||||
@@ -470,6 +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,
|
||||
modelSelection: event.payload.modelSelection,
|
||||
runtimeMode: event.payload.runtimeMode,
|
||||
interactionMode: event.payload.interactionMode,
|
||||
@@ -519,6 +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.modelSelection !== undefined
|
||||
? { modelSelection: normalizeModelSelection(event.payload.modelSelection) }
|
||||
: {}),
|
||||
|
||||
@@ -82,6 +82,7 @@ export interface Project {
|
||||
id: ProjectId;
|
||||
name: string;
|
||||
cwd: string;
|
||||
pinned: boolean;
|
||||
defaultModelSelection: ModelSelection | null;
|
||||
createdAt?: string | undefined;
|
||||
updatedAt?: string | undefined;
|
||||
@@ -93,6 +94,7 @@ export interface Thread {
|
||||
codexThreadId: string | null;
|
||||
projectId: ProjectId;
|
||||
title: string;
|
||||
pinned: boolean;
|
||||
modelSelection: ModelSelection;
|
||||
runtimeMode: RuntimeMode;
|
||||
interactionMode: ProviderInteractionMode;
|
||||
|
||||
@@ -10,6 +10,7 @@ function makeThread(overrides: Partial<Thread> = {}): Thread {
|
||||
codexThreadId: null,
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.3-codex",
|
||||
|
||||
@@ -289,6 +289,7 @@ describe("wsNativeApi", () => {
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/workspace",
|
||||
pinned: false,
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: "2026-02-24T00:00:00.000Z",
|
||||
@@ -331,6 +332,7 @@ describe("wsNativeApi", () => {
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/project",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
|
||||
@@ -95,6 +95,7 @@ it.effect("trims branded ids and command string fields at decode boundaries", ()
|
||||
assert.strictEqual(parsed.projectId, "project-1");
|
||||
assert.strictEqual(parsed.title, "Project Title");
|
||||
assert.strictEqual(parsed.workspaceRoot, "/tmp/workspace");
|
||||
assert.strictEqual(parsed.pinned, false);
|
||||
assert.deepStrictEqual(parsed.defaultModelSelection, {
|
||||
provider: "codex",
|
||||
model: "gpt-5.2",
|
||||
@@ -117,6 +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);
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -214,6 +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);
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
@@ -145,6 +145,7 @@ export const OrchestrationProject = Schema.Struct({
|
||||
id: ProjectId,
|
||||
title: TrimmedNonEmptyString,
|
||||
workspaceRoot: TrimmedNonEmptyString,
|
||||
pinned: Schema.Boolean.pipe(Schema.withDecodingDefault(() => false)),
|
||||
defaultModelSelection: Schema.NullOr(ModelSelection),
|
||||
scripts: Schema.Array(ProjectScript),
|
||||
createdAt: IsoDateTime,
|
||||
@@ -274,6 +275,7 @@ export const OrchestrationThread = Schema.Struct({
|
||||
id: ThreadId,
|
||||
projectId: ProjectId,
|
||||
title: TrimmedNonEmptyString,
|
||||
pinned: Schema.Boolean.pipe(Schema.withDecodingDefault(() => false)),
|
||||
modelSelection: ModelSelection,
|
||||
runtimeMode: RuntimeMode,
|
||||
interactionMode: ProviderInteractionMode.pipe(
|
||||
@@ -308,6 +310,7 @@ export const ProjectCreateCommand = Schema.Struct({
|
||||
projectId: ProjectId,
|
||||
title: TrimmedNonEmptyString,
|
||||
workspaceRoot: TrimmedNonEmptyString,
|
||||
pinned: Schema.Boolean.pipe(Schema.withDecodingDefault(() => false)),
|
||||
defaultModelSelection: Schema.optional(Schema.NullOr(ModelSelection)),
|
||||
createdAt: IsoDateTime,
|
||||
});
|
||||
@@ -318,6 +321,7 @@ const ProjectMetaUpdateCommand = Schema.Struct({
|
||||
projectId: ProjectId,
|
||||
title: Schema.optional(TrimmedNonEmptyString),
|
||||
workspaceRoot: Schema.optional(TrimmedNonEmptyString),
|
||||
pinned: Schema.optional(Schema.Boolean),
|
||||
defaultModelSelection: Schema.optional(Schema.NullOr(ModelSelection)),
|
||||
scripts: Schema.optional(Schema.Array(ProjectScript)),
|
||||
});
|
||||
@@ -334,6 +338,7 @@ const ThreadCreateCommand = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
projectId: ProjectId,
|
||||
title: TrimmedNonEmptyString,
|
||||
pinned: Schema.Boolean.pipe(Schema.withDecodingDefault(() => false)),
|
||||
modelSelection: ModelSelection,
|
||||
runtimeMode: RuntimeMode,
|
||||
interactionMode: ProviderInteractionMode.pipe(
|
||||
@@ -367,6 +372,7 @@ const ThreadMetaUpdateCommand = Schema.Struct({
|
||||
commandId: CommandId,
|
||||
threadId: ThreadId,
|
||||
title: Schema.optional(TrimmedNonEmptyString),
|
||||
pinned: Schema.optional(Schema.Boolean),
|
||||
modelSelection: Schema.optional(ModelSelection),
|
||||
branch: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
||||
worktreePath: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
||||
@@ -624,6 +630,7 @@ export const ProjectCreatedPayload = Schema.Struct({
|
||||
projectId: ProjectId,
|
||||
title: TrimmedNonEmptyString,
|
||||
workspaceRoot: TrimmedNonEmptyString,
|
||||
pinned: Schema.Boolean.pipe(Schema.withDecodingDefault(() => false)),
|
||||
defaultModelSelection: Schema.NullOr(ModelSelection),
|
||||
scripts: Schema.Array(ProjectScript),
|
||||
createdAt: IsoDateTime,
|
||||
@@ -634,6 +641,7 @@ export const ProjectMetaUpdatedPayload = Schema.Struct({
|
||||
projectId: ProjectId,
|
||||
title: Schema.optional(TrimmedNonEmptyString),
|
||||
workspaceRoot: Schema.optional(TrimmedNonEmptyString),
|
||||
pinned: Schema.optional(Schema.Boolean),
|
||||
defaultModelSelection: Schema.optional(Schema.NullOr(ModelSelection)),
|
||||
scripts: Schema.optional(Schema.Array(ProjectScript)),
|
||||
updatedAt: IsoDateTime,
|
||||
@@ -648,6 +656,7 @@ export const ThreadCreatedPayload = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
projectId: ProjectId,
|
||||
title: TrimmedNonEmptyString,
|
||||
pinned: Schema.Boolean.pipe(Schema.withDecodingDefault(() => false)),
|
||||
modelSelection: ModelSelection,
|
||||
runtimeMode: RuntimeMode.pipe(Schema.withDecodingDefault(() => DEFAULT_RUNTIME_MODE)),
|
||||
interactionMode: ProviderInteractionMode.pipe(
|
||||
@@ -678,6 +687,7 @@ export const ThreadUnarchivedPayload = Schema.Struct({
|
||||
export const ThreadMetaUpdatedPayload = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
title: Schema.optional(TrimmedNonEmptyString),
|
||||
pinned: Schema.optional(Schema.Boolean),
|
||||
modelSelection: Schema.optional(ModelSelection),
|
||||
branch: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
||||
worktreePath: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
||||
|
||||
Reference in new issue
Block a user