Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6923a71376 | ||
|
|
44499ae62f | ||
|
|
76f7bd1e57 | ||
|
|
0273d5d63b | ||
|
|
f7bcc489f9 | ||
|
|
ad25d0b247 | ||
|
|
c8cf535780 | ||
|
|
9b5063bcd4 | ||
|
|
0ed495a122 |
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -83,6 +83,8 @@ describe("CheckpointDiffQuery.layer", () => {
|
|||||||
Effect.die("CheckpointDiffQuery should not request the orchestration shell snapshot"),
|
Effect.die("CheckpointDiffQuery should not request the orchestration shell snapshot"),
|
||||||
getArchivedShellSnapshot: () =>
|
getArchivedShellSnapshot: () =>
|
||||||
Effect.die("CheckpointDiffQuery should not request archived shell snapshots"),
|
Effect.die("CheckpointDiffQuery should not request archived shell snapshots"),
|
||||||
|
getClosedTaskTabs: () =>
|
||||||
|
Effect.die("CheckpointDiffQuery should not request closed task tabs"),
|
||||||
getSnapshotSequence: () => Effect.succeed({ snapshotSequence: 0 }),
|
getSnapshotSequence: () => Effect.succeed({ snapshotSequence: 0 }),
|
||||||
getCounts: () => Effect.succeed({ projectCount: 0, threadCount: 0 }),
|
getCounts: () => Effect.succeed({ projectCount: 0, threadCount: 0 }),
|
||||||
getActiveProjectByWorkspaceRoot: () => Effect.succeed(Option.none()),
|
getActiveProjectByWorkspaceRoot: () => Effect.succeed(Option.none()),
|
||||||
@@ -191,6 +193,8 @@ describe("CheckpointDiffQuery.layer", () => {
|
|||||||
Effect.die("CheckpointDiffQuery should not request the orchestration shell snapshot"),
|
Effect.die("CheckpointDiffQuery should not request the orchestration shell snapshot"),
|
||||||
getArchivedShellSnapshot: () =>
|
getArchivedShellSnapshot: () =>
|
||||||
Effect.die("CheckpointDiffQuery should not request archived shell snapshots"),
|
Effect.die("CheckpointDiffQuery should not request archived shell snapshots"),
|
||||||
|
getClosedTaskTabs: () =>
|
||||||
|
Effect.die("CheckpointDiffQuery should not request closed task tabs"),
|
||||||
getSnapshotSequence: () => Effect.succeed({ snapshotSequence: 0 }),
|
getSnapshotSequence: () => Effect.succeed({ snapshotSequence: 0 }),
|
||||||
getCounts: () => Effect.succeed({ projectCount: 0, threadCount: 0 }),
|
getCounts: () => Effect.succeed({ projectCount: 0, threadCount: 0 }),
|
||||||
getActiveProjectByWorkspaceRoot: () => Effect.succeed(Option.none()),
|
getActiveProjectByWorkspaceRoot: () => Effect.succeed(Option.none()),
|
||||||
@@ -274,6 +278,8 @@ describe("CheckpointDiffQuery.layer", () => {
|
|||||||
Effect.die("CheckpointDiffQuery should not request the orchestration shell snapshot"),
|
Effect.die("CheckpointDiffQuery should not request the orchestration shell snapshot"),
|
||||||
getArchivedShellSnapshot: () =>
|
getArchivedShellSnapshot: () =>
|
||||||
Effect.die("CheckpointDiffQuery should not request archived shell snapshots"),
|
Effect.die("CheckpointDiffQuery should not request archived shell snapshots"),
|
||||||
|
getClosedTaskTabs: () =>
|
||||||
|
Effect.die("CheckpointDiffQuery should not request closed task tabs"),
|
||||||
getSnapshotSequence: () => Effect.succeed({ snapshotSequence: 0 }),
|
getSnapshotSequence: () => Effect.succeed({ snapshotSequence: 0 }),
|
||||||
getCounts: () => Effect.succeed({ projectCount: 0, threadCount: 0 }),
|
getCounts: () => Effect.succeed({ projectCount: 0, threadCount: 0 }),
|
||||||
getActiveProjectByWorkspaceRoot: () => Effect.succeed(Option.none()),
|
getActiveProjectByWorkspaceRoot: () => Effect.succeed(Option.none()),
|
||||||
@@ -342,6 +348,8 @@ describe("CheckpointDiffQuery.layer", () => {
|
|||||||
Effect.die("CheckpointDiffQuery should not request the orchestration shell snapshot"),
|
Effect.die("CheckpointDiffQuery should not request the orchestration shell snapshot"),
|
||||||
getArchivedShellSnapshot: () =>
|
getArchivedShellSnapshot: () =>
|
||||||
Effect.die("CheckpointDiffQuery should not request archived shell snapshots"),
|
Effect.die("CheckpointDiffQuery should not request archived shell snapshots"),
|
||||||
|
getClosedTaskTabs: () =>
|
||||||
|
Effect.die("CheckpointDiffQuery should not request closed task tabs"),
|
||||||
getSnapshotSequence: () => Effect.succeed({ snapshotSequence: 0 }),
|
getSnapshotSequence: () => Effect.succeed({ snapshotSequence: 0 }),
|
||||||
getCounts: () => Effect.succeed({ projectCount: 0, threadCount: 0 }),
|
getCounts: () => Effect.succeed({ projectCount: 0, threadCount: 0 }),
|
||||||
getActiveProjectByWorkspaceRoot: () => Effect.succeed(Option.none()),
|
getActiveProjectByWorkspaceRoot: () => Effect.succeed(Option.none()),
|
||||||
@@ -395,6 +403,8 @@ describe("CheckpointDiffQuery.layer", () => {
|
|||||||
Effect.die("CheckpointDiffQuery should not request the orchestration shell snapshot"),
|
Effect.die("CheckpointDiffQuery should not request the orchestration shell snapshot"),
|
||||||
getArchivedShellSnapshot: () =>
|
getArchivedShellSnapshot: () =>
|
||||||
Effect.die("CheckpointDiffQuery should not request archived shell snapshots"),
|
Effect.die("CheckpointDiffQuery should not request archived shell snapshots"),
|
||||||
|
getClosedTaskTabs: () =>
|
||||||
|
Effect.die("CheckpointDiffQuery should not request closed task tabs"),
|
||||||
getSnapshotSequence: () => Effect.succeed({ snapshotSequence: 0 }),
|
getSnapshotSequence: () => Effect.succeed({ snapshotSequence: 0 }),
|
||||||
getCounts: () => Effect.succeed({ projectCount: 0, threadCount: 0 }),
|
getCounts: () => Effect.succeed({ projectCount: 0, threadCount: 0 }),
|
||||||
getActiveProjectByWorkspaceRoot: () => Effect.succeed(Option.none()),
|
getActiveProjectByWorkspaceRoot: () => Effect.succeed(Option.none()),
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ it.layer(NodeServices.layer)("ServerEnvironmentLive", (it) => {
|
|||||||
expect(first.environmentId).toBe(second.environmentId);
|
expect(first.environmentId).toBe(second.environmentId);
|
||||||
expect(second.capabilities.repositoryIdentity).toBe(true);
|
expect(second.capabilities.repositoryIdentity).toBe(true);
|
||||||
expect(second.capabilities.connectionProbe).toBe(true);
|
expect(second.capabilities.connectionProbe).toBe(true);
|
||||||
|
expect(second.capabilities.workspaceTaskTabs).toBe(true);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ export const make = Effect.gen(function* () {
|
|||||||
connectionProbe: true,
|
connectionProbe: true,
|
||||||
threadSettlement: true,
|
threadSettlement: true,
|
||||||
threadSnooze: true,
|
threadSnooze: true,
|
||||||
|
workspaceTaskTabs: true,
|
||||||
...(serverSelfUpdate === null ? {} : { serverSelfUpdate }),
|
...(serverSelfUpdate === null ? {} : { serverSelfUpdate }),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -198,6 +198,8 @@ it.layer(NodeServices.layer)("keybindings", (it) => {
|
|||||||
assert.equal(defaultsByCommand.get("thread.jump.1"), "mod+1");
|
assert.equal(defaultsByCommand.get("thread.jump.1"), "mod+1");
|
||||||
assert.equal(defaultsByCommand.get("thread.jump.9"), "mod+9");
|
assert.equal(defaultsByCommand.get("thread.jump.9"), "mod+9");
|
||||||
assert.equal(defaultsByCommand.get("modelPicker.toggle"), "mod+shift+m");
|
assert.equal(defaultsByCommand.get("modelPicker.toggle"), "mod+shift+m");
|
||||||
|
assert.equal(defaultsByCommand.get("chat.newTab"), "mod+t");
|
||||||
|
assert.equal(defaultsByCommand.get("chat.reopenClosedTab"), "mod+shift+t");
|
||||||
assert.equal(defaultsByCommand.get("sidebar.toggle"), "mod+b");
|
assert.equal(defaultsByCommand.get("sidebar.toggle"), "mod+b");
|
||||||
assert.equal(defaultsByCommand.get("rightPanel.toggle"), "mod+alt+b");
|
assert.equal(defaultsByCommand.get("rightPanel.toggle"), "mod+alt+b");
|
||||||
assert.equal(defaultsByCommand.get("terminal.splitVertical"), "mod+shift+d");
|
assert.equal(defaultsByCommand.get("terminal.splitVertical"), "mod+shift+d");
|
||||||
|
|||||||
@@ -192,6 +192,7 @@ describe("OrchestrationEngine", () => {
|
|||||||
threads: [],
|
threads: [],
|
||||||
updatedAt: projectionSnapshot.updatedAt,
|
updatedAt: projectionSnapshot.updatedAt,
|
||||||
}),
|
}),
|
||||||
|
getClosedTaskTabs: () => Effect.succeed([]),
|
||||||
getSnapshotSequence: () =>
|
getSnapshotSequence: () =>
|
||||||
Effect.succeed({ snapshotSequence: projectionSnapshot.snapshotSequence }),
|
Effect.succeed({ snapshotSequence: projectionSnapshot.snapshotSequence }),
|
||||||
getCounts: () => Effect.succeed({ projectCount: 1, threadCount: 1 }),
|
getCounts: () => Effect.succeed({ projectCount: 1, threadCount: 1 }),
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
type OrchestrationEvent,
|
type OrchestrationEvent,
|
||||||
type OrchestrationSessionStatus,
|
type OrchestrationSessionStatus,
|
||||||
ThreadId,
|
ThreadId,
|
||||||
|
WorkspaceTaskId,
|
||||||
} from "@t3tools/contracts";
|
} from "@t3tools/contracts";
|
||||||
import * as Effect from "effect/Effect";
|
import * as Effect from "effect/Effect";
|
||||||
import * as FileSystem from "effect/FileSystem";
|
import * as FileSystem from "effect/FileSystem";
|
||||||
@@ -597,6 +598,12 @@ const makeOrchestrationProjectionPipeline = Effect.fn("makeOrchestrationProjecti
|
|||||||
yield* projectionThreadRepository.upsert({
|
yield* projectionThreadRepository.upsert({
|
||||||
threadId: event.payload.threadId,
|
threadId: event.payload.threadId,
|
||||||
projectId: event.payload.projectId,
|
projectId: event.payload.projectId,
|
||||||
|
workspaceTaskId:
|
||||||
|
event.payload.workspaceTaskId ?? WorkspaceTaskId.make(String(event.payload.threadId)),
|
||||||
|
tabLabel: event.payload.tabLabel ?? null,
|
||||||
|
tabPosition: event.payload.tabPosition ?? 0,
|
||||||
|
tabClosedAt: event.payload.tabClosedAt ?? null,
|
||||||
|
forkProvenance: event.payload.forkProvenance ?? null,
|
||||||
title: event.payload.title,
|
title: event.payload.title,
|
||||||
modelSelection: event.payload.modelSelection,
|
modelSelection: event.payload.modelSelection,
|
||||||
runtimeMode: event.payload.runtimeMode,
|
runtimeMode: event.payload.runtimeMode,
|
||||||
@@ -730,6 +737,13 @@ const makeOrchestrationProjectionPipeline = Effect.fn("makeOrchestrationProjecti
|
|||||||
...(event.payload.worktreePath !== undefined
|
...(event.payload.worktreePath !== undefined
|
||||||
? { worktreePath: event.payload.worktreePath }
|
? { worktreePath: event.payload.worktreePath }
|
||||||
: {}),
|
: {}),
|
||||||
|
...(event.payload.tabLabel !== undefined ? { tabLabel: event.payload.tabLabel } : {}),
|
||||||
|
...(event.payload.tabPosition !== undefined
|
||||||
|
? { tabPosition: event.payload.tabPosition }
|
||||||
|
: {}),
|
||||||
|
...(event.payload.tabClosedAt !== undefined
|
||||||
|
? { tabClosedAt: event.payload.tabClosedAt }
|
||||||
|
: {}),
|
||||||
updatedAt: event.payload.updatedAt,
|
updatedAt: event.payload.updatedAt,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
ThreadId,
|
ThreadId,
|
||||||
TurnId,
|
TurnId,
|
||||||
ProviderInstanceId,
|
ProviderInstanceId,
|
||||||
|
WorkspaceTaskId,
|
||||||
} from "@t3tools/contracts";
|
} from "@t3tools/contracts";
|
||||||
import { assert, it } from "@effect/vitest";
|
import { assert, it } from "@effect/vitest";
|
||||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||||
@@ -284,6 +285,11 @@ projectionSnapshotLayer("ProjectionSnapshotQuery", (it) => {
|
|||||||
{
|
{
|
||||||
id: ThreadId.make("thread-1"),
|
id: ThreadId.make("thread-1"),
|
||||||
projectId: asProjectId("project-1"),
|
projectId: asProjectId("project-1"),
|
||||||
|
workspaceTaskId: WorkspaceTaskId.make("thread-1"),
|
||||||
|
tabLabel: null,
|
||||||
|
tabPosition: 0,
|
||||||
|
tabClosedAt: null,
|
||||||
|
forkProvenance: null,
|
||||||
title: "Thread 1",
|
title: "Thread 1",
|
||||||
modelSelection: {
|
modelSelection: {
|
||||||
instanceId: ProviderInstanceId.make("codex"),
|
instanceId: ProviderInstanceId.make("codex"),
|
||||||
@@ -398,6 +404,11 @@ projectionSnapshotLayer("ProjectionSnapshotQuery", (it) => {
|
|||||||
{
|
{
|
||||||
id: ThreadId.make("thread-1"),
|
id: ThreadId.make("thread-1"),
|
||||||
projectId: asProjectId("project-1"),
|
projectId: asProjectId("project-1"),
|
||||||
|
workspaceTaskId: WorkspaceTaskId.make("thread-1"),
|
||||||
|
tabLabel: null,
|
||||||
|
tabPosition: 0,
|
||||||
|
tabClosedAt: null,
|
||||||
|
forkProvenance: null,
|
||||||
title: "Thread 1",
|
title: "Thread 1",
|
||||||
modelSelection: {
|
modelSelection: {
|
||||||
instanceId: ProviderInstanceId.make("codex"),
|
instanceId: ProviderInstanceId.make("codex"),
|
||||||
@@ -447,6 +458,29 @@ projectionSnapshotLayer("ProjectionSnapshotQuery", (it) => {
|
|||||||
if (threadDetail._tag === "Some") {
|
if (threadDetail._tag === "Some") {
|
||||||
assert.deepEqual(threadDetail.value, snapshot.threads[0]);
|
assert.deepEqual(threadDetail.value, snapshot.threads[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
yield* sql`
|
||||||
|
UPDATE projection_threads
|
||||||
|
SET tab_closed_at = '2026-02-24T00:00:09.000Z'
|
||||||
|
WHERE thread_id = 'thread-1'
|
||||||
|
`;
|
||||||
|
const closedShellSnapshot = yield* snapshotQuery.getShellSnapshot();
|
||||||
|
assert.deepEqual(closedShellSnapshot.threads, []);
|
||||||
|
const closedThreadShell = yield* snapshotQuery.getThreadShellById(ThreadId.make("thread-1"));
|
||||||
|
assert.equal(closedThreadShell._tag, "None");
|
||||||
|
const closedTaskTabs = yield* snapshotQuery.getClosedTaskTabs();
|
||||||
|
assert.equal(closedTaskTabs.length, 1);
|
||||||
|
assert.equal(closedTaskTabs[0]?.id, ThreadId.make("thread-1"));
|
||||||
|
assert.equal(closedTaskTabs[0]?.tabClosedAt, "2026-02-24T00:00:09.000Z");
|
||||||
|
assert.isNull(closedTaskTabs[0]?.session);
|
||||||
|
assert.isNull(closedTaskTabs[0]?.latestTurn);
|
||||||
|
const closedThreadDetail = yield* snapshotQuery.getThreadDetailById(
|
||||||
|
ThreadId.make("thread-1"),
|
||||||
|
);
|
||||||
|
assert.equal(closedThreadDetail._tag, "Some");
|
||||||
|
if (closedThreadDetail._tag === "Some") {
|
||||||
|
assert.equal(closedThreadDetail.value.tabClosedAt, "2026-02-24T00:00:09.000Z");
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import {
|
|||||||
ModelSelection,
|
ModelSelection,
|
||||||
ProjectId,
|
ProjectId,
|
||||||
ThreadId,
|
ThreadId,
|
||||||
|
ThreadForkProvenance,
|
||||||
} from "@t3tools/contracts";
|
} from "@t3tools/contracts";
|
||||||
import * as Arr from "effect/Array";
|
import * as Arr from "effect/Array";
|
||||||
import * as Effect from "effect/Effect";
|
import * as Effect from "effect/Effect";
|
||||||
@@ -78,6 +79,7 @@ const ProjectionThreadProposedPlanDbRowSchema = ProjectionThreadProposedPlan;
|
|||||||
const ProjectionThreadDbRowSchema = ProjectionThread.mapFields(
|
const ProjectionThreadDbRowSchema = ProjectionThread.mapFields(
|
||||||
Struct.assign({
|
Struct.assign({
|
||||||
modelSelection: Schema.fromJsonString(ModelSelection),
|
modelSelection: Schema.fromJsonString(ModelSelection),
|
||||||
|
forkProvenance: Schema.NullOr(Schema.fromJsonString(ThreadForkProvenance)),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
const ProjectionThreadActivityDbRowSchema = ProjectionThreadActivity.mapFields(
|
const ProjectionThreadActivityDbRowSchema = ProjectionThreadActivity.mapFields(
|
||||||
@@ -117,6 +119,10 @@ const ProjectIdLookupInput = Schema.Struct({
|
|||||||
const ThreadIdLookupInput = Schema.Struct({
|
const ThreadIdLookupInput = Schema.Struct({
|
||||||
threadId: ThreadId,
|
threadId: ThreadId,
|
||||||
});
|
});
|
||||||
|
const ThreadRowByIdLookupInput = Schema.Struct({
|
||||||
|
threadId: ThreadId,
|
||||||
|
includeClosed: Schema.Boolean,
|
||||||
|
});
|
||||||
const ProjectionProjectLookupRowSchema = ProjectionProjectDbRowSchema;
|
const ProjectionProjectLookupRowSchema = ProjectionProjectDbRowSchema;
|
||||||
const ProjectionThreadIdLookupRowSchema = Schema.Struct({
|
const ProjectionThreadIdLookupRowSchema = Schema.Struct({
|
||||||
threadId: ThreadId,
|
threadId: ThreadId,
|
||||||
@@ -240,6 +246,39 @@ function mapProjectShellRow(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function mapThreadShellRow(
|
||||||
|
row: Schema.Schema.Type<typeof ProjectionThreadDbRowSchema>,
|
||||||
|
): OrchestrationThreadShell {
|
||||||
|
return {
|
||||||
|
id: row.threadId,
|
||||||
|
projectId: row.projectId,
|
||||||
|
workspaceTaskId: row.workspaceTaskId,
|
||||||
|
tabLabel: row.tabLabel,
|
||||||
|
tabPosition: row.tabPosition,
|
||||||
|
tabClosedAt: row.tabClosedAt,
|
||||||
|
forkProvenance: row.forkProvenance,
|
||||||
|
title: row.title,
|
||||||
|
modelSelection: row.modelSelection,
|
||||||
|
runtimeMode: row.runtimeMode,
|
||||||
|
interactionMode: row.interactionMode,
|
||||||
|
branch: row.branch,
|
||||||
|
worktreePath: row.worktreePath,
|
||||||
|
latestTurn: null,
|
||||||
|
createdAt: row.createdAt,
|
||||||
|
updatedAt: row.updatedAt,
|
||||||
|
archivedAt: row.archivedAt,
|
||||||
|
settledOverride: row.settledOverride,
|
||||||
|
settledAt: row.settledAt,
|
||||||
|
snoozedUntil: row.snoozedUntil,
|
||||||
|
snoozedAt: row.snoozedAt,
|
||||||
|
session: null,
|
||||||
|
latestUserMessageAt: row.latestUserMessageAt,
|
||||||
|
hasPendingApprovals: row.pendingApprovalCount > 0,
|
||||||
|
hasPendingUserInput: row.pendingUserInputCount > 0,
|
||||||
|
hasActionableProposedPlan: row.hasActionableProposedPlan > 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function mapProposedPlanRow(
|
function mapProposedPlanRow(
|
||||||
row: Schema.Schema.Type<typeof ProjectionThreadProposedPlanDbRowSchema>,
|
row: Schema.Schema.Type<typeof ProjectionThreadProposedPlanDbRowSchema>,
|
||||||
): OrchestrationProposedPlan {
|
): OrchestrationProposedPlan {
|
||||||
@@ -324,6 +363,11 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|||||||
SELECT
|
SELECT
|
||||||
thread_id AS "threadId",
|
thread_id AS "threadId",
|
||||||
project_id AS "projectId",
|
project_id AS "projectId",
|
||||||
|
COALESCE(workspace_task_id, thread_id) AS "workspaceTaskId",
|
||||||
|
tab_label AS "tabLabel",
|
||||||
|
tab_position AS "tabPosition",
|
||||||
|
tab_closed_at AS "tabClosedAt",
|
||||||
|
fork_provenance_json AS "forkProvenance",
|
||||||
title,
|
title,
|
||||||
model_selection_json AS "modelSelection",
|
model_selection_json AS "modelSelection",
|
||||||
runtime_mode AS "runtimeMode",
|
runtime_mode AS "runtimeMode",
|
||||||
@@ -356,6 +400,11 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|||||||
SELECT
|
SELECT
|
||||||
thread_id AS "threadId",
|
thread_id AS "threadId",
|
||||||
project_id AS "projectId",
|
project_id AS "projectId",
|
||||||
|
COALESCE(workspace_task_id, thread_id) AS "workspaceTaskId",
|
||||||
|
tab_label AS "tabLabel",
|
||||||
|
tab_position AS "tabPosition",
|
||||||
|
tab_closed_at AS "tabClosedAt",
|
||||||
|
fork_provenance_json AS "forkProvenance",
|
||||||
title,
|
title,
|
||||||
model_selection_json AS "modelSelection",
|
model_selection_json AS "modelSelection",
|
||||||
runtime_mode AS "runtimeMode",
|
runtime_mode AS "runtimeMode",
|
||||||
@@ -378,10 +427,51 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|||||||
FROM projection_threads
|
FROM projection_threads
|
||||||
WHERE deleted_at IS NULL
|
WHERE deleted_at IS NULL
|
||||||
AND archived_at IS NULL
|
AND archived_at IS NULL
|
||||||
|
AND tab_closed_at IS NULL
|
||||||
ORDER BY project_id ASC, created_at ASC, thread_id ASC
|
ORDER BY project_id ASC, created_at ASC, thread_id ASC
|
||||||
`,
|
`,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const listClosedTaskTabRows = SqlSchema.findAll({
|
||||||
|
Request: Schema.Void,
|
||||||
|
Result: ProjectionThreadDbRowSchema,
|
||||||
|
execute: () =>
|
||||||
|
sql`
|
||||||
|
SELECT
|
||||||
|
thread_id AS "threadId",
|
||||||
|
project_id AS "projectId",
|
||||||
|
COALESCE(workspace_task_id, thread_id) AS "workspaceTaskId",
|
||||||
|
tab_label AS "tabLabel",
|
||||||
|
tab_position AS "tabPosition",
|
||||||
|
tab_closed_at AS "tabClosedAt",
|
||||||
|
fork_provenance_json AS "forkProvenance",
|
||||||
|
title,
|
||||||
|
model_selection_json AS "modelSelection",
|
||||||
|
runtime_mode AS "runtimeMode",
|
||||||
|
interaction_mode AS "interactionMode",
|
||||||
|
branch,
|
||||||
|
worktree_path AS "worktreePath",
|
||||||
|
latest_turn_id AS "latestTurnId",
|
||||||
|
created_at AS "createdAt",
|
||||||
|
updated_at AS "updatedAt",
|
||||||
|
archived_at AS "archivedAt",
|
||||||
|
settled_override AS "settledOverride",
|
||||||
|
settled_at AS "settledAt",
|
||||||
|
snoozed_until AS "snoozedUntil",
|
||||||
|
snoozed_at AS "snoozedAt",
|
||||||
|
latest_user_message_at AS "latestUserMessageAt",
|
||||||
|
pending_approval_count AS "pendingApprovalCount",
|
||||||
|
pending_user_input_count AS "pendingUserInputCount",
|
||||||
|
has_actionable_proposed_plan AS "hasActionableProposedPlan",
|
||||||
|
deleted_at AS "deletedAt"
|
||||||
|
FROM projection_threads
|
||||||
|
WHERE deleted_at IS NULL
|
||||||
|
AND archived_at IS NULL
|
||||||
|
AND tab_closed_at IS NOT NULL
|
||||||
|
ORDER BY tab_closed_at DESC, thread_id ASC
|
||||||
|
`,
|
||||||
|
});
|
||||||
|
|
||||||
const listArchivedThreadRows = SqlSchema.findAll({
|
const listArchivedThreadRows = SqlSchema.findAll({
|
||||||
Request: Schema.Void,
|
Request: Schema.Void,
|
||||||
Result: ProjectionThreadDbRowSchema,
|
Result: ProjectionThreadDbRowSchema,
|
||||||
@@ -390,6 +480,11 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|||||||
SELECT
|
SELECT
|
||||||
thread_id AS "threadId",
|
thread_id AS "threadId",
|
||||||
project_id AS "projectId",
|
project_id AS "projectId",
|
||||||
|
COALESCE(workspace_task_id, thread_id) AS "workspaceTaskId",
|
||||||
|
tab_label AS "tabLabel",
|
||||||
|
tab_position AS "tabPosition",
|
||||||
|
tab_closed_at AS "tabClosedAt",
|
||||||
|
fork_provenance_json AS "forkProvenance",
|
||||||
title,
|
title,
|
||||||
model_selection_json AS "modelSelection",
|
model_selection_json AS "modelSelection",
|
||||||
runtime_mode AS "runtimeMode",
|
runtime_mode AS "runtimeMode",
|
||||||
@@ -748,14 +843,19 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|||||||
`,
|
`,
|
||||||
});
|
});
|
||||||
|
|
||||||
const getActiveThreadRowById = SqlSchema.findOneOption({
|
const getThreadRowById = SqlSchema.findOneOption({
|
||||||
Request: ThreadIdLookupInput,
|
Request: ThreadRowByIdLookupInput,
|
||||||
Result: ProjectionThreadDbRowSchema,
|
Result: ProjectionThreadDbRowSchema,
|
||||||
execute: ({ threadId }) =>
|
execute: ({ threadId, includeClosed }) =>
|
||||||
sql`
|
sql`
|
||||||
SELECT
|
SELECT
|
||||||
thread_id AS "threadId",
|
thread_id AS "threadId",
|
||||||
project_id AS "projectId",
|
project_id AS "projectId",
|
||||||
|
COALESCE(workspace_task_id, thread_id) AS "workspaceTaskId",
|
||||||
|
tab_label AS "tabLabel",
|
||||||
|
tab_position AS "tabPosition",
|
||||||
|
tab_closed_at AS "tabClosedAt",
|
||||||
|
fork_provenance_json AS "forkProvenance",
|
||||||
title,
|
title,
|
||||||
model_selection_json AS "modelSelection",
|
model_selection_json AS "modelSelection",
|
||||||
runtime_mode AS "runtimeMode",
|
runtime_mode AS "runtimeMode",
|
||||||
@@ -779,6 +879,7 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|||||||
WHERE thread_id = ${threadId}
|
WHERE thread_id = ${threadId}
|
||||||
AND deleted_at IS NULL
|
AND deleted_at IS NULL
|
||||||
AND archived_at IS NULL
|
AND archived_at IS NULL
|
||||||
|
AND (${includeClosed ? 1 : 0} = 1 OR tab_closed_at IS NULL)
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
`,
|
`,
|
||||||
});
|
});
|
||||||
@@ -1192,6 +1293,11 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|||||||
const threads: ReadonlyArray<OrchestrationThread> = threadRows.map((row) => ({
|
const threads: ReadonlyArray<OrchestrationThread> = threadRows.map((row) => ({
|
||||||
id: row.threadId,
|
id: row.threadId,
|
||||||
projectId: row.projectId,
|
projectId: row.projectId,
|
||||||
|
workspaceTaskId: row.workspaceTaskId,
|
||||||
|
tabLabel: row.tabLabel,
|
||||||
|
tabPosition: row.tabPosition,
|
||||||
|
tabClosedAt: row.tabClosedAt,
|
||||||
|
forkProvenance: row.forkProvenance,
|
||||||
title: row.title,
|
title: row.title,
|
||||||
modelSelection: row.modelSelection,
|
modelSelection: row.modelSelection,
|
||||||
runtimeMode: row.runtimeMode,
|
runtimeMode: row.runtimeMode,
|
||||||
@@ -1394,6 +1500,11 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|||||||
threads.push({
|
threads.push({
|
||||||
id: row.threadId,
|
id: row.threadId,
|
||||||
projectId: row.projectId,
|
projectId: row.projectId,
|
||||||
|
workspaceTaskId: row.workspaceTaskId,
|
||||||
|
tabLabel: row.tabLabel,
|
||||||
|
tabPosition: row.tabPosition,
|
||||||
|
tabClosedAt: row.tabClosedAt,
|
||||||
|
forkProvenance: row.forkProvenance,
|
||||||
title: row.title,
|
title: row.title,
|
||||||
modelSelection: row.modelSelection,
|
modelSelection: row.modelSelection,
|
||||||
runtimeMode: row.runtimeMode,
|
runtimeMode: row.runtimeMode,
|
||||||
@@ -1527,6 +1638,11 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|||||||
? Result.succeed({
|
? Result.succeed({
|
||||||
id: row.threadId,
|
id: row.threadId,
|
||||||
projectId: row.projectId,
|
projectId: row.projectId,
|
||||||
|
workspaceTaskId: row.workspaceTaskId,
|
||||||
|
tabLabel: row.tabLabel,
|
||||||
|
tabPosition: row.tabPosition,
|
||||||
|
tabClosedAt: row.tabClosedAt,
|
||||||
|
forkProvenance: row.forkProvenance,
|
||||||
title: row.title,
|
title: row.title,
|
||||||
modelSelection: row.modelSelection,
|
modelSelection: row.modelSelection,
|
||||||
runtimeMode: row.runtimeMode,
|
runtimeMode: row.runtimeMode,
|
||||||
@@ -1665,6 +1781,11 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|||||||
(row): OrchestrationThreadShell => ({
|
(row): OrchestrationThreadShell => ({
|
||||||
id: row.threadId,
|
id: row.threadId,
|
||||||
projectId: row.projectId,
|
projectId: row.projectId,
|
||||||
|
workspaceTaskId: row.workspaceTaskId,
|
||||||
|
tabLabel: row.tabLabel,
|
||||||
|
tabPosition: row.tabPosition,
|
||||||
|
tabClosedAt: row.tabClosedAt,
|
||||||
|
forkProvenance: row.forkProvenance,
|
||||||
title: row.title,
|
title: row.title,
|
||||||
modelSelection: row.modelSelection,
|
modelSelection: row.modelSelection,
|
||||||
runtimeMode: row.runtimeMode,
|
runtimeMode: row.runtimeMode,
|
||||||
@@ -1708,6 +1829,17 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const getClosedTaskTabs: ProjectionSnapshotQueryShape["getClosedTaskTabs"] = () =>
|
||||||
|
listClosedTaskTabRows(undefined).pipe(
|
||||||
|
Effect.map((rows) => rows.map(mapThreadShellRow)),
|
||||||
|
Effect.mapError(
|
||||||
|
toPersistenceSqlOrDecodeError(
|
||||||
|
"ProjectionSnapshotQuery.getClosedTaskTabs:query",
|
||||||
|
"ProjectionSnapshotQuery.getClosedTaskTabs:decodeRows",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
const getSnapshotSequence: ProjectionSnapshotQueryShape["getSnapshotSequence"] = () =>
|
const getSnapshotSequence: ProjectionSnapshotQueryShape["getSnapshotSequence"] = () =>
|
||||||
listProjectionStateRows(undefined).pipe(
|
listProjectionStateRows(undefined).pipe(
|
||||||
Effect.mapError(
|
Effect.mapError(
|
||||||
@@ -1876,7 +2008,7 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|||||||
const getThreadShellById: ProjectionSnapshotQueryShape["getThreadShellById"] = (threadId) =>
|
const getThreadShellById: ProjectionSnapshotQueryShape["getThreadShellById"] = (threadId) =>
|
||||||
Effect.gen(function* () {
|
Effect.gen(function* () {
|
||||||
const [threadRow, latestTurnRow, sessionRow] = yield* Effect.all([
|
const [threadRow, latestTurnRow, sessionRow] = yield* Effect.all([
|
||||||
getActiveThreadRowById({ threadId }).pipe(
|
getThreadRowById({ threadId, includeClosed: false }).pipe(
|
||||||
Effect.mapError(
|
Effect.mapError(
|
||||||
toPersistenceSqlOrDecodeError(
|
toPersistenceSqlOrDecodeError(
|
||||||
"ProjectionSnapshotQuery.getThreadShellById:getThread:query",
|
"ProjectionSnapshotQuery.getThreadShellById:getThread:query",
|
||||||
@@ -1909,6 +2041,11 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|||||||
return Option.some({
|
return Option.some({
|
||||||
id: threadRow.value.threadId,
|
id: threadRow.value.threadId,
|
||||||
projectId: threadRow.value.projectId,
|
projectId: threadRow.value.projectId,
|
||||||
|
workspaceTaskId: threadRow.value.workspaceTaskId,
|
||||||
|
tabLabel: threadRow.value.tabLabel,
|
||||||
|
tabPosition: threadRow.value.tabPosition,
|
||||||
|
tabClosedAt: threadRow.value.tabClosedAt,
|
||||||
|
forkProvenance: threadRow.value.forkProvenance,
|
||||||
title: threadRow.value.title,
|
title: threadRow.value.title,
|
||||||
modelSelection: threadRow.value.modelSelection,
|
modelSelection: threadRow.value.modelSelection,
|
||||||
runtimeMode: threadRow.value.runtimeMode,
|
runtimeMode: threadRow.value.runtimeMode,
|
||||||
@@ -1942,7 +2079,7 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|||||||
latestTurnRow,
|
latestTurnRow,
|
||||||
sessionRow,
|
sessionRow,
|
||||||
] = yield* Effect.all([
|
] = yield* Effect.all([
|
||||||
getActiveThreadRowById({ threadId }).pipe(
|
getThreadRowById({ threadId, includeClosed: true }).pipe(
|
||||||
Effect.mapError(
|
Effect.mapError(
|
||||||
toPersistenceSqlOrDecodeError(
|
toPersistenceSqlOrDecodeError(
|
||||||
"ProjectionSnapshotQuery.getThreadDetailById:getThread:query",
|
"ProjectionSnapshotQuery.getThreadDetailById:getThread:query",
|
||||||
@@ -2007,6 +2144,11 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|||||||
const thread = {
|
const thread = {
|
||||||
id: threadRow.value.threadId,
|
id: threadRow.value.threadId,
|
||||||
projectId: threadRow.value.projectId,
|
projectId: threadRow.value.projectId,
|
||||||
|
workspaceTaskId: threadRow.value.workspaceTaskId,
|
||||||
|
tabLabel: threadRow.value.tabLabel,
|
||||||
|
tabPosition: threadRow.value.tabPosition,
|
||||||
|
tabClosedAt: threadRow.value.tabClosedAt,
|
||||||
|
forkProvenance: threadRow.value.forkProvenance,
|
||||||
title: threadRow.value.title,
|
title: threadRow.value.title,
|
||||||
modelSelection: threadRow.value.modelSelection,
|
modelSelection: threadRow.value.modelSelection,
|
||||||
runtimeMode: threadRow.value.runtimeMode,
|
runtimeMode: threadRow.value.runtimeMode,
|
||||||
@@ -2108,6 +2250,7 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|||||||
getSnapshot,
|
getSnapshot,
|
||||||
getShellSnapshot,
|
getShellSnapshot,
|
||||||
getArchivedShellSnapshot,
|
getArchivedShellSnapshot,
|
||||||
|
getClosedTaskTabs,
|
||||||
getSnapshotSequence,
|
getSnapshotSequence,
|
||||||
getCounts,
|
getCounts,
|
||||||
getActiveProjectByWorkspaceRoot,
|
getActiveProjectByWorkspaceRoot,
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import {
|
|||||||
ProjectId,
|
ProjectId,
|
||||||
ThreadId,
|
ThreadId,
|
||||||
TurnId,
|
TurnId,
|
||||||
|
WorkspaceTaskId,
|
||||||
} from "@t3tools/contracts";
|
} from "@t3tools/contracts";
|
||||||
import * as Effect from "effect/Effect";
|
import * as Effect from "effect/Effect";
|
||||||
import * as Deferred from "effect/Deferred";
|
import * as Deferred from "effect/Deferred";
|
||||||
@@ -477,6 +478,80 @@ describe("ProviderCommandReactor", () => {
|
|||||||
expect(thread?.session?.runtimeMode).toBe("approval-required");
|
expect(thread?.session?.runtimeMode).toBe("approval-required");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
effectIt.effect(
|
||||||
|
"injects a source transcript only into the first provider turn of a portable task fork",
|
||||||
|
() =>
|
||||||
|
Effect.gen(function* () {
|
||||||
|
const harness = yield* Effect.promise(() => createHarness());
|
||||||
|
const now = "2026-01-01T00:00:00.000Z";
|
||||||
|
|
||||||
|
yield* harness.engine.dispatch({
|
||||||
|
type: "thread.turn.start",
|
||||||
|
commandId: CommandId.make("cmd-source-turn"),
|
||||||
|
threadId: ThreadId.make("thread-1"),
|
||||||
|
message: {
|
||||||
|
messageId: asMessageId("source-user-message"),
|
||||||
|
role: "user",
|
||||||
|
text: "Source tab context",
|
||||||
|
attachments: [],
|
||||||
|
},
|
||||||
|
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||||
|
runtimeMode: "approval-required",
|
||||||
|
createdAt: now,
|
||||||
|
});
|
||||||
|
yield* Effect.promise(() => waitFor(() => harness.sendTurn.mock.calls.length === 1));
|
||||||
|
|
||||||
|
yield* harness.engine.dispatch({
|
||||||
|
type: "thread.create",
|
||||||
|
commandId: CommandId.make("cmd-fork-thread-create"),
|
||||||
|
threadId: ThreadId.make("thread-fork"),
|
||||||
|
projectId: asProjectId("project-1"),
|
||||||
|
workspaceTaskId: WorkspaceTaskId.make("thread-1"),
|
||||||
|
tabPosition: 1,
|
||||||
|
forkProvenance: {
|
||||||
|
mode: "portable",
|
||||||
|
sourceThreadId: ThreadId.make("thread-1"),
|
||||||
|
createdAt: now,
|
||||||
|
},
|
||||||
|
title: "Fork",
|
||||||
|
modelSelection: {
|
||||||
|
instanceId: ProviderInstanceId.make("codex"),
|
||||||
|
model: "gpt-5-codex",
|
||||||
|
},
|
||||||
|
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||||
|
runtimeMode: "approval-required",
|
||||||
|
branch: null,
|
||||||
|
worktreePath: null,
|
||||||
|
createdAt: now,
|
||||||
|
});
|
||||||
|
yield* harness.engine.dispatch({
|
||||||
|
type: "thread.turn.start",
|
||||||
|
commandId: CommandId.make("cmd-fork-turn"),
|
||||||
|
threadId: ThreadId.make("thread-fork"),
|
||||||
|
message: {
|
||||||
|
messageId: asMessageId("fork-user-message"),
|
||||||
|
role: "user",
|
||||||
|
text: "Try another approach",
|
||||||
|
attachments: [],
|
||||||
|
},
|
||||||
|
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||||
|
runtimeMode: "approval-required",
|
||||||
|
createdAt: now,
|
||||||
|
});
|
||||||
|
|
||||||
|
yield* Effect.promise(() => waitFor(() => harness.sendTurn.mock.calls.length === 2));
|
||||||
|
expect(harness.sendTurn.mock.calls[1]?.[0]).toMatchObject({
|
||||||
|
threadId: ThreadId.make("thread-fork"),
|
||||||
|
});
|
||||||
|
const forkInput = harness.sendTurn.mock.calls[1]?.[0] as { input?: string };
|
||||||
|
expect(forkInput.input).toContain("Source tab context");
|
||||||
|
expect(forkInput.input?.endsWith("Try another approach")).toBe(true);
|
||||||
|
const readModel = yield* Effect.promise(() => harness.readModel());
|
||||||
|
const fork = readModel.threads.find((thread) => thread.id === ThreadId.make("thread-fork"));
|
||||||
|
expect(fork?.messages.map((message) => message.text)).toEqual(["Try another approach"]);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
effectIt.effect("projects starting before a slow provider session finishes", () =>
|
effectIt.effect("projects starting before a slow provider session finishes", () =>
|
||||||
Effect.gen(function* () {
|
Effect.gen(function* () {
|
||||||
const releaseStart = yield* Deferred.make<void>();
|
const releaseStart = yield* Deferred.make<void>();
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import {
|
|||||||
import { ServerSettingsService } from "../../serverSettings.ts";
|
import { ServerSettingsService } from "../../serverSettings.ts";
|
||||||
import { VcsStatusBroadcaster } from "../../vcs/VcsStatusBroadcaster.ts";
|
import { VcsStatusBroadcaster } from "../../vcs/VcsStatusBroadcaster.ts";
|
||||||
import { GitWorkflowService } from "../../git/GitWorkflowService.ts";
|
import { GitWorkflowService } from "../../git/GitWorkflowService.ts";
|
||||||
|
import { buildPortableForkProviderInput } from "../portableFork.ts";
|
||||||
const isProviderAdapterRequestError = Schema.is(ProviderAdapterRequestError);
|
const isProviderAdapterRequestError = Schema.is(ProviderAdapterRequestError);
|
||||||
const isProviderDriverKind = Schema.is(ProviderDriverKind);
|
const isProviderDriverKind = Schema.is(ProviderDriverKind);
|
||||||
|
|
||||||
@@ -629,7 +630,20 @@ const make = Effect.gen(function* () {
|
|||||||
if (input.modelSelection !== undefined) {
|
if (input.modelSelection !== undefined) {
|
||||||
threadModelSelections.set(input.threadId, input.modelSelection);
|
threadModelSelections.set(input.threadId, input.modelSelection);
|
||||||
}
|
}
|
||||||
const normalizedInput = toNonEmptyProviderInput(input.messageText);
|
const sourceThread =
|
||||||
|
thread.forkProvenance?.mode === "portable" &&
|
||||||
|
thread.forkProvenance.sourceThreadId !== null &&
|
||||||
|
thread.messages.filter((entry) => entry.role === "user").length === 1
|
||||||
|
? yield* resolveThread(thread.forkProvenance.sourceThreadId)
|
||||||
|
: undefined;
|
||||||
|
const providerInput =
|
||||||
|
sourceThread !== undefined
|
||||||
|
? buildPortableForkProviderInput({
|
||||||
|
source: sourceThread,
|
||||||
|
userInput: input.messageText,
|
||||||
|
})
|
||||||
|
: input.messageText;
|
||||||
|
const normalizedInput = toNonEmptyProviderInput(providerInput);
|
||||||
const normalizedAttachments = input.attachments ?? [];
|
const normalizedAttachments = input.attachments ?? [];
|
||||||
const activeSession = yield* providerService
|
const activeSession = yield* providerService
|
||||||
.listSessions()
|
.listSessions()
|
||||||
|
|||||||
@@ -94,6 +94,15 @@ export interface ProjectionSnapshotQueryShape {
|
|||||||
ProjectionRepositoryError
|
ProjectionRepositoryError
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read closed, non-archived task-tab shells so clients can offer restore
|
||||||
|
* without bootstrapping them into normal navigation state.
|
||||||
|
*/
|
||||||
|
readonly getClosedTaskTabs: () => Effect.Effect<
|
||||||
|
ReadonlyArray<OrchestrationThreadShell>,
|
||||||
|
ProjectionRepositoryError
|
||||||
|
>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the latest projection snapshot sequence without hydrating read-model
|
* Read the latest projection snapshot sequence without hydrating read-model
|
||||||
* entities.
|
* entities.
|
||||||
|
|||||||
@@ -0,0 +1,216 @@
|
|||||||
|
import {
|
||||||
|
CommandId,
|
||||||
|
EventId,
|
||||||
|
ProjectId,
|
||||||
|
ProviderInstanceId,
|
||||||
|
ThreadId,
|
||||||
|
WorkspaceTaskId,
|
||||||
|
} from "@t3tools/contracts";
|
||||||
|
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||||
|
import { expect, it } from "@effect/vitest";
|
||||||
|
import * as Effect from "effect/Effect";
|
||||||
|
|
||||||
|
import { decideOrchestrationCommand } from "./decider.ts";
|
||||||
|
import { createEmptyReadModel, projectEvent } from "./projector.ts";
|
||||||
|
|
||||||
|
const now = "2026-07-24T00:00:00.000Z";
|
||||||
|
const projectId = ProjectId.make("project-1");
|
||||||
|
const taskId = WorkspaceTaskId.make("task-1");
|
||||||
|
const rootThreadId = ThreadId.make("thread-root");
|
||||||
|
const modelSelection = {
|
||||||
|
instanceId: ProviderInstanceId.make("codex"),
|
||||||
|
model: "gpt-5",
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
const seededReadModel = Effect.gen(function* () {
|
||||||
|
const withProject = yield* projectEvent(createEmptyReadModel(now), {
|
||||||
|
sequence: 1,
|
||||||
|
eventId: EventId.make("event-project"),
|
||||||
|
aggregateKind: "project",
|
||||||
|
aggregateId: projectId,
|
||||||
|
type: "project.created",
|
||||||
|
occurredAt: now,
|
||||||
|
commandId: CommandId.make("command-project"),
|
||||||
|
causationEventId: null,
|
||||||
|
correlationId: CommandId.make("command-project"),
|
||||||
|
metadata: {},
|
||||||
|
payload: {
|
||||||
|
projectId,
|
||||||
|
title: "Project",
|
||||||
|
workspaceRoot: "/tmp/project",
|
||||||
|
defaultModelSelection: modelSelection,
|
||||||
|
scripts: [],
|
||||||
|
createdAt: now,
|
||||||
|
updatedAt: now,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return yield* projectEvent(withProject, {
|
||||||
|
sequence: 2,
|
||||||
|
eventId: EventId.make("event-root"),
|
||||||
|
aggregateKind: "thread",
|
||||||
|
aggregateId: rootThreadId,
|
||||||
|
type: "thread.created",
|
||||||
|
occurredAt: now,
|
||||||
|
commandId: CommandId.make("command-root"),
|
||||||
|
causationEventId: null,
|
||||||
|
correlationId: CommandId.make("command-root"),
|
||||||
|
metadata: {},
|
||||||
|
payload: {
|
||||||
|
threadId: rootThreadId,
|
||||||
|
projectId,
|
||||||
|
workspaceTaskId: taskId,
|
||||||
|
tabLabel: null,
|
||||||
|
tabPosition: 0,
|
||||||
|
tabClosedAt: null,
|
||||||
|
forkProvenance: null,
|
||||||
|
title: "Task",
|
||||||
|
modelSelection,
|
||||||
|
runtimeMode: "full-access",
|
||||||
|
interactionMode: "default",
|
||||||
|
branch: "feature/task",
|
||||||
|
worktreePath: "/tmp/project-task",
|
||||||
|
createdAt: now,
|
||||||
|
updatedAt: now,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const seededReadModelWithSibling = Effect.gen(function* () {
|
||||||
|
const readModel = yield* seededReadModel;
|
||||||
|
const decided = yield* decideOrchestrationCommand({
|
||||||
|
readModel,
|
||||||
|
command: {
|
||||||
|
type: "thread.create",
|
||||||
|
commandId: CommandId.make("command-seed-child"),
|
||||||
|
threadId: ThreadId.make("thread-child"),
|
||||||
|
projectId,
|
||||||
|
workspaceTaskId: taskId,
|
||||||
|
tabPosition: 1,
|
||||||
|
title: "Alternative",
|
||||||
|
modelSelection,
|
||||||
|
runtimeMode: "full-access",
|
||||||
|
interactionMode: "default",
|
||||||
|
branch: "feature/task",
|
||||||
|
worktreePath: "/tmp/project-task",
|
||||||
|
createdAt: now,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const event = Array.isArray(decided) ? decided[0]! : decided;
|
||||||
|
return yield* projectEvent(readModel, event);
|
||||||
|
});
|
||||||
|
|
||||||
|
it.layer(NodeServices.layer)("task tab invariants", (it) => {
|
||||||
|
it.effect("accepts a sibling tab on the same project and worktree", () =>
|
||||||
|
Effect.gen(function* () {
|
||||||
|
const event = yield* decideOrchestrationCommand({
|
||||||
|
readModel: yield* seededReadModel,
|
||||||
|
command: {
|
||||||
|
type: "thread.create",
|
||||||
|
commandId: CommandId.make("command-child"),
|
||||||
|
threadId: ThreadId.make("thread-child"),
|
||||||
|
projectId,
|
||||||
|
workspaceTaskId: taskId,
|
||||||
|
tabPosition: 1,
|
||||||
|
forkProvenance: {
|
||||||
|
mode: "portable",
|
||||||
|
sourceThreadId: rootThreadId,
|
||||||
|
createdAt: now,
|
||||||
|
},
|
||||||
|
title: "Alternative",
|
||||||
|
modelSelection,
|
||||||
|
runtimeMode: "full-access",
|
||||||
|
interactionMode: "default",
|
||||||
|
branch: "feature/task",
|
||||||
|
worktreePath: "/tmp/project-task",
|
||||||
|
createdAt: now,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const firstEvent = Array.isArray(event) ? event[0] : event;
|
||||||
|
expect(firstEvent.type).toBe("thread.created");
|
||||||
|
expect(firstEvent.payload).toMatchObject({
|
||||||
|
workspaceTaskId: taskId,
|
||||||
|
tabPosition: 1,
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
it.effect("rejects a sibling tab that points at another worktree", () =>
|
||||||
|
Effect.gen(function* () {
|
||||||
|
const failure = yield* Effect.flip(
|
||||||
|
decideOrchestrationCommand({
|
||||||
|
readModel: yield* seededReadModel,
|
||||||
|
command: {
|
||||||
|
type: "thread.create",
|
||||||
|
commandId: CommandId.make("command-wrong-tree"),
|
||||||
|
threadId: ThreadId.make("thread-wrong-tree"),
|
||||||
|
projectId,
|
||||||
|
workspaceTaskId: taskId,
|
||||||
|
title: "Wrong tree",
|
||||||
|
modelSelection,
|
||||||
|
runtimeMode: "full-access",
|
||||||
|
interactionMode: "default",
|
||||||
|
branch: "other",
|
||||||
|
worktreePath: "/tmp/other-tree",
|
||||||
|
createdAt: now,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
expect(failure.message).toContain("must keep project and worktree identity");
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
it.effect("rejects moving one tab to another worktree after task creation", () =>
|
||||||
|
Effect.gen(function* () {
|
||||||
|
const failure = yield* Effect.flip(
|
||||||
|
decideOrchestrationCommand({
|
||||||
|
readModel: yield* seededReadModelWithSibling,
|
||||||
|
command: {
|
||||||
|
type: "thread.meta.update",
|
||||||
|
commandId: CommandId.make("command-move-root"),
|
||||||
|
threadId: rootThreadId,
|
||||||
|
worktreePath: "/tmp/other-tree",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
expect(failure.message).toContain("must keep project and worktree identity");
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
it.effect("rejects a deleted source for a portable fork", () =>
|
||||||
|
Effect.gen(function* () {
|
||||||
|
const readModel = yield* seededReadModel;
|
||||||
|
const withDeletedSource = {
|
||||||
|
...readModel,
|
||||||
|
threads: readModel.threads.map((thread) =>
|
||||||
|
thread.id === rootThreadId ? { ...thread, deletedAt: now } : thread,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
const failure = yield* Effect.flip(
|
||||||
|
decideOrchestrationCommand({
|
||||||
|
readModel: withDeletedSource,
|
||||||
|
command: {
|
||||||
|
type: "thread.create",
|
||||||
|
commandId: CommandId.make("command-deleted-source"),
|
||||||
|
threadId: ThreadId.make("thread-from-deleted-source"),
|
||||||
|
projectId,
|
||||||
|
workspaceTaskId: taskId,
|
||||||
|
tabPosition: 1,
|
||||||
|
forkProvenance: {
|
||||||
|
mode: "portable",
|
||||||
|
sourceThreadId: rootThreadId,
|
||||||
|
createdAt: now,
|
||||||
|
},
|
||||||
|
title: "Deleted source",
|
||||||
|
modelSelection,
|
||||||
|
runtimeMode: "full-access",
|
||||||
|
interactionMode: "default",
|
||||||
|
branch: "feature/task",
|
||||||
|
worktreePath: "/tmp/project-task",
|
||||||
|
createdAt: now,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
expect(failure.message).toContain("portable fork source must be an existing tab");
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
type OrchestrationCommand,
|
type OrchestrationCommand,
|
||||||
type OrchestrationEvent,
|
type OrchestrationEvent,
|
||||||
type OrchestrationReadModel,
|
type OrchestrationReadModel,
|
||||||
|
WorkspaceTaskId,
|
||||||
} from "@t3tools/contracts";
|
} from "@t3tools/contracts";
|
||||||
import * as DateTime from "effect/DateTime";
|
import * as DateTime from "effect/DateTime";
|
||||||
import * as Crypto from "effect/Crypto";
|
import * as Crypto from "effect/Crypto";
|
||||||
@@ -24,6 +25,10 @@ import { projectEvent } from "./projector.ts";
|
|||||||
|
|
||||||
const nowIso = Effect.map(DateTime.now, DateTime.formatIso);
|
const nowIso = Effect.map(DateTime.now, DateTime.formatIso);
|
||||||
|
|
||||||
|
function workspaceTaskIdForThread(thread: OrchestrationReadModel["threads"][number]) {
|
||||||
|
return thread.workspaceTaskId ?? WorkspaceTaskId.make(String(thread.id));
|
||||||
|
}
|
||||||
|
|
||||||
// Session adoption takes seconds; a user message still unadopted after this
|
// Session adoption takes seconds; a user message still unadopted after this
|
||||||
// window is a failed/stale start, not pending work. Mirrors the client's
|
// window is a failed/stale start, not pending work. Mirrors the client's
|
||||||
// QUEUED_TURN_START_GRACE_MS in client-runtime threadSettled.ts.
|
// QUEUED_TURN_START_GRACE_MS in client-runtime threadSettled.ts.
|
||||||
@@ -355,6 +360,47 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
|||||||
command,
|
command,
|
||||||
threadId: command.threadId,
|
threadId: command.threadId,
|
||||||
});
|
});
|
||||||
|
const workspaceTaskId =
|
||||||
|
command.workspaceTaskId ?? WorkspaceTaskId.make(String(command.threadId));
|
||||||
|
const sibling = readModel.threads.find(
|
||||||
|
(thread) =>
|
||||||
|
thread.deletedAt === null && workspaceTaskIdForThread(thread) === workspaceTaskId,
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
sibling &&
|
||||||
|
(sibling.projectId !== command.projectId || sibling.worktreePath !== command.worktreePath)
|
||||||
|
) {
|
||||||
|
return yield* new OrchestrationCommandInvariantError({
|
||||||
|
commandType: command.type,
|
||||||
|
detail: `workspace task ${workspaceTaskId} must keep project and worktree identity from sibling thread ${sibling.id}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
command.forkProvenance?.mode === "fresh" &&
|
||||||
|
command.forkProvenance.sourceThreadId !== null
|
||||||
|
) {
|
||||||
|
return yield* new OrchestrationCommandInvariantError({
|
||||||
|
commandType: command.type,
|
||||||
|
detail: "a fresh task tab cannot declare a source thread",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (command.forkProvenance?.mode === "portable") {
|
||||||
|
const source = readModel.threads.find(
|
||||||
|
(thread) => thread.id === command.forkProvenance?.sourceThreadId,
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
!source ||
|
||||||
|
source.deletedAt !== null ||
|
||||||
|
workspaceTaskIdForThread(source) !== workspaceTaskId ||
|
||||||
|
source.projectId !== command.projectId ||
|
||||||
|
source.worktreePath !== command.worktreePath
|
||||||
|
) {
|
||||||
|
return yield* new OrchestrationCommandInvariantError({
|
||||||
|
commandType: command.type,
|
||||||
|
detail: `portable fork source must be an existing tab in workspace task ${workspaceTaskId}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
...(yield* withEventBase({
|
...(yield* withEventBase({
|
||||||
aggregateKind: "thread",
|
aggregateKind: "thread",
|
||||||
@@ -366,6 +412,11 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
|||||||
payload: {
|
payload: {
|
||||||
threadId: command.threadId,
|
threadId: command.threadId,
|
||||||
projectId: command.projectId,
|
projectId: command.projectId,
|
||||||
|
workspaceTaskId,
|
||||||
|
tabLabel: command.tabLabel ?? null,
|
||||||
|
tabPosition: command.tabPosition ?? 0,
|
||||||
|
tabClosedAt: command.tabClosedAt ?? null,
|
||||||
|
forkProvenance: command.forkProvenance ?? null,
|
||||||
title: command.title,
|
title: command.title,
|
||||||
modelSelection: command.modelSelection,
|
modelSelection: command.modelSelection,
|
||||||
runtimeMode: command.runtimeMode,
|
runtimeMode: command.runtimeMode,
|
||||||
@@ -642,6 +693,24 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
|||||||
thread.branch !== command.expectedBranch
|
thread.branch !== command.expectedBranch
|
||||||
? thread.branch
|
? thread.branch
|
||||||
: command.branch;
|
: command.branch;
|
||||||
|
if (command.worktreePath !== undefined) {
|
||||||
|
const workspaceTaskId = workspaceTaskIdForThread(thread);
|
||||||
|
const sibling = readModel.threads.find(
|
||||||
|
(candidate) =>
|
||||||
|
candidate.id !== thread.id &&
|
||||||
|
candidate.deletedAt === null &&
|
||||||
|
workspaceTaskIdForThread(candidate) === workspaceTaskId,
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
sibling &&
|
||||||
|
(sibling.projectId !== thread.projectId || sibling.worktreePath !== command.worktreePath)
|
||||||
|
) {
|
||||||
|
return yield* new OrchestrationCommandInvariantError({
|
||||||
|
commandType: command.type,
|
||||||
|
detail: `workspace task ${workspaceTaskId} must keep project and worktree identity from sibling thread ${sibling.id}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
const occurredAt = yield* nowIso;
|
const occurredAt = yield* nowIso;
|
||||||
return {
|
return {
|
||||||
...(yield* withEventBase({
|
...(yield* withEventBase({
|
||||||
@@ -659,6 +728,9 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
|||||||
: {}),
|
: {}),
|
||||||
...(branch !== undefined ? { branch } : {}),
|
...(branch !== undefined ? { branch } : {}),
|
||||||
...(command.worktreePath !== undefined ? { worktreePath: command.worktreePath } : {}),
|
...(command.worktreePath !== undefined ? { worktreePath: command.worktreePath } : {}),
|
||||||
|
...(command.tabLabel !== undefined ? { tabLabel: command.tabLabel } : {}),
|
||||||
|
...(command.tabPosition !== undefined ? { tabPosition: command.tabPosition } : {}),
|
||||||
|
...(command.tabClosedAt !== undefined ? { tabClosedAt: command.tabClosedAt } : {}),
|
||||||
updatedAt: occurredAt,
|
updatedAt: occurredAt,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
import { describe, expect, it } from "@effect/vitest";
|
||||||
|
import {
|
||||||
|
MessageId,
|
||||||
|
ProviderInstanceId,
|
||||||
|
ProjectId,
|
||||||
|
ThreadId,
|
||||||
|
WorkspaceTaskId,
|
||||||
|
type OrchestrationThread,
|
||||||
|
} from "@t3tools/contracts";
|
||||||
|
|
||||||
|
import { buildPortableForkProviderInput } from "./portableFork.ts";
|
||||||
|
|
||||||
|
function makeSource(messages: OrchestrationThread["messages"]): OrchestrationThread {
|
||||||
|
return {
|
||||||
|
id: ThreadId.make("source-thread"),
|
||||||
|
projectId: ProjectId.make("project-1"),
|
||||||
|
workspaceTaskId: WorkspaceTaskId.make("task-1"),
|
||||||
|
tabLabel: "Main",
|
||||||
|
tabPosition: 0,
|
||||||
|
tabClosedAt: null,
|
||||||
|
forkProvenance: null,
|
||||||
|
title: "Investigate task tabs",
|
||||||
|
modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5" },
|
||||||
|
runtimeMode: "full-access",
|
||||||
|
interactionMode: "default",
|
||||||
|
branch: "feature/task-tabs",
|
||||||
|
worktreePath: "/tmp/task-tabs",
|
||||||
|
latestTurn: null,
|
||||||
|
createdAt: "2026-07-24T00:00:00.000Z",
|
||||||
|
updatedAt: "2026-07-24T00:00:00.000Z",
|
||||||
|
archivedAt: null,
|
||||||
|
settledOverride: null,
|
||||||
|
settledAt: null,
|
||||||
|
snoozedUntil: null,
|
||||||
|
snoozedAt: null,
|
||||||
|
deletedAt: null,
|
||||||
|
messages,
|
||||||
|
proposedPlans: [],
|
||||||
|
activities: [],
|
||||||
|
checkpoints: [],
|
||||||
|
session: null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
describe("buildPortableForkProviderInput", () => {
|
||||||
|
it("places the source transcript before the child tab request", () => {
|
||||||
|
const result = buildPortableForkProviderInput({
|
||||||
|
source: makeSource([
|
||||||
|
{
|
||||||
|
id: MessageId.make("message-1"),
|
||||||
|
role: "user",
|
||||||
|
text: "Inspect the architecture.",
|
||||||
|
attachments: [],
|
||||||
|
turnId: null,
|
||||||
|
streaming: false,
|
||||||
|
createdAt: "2026-07-24T00:00:00.000Z",
|
||||||
|
updatedAt: "2026-07-24T00:00:00.000Z",
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
userInput: "Try a different implementation.",
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result).toContain("same T3 Code task");
|
||||||
|
expect(result).toContain("Inspect the architecture.");
|
||||||
|
expect(result).toContain("Shared worktree: /tmp/task-tabs");
|
||||||
|
expect(result.endsWith("Try a different implementation.")).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("bounds large transcripts while retaining recent messages", () => {
|
||||||
|
const result = buildPortableForkProviderInput({
|
||||||
|
source: makeSource([
|
||||||
|
{
|
||||||
|
id: MessageId.make("message-old"),
|
||||||
|
role: "user",
|
||||||
|
text: `old-${"x".repeat(48_000)}`,
|
||||||
|
attachments: [],
|
||||||
|
turnId: null,
|
||||||
|
streaming: false,
|
||||||
|
createdAt: "2026-07-24T00:00:00.000Z",
|
||||||
|
updatedAt: "2026-07-24T00:00:00.000Z",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: MessageId.make("message-recent"),
|
||||||
|
role: "assistant",
|
||||||
|
text: "recent-context",
|
||||||
|
attachments: [],
|
||||||
|
turnId: null,
|
||||||
|
streaming: false,
|
||||||
|
createdAt: "2026-07-24T00:01:00.000Z",
|
||||||
|
updatedAt: "2026-07-24T00:01:00.000Z",
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
userInput: "Continue.",
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result).not.toContain("old-");
|
||||||
|
expect(result).toContain("recent-context");
|
||||||
|
expect(result.length).toBeLessThan(50_000);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import type { OrchestrationMessage, OrchestrationThread } from "@t3tools/contracts";
|
||||||
|
|
||||||
|
const MAX_HANDOFF_CHARACTERS = 48_000;
|
||||||
|
|
||||||
|
function renderMessage(message: OrchestrationMessage): string {
|
||||||
|
const attachmentNote =
|
||||||
|
message.attachments && message.attachments.length > 0
|
||||||
|
? `\n[${message.attachments.length} attachment${message.attachments.length === 1 ? "" : "s"} omitted from the handoff]`
|
||||||
|
: "";
|
||||||
|
return `<message role="${message.role}">\n${message.text}${attachmentNote}\n</message>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a provider-neutral first-turn handoff for a context-forked task tab.
|
||||||
|
* The source transcript remains owned by its original thread; the child only
|
||||||
|
* receives this bounded snapshot as provider input.
|
||||||
|
*/
|
||||||
|
export function buildPortableForkProviderInput(input: {
|
||||||
|
readonly source: OrchestrationThread;
|
||||||
|
readonly userInput: string;
|
||||||
|
}): string {
|
||||||
|
const header = [
|
||||||
|
"<t3-task-tab-context>",
|
||||||
|
"You are continuing in a sibling tab of the same T3 Code task.",
|
||||||
|
"The sibling tabs share one worktree. Treat the source transcript below as prior context,",
|
||||||
|
"but follow the new user request after the closing tag as the current instruction.",
|
||||||
|
`Source tab: ${input.source.title}`,
|
||||||
|
`Source thread id: ${input.source.id}`,
|
||||||
|
`Source branch: ${input.source.branch ?? "(current checkout)"}`,
|
||||||
|
`Shared worktree: ${input.source.worktreePath ?? "(project workspace)"}`,
|
||||||
|
"<source-transcript>",
|
||||||
|
].join("\n");
|
||||||
|
const footer = "\n</source-transcript>\n</t3-task-tab-context>";
|
||||||
|
const fixedSize = header.length + footer.length;
|
||||||
|
const budget = Math.max(0, MAX_HANDOFF_CHARACTERS - fixedSize);
|
||||||
|
const selected: string[] = [];
|
||||||
|
let used = 0;
|
||||||
|
|
||||||
|
// Preserve the most recent context when the source conversation is larger
|
||||||
|
// than the portable handoff budget.
|
||||||
|
for (let index = input.source.messages.length - 1; index >= 0; index -= 1) {
|
||||||
|
const message = input.source.messages[index];
|
||||||
|
if (!message) continue;
|
||||||
|
const rendered = renderMessage(message);
|
||||||
|
if (used + rendered.length > budget) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
selected.unshift(rendered);
|
||||||
|
used += rendered.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
const transcript =
|
||||||
|
selected.length > 0 ? selected.join("\n") : "[No source transcript was available.]";
|
||||||
|
return `${header}\n${transcript}${footer}\n\n${input.userInput}`;
|
||||||
|
}
|
||||||
@@ -280,6 +280,11 @@ export function projectEvent(
|
|||||||
{
|
{
|
||||||
id: payload.threadId,
|
id: payload.threadId,
|
||||||
projectId: payload.projectId,
|
projectId: payload.projectId,
|
||||||
|
workspaceTaskId: payload.workspaceTaskId,
|
||||||
|
tabLabel: payload.tabLabel,
|
||||||
|
tabPosition: payload.tabPosition,
|
||||||
|
tabClosedAt: payload.tabClosedAt,
|
||||||
|
forkProvenance: payload.forkProvenance,
|
||||||
title: payload.title,
|
title: payload.title,
|
||||||
modelSelection: payload.modelSelection,
|
modelSelection: payload.modelSelection,
|
||||||
runtimeMode: payload.runtimeMode,
|
runtimeMode: payload.runtimeMode,
|
||||||
@@ -404,6 +409,9 @@ export function projectEvent(
|
|||||||
: {}),
|
: {}),
|
||||||
...(payload.branch !== undefined ? { branch: payload.branch } : {}),
|
...(payload.branch !== undefined ? { branch: payload.branch } : {}),
|
||||||
...(payload.worktreePath !== undefined ? { worktreePath: payload.worktreePath } : {}),
|
...(payload.worktreePath !== undefined ? { worktreePath: payload.worktreePath } : {}),
|
||||||
|
...(payload.tabLabel !== undefined ? { tabLabel: payload.tabLabel } : {}),
|
||||||
|
...(payload.tabPosition !== undefined ? { tabPosition: payload.tabPosition } : {}),
|
||||||
|
...(payload.tabClosedAt !== undefined ? { tabClosedAt: payload.tabClosedAt } : {}),
|
||||||
updatedAt: payload.updatedAt,
|
updatedAt: payload.updatedAt,
|
||||||
}),
|
}),
|
||||||
})),
|
})),
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ProjectId, ThreadId, ProviderInstanceId } from "@t3tools/contracts";
|
import { ProjectId, ProviderInstanceId, ThreadId, WorkspaceTaskId } from "@t3tools/contracts";
|
||||||
import { assert, it } from "@effect/vitest";
|
import { assert, it } from "@effect/vitest";
|
||||||
import * as Effect from "effect/Effect";
|
import * as Effect from "effect/Effect";
|
||||||
import * as Layer from "effect/Layer";
|
import * as Layer from "effect/Layer";
|
||||||
@@ -78,6 +78,11 @@ projectionRepositoriesLayer("Projection repositories", (it) => {
|
|||||||
yield* threads.upsert({
|
yield* threads.upsert({
|
||||||
threadId: ThreadId.make("thread-null-options"),
|
threadId: ThreadId.make("thread-null-options"),
|
||||||
projectId: ProjectId.make("project-null-options"),
|
projectId: ProjectId.make("project-null-options"),
|
||||||
|
workspaceTaskId: WorkspaceTaskId.make("thread-null-options"),
|
||||||
|
tabLabel: null,
|
||||||
|
tabPosition: 0,
|
||||||
|
tabClosedAt: null,
|
||||||
|
forkProvenance: null,
|
||||||
title: "Null options thread",
|
title: "Null options thread",
|
||||||
modelSelection: {
|
modelSelection: {
|
||||||
instanceId: ProviderInstanceId.make("claudeAgent"),
|
instanceId: ProviderInstanceId.make("claudeAgent"),
|
||||||
@@ -140,6 +145,11 @@ projectionRepositoriesLayer("Projection repositories", (it) => {
|
|||||||
yield* threads.upsert({
|
yield* threads.upsert({
|
||||||
threadId: ThreadId.make("thread-settled"),
|
threadId: ThreadId.make("thread-settled"),
|
||||||
projectId: ProjectId.make("project-1"),
|
projectId: ProjectId.make("project-1"),
|
||||||
|
workspaceTaskId: WorkspaceTaskId.make("thread-settled"),
|
||||||
|
tabLabel: null,
|
||||||
|
tabPosition: 0,
|
||||||
|
tabClosedAt: null,
|
||||||
|
forkProvenance: null,
|
||||||
title: "Settled thread",
|
title: "Settled thread",
|
||||||
modelSelection: {
|
modelSelection: {
|
||||||
instanceId: ProviderInstanceId.make("codex"),
|
instanceId: ProviderInstanceId.make("codex"),
|
||||||
|
|||||||
@@ -14,11 +14,12 @@ import {
|
|||||||
ProjectionThreadRepository,
|
ProjectionThreadRepository,
|
||||||
type ProjectionThreadRepositoryShape,
|
type ProjectionThreadRepositoryShape,
|
||||||
} from "../Services/ProjectionThreads.ts";
|
} from "../Services/ProjectionThreads.ts";
|
||||||
import { ModelSelection } from "@t3tools/contracts";
|
import { ModelSelection, ThreadForkProvenance } from "@t3tools/contracts";
|
||||||
|
|
||||||
const ProjectionThreadDbRow = ProjectionThread.mapFields(
|
const ProjectionThreadDbRow = ProjectionThread.mapFields(
|
||||||
Struct.assign({
|
Struct.assign({
|
||||||
modelSelection: Schema.fromJsonString(ModelSelection),
|
modelSelection: Schema.fromJsonString(ModelSelection),
|
||||||
|
forkProvenance: Schema.NullOr(Schema.fromJsonString(ThreadForkProvenance)),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
type ProjectionThreadDbRow = typeof ProjectionThreadDbRow.Type;
|
type ProjectionThreadDbRow = typeof ProjectionThreadDbRow.Type;
|
||||||
@@ -33,6 +34,11 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
|||||||
INSERT INTO projection_threads (
|
INSERT INTO projection_threads (
|
||||||
thread_id,
|
thread_id,
|
||||||
project_id,
|
project_id,
|
||||||
|
workspace_task_id,
|
||||||
|
tab_label,
|
||||||
|
tab_position,
|
||||||
|
tab_closed_at,
|
||||||
|
fork_provenance_json,
|
||||||
title,
|
title,
|
||||||
model_selection_json,
|
model_selection_json,
|
||||||
runtime_mode,
|
runtime_mode,
|
||||||
@@ -56,6 +62,11 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
|||||||
VALUES (
|
VALUES (
|
||||||
${row.threadId},
|
${row.threadId},
|
||||||
${row.projectId},
|
${row.projectId},
|
||||||
|
${row.workspaceTaskId},
|
||||||
|
${row.tabLabel},
|
||||||
|
${row.tabPosition},
|
||||||
|
${row.tabClosedAt},
|
||||||
|
${row.forkProvenance === null ? null : JSON.stringify(row.forkProvenance)},
|
||||||
${row.title},
|
${row.title},
|
||||||
${JSON.stringify(row.modelSelection)},
|
${JSON.stringify(row.modelSelection)},
|
||||||
${row.runtimeMode},
|
${row.runtimeMode},
|
||||||
@@ -79,6 +90,11 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
|||||||
ON CONFLICT (thread_id)
|
ON CONFLICT (thread_id)
|
||||||
DO UPDATE SET
|
DO UPDATE SET
|
||||||
project_id = excluded.project_id,
|
project_id = excluded.project_id,
|
||||||
|
workspace_task_id = excluded.workspace_task_id,
|
||||||
|
tab_label = excluded.tab_label,
|
||||||
|
tab_position = excluded.tab_position,
|
||||||
|
tab_closed_at = excluded.tab_closed_at,
|
||||||
|
fork_provenance_json = excluded.fork_provenance_json,
|
||||||
title = excluded.title,
|
title = excluded.title,
|
||||||
model_selection_json = excluded.model_selection_json,
|
model_selection_json = excluded.model_selection_json,
|
||||||
runtime_mode = excluded.runtime_mode,
|
runtime_mode = excluded.runtime_mode,
|
||||||
@@ -109,6 +125,11 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
|||||||
SELECT
|
SELECT
|
||||||
thread_id AS "threadId",
|
thread_id AS "threadId",
|
||||||
project_id AS "projectId",
|
project_id AS "projectId",
|
||||||
|
COALESCE(workspace_task_id, thread_id) AS "workspaceTaskId",
|
||||||
|
tab_label AS "tabLabel",
|
||||||
|
tab_position AS "tabPosition",
|
||||||
|
tab_closed_at AS "tabClosedAt",
|
||||||
|
fork_provenance_json AS "forkProvenance",
|
||||||
title,
|
title,
|
||||||
model_selection_json AS "modelSelection",
|
model_selection_json AS "modelSelection",
|
||||||
runtime_mode AS "runtimeMode",
|
runtime_mode AS "runtimeMode",
|
||||||
@@ -141,6 +162,11 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
|||||||
SELECT
|
SELECT
|
||||||
thread_id AS "threadId",
|
thread_id AS "threadId",
|
||||||
project_id AS "projectId",
|
project_id AS "projectId",
|
||||||
|
COALESCE(workspace_task_id, thread_id) AS "workspaceTaskId",
|
||||||
|
tab_label AS "tabLabel",
|
||||||
|
tab_position AS "tabPosition",
|
||||||
|
tab_closed_at AS "tabClosedAt",
|
||||||
|
fork_provenance_json AS "forkProvenance",
|
||||||
title,
|
title,
|
||||||
model_selection_json AS "modelSelection",
|
model_selection_json AS "modelSelection",
|
||||||
runtime_mode AS "runtimeMode",
|
runtime_mode AS "runtimeMode",
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import Migration0031 from "./Migrations/031_AuthAuthorizationScopes.ts";
|
|||||||
import Migration0032 from "./Migrations/032_AuthPairingProofKeyThumbprint.ts";
|
import Migration0032 from "./Migrations/032_AuthPairingProofKeyThumbprint.ts";
|
||||||
import Migration0033 from "./Migrations/033_ProjectionThreadsSettled.ts";
|
import Migration0033 from "./Migrations/033_ProjectionThreadsSettled.ts";
|
||||||
import Migration0034 from "./Migrations/034_ProjectionThreadsSnoozed.ts";
|
import Migration0034 from "./Migrations/034_ProjectionThreadsSnoozed.ts";
|
||||||
|
import Migration0035 from "./Migrations/035_ProjectionThreadTasks.ts";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Migration loader with all migrations defined inline.
|
* Migration loader with all migrations defined inline.
|
||||||
@@ -93,6 +94,7 @@ export const migrationEntries = [
|
|||||||
[32, "AuthPairingProofKeyThumbprint", Migration0032],
|
[32, "AuthPairingProofKeyThumbprint", Migration0032],
|
||||||
[33, "ProjectionThreadsSettled", Migration0033],
|
[33, "ProjectionThreadsSettled", Migration0033],
|
||||||
[34, "ProjectionThreadsSnoozed", Migration0034],
|
[34, "ProjectionThreadsSnoozed", Migration0034],
|
||||||
|
[35, "ProjectionThreadTasks", Migration0035],
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
export const makeMigrationLoader = (throughId?: number) =>
|
export const makeMigrationLoader = (throughId?: number) =>
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
import { assert, it } from "@effect/vitest";
|
||||||
|
import * as Effect from "effect/Effect";
|
||||||
|
import * as Layer from "effect/Layer";
|
||||||
|
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
||||||
|
|
||||||
|
import { runMigrations } from "../Migrations.ts";
|
||||||
|
import * as NodeSqliteClient from "../NodeSqliteClient.ts";
|
||||||
|
|
||||||
|
const layer = it.layer(Layer.mergeAll(NodeSqliteClient.layerMemory()));
|
||||||
|
|
||||||
|
layer("035_ProjectionThreadTasks", (it) => {
|
||||||
|
it.effect("backfills legacy threads as one-tab tasks and creates the lookup index", () =>
|
||||||
|
Effect.gen(function* () {
|
||||||
|
const sql = yield* SqlClient.SqlClient;
|
||||||
|
|
||||||
|
yield* runMigrations({ toMigrationInclusive: 34 });
|
||||||
|
yield* sql`
|
||||||
|
INSERT INTO projection_threads (
|
||||||
|
thread_id,
|
||||||
|
project_id,
|
||||||
|
title,
|
||||||
|
model_selection_json,
|
||||||
|
runtime_mode,
|
||||||
|
interaction_mode,
|
||||||
|
branch,
|
||||||
|
worktree_path,
|
||||||
|
latest_turn_id,
|
||||||
|
created_at,
|
||||||
|
updated_at,
|
||||||
|
archived_at,
|
||||||
|
settled_override,
|
||||||
|
settled_at,
|
||||||
|
snoozed_until,
|
||||||
|
snoozed_at,
|
||||||
|
latest_user_message_at,
|
||||||
|
pending_approval_count,
|
||||||
|
pending_user_input_count,
|
||||||
|
has_actionable_proposed_plan,
|
||||||
|
deleted_at
|
||||||
|
)
|
||||||
|
VALUES (
|
||||||
|
'thread-legacy',
|
||||||
|
'project-1',
|
||||||
|
'Legacy thread',
|
||||||
|
'{"instanceId":"codex","model":"gpt-5"}',
|
||||||
|
'full-access',
|
||||||
|
'default',
|
||||||
|
'main',
|
||||||
|
'/tmp/worktree',
|
||||||
|
NULL,
|
||||||
|
'2026-07-24T00:00:00.000Z',
|
||||||
|
'2026-07-24T00:00:00.000Z',
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
NULL
|
||||||
|
)
|
||||||
|
`;
|
||||||
|
|
||||||
|
yield* runMigrations({ toMigrationInclusive: 35 });
|
||||||
|
|
||||||
|
const rows = yield* sql<{
|
||||||
|
readonly workspaceTaskId: string;
|
||||||
|
readonly tabPosition: number;
|
||||||
|
readonly tabClosedAt: string | null;
|
||||||
|
readonly forkProvenance: string | null;
|
||||||
|
}>`
|
||||||
|
SELECT
|
||||||
|
workspace_task_id AS "workspaceTaskId",
|
||||||
|
tab_position AS "tabPosition",
|
||||||
|
tab_closed_at AS "tabClosedAt",
|
||||||
|
fork_provenance_json AS "forkProvenance"
|
||||||
|
FROM projection_threads
|
||||||
|
WHERE thread_id = 'thread-legacy'
|
||||||
|
`;
|
||||||
|
assert.deepStrictEqual(rows, [
|
||||||
|
{
|
||||||
|
workspaceTaskId: "thread-legacy",
|
||||||
|
tabPosition: 0,
|
||||||
|
tabClosedAt: null,
|
||||||
|
forkProvenance: null,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
const indexes = yield* sql<{ readonly name: string }>`
|
||||||
|
PRAGMA index_list(projection_threads)
|
||||||
|
`;
|
||||||
|
assert.ok(indexes.some((index) => index.name === "idx_projection_threads_workspace_task"));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
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 columns = yield* sql<{ readonly name: string }>`
|
||||||
|
PRAGMA table_info(projection_threads)
|
||||||
|
`;
|
||||||
|
|
||||||
|
if (!columns.some((column) => column.name === "workspace_task_id")) {
|
||||||
|
yield* sql`
|
||||||
|
ALTER TABLE projection_threads
|
||||||
|
ADD COLUMN workspace_task_id TEXT
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
if (!columns.some((column) => column.name === "tab_label")) {
|
||||||
|
yield* sql`
|
||||||
|
ALTER TABLE projection_threads
|
||||||
|
ADD COLUMN tab_label TEXT
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
if (!columns.some((column) => column.name === "tab_position")) {
|
||||||
|
yield* sql`
|
||||||
|
ALTER TABLE projection_threads
|
||||||
|
ADD COLUMN tab_position INTEGER NOT NULL DEFAULT 0
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
if (!columns.some((column) => column.name === "tab_closed_at")) {
|
||||||
|
yield* sql`
|
||||||
|
ALTER TABLE projection_threads
|
||||||
|
ADD COLUMN tab_closed_at TEXT
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
if (!columns.some((column) => column.name === "fork_provenance_json")) {
|
||||||
|
yield* sql`
|
||||||
|
ALTER TABLE projection_threads
|
||||||
|
ADD COLUMN fork_provenance_json TEXT
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Every pre-task thread becomes a one-tab task. This makes the migration
|
||||||
|
// lossless and lets mixed-version clients continue using thread routes.
|
||||||
|
yield* sql`
|
||||||
|
UPDATE projection_threads
|
||||||
|
SET workspace_task_id = thread_id
|
||||||
|
WHERE workspace_task_id IS NULL
|
||||||
|
`;
|
||||||
|
|
||||||
|
yield* sql`
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_projection_threads_workspace_task
|
||||||
|
ON projection_threads (workspace_task_id, tab_closed_at, tab_position, created_at, thread_id)
|
||||||
|
`;
|
||||||
|
});
|
||||||
@@ -14,7 +14,9 @@ import {
|
|||||||
ProviderInteractionMode,
|
ProviderInteractionMode,
|
||||||
RuntimeMode,
|
RuntimeMode,
|
||||||
ThreadId,
|
ThreadId,
|
||||||
|
ThreadForkProvenance,
|
||||||
TurnId,
|
TurnId,
|
||||||
|
WorkspaceTaskId,
|
||||||
} from "@t3tools/contracts";
|
} from "@t3tools/contracts";
|
||||||
import * as Option from "effect/Option";
|
import * as Option from "effect/Option";
|
||||||
import * as Schema from "effect/Schema";
|
import * as Schema from "effect/Schema";
|
||||||
@@ -26,6 +28,11 @@ import type { ProjectionRepositoryError } from "../Errors.ts";
|
|||||||
export const ProjectionThread = Schema.Struct({
|
export const ProjectionThread = Schema.Struct({
|
||||||
threadId: ThreadId,
|
threadId: ThreadId,
|
||||||
projectId: ProjectId,
|
projectId: ProjectId,
|
||||||
|
workspaceTaskId: WorkspaceTaskId,
|
||||||
|
tabLabel: Schema.NullOr(Schema.String),
|
||||||
|
tabPosition: NonNegativeInt,
|
||||||
|
tabClosedAt: Schema.NullOr(IsoDateTime),
|
||||||
|
forkProvenance: Schema.NullOr(ThreadForkProvenance),
|
||||||
title: Schema.String,
|
title: Schema.String,
|
||||||
modelSelection: ModelSelection,
|
modelSelection: ModelSelection,
|
||||||
runtimeMode: RuntimeMode,
|
runtimeMode: RuntimeMode,
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ const makeProjectionSnapshotQueryLayer = (project: OrchestrationProject) =>
|
|||||||
getSnapshot: () => Effect.die("unused"),
|
getSnapshot: () => Effect.die("unused"),
|
||||||
getShellSnapshot: () => Effect.die("unused"),
|
getShellSnapshot: () => Effect.die("unused"),
|
||||||
getArchivedShellSnapshot: () => Effect.die("unused"),
|
getArchivedShellSnapshot: () => Effect.die("unused"),
|
||||||
|
getClosedTaskTabs: () => Effect.die("unused"),
|
||||||
getSnapshotSequence: () => Effect.succeed({ snapshotSequence: 1 }),
|
getSnapshotSequence: () => Effect.succeed({ snapshotSequence: 1 }),
|
||||||
getCounts: () => Effect.die("unused"),
|
getCounts: () => Effect.die("unused"),
|
||||||
getActiveProjectByWorkspaceRoot: (workspaceRoot) =>
|
getActiveProjectByWorkspaceRoot: (workspaceRoot) =>
|
||||||
|
|||||||
@@ -196,6 +196,7 @@ describe("ProviderSessionReaper", () => {
|
|||||||
getSnapshot: () => Effect.die("unused"),
|
getSnapshot: () => Effect.die("unused"),
|
||||||
getShellSnapshot: () => Effect.die("unused"),
|
getShellSnapshot: () => Effect.die("unused"),
|
||||||
getArchivedShellSnapshot: () => Effect.die("unused"),
|
getArchivedShellSnapshot: () => Effect.die("unused"),
|
||||||
|
getClosedTaskTabs: () => Effect.die("unused"),
|
||||||
getSnapshotSequence: () =>
|
getSnapshotSequence: () =>
|
||||||
Effect.succeed({ snapshotSequence: input.readModel.snapshotSequence }),
|
Effect.succeed({ snapshotSequence: input.readModel.snapshotSequence }),
|
||||||
getCounts: () => Effect.die("unused"),
|
getCounts: () => Effect.die("unused"),
|
||||||
|
|||||||
@@ -5553,11 +5553,16 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
const closedTaskTab = makeDefaultOrchestrationThreadShell({
|
||||||
|
id: ThreadId.make("thread-closed"),
|
||||||
|
tabClosedAt: now,
|
||||||
|
});
|
||||||
|
|
||||||
yield* buildAppUnderTest({
|
yield* buildAppUnderTest({
|
||||||
layers: {
|
layers: {
|
||||||
projectionSnapshotQuery: {
|
projectionSnapshotQuery: {
|
||||||
getSnapshot: () => Effect.succeed(snapshot),
|
getSnapshot: () => Effect.succeed(snapshot),
|
||||||
|
getClosedTaskTabs: () => Effect.succeed([closedTaskTab]),
|
||||||
},
|
},
|
||||||
orchestrationEngine: {
|
orchestrationEngine: {
|
||||||
dispatch: () => Effect.succeed({ sequence: 7 }),
|
dispatch: () => Effect.succeed({ sequence: 7 }),
|
||||||
@@ -5624,6 +5629,11 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
assert.deepEqual(replayResult, []);
|
assert.deepEqual(replayResult, []);
|
||||||
|
|
||||||
|
const closedTaskTabs = yield* Effect.scoped(
|
||||||
|
withWsRpcClient(wsUrl, (client) => client[ORCHESTRATION_WS_METHODS.getClosedTaskTabs]({})),
|
||||||
|
);
|
||||||
|
assert.deepEqual(closedTaskTabs, [closedTaskTab]);
|
||||||
}).pipe(Effect.provide(NodeHttpServer.layerTest)),
|
}).pipe(Effect.provide(NodeHttpServer.layerTest)),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ it.effect("launchStartupHeartbeat does not block the caller while counts are loa
|
|||||||
getSnapshot: () => Effect.die("unused"),
|
getSnapshot: () => Effect.die("unused"),
|
||||||
getShellSnapshot: () => Effect.die("unused"),
|
getShellSnapshot: () => Effect.die("unused"),
|
||||||
getArchivedShellSnapshot: () => Effect.die("unused"),
|
getArchivedShellSnapshot: () => Effect.die("unused"),
|
||||||
|
getClosedTaskTabs: () => Effect.die("unused"),
|
||||||
getSnapshotSequence: () => Effect.die("unused"),
|
getSnapshotSequence: () => Effect.die("unused"),
|
||||||
getCounts: () =>
|
getCounts: () =>
|
||||||
Deferred.await(releaseCounts).pipe(
|
Deferred.await(releaseCounts).pipe(
|
||||||
@@ -138,6 +139,7 @@ it.effect("resolveAutoBootstrapWelcomeTargets returns existing project and threa
|
|||||||
getSnapshot: () => Effect.die("unused"),
|
getSnapshot: () => Effect.die("unused"),
|
||||||
getShellSnapshot: () => Effect.die("unused"),
|
getShellSnapshot: () => Effect.die("unused"),
|
||||||
getArchivedShellSnapshot: () => Effect.die("unused"),
|
getArchivedShellSnapshot: () => Effect.die("unused"),
|
||||||
|
getClosedTaskTabs: () => Effect.die("unused"),
|
||||||
getSnapshotSequence: () => Effect.die("unused"),
|
getSnapshotSequence: () => Effect.die("unused"),
|
||||||
getCounts: () => Effect.die("unused"),
|
getCounts: () => Effect.die("unused"),
|
||||||
getActiveProjectByWorkspaceRoot: () =>
|
getActiveProjectByWorkspaceRoot: () =>
|
||||||
@@ -194,6 +196,7 @@ it.effect("resolveAutoBootstrapWelcomeTargets creates a project and thread when
|
|||||||
getSnapshot: () => Effect.die("unused"),
|
getSnapshot: () => Effect.die("unused"),
|
||||||
getShellSnapshot: () => Effect.die("unused"),
|
getShellSnapshot: () => Effect.die("unused"),
|
||||||
getArchivedShellSnapshot: () => Effect.die("unused"),
|
getArchivedShellSnapshot: () => Effect.die("unused"),
|
||||||
|
getClosedTaskTabs: () => Effect.die("unused"),
|
||||||
getSnapshotSequence: () => Effect.die("unused"),
|
getSnapshotSequence: () => Effect.die("unused"),
|
||||||
getCounts: () => Effect.die("unused"),
|
getCounts: () => Effect.die("unused"),
|
||||||
getActiveProjectByWorkspaceRoot: () => Effect.succeed(Option.none()),
|
getActiveProjectByWorkspaceRoot: () => Effect.succeed(Option.none()),
|
||||||
@@ -244,6 +247,7 @@ it.effect("resolveAutoBootstrapWelcomeTargets preserves typed UUID generation fa
|
|||||||
getSnapshot: () => Effect.die("unused"),
|
getSnapshot: () => Effect.die("unused"),
|
||||||
getShellSnapshot: () => Effect.die("unused"),
|
getShellSnapshot: () => Effect.die("unused"),
|
||||||
getArchivedShellSnapshot: () => Effect.die("unused"),
|
getArchivedShellSnapshot: () => Effect.die("unused"),
|
||||||
|
getClosedTaskTabs: () => Effect.die("unused"),
|
||||||
getSnapshotSequence: () => Effect.die("unused"),
|
getSnapshotSequence: () => Effect.die("unused"),
|
||||||
getCounts: () => Effect.die("unused"),
|
getCounts: () => Effect.die("unused"),
|
||||||
getActiveProjectByWorkspaceRoot: () => Effect.succeed(Option.none()),
|
getActiveProjectByWorkspaceRoot: () => Effect.succeed(Option.none()),
|
||||||
|
|||||||
@@ -296,6 +296,7 @@ const RPC_REQUIRED_SCOPE = new Map<string, AuthEnvironmentScope>([
|
|||||||
[ORCHESTRATION_WS_METHODS.replayEvents, AuthOrchestrationReadScope],
|
[ORCHESTRATION_WS_METHODS.replayEvents, AuthOrchestrationReadScope],
|
||||||
[ORCHESTRATION_WS_METHODS.subscribeShell, AuthOrchestrationReadScope],
|
[ORCHESTRATION_WS_METHODS.subscribeShell, AuthOrchestrationReadScope],
|
||||||
[ORCHESTRATION_WS_METHODS.getArchivedShellSnapshot, AuthOrchestrationReadScope],
|
[ORCHESTRATION_WS_METHODS.getArchivedShellSnapshot, AuthOrchestrationReadScope],
|
||||||
|
[ORCHESTRATION_WS_METHODS.getClosedTaskTabs, AuthOrchestrationReadScope],
|
||||||
[ORCHESTRATION_WS_METHODS.subscribeThread, AuthOrchestrationReadScope],
|
[ORCHESTRATION_WS_METHODS.subscribeThread, AuthOrchestrationReadScope],
|
||||||
[WS_METHODS.serverProbe, AuthOrchestrationReadScope],
|
[WS_METHODS.serverProbe, AuthOrchestrationReadScope],
|
||||||
[WS_METHODS.serverGetConfig, AuthOrchestrationReadScope],
|
[WS_METHODS.serverGetConfig, AuthOrchestrationReadScope],
|
||||||
@@ -988,6 +989,21 @@ const makeWsRpcLayer = (
|
|||||||
commandId: yield* serverCommandId("bootstrap-thread-create"),
|
commandId: yield* serverCommandId("bootstrap-thread-create"),
|
||||||
threadId: command.threadId,
|
threadId: command.threadId,
|
||||||
projectId: bootstrap.createThread.projectId,
|
projectId: bootstrap.createThread.projectId,
|
||||||
|
...(bootstrap.createThread.workspaceTaskId !== undefined
|
||||||
|
? { workspaceTaskId: bootstrap.createThread.workspaceTaskId }
|
||||||
|
: {}),
|
||||||
|
...(bootstrap.createThread.tabLabel !== undefined
|
||||||
|
? { tabLabel: bootstrap.createThread.tabLabel }
|
||||||
|
: {}),
|
||||||
|
...(bootstrap.createThread.tabPosition !== undefined
|
||||||
|
? { tabPosition: bootstrap.createThread.tabPosition }
|
||||||
|
: {}),
|
||||||
|
...(bootstrap.createThread.tabClosedAt !== undefined
|
||||||
|
? { tabClosedAt: bootstrap.createThread.tabClosedAt }
|
||||||
|
: {}),
|
||||||
|
...(bootstrap.createThread.forkProvenance !== undefined
|
||||||
|
? { forkProvenance: bootstrap.createThread.forkProvenance }
|
||||||
|
: {}),
|
||||||
title: bootstrap.createThread.title,
|
title: bootstrap.createThread.title,
|
||||||
modelSelection: bootstrap.createThread.modelSelection,
|
modelSelection: bootstrap.createThread.modelSelection,
|
||||||
runtimeMode: bootstrap.createThread.runtimeMode,
|
runtimeMode: bootstrap.createThread.runtimeMode,
|
||||||
@@ -1352,6 +1368,23 @@ const makeWsRpcLayer = (
|
|||||||
),
|
),
|
||||||
{ "rpc.aggregate": "orchestration" },
|
{ "rpc.aggregate": "orchestration" },
|
||||||
),
|
),
|
||||||
|
[ORCHESTRATION_WS_METHODS.getClosedTaskTabs]: (_input) =>
|
||||||
|
observeRpcEffect(
|
||||||
|
ORCHESTRATION_WS_METHODS.getClosedTaskTabs,
|
||||||
|
projectionSnapshotQuery.getClosedTaskTabs().pipe(
|
||||||
|
Effect.tapError((cause) =>
|
||||||
|
Effect.logError("orchestration closed task tabs load failed", { cause }),
|
||||||
|
),
|
||||||
|
Effect.mapError(
|
||||||
|
(cause) =>
|
||||||
|
new OrchestrationGetSnapshotError({
|
||||||
|
message: "Failed to load closed task tabs",
|
||||||
|
cause,
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
{ "rpc.aggregate": "orchestration" },
|
||||||
|
),
|
||||||
[ORCHESTRATION_WS_METHODS.subscribeThread]: (input) =>
|
[ORCHESTRATION_WS_METHODS.subscribeThread]: (input) =>
|
||||||
observeRpcStreamEffect(
|
observeRpcStreamEffect(
|
||||||
ORCHESTRATION_WS_METHODS.subscribeThread,
|
ORCHESTRATION_WS_METHODS.subscribeThread,
|
||||||
|
|||||||
@@ -69,6 +69,22 @@ function makeThread(activities: ReadonlyArray<OrchestrationThreadActivity>): Orc
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildMaterializedThreadFeed(activities: ReadonlyArray<OrchestrationThreadActivity>) {
|
||||||
|
return buildThreadFeed(makeThread(activities)).map((entry) => {
|
||||||
|
if (entry.type !== "activity-group") {
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
...entry,
|
||||||
|
activities: entry.activities.map(({ getFullDetail, getCopyText, ...activity }) => ({
|
||||||
|
...activity,
|
||||||
|
fullDetail: getFullDetail(),
|
||||||
|
copyText: getCopyText(),
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const fixtures = [
|
const fixtures = [
|
||||||
makeActivity("command", "command_execution", {
|
makeActivity("command", "command_execution", {
|
||||||
item: {
|
item: {
|
||||||
@@ -170,8 +186,8 @@ describe("projectActivityPayload", () => {
|
|||||||
for (const activity of fixtures) {
|
for (const activity of fixtures) {
|
||||||
const projected = projectActivityPayload(activity);
|
const projected = projectActivityPayload(activity);
|
||||||
expect(deriveWorkLogEntries([projected])).toEqual(deriveWorkLogEntries([activity]));
|
expect(deriveWorkLogEntries([projected])).toEqual(deriveWorkLogEntries([activity]));
|
||||||
expect(buildThreadFeed(makeThread([projected]))).toEqual(
|
expect(buildMaterializedThreadFeed([projected])).toEqual(
|
||||||
buildThreadFeed(makeThread([activity])),
|
buildMaterializedThreadFeed([activity]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ import { useTheme } from "../hooks/useTheme";
|
|||||||
import { useTurnDiffSummaries } from "../hooks/useTurnDiffSummaries";
|
import { useTurnDiffSummaries } from "../hooks/useTurnDiffSummaries";
|
||||||
import { isCommandPaletteOpen } from "../commandPaletteBus";
|
import { isCommandPaletteOpen } from "../commandPaletteBus";
|
||||||
import { buildTemporaryWorktreeBranchName } from "@t3tools/shared/git";
|
import { buildTemporaryWorktreeBranchName } from "@t3tools/shared/git";
|
||||||
|
import { WorkspaceTaskTabs } from "./WorkspaceTaskTabs";
|
||||||
import { useMediaQuery } from "../hooks/useMediaQuery";
|
import { useMediaQuery } from "../hooks/useMediaQuery";
|
||||||
import { RIGHT_PANEL_INLINE_LAYOUT_MEDIA_QUERY } from "../rightPanelLayout";
|
import { RIGHT_PANEL_INLINE_LAYOUT_MEDIA_QUERY } from "../rightPanelLayout";
|
||||||
import {
|
import {
|
||||||
@@ -4725,6 +4726,18 @@ function ChatViewContent(props: ChatViewProps) {
|
|||||||
? {
|
? {
|
||||||
createThread: {
|
createThread: {
|
||||||
projectId: activeProject.id,
|
projectId: activeProject.id,
|
||||||
|
...(draftThread?.workspaceTaskId
|
||||||
|
? { workspaceTaskId: draftThread.workspaceTaskId }
|
||||||
|
: {}),
|
||||||
|
...(draftThread?.tabLabel !== undefined
|
||||||
|
? { tabLabel: draftThread.tabLabel }
|
||||||
|
: {}),
|
||||||
|
...(draftThread?.tabPosition !== undefined
|
||||||
|
? { tabPosition: draftThread.tabPosition }
|
||||||
|
: {}),
|
||||||
|
...(draftThread?.forkProvenance !== undefined
|
||||||
|
? { forkProvenance: draftThread.forkProvenance }
|
||||||
|
: {}),
|
||||||
title,
|
title,
|
||||||
modelSelection: threadCreateModelSelection,
|
modelSelection: threadCreateModelSelection,
|
||||||
runtimeMode,
|
runtimeMode,
|
||||||
@@ -5655,6 +5668,7 @@ function ChatViewContent(props: ChatViewProps) {
|
|||||||
/>
|
/>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
<WorkspaceTaskTabs />
|
||||||
<ThreadErrorBanner
|
<ThreadErrorBanner
|
||||||
error={threadError}
|
error={threadError}
|
||||||
onDismiss={() => setThreadError(activeThread.id, null)}
|
onDismiss={() => setThreadError(activeThread.id, null)}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import {
|
|||||||
SearchIcon,
|
SearchIcon,
|
||||||
ServerIcon,
|
ServerIcon,
|
||||||
SquarePenIcon,
|
SquarePenIcon,
|
||||||
|
SquareStackIcon,
|
||||||
Trash2Icon,
|
Trash2Icon,
|
||||||
Undo2Icon,
|
Undo2Icon,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
@@ -100,6 +101,11 @@ import { buildThreadRouteParams, resolveThreadRouteTarget } from "../threadRoute
|
|||||||
import { formatRelativeTimeLabel, parseTimestampDate } from "../timestampFormat";
|
import { formatRelativeTimeLabel, parseTimestampDate } from "../timestampFormat";
|
||||||
import type { SidebarThreadSummary } from "../types";
|
import type { SidebarThreadSummary } from "../types";
|
||||||
import { cn } from "~/lib/utils";
|
import { cn } from "~/lib/utils";
|
||||||
|
import {
|
||||||
|
groupThreadsByWorkspaceTask,
|
||||||
|
taskPresentationThread,
|
||||||
|
workspaceTaskKey,
|
||||||
|
} from "../lib/workspaceTasks";
|
||||||
import {
|
import {
|
||||||
formatWorkingDurationLabel,
|
formatWorkingDurationLabel,
|
||||||
firstValidTimestampMs,
|
firstValidTimestampMs,
|
||||||
@@ -212,6 +218,23 @@ function WorkingDuration(props: { startedAt: string | null }) {
|
|||||||
return <span className="tabular-nums">{formatWorkingDurationLabel(Date.now() - startedMs)}</span>;
|
return <span className="tabular-nums">{formatWorkingDurationLabel(Date.now() - startedMs)}</span>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A task row stands for every tab of that task, so the count is a quiet glyph
|
||||||
|
* badge rather than a bare number — the icon carries the meaning without color,
|
||||||
|
* and the row tooltip explains what the tabs do and don't share.
|
||||||
|
*/
|
||||||
|
function TaskTabCountBadge(props: { count: number }) {
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
className="inline-flex shrink-0 items-center gap-0.5 rounded bg-sidebar-accent px-1 font-mono text-[10px] text-sidebar-muted-foreground"
|
||||||
|
aria-label={`${props.count} task tabs`}
|
||||||
|
>
|
||||||
|
<SquareStackIcon aria-hidden className="size-2.5" />
|
||||||
|
{props.count}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function SidebarV2ThreadTooltip({
|
function SidebarV2ThreadTooltip({
|
||||||
thread,
|
thread,
|
||||||
projectTitle,
|
projectTitle,
|
||||||
@@ -221,11 +244,13 @@ function SidebarV2ThreadTooltip({
|
|||||||
modelInstanceId,
|
modelInstanceId,
|
||||||
modelLabel,
|
modelLabel,
|
||||||
branchMismatch,
|
branchMismatch,
|
||||||
|
tabCount,
|
||||||
}: {
|
}: {
|
||||||
thread: SidebarThreadSummary;
|
thread: SidebarThreadSummary;
|
||||||
projectTitle: string | null;
|
projectTitle: string | null;
|
||||||
projectCwd: string | null;
|
projectCwd: string | null;
|
||||||
environmentLabel: string | null;
|
environmentLabel: string | null;
|
||||||
|
tabCount: number;
|
||||||
driverKind: ProviderInstanceEntry["driverKind"] | null;
|
driverKind: ProviderInstanceEntry["driverKind"] | null;
|
||||||
modelInstanceId: string;
|
modelInstanceId: string;
|
||||||
modelLabel: string;
|
modelLabel: string;
|
||||||
@@ -288,6 +313,14 @@ function SidebarV2ThreadTooltip({
|
|||||||
<div className="min-w-0 wrap-break-word text-foreground/90">{modelLabel}</div>
|
<div className="min-w-0 wrap-break-word text-foreground/90">{modelLabel}</div>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
{tabCount > 1 ? (
|
||||||
|
<div className="flex min-w-0 items-start gap-2">
|
||||||
|
<SquareStackIcon aria-hidden className="mt-0.5 size-4 shrink-0 stroke-current" />
|
||||||
|
<div className="min-w-0 flex-1 wrap-break-word leading-5">
|
||||||
|
{tabCount} tabs · Shared files, separate chats.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
{thread.session?.lastError ? (
|
{thread.session?.lastError ? (
|
||||||
<div className="flex min-w-0 items-center gap-2 text-red-600 dark:text-red-400">
|
<div className="flex min-w-0 items-center gap-2 text-red-600 dark:text-red-400">
|
||||||
<CircleAlertIcon className="size-4 shrink-0 stroke-current" />
|
<CircleAlertIcon className="size-4 shrink-0 stroke-current" />
|
||||||
@@ -368,6 +401,7 @@ const SidebarV2Row = memo(function SidebarV2Row(props: {
|
|||||||
// When a snooze ended (timer or early wake); drives the Woke pill until
|
// When a snooze ended (timer or early wake); drives the Woke pill until
|
||||||
// the user visits the thread.
|
// the user visits the thread.
|
||||||
wokeAt: string | null;
|
wokeAt: string | null;
|
||||||
|
tabCount: number;
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
jumpLabel: string | null;
|
jumpLabel: string | null;
|
||||||
currentEnvironmentId: string | null;
|
currentEnvironmentId: string | null;
|
||||||
@@ -536,6 +570,7 @@ const SidebarV2Row = memo(function SidebarV2Row(props: {
|
|||||||
modelInstanceId={modelInstanceId}
|
modelInstanceId={modelInstanceId}
|
||||||
modelLabel={modelLabel}
|
modelLabel={modelLabel}
|
||||||
branchMismatch={branchMismatch}
|
branchMismatch={branchMismatch}
|
||||||
|
tabCount={props.tabCount}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -768,6 +803,7 @@ const SidebarV2Row = memo(function SidebarV2Row(props: {
|
|||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
{title}
|
{title}
|
||||||
|
{props.tabCount > 1 ? <TaskTabCountBadge count={props.tabCount} /> : null}
|
||||||
{/* The PR badge stays outside the hover-fading slot: it must
|
{/* The PR badge stays outside the hover-fading slot: it must
|
||||||
remain visible AND clickable while the row is hovered. Only
|
remain visible AND clickable while the row is hovered. Only
|
||||||
the time/jump label yields to the settle affordance. */}
|
the time/jump label yields to the settle affordance. */}
|
||||||
@@ -943,7 +979,10 @@ const SidebarV2Row = memo(function SidebarV2Row(props: {
|
|||||||
) : null}
|
) : null}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-1 flex min-w-0">{title}</div>
|
<div className="mt-1 flex min-w-0 items-center gap-1.5">
|
||||||
|
{title}
|
||||||
|
{props.tabCount > 1 ? <TaskTabCountBadge count={props.tabCount} /> : null}
|
||||||
|
</div>
|
||||||
<div className="mt-0.5 flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground/75">
|
<div className="mt-0.5 flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground/75">
|
||||||
{thread.branch ? (
|
{thread.branch ? (
|
||||||
<span className="min-w-0 flex-1 truncate whitespace-nowrap">{thread.branch}</span>
|
<span className="min-w-0 flex-1 truncate whitespace-nowrap">{thread.branch}</span>
|
||||||
@@ -1058,6 +1097,34 @@ export default function SidebarV2() {
|
|||||||
});
|
});
|
||||||
const routeThreadRef = routeTarget?.kind === "server" ? routeTarget.threadRef : null;
|
const routeThreadRef = routeTarget?.kind === "server" ? routeTarget.threadRef : null;
|
||||||
const routeThreadKey = routeThreadRef ? scopedThreadKey(routeThreadRef) : null;
|
const routeThreadKey = routeThreadRef ? scopedThreadKey(routeThreadRef) : null;
|
||||||
|
const routeTaskKey = useMemo(() => {
|
||||||
|
if (routeThreadKey === null) return null;
|
||||||
|
const routeThread = threads.find(
|
||||||
|
(thread) =>
|
||||||
|
scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)) === routeThreadKey,
|
||||||
|
);
|
||||||
|
return routeThread ? workspaceTaskKey(routeThread) : null;
|
||||||
|
}, [routeThreadKey, threads]);
|
||||||
|
const taskTabCountByKey = useMemo(
|
||||||
|
() =>
|
||||||
|
new Map(
|
||||||
|
groupThreadsByWorkspaceTask(threads.filter((thread) => thread.tabClosedAt == null)).map(
|
||||||
|
(task) => [task.key, task.tabs.length] as const,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
[threads],
|
||||||
|
);
|
||||||
|
const taskTabsByThreadKey = useMemo(() => {
|
||||||
|
const mapping = new Map<string, ReadonlyArray<EnvironmentThreadShell>>();
|
||||||
|
for (const task of groupThreadsByWorkspaceTask(
|
||||||
|
threads.filter((thread) => thread.tabClosedAt == null),
|
||||||
|
)) {
|
||||||
|
for (const tab of task.tabs) {
|
||||||
|
mapping.set(scopedThreadKey(scopeThreadRef(tab.environmentId, tab.id)), task.tabs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mapping;
|
||||||
|
}, [threads]);
|
||||||
const routeTargetRef = useRef(routeTarget);
|
const routeTargetRef = useRef(routeTarget);
|
||||||
routeTargetRef.current = routeTarget;
|
routeTargetRef.current = routeTarget;
|
||||||
// Post-settle navigation validates against the CURRENT route, not the one
|
// Post-settle navigation validates against the CURRENT route, not the one
|
||||||
@@ -1370,13 +1437,15 @@ export default function SidebarV2() {
|
|||||||
const visible = threads.filter(
|
const visible = threads.filter(
|
||||||
(thread) =>
|
(thread) =>
|
||||||
thread.archivedAt === null &&
|
thread.archivedAt === null &&
|
||||||
|
thread.tabClosedAt == null &&
|
||||||
(scopedProjectKeys === null ||
|
(scopedProjectKeys === null ||
|
||||||
scopedProjectKeys.has(`${thread.environmentId}:${thread.projectId}`)),
|
scopedProjectKeys.has(`${thread.environmentId}:${thread.projectId}`)),
|
||||||
);
|
);
|
||||||
const active: EnvironmentThreadShell[] = [];
|
const active: EnvironmentThreadShell[] = [];
|
||||||
const snoozed: EnvironmentThreadShell[] = [];
|
const snoozed: EnvironmentThreadShell[] = [];
|
||||||
const settled: EnvironmentThreadShell[] = [];
|
const settled: EnvironmentThreadShell[] = [];
|
||||||
for (const thread of visible) {
|
for (const task of groupThreadsByWorkspaceTask(visible)) {
|
||||||
|
const thread = taskPresentationThread(task, routeThreadKey);
|
||||||
// Threads on servers without the settlement capability (old server,
|
// Threads on servers without the settlement capability (old server,
|
||||||
// or descriptor not loaded yet) never classify as settled: the user
|
// or descriptor not loaded yet) never classify as settled: the user
|
||||||
// could neither un-settle nor pin them, so auto-settling them would
|
// could neither un-settle nor pin them, so auto-settling them would
|
||||||
@@ -1385,17 +1454,22 @@ export default function SidebarV2() {
|
|||||||
serverConfigs.get(thread.environmentId)?.environment.capabilities.threadSettlement === true;
|
serverConfigs.get(thread.environmentId)?.environment.capabilities.threadSettlement === true;
|
||||||
const supportsSnooze =
|
const supportsSnooze =
|
||||||
serverConfigs.get(thread.environmentId)?.environment.capabilities.threadSnooze === true;
|
serverConfigs.get(thread.environmentId)?.environment.capabilities.threadSnooze === true;
|
||||||
const threadKey = scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id));
|
const tabStates = task.tabs.map((tab) => {
|
||||||
const changeRequestState = changeRequestStateByKey.get(threadKey) ?? null;
|
const threadKey = scopedThreadKey(scopeThreadRef(tab.environmentId, tab.id));
|
||||||
|
const changeRequestState = changeRequestStateByKey.get(threadKey) ?? null;
|
||||||
|
return {
|
||||||
|
snoozed: supportsSnooze && effectiveSnoozed(tab, { now: preciseNow }),
|
||||||
|
settled:
|
||||||
|
supportsSettlement &&
|
||||||
|
effectiveSettled(tab, { now, autoSettleAfterDays, changeRequestState }),
|
||||||
|
};
|
||||||
|
});
|
||||||
// Snooze outranks settled classification: an explicitly snoozed thread
|
// Snooze outranks settled classification: an explicitly snoozed thread
|
||||||
// belongs to the shelf even if it would also auto-settle (the shelf's
|
// belongs to the shelf even if it would also auto-settle (the shelf's
|
||||||
// wake time is a stronger statement about when it matters again).
|
// wake time is a stronger statement about when it matters again).
|
||||||
if (supportsSnooze && effectiveSnoozed(thread, { now: preciseNow })) {
|
if (tabStates.every((state) => state.snoozed)) {
|
||||||
snoozed.push(thread);
|
snoozed.push(thread);
|
||||||
} else if (
|
} else if (tabStates.every((state) => state.settled)) {
|
||||||
supportsSettlement &&
|
|
||||||
effectiveSettled(thread, { now, autoSettleAfterDays, changeRequestState })
|
|
||||||
) {
|
|
||||||
settled.push(thread);
|
settled.push(thread);
|
||||||
} else {
|
} else {
|
||||||
active.push(thread);
|
active.push(thread);
|
||||||
@@ -1420,6 +1494,7 @@ export default function SidebarV2() {
|
|||||||
serverConfigs,
|
serverConfigs,
|
||||||
snoozeWakeTick,
|
snoozeWakeTick,
|
||||||
threads,
|
threads,
|
||||||
|
routeThreadKey,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Arm a timeout for the earliest upcoming wake so the shelf empties the
|
// Arm a timeout for the earliest upcoming wake so the shelf empties the
|
||||||
@@ -1457,17 +1532,14 @@ export default function SidebarV2() {
|
|||||||
// The open thread must never hide under "Show more": navigating into a
|
// The open thread must never hide under "Show more": navigating into a
|
||||||
// deep settled thread (search, deep link) pulls its row into the visible
|
// deep settled thread (search, deep link) pulls its row into the visible
|
||||||
// tail so the highlight and the un-settle affordance stay reachable.
|
// tail so the highlight and the un-settle affordance stay reachable.
|
||||||
if (routeThreadKey !== null) {
|
if (routeTaskKey !== null) {
|
||||||
const routeThread = settledThreads
|
const routeThread = settledThreads
|
||||||
.slice(settledVisibleCount)
|
.slice(settledVisibleCount)
|
||||||
.find(
|
.find((thread) => workspaceTaskKey(thread) === routeTaskKey);
|
||||||
(thread) =>
|
|
||||||
scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)) === routeThreadKey,
|
|
||||||
);
|
|
||||||
if (routeThread !== undefined) visible.push(routeThread);
|
if (routeThread !== undefined) visible.push(routeThread);
|
||||||
}
|
}
|
||||||
return visible;
|
return visible;
|
||||||
}, [routeThreadKey, settledThreads, settledVisibleCount]);
|
}, [routeTaskKey, settledThreads, settledVisibleCount]);
|
||||||
const hiddenSettledCount = settledThreads.length - visibleSettledThreads.length;
|
const hiddenSettledCount = settledThreads.length - visibleSettledThreads.length;
|
||||||
const showMoreSettled = useCallback(
|
const showMoreSettled = useCallback(
|
||||||
() => setSettledVisibleCount((count) => count + SETTLED_TAIL_PAGE_COUNT),
|
() => setSettledVisibleCount((count) => count + SETTLED_TAIL_PAGE_COUNT),
|
||||||
@@ -1477,13 +1549,12 @@ export default function SidebarV2() {
|
|||||||
const toggleSettledShelf = useCallback(() => setSettledShelfExpanded((value) => !value), []);
|
const toggleSettledShelf = useCallback(() => setSettledShelfExpanded((value) => !value), []);
|
||||||
const renderedSettledThreads = useMemo(() => {
|
const renderedSettledThreads = useMemo(() => {
|
||||||
if (settledShelfExpanded) return visibleSettledThreads;
|
if (settledShelfExpanded) return visibleSettledThreads;
|
||||||
if (routeThreadKey === null) return [];
|
if (routeTaskKey === null) return [];
|
||||||
const routeThread = visibleSettledThreads.find(
|
const routeThread = visibleSettledThreads.find(
|
||||||
(thread) =>
|
(thread) => workspaceTaskKey(thread) === routeTaskKey,
|
||||||
scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)) === routeThreadKey,
|
|
||||||
);
|
);
|
||||||
return routeThread === undefined ? [] : [routeThread];
|
return routeThread === undefined ? [] : [routeThread];
|
||||||
}, [routeThreadKey, settledShelfExpanded, visibleSettledThreads]);
|
}, [routeTaskKey, settledShelfExpanded, visibleSettledThreads]);
|
||||||
|
|
||||||
// The snoozed shelf is collapsed by default: out of the way, never gone.
|
// The snoozed shelf is collapsed by default: out of the way, never gone.
|
||||||
// Collapsed threads don't render (and so don't participate in jump
|
// Collapsed threads don't render (and so don't participate in jump
|
||||||
@@ -1496,13 +1567,10 @@ export default function SidebarV2() {
|
|||||||
// snoozed thread reached by route (deep link, open before snoozing
|
// snoozed thread reached by route (deep link, open before snoozing
|
||||||
// elsewhere) keeps its row — with highlight and wake affordance — same
|
// elsewhere) keeps its row — with highlight and wake affordance — same
|
||||||
// exception the settled tail's "Show more" makes.
|
// exception the settled tail's "Show more" makes.
|
||||||
if (routeThreadKey === null) return [];
|
if (routeTaskKey === null) return [];
|
||||||
const routeThread = snoozedThreads.find(
|
const routeThread = snoozedThreads.find((thread) => workspaceTaskKey(thread) === routeTaskKey);
|
||||||
(thread) =>
|
|
||||||
scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)) === routeThreadKey,
|
|
||||||
);
|
|
||||||
return routeThread === undefined ? [] : [routeThread];
|
return routeThread === undefined ? [] : [routeThread];
|
||||||
}, [routeThreadKey, snoozedShelfExpanded, snoozedThreads]);
|
}, [routeTaskKey, snoozedShelfExpanded, snoozedThreads]);
|
||||||
|
|
||||||
const orderedThreads = useMemo(
|
const orderedThreads = useMemo(
|
||||||
() => [...activeThreads, ...visibleSnoozedThreads, ...renderedSettledThreads],
|
() => [...activeThreads, ...visibleSnoozedThreads, ...renderedSettledThreads],
|
||||||
@@ -1814,6 +1882,52 @@ export default function SidebarV2() {
|
|||||||
},
|
},
|
||||||
[attemptUnsnooze, planForwardNavigation, snoozeThread],
|
[attemptUnsnooze, planForwardNavigation, snoozeThread],
|
||||||
);
|
);
|
||||||
|
const taskTabsForRef = useCallback(
|
||||||
|
(threadRef: ScopedThreadRef) => taskTabsByThreadKey.get(scopedThreadKey(threadRef)) ?? [],
|
||||||
|
[taskTabsByThreadKey],
|
||||||
|
);
|
||||||
|
const attemptSettleTask = useCallback(
|
||||||
|
(threadRef: ScopedThreadRef) => {
|
||||||
|
const tabs = taskTabsForRef(threadRef);
|
||||||
|
const coSettlingKeys = new Set(
|
||||||
|
tabs.map((tab) => scopedThreadKey(scopeThreadRef(tab.environmentId, tab.id))),
|
||||||
|
);
|
||||||
|
for (const tab of tabs) {
|
||||||
|
attemptSettle(scopeThreadRef(tab.environmentId, tab.id), { coSettlingKeys });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[attemptSettle, taskTabsForRef],
|
||||||
|
);
|
||||||
|
const attemptUnsettleTask = useCallback(
|
||||||
|
(threadRef: ScopedThreadRef) => {
|
||||||
|
for (const tab of taskTabsForRef(threadRef)) {
|
||||||
|
attemptUnsettle(scopeThreadRef(tab.environmentId, tab.id));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[attemptUnsettle, taskTabsForRef],
|
||||||
|
);
|
||||||
|
const attemptSnoozeTask = useCallback(
|
||||||
|
(threadRef: ScopedThreadRef, preset: SnoozePreset) => {
|
||||||
|
const tabs = taskTabsForRef(threadRef);
|
||||||
|
const coSnoozingKeys = new Set(
|
||||||
|
tabs.map((tab) => scopedThreadKey(scopeThreadRef(tab.environmentId, tab.id))),
|
||||||
|
);
|
||||||
|
for (const tab of tabs) {
|
||||||
|
attemptSnooze(scopeThreadRef(tab.environmentId, tab.id), preset, {
|
||||||
|
coSnoozingKeys,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[attemptSnooze, taskTabsForRef],
|
||||||
|
);
|
||||||
|
const attemptUnsnoozeTask = useCallback(
|
||||||
|
(threadRef: ScopedThreadRef) => {
|
||||||
|
for (const tab of taskTabsForRef(threadRef)) {
|
||||||
|
attemptUnsnooze(scopeThreadRef(tab.environmentId, tab.id));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[attemptUnsnooze, taskTabsForRef],
|
||||||
|
);
|
||||||
|
|
||||||
const removeFromSelection = useThreadSelectionStore((s) => s.removeFromSelection);
|
const removeFromSelection = useThreadSelectionStore((s) => s.removeFromSelection);
|
||||||
const handleMultiSelectContextMenu = useCallback(
|
const handleMultiSelectContextMenu = useCallback(
|
||||||
@@ -1829,13 +1943,20 @@ export default function SidebarV2() {
|
|||||||
);
|
);
|
||||||
if (threadKeys.length === 0) return;
|
if (threadKeys.length === 0) return;
|
||||||
const count = threadKeys.length;
|
const count = threadKeys.length;
|
||||||
|
const selectedTabsByKey = new Map<string, EnvironmentThreadShell>();
|
||||||
|
for (const threadKey of threadKeys) {
|
||||||
|
const thread = threadByKeyRef.current.get(threadKey);
|
||||||
|
if (!thread) continue;
|
||||||
|
const tabs = taskTabsByThreadKey.get(threadKey) ?? [thread];
|
||||||
|
for (const tab of tabs) {
|
||||||
|
selectedTabsByKey.set(scopedThreadKey(scopeThreadRef(tab.environmentId, tab.id)), tab);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const selectedTabEntries = [...selectedTabsByKey.entries()];
|
||||||
// Snooze (N) is offered when every selected thread can actually take
|
// Snooze (N) is offered when every selected thread can actually take
|
||||||
// it — a mixed selection with blocked-on-you work would half-apply.
|
// it — a mixed selection with blocked-on-you work would half-apply.
|
||||||
const selectionNow = new Date().toISOString();
|
const selectionNow = new Date().toISOString();
|
||||||
const snoozableThreads = threadKeys.flatMap((threadKey) => {
|
const snoozableThreads = selectedTabEntries.map(([, thread]) => thread);
|
||||||
const thread = threadByKeyRef.current.get(threadKey);
|
|
||||||
return thread ? [thread] : [];
|
|
||||||
});
|
|
||||||
const canSnoozeSelection = snoozableThreads.every(
|
const canSnoozeSelection = snoozableThreads.every(
|
||||||
(thread) =>
|
(thread) =>
|
||||||
serverConfigs.get(thread.environmentId)?.environment.capabilities.threadSnooze === true &&
|
serverConfigs.get(thread.environmentId)?.environment.capabilities.threadSnooze === true &&
|
||||||
@@ -1872,7 +1993,7 @@ export default function SidebarV2() {
|
|||||||
if (preset) {
|
if (preset) {
|
||||||
// Post-snooze navigation must skip threads snoozing in this same
|
// Post-snooze navigation must skip threads snoozing in this same
|
||||||
// batch — they are all leaving the card block together.
|
// batch — they are all leaving the card block together.
|
||||||
const coSnoozingKeys = new Set(threadKeys);
|
const coSnoozingKeys = new Set(selectedTabsByKey.keys());
|
||||||
for (const thread of snoozableThreads) {
|
for (const thread of snoozableThreads) {
|
||||||
attemptSnooze(scopeThreadRef(thread.environmentId, thread.id), preset, {
|
attemptSnooze(scopeThreadRef(thread.environmentId, thread.id), preset, {
|
||||||
coSnoozingKeys,
|
coSnoozingKeys,
|
||||||
@@ -1887,18 +2008,16 @@ export default function SidebarV2() {
|
|||||||
// batch — they are all leaving the card block together. Rows that
|
// batch — they are all leaving the card block together. Rows that
|
||||||
// are already explicitly settled are skipped: nothing to do on a
|
// are already explicitly settled are skipped: nothing to do on a
|
||||||
// valid mixed selection.
|
// valid mixed selection.
|
||||||
const coSettlingKeys = new Set(threadKeys);
|
const coSettlingKeys = new Set(selectedTabsByKey.keys());
|
||||||
for (const threadKey of threadKeys) {
|
for (const [, thread] of selectedTabEntries) {
|
||||||
const thread = threadByKeyRef.current.get(threadKey);
|
if (thread.settledOverride === "settled") continue;
|
||||||
if (!thread || thread.settledOverride === "settled") continue;
|
|
||||||
attemptSettle(scopeThreadRef(thread.environmentId, thread.id), { coSettlingKeys });
|
attemptSettle(scopeThreadRef(thread.environmentId, thread.id), { coSettlingKeys });
|
||||||
}
|
}
|
||||||
clearSelection();
|
clearSelection();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (clicked.value === "mark-unread") {
|
if (clicked.value === "mark-unread") {
|
||||||
for (const threadKey of threadKeys) {
|
for (const [threadKey, thread] of selectedTabEntries) {
|
||||||
const thread = threadByKeyRef.current.get(threadKey);
|
|
||||||
markThreadUnread(threadKey, thread?.latestTurn?.completedAt);
|
markThreadUnread(threadKey, thread?.latestTurn?.completedAt);
|
||||||
}
|
}
|
||||||
clearSelection();
|
clearSelection();
|
||||||
@@ -1909,8 +2028,8 @@ export default function SidebarV2() {
|
|||||||
const confirmed = await settlePromise(() =>
|
const confirmed = await settlePromise(() =>
|
||||||
api.dialogs.confirm(
|
api.dialogs.confirm(
|
||||||
[
|
[
|
||||||
`Delete ${count} thread${count === 1 ? "" : "s"}?`,
|
`Delete ${count} task${count === 1 ? "" : "s"}?`,
|
||||||
"This permanently clears conversation history for these threads.",
|
"This permanently clears conversation history for every tab in these tasks.",
|
||||||
].join("\n"),
|
].join("\n"),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -1921,9 +2040,7 @@ export default function SidebarV2() {
|
|||||||
// really gone, or the first delete would treat still-alive batch mates
|
// really gone, or the first delete would treat still-alive batch mates
|
||||||
// as deleted and remove a worktree they still point at.
|
// as deleted and remove a worktree they still point at.
|
||||||
const deletedThreadKeys = new Set<string>();
|
const deletedThreadKeys = new Set<string>();
|
||||||
for (const threadKey of threadKeys) {
|
for (const [threadKey, thread] of selectedTabEntries) {
|
||||||
const thread = threadByKeyRef.current.get(threadKey);
|
|
||||||
if (!thread) continue;
|
|
||||||
const result = await deleteThread(scopeThreadRef(thread.environmentId, thread.id), {
|
const result = await deleteThread(scopeThreadRef(thread.environmentId, thread.id), {
|
||||||
deletedThreadKeys,
|
deletedThreadKeys,
|
||||||
});
|
});
|
||||||
@@ -1953,6 +2070,7 @@ export default function SidebarV2() {
|
|||||||
markThreadUnread,
|
markThreadUnread,
|
||||||
removeFromSelection,
|
removeFromSelection,
|
||||||
serverConfigs,
|
serverConfigs,
|
||||||
|
taskTabsByThreadKey,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -1969,6 +2087,7 @@ export default function SidebarV2() {
|
|||||||
}
|
}
|
||||||
const thread = threadByKeyRef.current.get(threadKey);
|
const thread = threadByKeyRef.current.get(threadKey);
|
||||||
if (!thread) return;
|
if (!thread) return;
|
||||||
|
const taskTabs = taskTabsForRef(threadRef);
|
||||||
// Un-settle works on every settled row: for explicit settles it
|
// Un-settle works on every settled row: for explicit settles it
|
||||||
// clears the override, for auto-settled rows it pins the thread
|
// clears the override, for auto-settled rows it pins the thread
|
||||||
// active until real activity clears the pin. Environments without
|
// active until real activity clears the pin. Environments without
|
||||||
@@ -1996,8 +2115,8 @@ export default function SidebarV2() {
|
|||||||
...(supportsSettlement
|
...(supportsSettlement
|
||||||
? [
|
? [
|
||||||
isSettled
|
isSettled
|
||||||
? { id: "unsettle", label: "Un-settle thread" }
|
? { id: "unsettle", label: "Un-settle task" }
|
||||||
: { id: "settle", label: "Settle thread" },
|
: { id: "settle", label: "Settle task" },
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
...(supportsSnooze
|
...(supportsSnooze
|
||||||
@@ -2015,9 +2134,9 @@ export default function SidebarV2() {
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
{ id: "rename", label: "Rename thread" },
|
{ id: "rename", label: "Rename task" },
|
||||||
{ id: "mark-unread", label: "Mark unread" },
|
{ id: "mark-unread", label: "Mark unread" },
|
||||||
{ id: "delete", label: "Delete", destructive: true, icon: "trash" },
|
{ id: "delete", label: "Delete task", destructive: true, icon: "trash" },
|
||||||
],
|
],
|
||||||
position,
|
position,
|
||||||
),
|
),
|
||||||
@@ -2027,7 +2146,7 @@ export default function SidebarV2() {
|
|||||||
const preset = snoozePresets.find(
|
const preset = snoozePresets.find(
|
||||||
(candidate) => `snooze:${candidate.id}` === clicked.value,
|
(candidate) => `snooze:${candidate.id}` === clicked.value,
|
||||||
);
|
);
|
||||||
if (preset) attemptSnooze(threadRef, preset);
|
if (preset) attemptSnoozeTask(threadRef, preset);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (clicked.value) {
|
switch (clicked.value) {
|
||||||
@@ -2055,43 +2174,53 @@ export default function SidebarV2() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case "settle":
|
case "settle":
|
||||||
attemptSettle(threadRef);
|
attemptSettleTask(threadRef);
|
||||||
return;
|
return;
|
||||||
case "unsettle":
|
case "unsettle":
|
||||||
attemptUnsettle(threadRef);
|
attemptUnsettleTask(threadRef);
|
||||||
return;
|
return;
|
||||||
case "unsnooze":
|
case "unsnooze":
|
||||||
attemptUnsnooze(threadRef);
|
attemptUnsnoozeTask(threadRef);
|
||||||
return;
|
return;
|
||||||
case "rename":
|
case "rename":
|
||||||
startThreadRename(threadRef, thread.title);
|
startThreadRename(threadRef, thread.title);
|
||||||
return;
|
return;
|
||||||
case "mark-unread":
|
case "mark-unread":
|
||||||
markThreadUnread(threadKey, thread.latestTurn?.completedAt);
|
for (const tab of taskTabs) {
|
||||||
|
markThreadUnread(
|
||||||
|
scopedThreadKey(scopeThreadRef(tab.environmentId, tab.id)),
|
||||||
|
tab.latestTurn?.completedAt,
|
||||||
|
);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
case "delete": {
|
case "delete": {
|
||||||
if (confirmThreadDelete) {
|
if (confirmThreadDelete) {
|
||||||
const confirmed = await settlePromise(() =>
|
const confirmed = await settlePromise(() =>
|
||||||
api.dialogs.confirm(
|
api.dialogs.confirm(
|
||||||
[
|
[
|
||||||
`Delete thread "${thread.title}"?`,
|
`Delete task "${thread.title}" and its ${taskTabs.length} tab${taskTabs.length === 1 ? "" : "s"}?`,
|
||||||
"This permanently clears conversation history for this thread.",
|
"This permanently clears conversation history for every tab in the task.",
|
||||||
].join("\n"),
|
].join("\n"),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (confirmed._tag === "Failure" || !confirmed.value) return;
|
if (confirmed._tag === "Failure" || !confirmed.value) return;
|
||||||
}
|
}
|
||||||
const result = await deleteThread(threadRef);
|
const deletedThreadKeys = new Set<string>();
|
||||||
if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
|
for (const tab of taskTabs) {
|
||||||
const error = squashAtomCommandFailure(result);
|
const tabRef = scopeThreadRef(tab.environmentId, tab.id);
|
||||||
toastManager.add(
|
const result = await deleteThread(tabRef, { deletedThreadKeys });
|
||||||
stackedThreadToast({
|
if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
|
||||||
type: "error",
|
const error = squashAtomCommandFailure(result);
|
||||||
title: "Failed to delete thread",
|
toastManager.add(
|
||||||
description: error instanceof Error ? error.message : "An error occurred.",
|
stackedThreadToast({
|
||||||
}),
|
type: "error",
|
||||||
);
|
title: "Failed to delete task",
|
||||||
return;
|
description: error instanceof Error ? error.message : "An error occurred.",
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
deletedThreadKeys.add(scopedThreadKey(tabRef));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2101,16 +2230,17 @@ export default function SidebarV2() {
|
|||||||
})();
|
})();
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
attemptSettle,
|
attemptSettleTask,
|
||||||
attemptSnooze,
|
attemptSnoozeTask,
|
||||||
attemptUnsettle,
|
attemptUnsettleTask,
|
||||||
attemptUnsnooze,
|
attemptUnsnoozeTask,
|
||||||
confirmThreadDelete,
|
confirmThreadDelete,
|
||||||
deleteThread,
|
deleteThread,
|
||||||
handleMultiSelectContextMenu,
|
handleMultiSelectContextMenu,
|
||||||
markThreadUnread,
|
markThreadUnread,
|
||||||
serverConfigs,
|
serverConfigs,
|
||||||
startThreadRename,
|
startThreadRename,
|
||||||
|
taskTabsForRef,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -2223,7 +2353,7 @@ export default function SidebarV2() {
|
|||||||
<SidebarMenuButton
|
<SidebarMenuButton
|
||||||
size="sm"
|
size="sm"
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="Search threads and commands"
|
aria-label="Search tasks and commands"
|
||||||
className="h-8 gap-2 rounded-md border-0 bg-transparent px-2 py-1.5 text-sm font-medium text-sidebar-muted-foreground hover:bg-sidebar-row-hover hover:text-sidebar-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-sidebar"
|
className="h-8 gap-2 rounded-md border-0 bg-transparent px-2 py-1.5 text-sm font-medium text-sidebar-muted-foreground hover:bg-sidebar-row-hover hover:text-sidebar-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-sidebar"
|
||||||
data-testid="command-palette-trigger"
|
data-testid="command-palette-trigger"
|
||||||
/>
|
/>
|
||||||
@@ -2248,7 +2378,7 @@ export default function SidebarV2() {
|
|||||||
className="relative size-8 justify-center rounded-md border-0 bg-transparent p-0 text-sidebar-muted-foreground hover:bg-sidebar-row-hover hover:text-sidebar-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-sidebar"
|
className="relative size-8 justify-center rounded-md border-0 bg-transparent p-0 text-sidebar-muted-foreground hover:bg-sidebar-row-hover hover:text-sidebar-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-sidebar"
|
||||||
onClick={handleNewThreadClick}
|
onClick={handleNewThreadClick}
|
||||||
disabled={projects.length === 0}
|
disabled={projects.length === 0}
|
||||||
aria-label="New thread"
|
aria-label="New task"
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
@@ -2259,7 +2389,7 @@ export default function SidebarV2() {
|
|||||||
/>
|
/>
|
||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
<TooltipPopup side="right">
|
<TooltipPopup side="right">
|
||||||
{newThreadShortcutLabel ? `New thread (${newThreadShortcutLabel})` : "New thread"}
|
{newThreadShortcutLabel ? `New task (${newThreadShortcutLabel})` : "New task"}
|
||||||
</TooltipPopup>
|
</TooltipPopup>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
@@ -2270,7 +2400,7 @@ export default function SidebarV2() {
|
|||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
<Menu open={projectScopeMenuOpen} onOpenChange={setProjectScopeMenuOpen}>
|
<Menu open={projectScopeMenuOpen} onOpenChange={setProjectScopeMenuOpen}>
|
||||||
<MenuTrigger
|
<MenuTrigger
|
||||||
aria-label="Filter threads by project"
|
aria-label="Filter tasks by project"
|
||||||
className="flex h-8 min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-md px-2 text-left text-sm font-medium text-sidebar-muted-foreground outline-none hover:bg-sidebar-row-hover hover:text-sidebar-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-sidebar"
|
className="flex h-8 min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-md px-2 text-left text-sm font-medium text-sidebar-muted-foreground outline-none hover:bg-sidebar-row-hover hover:text-sidebar-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-sidebar"
|
||||||
>
|
>
|
||||||
{scopedProjectGroup ? (
|
{scopedProjectGroup ? (
|
||||||
@@ -2419,7 +2549,8 @@ export default function SidebarV2() {
|
|||||||
// the wake signal must survive the trip. Still-snoozed
|
// the wake signal must survive the trip. Still-snoozed
|
||||||
// rows resolve to null on their own.
|
// rows resolve to null on their own.
|
||||||
wokeAt={threadWokeAt(thread, { now: snoozeNow })}
|
wokeAt={threadWokeAt(thread, { now: snoozeNow })}
|
||||||
isActive={routeThreadKey === threadKey}
|
tabCount={taskTabCountByKey.get(workspaceTaskKey(thread)) ?? 1}
|
||||||
|
isActive={routeTaskKey === workspaceTaskKey(thread)}
|
||||||
jumpLabel={showJumpHints ? (jumpLabelByKey.get(threadKey) ?? null) : null}
|
jumpLabel={showJumpHints ? (jumpLabelByKey.get(threadKey) ?? null) : null}
|
||||||
currentEnvironmentId={primaryEnvironmentId}
|
currentEnvironmentId={primaryEnvironmentId}
|
||||||
environmentLabel={environmentLabelById.get(thread.environmentId) ?? null}
|
environmentLabel={environmentLabelById.get(thread.environmentId) ?? null}
|
||||||
@@ -2441,10 +2572,10 @@ export default function SidebarV2() {
|
|||||||
isRenaming={renamingThreadKey === threadKey}
|
isRenaming={renamingThreadKey === threadKey}
|
||||||
renamingTitle={renamingThreadKey === threadKey ? renamingTitle : ""}
|
renamingTitle={renamingThreadKey === threadKey ? renamingTitle : ""}
|
||||||
onContextMenu={handleThreadContextMenu}
|
onContextMenu={handleThreadContextMenu}
|
||||||
onSettle={attemptSettle}
|
onSettle={attemptSettleTask}
|
||||||
onUnsettle={attemptUnsettle}
|
onUnsettle={attemptUnsettleTask}
|
||||||
onSnooze={attemptSnooze}
|
onSnooze={attemptSnoozeTask}
|
||||||
onUnsnooze={attemptUnsnooze}
|
onUnsnooze={attemptUnsnoozeTask}
|
||||||
onChangeRequestState={handleChangeRequestState}
|
onChangeRequestState={handleChangeRequestState}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -2546,9 +2677,9 @@ export default function SidebarV2() {
|
|||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
) : scopedProjectGroup ? (
|
) : scopedProjectGroup ? (
|
||||||
`No threads in ${scopedProjectGroup.displayName} yet`
|
`No tasks in ${scopedProjectGroup.displayName} yet`
|
||||||
) : (
|
) : (
|
||||||
"No threads yet"
|
"No tasks yet"
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|||||||
@@ -0,0 +1,289 @@
|
|||||||
|
import {
|
||||||
|
CircleDashedIcon,
|
||||||
|
CopyPlusIcon,
|
||||||
|
HistoryIcon,
|
||||||
|
PlusIcon,
|
||||||
|
RotateCcwIcon,
|
||||||
|
XIcon,
|
||||||
|
} from "lucide-react";
|
||||||
|
import { useMemo, useState } from "react";
|
||||||
|
|
||||||
|
import { shortcutLabelForCommand } from "../keybindings";
|
||||||
|
import { useClientSettings } from "../hooks/useSettings";
|
||||||
|
import {
|
||||||
|
type ClosedWorkspaceTaskTab,
|
||||||
|
type WorkspaceTaskTab,
|
||||||
|
useWorkspaceTaskTabs,
|
||||||
|
} from "../hooks/useWorkspaceTaskTabs";
|
||||||
|
import {
|
||||||
|
describeTaskTabContexts,
|
||||||
|
type TaskTabContextDescriptor,
|
||||||
|
type TaskTabContextSource,
|
||||||
|
} from "../lib/taskTabContext";
|
||||||
|
import { cn } from "../lib/utils";
|
||||||
|
import { Menu, MenuItem, MenuPopup, MenuShortcut, MenuTrigger } from "./ui/menu";
|
||||||
|
import { Tooltip, TooltipPopup, TooltipProvider, TooltipTrigger } from "./ui/tooltip";
|
||||||
|
|
||||||
|
type AnyWorkspaceTaskTab = WorkspaceTaskTab | ClosedWorkspaceTaskTab;
|
||||||
|
|
||||||
|
function tabContextSource(tab: AnyWorkspaceTaskTab): TaskTabContextSource {
|
||||||
|
return {
|
||||||
|
kind: tab.kind,
|
||||||
|
threadId: String(tab.kind === "server" ? tab.threadRef.threadId : tab.threadId),
|
||||||
|
title: tab.title,
|
||||||
|
position: tab.position,
|
||||||
|
forkProvenance: tab.forkProvenance
|
||||||
|
? {
|
||||||
|
mode: tab.forkProvenance.mode,
|
||||||
|
sourceThreadId:
|
||||||
|
tab.forkProvenance.sourceThreadId === null
|
||||||
|
? null
|
||||||
|
: String(tab.forkProvenance.sourceThreadId),
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* State is carried by shape and text as well as hue: blocked tabs get a filled
|
||||||
|
* ring plus "Waiting on you", working tabs get a dashed spinner glyph.
|
||||||
|
*/
|
||||||
|
function TabStateGlyph(props: { tab: WorkspaceTaskTab }) {
|
||||||
|
const { tab } = props;
|
||||||
|
if (tab.blocked) {
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
role="img"
|
||||||
|
aria-label="Waiting on you"
|
||||||
|
className="inline-flex size-3.5 shrink-0 items-center justify-center rounded-full border-[1.5px] border-amber-500 text-amber-600 dark:text-amber-400"
|
||||||
|
>
|
||||||
|
<span aria-hidden className="size-1.5 rounded-full bg-current" />
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (tab.working) {
|
||||||
|
return (
|
||||||
|
<CircleDashedIcon
|
||||||
|
role="img"
|
||||||
|
aria-label="Working"
|
||||||
|
className="size-3.5 shrink-0 animate-status-pulse text-sky-600 motion-reduce:animate-none dark:text-sky-400"
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ContextSummary(props: {
|
||||||
|
context: TaskTabContextDescriptor;
|
||||||
|
active: boolean;
|
||||||
|
className?: string;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
aria-hidden
|
||||||
|
className={cn(
|
||||||
|
"hidden shrink-0 truncate text-[10px] font-normal whitespace-nowrap md:inline",
|
||||||
|
props.active ? "text-muted-foreground/80" : "text-muted-foreground/55",
|
||||||
|
props.className,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
· {props.context.label}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function WorkspaceTaskTabs() {
|
||||||
|
const sidebarV2Enabled = useClientSettings((settings) => settings.sidebarV2Enabled);
|
||||||
|
const {
|
||||||
|
tabs,
|
||||||
|
closedTabs,
|
||||||
|
keybindings,
|
||||||
|
hasTask,
|
||||||
|
canForkContext,
|
||||||
|
createTab,
|
||||||
|
closeTab,
|
||||||
|
reopenTab,
|
||||||
|
navigateToTab,
|
||||||
|
} = useWorkspaceTaskTabs();
|
||||||
|
const [creatingMode, setCreatingMode] = useState<"fresh" | "portable" | null>(null);
|
||||||
|
const [reopeningKey, setReopeningKey] = useState<string | null>(null);
|
||||||
|
const contextByTabKey = useMemo(() => {
|
||||||
|
const allTabs = [...tabs, ...closedTabs];
|
||||||
|
const contexts = describeTaskTabContexts(allTabs.map(tabContextSource));
|
||||||
|
return new Map(allTabs.map((tab, index) => [tab.key, contexts[index]!]));
|
||||||
|
}, [closedTabs, tabs]);
|
||||||
|
|
||||||
|
if (!sidebarV2Enabled || !hasTask) return null;
|
||||||
|
|
||||||
|
const newTabShortcut = shortcutLabelForCommand(keybindings, "chat.newTab");
|
||||||
|
const reopenShortcut = shortcutLabelForCommand(keybindings, "chat.reopenClosedTab");
|
||||||
|
const create = (mode: "fresh" | "portable") => {
|
||||||
|
if (creatingMode !== null) return;
|
||||||
|
setCreatingMode(mode);
|
||||||
|
void createTab(mode).finally(() => setCreatingMode(null));
|
||||||
|
};
|
||||||
|
const reopen = (tab: ClosedWorkspaceTaskTab) => {
|
||||||
|
if (reopeningKey !== null) return;
|
||||||
|
setReopeningKey(tab.key);
|
||||||
|
void reopenTab(tab).finally(() => setReopeningKey(null));
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TooltipProvider delay={250} closeDelay={0}>
|
||||||
|
<nav
|
||||||
|
aria-label="Task tabs"
|
||||||
|
data-testid="workspace-task-tabs"
|
||||||
|
className="flex h-9 shrink-0 items-center gap-2 border-b border-border/60 bg-background px-3 sm:px-5"
|
||||||
|
>
|
||||||
|
<div className="flex min-w-0 flex-1 items-center gap-0.5 overflow-x-auto rounded-md bg-muted/40 p-0.5 [scrollbar-width:none]">
|
||||||
|
{tabs.map((tab) => {
|
||||||
|
const context = contextByTabKey.get(tab.key);
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={tab.key}
|
||||||
|
className={cn(
|
||||||
|
"group/task-tab relative flex h-7 max-w-64 min-w-0 shrink-0 items-center rounded-[5px] pr-1 pl-2 text-xs transition-colors",
|
||||||
|
tab.active
|
||||||
|
? "bg-background text-foreground shadow-xs ring-1 ring-border/70"
|
||||||
|
: "text-muted-foreground hover:bg-background/60 hover:text-foreground",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger
|
||||||
|
render={
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="flex min-w-0 flex-1 items-center gap-1.5 text-left outline-none"
|
||||||
|
onClick={() => void navigateToTab(tab)}
|
||||||
|
aria-current={tab.active ? "page" : undefined}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<TabStateGlyph tab={tab} />
|
||||||
|
<span className="truncate font-medium">
|
||||||
|
{context?.title ?? tab.title}
|
||||||
|
{context ? <span className="sr-only"> — {context.label}</span> : null}
|
||||||
|
</span>
|
||||||
|
{context ? <ContextSummary context={context} active={tab.active} /> : null}
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipPopup side="bottom" className="max-w-56">
|
||||||
|
<span className="block text-left">
|
||||||
|
<span className="font-medium text-foreground">
|
||||||
|
{context?.label ?? "Independent"}
|
||||||
|
</span>
|
||||||
|
{context ? (
|
||||||
|
<span className="ml-1.5 text-muted-foreground">{context.detail}</span>
|
||||||
|
) : null}
|
||||||
|
</span>
|
||||||
|
</TooltipPopup>
|
||||||
|
</Tooltip>
|
||||||
|
{tabs.length > 1 ? (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
aria-label={`Close ${context?.title ?? tab.title}`}
|
||||||
|
disabled={tab.working || tab.blocked}
|
||||||
|
onClick={(event) => {
|
||||||
|
event.stopPropagation();
|
||||||
|
void closeTab(tab);
|
||||||
|
}}
|
||||||
|
className="ml-1 inline-flex size-4 shrink-0 items-center justify-center rounded-sm text-muted-foreground/50 opacity-0 transition-opacity hover:bg-muted hover:text-foreground focus-visible:opacity-100 disabled:cursor-not-allowed disabled:opacity-20 group-hover/task-tab:opacity-100"
|
||||||
|
>
|
||||||
|
<XIcon className="size-3" />
|
||||||
|
</button>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex shrink-0 items-center gap-0.5">
|
||||||
|
{closedTabs.length > 0 ? (
|
||||||
|
<Menu>
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger
|
||||||
|
render={
|
||||||
|
<MenuTrigger
|
||||||
|
render={
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
aria-label="Closed tabs"
|
||||||
|
className="inline-flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<HistoryIcon className="size-3.5" />
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipPopup side="bottom">
|
||||||
|
Closed tabs{reopenShortcut ? ` (${reopenShortcut})` : ""}
|
||||||
|
</TooltipPopup>
|
||||||
|
</Tooltip>
|
||||||
|
<MenuPopup align="end" className="min-w-52 max-w-72">
|
||||||
|
{closedTabs.map((tab, index) => {
|
||||||
|
const context = contextByTabKey.get(tab.key);
|
||||||
|
return (
|
||||||
|
<MenuItem
|
||||||
|
key={tab.key}
|
||||||
|
disabled={reopeningKey !== null}
|
||||||
|
onClick={() => reopen(tab)}
|
||||||
|
>
|
||||||
|
<RotateCcwIcon />
|
||||||
|
<span className="min-w-0 flex-1 truncate">{context?.title ?? tab.title}</span>
|
||||||
|
{context ? (
|
||||||
|
<span className="max-w-28 truncate text-xs text-muted-foreground">
|
||||||
|
{context.label}
|
||||||
|
</span>
|
||||||
|
) : null}
|
||||||
|
{index === 0 && reopenShortcut ? (
|
||||||
|
<MenuShortcut>{reopenShortcut}</MenuShortcut>
|
||||||
|
) : null}
|
||||||
|
</MenuItem>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</MenuPopup>
|
||||||
|
</Menu>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<Menu>
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger
|
||||||
|
render={
|
||||||
|
<MenuTrigger
|
||||||
|
render={
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
aria-label="New tab"
|
||||||
|
disabled={creatingMode !== null}
|
||||||
|
className="inline-flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<PlusIcon className="size-4" />
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipPopup side="bottom">
|
||||||
|
New tab{newTabShortcut ? ` (${newTabShortcut})` : ""}
|
||||||
|
</TooltipPopup>
|
||||||
|
</Tooltip>
|
||||||
|
<MenuPopup align="end" className="min-w-48">
|
||||||
|
<MenuItem disabled={creatingMode !== null} onClick={() => create("fresh")}>
|
||||||
|
<PlusIcon />
|
||||||
|
Empty
|
||||||
|
{newTabShortcut ? <MenuShortcut>{newTabShortcut}</MenuShortcut> : null}
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem
|
||||||
|
disabled={!canForkContext || creatingMode !== null}
|
||||||
|
onClick={() => create("portable")}
|
||||||
|
>
|
||||||
|
<CopyPlusIcon />
|
||||||
|
Copy current context
|
||||||
|
</MenuItem>
|
||||||
|
</MenuPopup>
|
||||||
|
</Menu>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</TooltipProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -62,7 +62,7 @@ export function BetaSettingsPanel() {
|
|||||||
<SettingsSection title="Beta features">
|
<SettingsSection title="Beta features">
|
||||||
<SettingsRow
|
<SettingsRow
|
||||||
title="Sidebar v2"
|
title="Sidebar v2"
|
||||||
description="One flat thread list in creation order. Active work renders as rich cards; settled threads collapse to compact rows. Settling requires an up-to-date server — on older servers threads simply stay active. Switch back any time."
|
description="Treat sidebar items as tasks. Each task can hold multiple provider tabs that share one worktree; active work renders as rich cards and settled tasks collapse to compact rows. Switch back any time."
|
||||||
control={
|
control={
|
||||||
<Switch
|
<Switch
|
||||||
checked={sidebarV2Enabled}
|
checked={sidebarV2Enabled}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
ProviderDriverKind,
|
ProviderDriverKind,
|
||||||
ProviderInstanceId,
|
ProviderInstanceId,
|
||||||
ThreadId,
|
ThreadId,
|
||||||
|
WorkspaceTaskId,
|
||||||
type ModelSelection,
|
type ModelSelection,
|
||||||
type ProviderOptionSelection,
|
type ProviderOptionSelection,
|
||||||
} from "@t3tools/contracts";
|
} from "@t3tools/contracts";
|
||||||
@@ -850,6 +851,102 @@ describe("composerDraftStore project draft thread mapping", () => {
|
|||||||
expect(draftByKey(draftId)).toBeUndefined();
|
expect(draftByKey(draftId)).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("retains sibling task-tab drafts and their fork metadata when remapping the project", () => {
|
||||||
|
const store = useComposerDraftStore.getState();
|
||||||
|
const workspaceTaskId = WorkspaceTaskId.make("task-a");
|
||||||
|
store.setProjectDraftThreadId(projectRef, draftId, {
|
||||||
|
threadId,
|
||||||
|
workspaceTaskId,
|
||||||
|
tabPosition: 0,
|
||||||
|
retainPreviousDraft: true,
|
||||||
|
});
|
||||||
|
store.setPrompt(draftId, "main tab draft");
|
||||||
|
|
||||||
|
store.setProjectDraftThreadId(projectRef, otherDraftId, {
|
||||||
|
threadId: otherThreadId,
|
||||||
|
workspaceTaskId,
|
||||||
|
tabPosition: 1,
|
||||||
|
forkProvenance: {
|
||||||
|
mode: "portable",
|
||||||
|
sourceThreadId: threadId,
|
||||||
|
createdAt: "2026-07-24T00:00:00.000Z",
|
||||||
|
},
|
||||||
|
retainPreviousDraft: true,
|
||||||
|
});
|
||||||
|
store.setPrompt(otherDraftId, "fork tab draft");
|
||||||
|
|
||||||
|
// Other call sites remap an already-existing draft without passing the
|
||||||
|
// creation-only retention option. Task identity itself must keep the
|
||||||
|
// sibling registered and preserve its unsent composer.
|
||||||
|
store.setProjectDraftThreadId(projectRef, draftId, { threadId });
|
||||||
|
|
||||||
|
expect(useComposerDraftStore.getState().getDraftThread(draftId)).toMatchObject({
|
||||||
|
threadId,
|
||||||
|
workspaceTaskId,
|
||||||
|
tabPosition: 0,
|
||||||
|
});
|
||||||
|
expect(draftByKey(draftId)?.prompt).toBe("main tab draft");
|
||||||
|
expect(useComposerDraftStore.getState().getDraftThread(otherDraftId)).toMatchObject({
|
||||||
|
threadId: otherThreadId,
|
||||||
|
workspaceTaskId,
|
||||||
|
tabPosition: 1,
|
||||||
|
forkProvenance: {
|
||||||
|
mode: "portable",
|
||||||
|
sourceThreadId: threadId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
expect(draftByKey(otherDraftId)?.prompt).toBe("fork tab draft");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("soft-closes and reopens draft tabs without losing composer state", () => {
|
||||||
|
const store = useComposerDraftStore.getState();
|
||||||
|
const closedAt = "2026-07-27T12:00:00.000Z";
|
||||||
|
store.setProjectDraftThreadId(projectRef, draftId, {
|
||||||
|
threadId,
|
||||||
|
workspaceTaskId: WorkspaceTaskId.make("task-a"),
|
||||||
|
tabPosition: 1,
|
||||||
|
});
|
||||||
|
store.setPrompt(draftId, "keep this unsent");
|
||||||
|
|
||||||
|
store.setDraftThreadContext(draftId, { tabClosedAt: closedAt });
|
||||||
|
|
||||||
|
expect(useComposerDraftStore.getState().getDraftThread(draftId)?.tabClosedAt).toBe(closedAt);
|
||||||
|
expect(draftByKey(draftId)?.prompt).toBe("keep this unsent");
|
||||||
|
|
||||||
|
const persistApi = useComposerDraftStore.persist as unknown as {
|
||||||
|
getOptions: () => {
|
||||||
|
partialize: (state: ReturnType<typeof useComposerDraftStore.getState>) => unknown;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
const persistedState = persistApi.getOptions().partialize(useComposerDraftStore.getState()) as {
|
||||||
|
draftThreadsByThreadKey?: Record<string, { tabClosedAt?: string }>;
|
||||||
|
};
|
||||||
|
expect(persistedState.draftThreadsByThreadKey?.[draftId]?.tabClosedAt).toBe(closedAt);
|
||||||
|
|
||||||
|
store.setDraftThreadContext(draftId, { tabClosedAt: null });
|
||||||
|
expect(useComposerDraftStore.getState().getDraftThread(draftId)?.tabClosedAt).toBeNull();
|
||||||
|
expect(draftByKey(draftId)?.prompt).toBe("keep this unsent");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("retains a closed draft when its project mapping moves to another task", () => {
|
||||||
|
const store = useComposerDraftStore.getState();
|
||||||
|
store.setProjectDraftThreadId(projectRef, draftId, {
|
||||||
|
threadId,
|
||||||
|
workspaceTaskId: WorkspaceTaskId.make("task-a"),
|
||||||
|
tabPosition: 1,
|
||||||
|
});
|
||||||
|
store.setPrompt(draftId, "restore me later");
|
||||||
|
store.setDraftThreadContext(draftId, { tabClosedAt: "2026-07-27T12:00:00.000Z" });
|
||||||
|
|
||||||
|
store.setProjectDraftThreadId(projectRef, otherDraftId, {
|
||||||
|
threadId: otherThreadId,
|
||||||
|
workspaceTaskId: WorkspaceTaskId.make("task-b"),
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(useComposerDraftStore.getState().getDraftThread(draftId)?.tabClosedAt).not.toBeNull();
|
||||||
|
expect(draftByKey(draftId)?.prompt).toBe("restore me later");
|
||||||
|
});
|
||||||
|
|
||||||
it("keeps composer drafts when the thread is still mapped by another project", () => {
|
it("keeps composer drafts when the thread is still mapped by another project", () => {
|
||||||
const store = useComposerDraftStore.getState();
|
const store = useComposerDraftStore.getState();
|
||||||
store.setProjectDraftThreadId(projectRef, draftId, { threadId });
|
store.setProjectDraftThreadId(projectRef, draftId, { threadId });
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ import {
|
|||||||
type ServerProvider,
|
type ServerProvider,
|
||||||
type ScopedProjectRef,
|
type ScopedProjectRef,
|
||||||
type ScopedThreadRef,
|
type ScopedThreadRef,
|
||||||
|
ThreadForkProvenance,
|
||||||
ThreadId,
|
ThreadId,
|
||||||
|
WorkspaceTaskId,
|
||||||
} from "@t3tools/contracts";
|
} from "@t3tools/contracts";
|
||||||
import {
|
import {
|
||||||
parseScopedProjectKey,
|
parseScopedProjectKey,
|
||||||
@@ -55,6 +57,7 @@ import { ReviewCommentContextSchema, type ReviewCommentContext } from "./reviewC
|
|||||||
const isRuntimeMode = Schema.is(RuntimeMode);
|
const isRuntimeMode = Schema.is(RuntimeMode);
|
||||||
const isProviderDriverKind = Schema.is(ProviderDriverKind);
|
const isProviderDriverKind = Schema.is(ProviderDriverKind);
|
||||||
const isReviewCommentContext = Schema.is(ReviewCommentContextSchema);
|
const isReviewCommentContext = Schema.is(ReviewCommentContextSchema);
|
||||||
|
const isThreadForkProvenance = Schema.is(ThreadForkProvenance);
|
||||||
|
|
||||||
export const COMPOSER_DRAFT_STORAGE_KEY = "t3code:composer-drafts:v1";
|
export const COMPOSER_DRAFT_STORAGE_KEY = "t3code:composer-drafts:v1";
|
||||||
const COMPOSER_DRAFT_STORAGE_VERSION = 8;
|
const COMPOSER_DRAFT_STORAGE_VERSION = 8;
|
||||||
@@ -206,6 +209,11 @@ type LegacyPersistedComposerDraftStoreState = PersistedComposerDraftStoreState &
|
|||||||
|
|
||||||
const PersistedDraftThreadState = Schema.Struct({
|
const PersistedDraftThreadState = Schema.Struct({
|
||||||
threadId: ThreadId,
|
threadId: ThreadId,
|
||||||
|
workspaceTaskId: Schema.optionalKey(WorkspaceTaskId),
|
||||||
|
tabLabel: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
||||||
|
tabPosition: Schema.optionalKey(Schema.Number),
|
||||||
|
forkProvenance: Schema.optionalKey(Schema.NullOr(ThreadForkProvenance)),
|
||||||
|
tabClosedAt: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
||||||
environmentId: Schema.String,
|
environmentId: Schema.String,
|
||||||
projectId: ProjectId,
|
projectId: ProjectId,
|
||||||
logicalProjectKey: Schema.optionalKey(Schema.String),
|
logicalProjectKey: Schema.optionalKey(Schema.String),
|
||||||
@@ -285,6 +293,11 @@ export interface ComposerThreadDraftState {
|
|||||||
*/
|
*/
|
||||||
export interface DraftSessionState {
|
export interface DraftSessionState {
|
||||||
threadId: ThreadId;
|
threadId: ThreadId;
|
||||||
|
workspaceTaskId?: WorkspaceTaskId | undefined;
|
||||||
|
tabLabel?: string | null | undefined;
|
||||||
|
tabPosition?: number | undefined;
|
||||||
|
forkProvenance?: ThreadForkProvenance | null | undefined;
|
||||||
|
tabClosedAt: string | null;
|
||||||
environmentId: EnvironmentId;
|
environmentId: EnvironmentId;
|
||||||
projectId: ProjectId;
|
projectId: ProjectId;
|
||||||
logicalProjectKey: string;
|
logicalProjectKey: string;
|
||||||
@@ -359,6 +372,12 @@ interface ComposerDraftStoreState {
|
|||||||
startFromOrigin?: boolean;
|
startFromOrigin?: boolean;
|
||||||
runtimeMode?: RuntimeMode;
|
runtimeMode?: RuntimeMode;
|
||||||
interactionMode?: ProviderInteractionMode;
|
interactionMode?: ProviderInteractionMode;
|
||||||
|
workspaceTaskId?: WorkspaceTaskId;
|
||||||
|
tabLabel?: string | null;
|
||||||
|
tabPosition?: number;
|
||||||
|
forkProvenance?: ThreadForkProvenance | null;
|
||||||
|
tabClosedAt?: string | null;
|
||||||
|
retainPreviousDraft?: boolean;
|
||||||
},
|
},
|
||||||
) => void;
|
) => void;
|
||||||
/** Creates or updates the draft session tracked for a concrete project ref. */
|
/** Creates or updates the draft session tracked for a concrete project ref. */
|
||||||
@@ -374,6 +393,12 @@ interface ComposerDraftStoreState {
|
|||||||
startFromOrigin?: boolean;
|
startFromOrigin?: boolean;
|
||||||
runtimeMode?: RuntimeMode;
|
runtimeMode?: RuntimeMode;
|
||||||
interactionMode?: ProviderInteractionMode;
|
interactionMode?: ProviderInteractionMode;
|
||||||
|
workspaceTaskId?: WorkspaceTaskId;
|
||||||
|
tabLabel?: string | null;
|
||||||
|
tabPosition?: number;
|
||||||
|
forkProvenance?: ThreadForkProvenance | null;
|
||||||
|
tabClosedAt?: string | null;
|
||||||
|
retainPreviousDraft?: boolean;
|
||||||
},
|
},
|
||||||
) => void;
|
) => void;
|
||||||
/** Updates mutable draft-session metadata without touching composer content. */
|
/** Updates mutable draft-session metadata without touching composer content. */
|
||||||
@@ -388,6 +413,7 @@ interface ComposerDraftStoreState {
|
|||||||
startFromOrigin?: boolean;
|
startFromOrigin?: boolean;
|
||||||
runtimeMode?: RuntimeMode;
|
runtimeMode?: RuntimeMode;
|
||||||
interactionMode?: ProviderInteractionMode;
|
interactionMode?: ProviderInteractionMode;
|
||||||
|
tabClosedAt?: string | null;
|
||||||
},
|
},
|
||||||
) => void;
|
) => void;
|
||||||
clearProjectDraftThreadId: (projectRef: ScopedProjectRef) => void;
|
clearProjectDraftThreadId: (projectRef: ScopedProjectRef) => void;
|
||||||
@@ -1331,6 +1357,12 @@ function createDraftThreadState(
|
|||||||
startFromOrigin?: boolean;
|
startFromOrigin?: boolean;
|
||||||
runtimeMode?: RuntimeMode;
|
runtimeMode?: RuntimeMode;
|
||||||
interactionMode?: ProviderInteractionMode;
|
interactionMode?: ProviderInteractionMode;
|
||||||
|
workspaceTaskId?: WorkspaceTaskId;
|
||||||
|
tabLabel?: string | null;
|
||||||
|
tabPosition?: number;
|
||||||
|
forkProvenance?: ThreadForkProvenance | null;
|
||||||
|
tabClosedAt?: string | null;
|
||||||
|
retainPreviousDraft?: boolean;
|
||||||
},
|
},
|
||||||
): DraftThreadState {
|
): DraftThreadState {
|
||||||
const projectChanged =
|
const projectChanged =
|
||||||
@@ -1357,6 +1389,14 @@ function createDraftThreadState(
|
|||||||
: options.startFromOrigin;
|
: options.startFromOrigin;
|
||||||
return {
|
return {
|
||||||
threadId,
|
threadId,
|
||||||
|
workspaceTaskId: options?.workspaceTaskId ?? existingThread?.workspaceTaskId,
|
||||||
|
tabLabel: options?.tabLabel ?? existingThread?.tabLabel ?? null,
|
||||||
|
tabPosition: options?.tabPosition ?? existingThread?.tabPosition ?? 0,
|
||||||
|
forkProvenance: options?.forkProvenance ?? existingThread?.forkProvenance ?? null,
|
||||||
|
tabClosedAt:
|
||||||
|
options?.tabClosedAt === undefined
|
||||||
|
? (existingThread?.tabClosedAt ?? null)
|
||||||
|
: options.tabClosedAt,
|
||||||
environmentId: projectRef.environmentId,
|
environmentId: projectRef.environmentId,
|
||||||
projectId: projectRef.projectId,
|
projectId: projectRef.projectId,
|
||||||
logicalProjectKey,
|
logicalProjectKey,
|
||||||
@@ -1396,6 +1436,11 @@ function draftThreadsEqual(left: DraftThreadState | undefined, right: DraftThrea
|
|||||||
return (
|
return (
|
||||||
!!left &&
|
!!left &&
|
||||||
left.threadId === right.threadId &&
|
left.threadId === right.threadId &&
|
||||||
|
left.workspaceTaskId === right.workspaceTaskId &&
|
||||||
|
left.tabLabel === right.tabLabel &&
|
||||||
|
left.tabPosition === right.tabPosition &&
|
||||||
|
Equal.equals(left.forkProvenance, right.forkProvenance) &&
|
||||||
|
left.tabClosedAt === right.tabClosedAt &&
|
||||||
left.environmentId === right.environmentId &&
|
left.environmentId === right.environmentId &&
|
||||||
left.projectId === right.projectId &&
|
left.projectId === right.projectId &&
|
||||||
left.logicalProjectKey === right.logicalProjectKey &&
|
left.logicalProjectKey === right.logicalProjectKey &&
|
||||||
@@ -1524,6 +1569,26 @@ function normalizePersistedDraftThreads(
|
|||||||
const normalizedEnvironmentId = environmentId as EnvironmentId;
|
const normalizedEnvironmentId = environmentId as EnvironmentId;
|
||||||
draftThreadsByThreadKey[threadKey] = {
|
draftThreadsByThreadKey[threadKey] = {
|
||||||
threadId,
|
threadId,
|
||||||
|
...(typeof candidateDraftThread.workspaceTaskId === "string" &&
|
||||||
|
candidateDraftThread.workspaceTaskId.length > 0
|
||||||
|
? {
|
||||||
|
workspaceTaskId: WorkspaceTaskId.make(candidateDraftThread.workspaceTaskId),
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
|
...(typeof candidateDraftThread.tabLabel === "string"
|
||||||
|
? { tabLabel: candidateDraftThread.tabLabel }
|
||||||
|
: {}),
|
||||||
|
...(typeof candidateDraftThread.tabPosition === "number" &&
|
||||||
|
Number.isInteger(candidateDraftThread.tabPosition) &&
|
||||||
|
candidateDraftThread.tabPosition >= 0
|
||||||
|
? { tabPosition: candidateDraftThread.tabPosition }
|
||||||
|
: {}),
|
||||||
|
...(isThreadForkProvenance(candidateDraftThread.forkProvenance)
|
||||||
|
? { forkProvenance: candidateDraftThread.forkProvenance }
|
||||||
|
: {}),
|
||||||
|
...(typeof candidateDraftThread.tabClosedAt === "string"
|
||||||
|
? { tabClosedAt: candidateDraftThread.tabClosedAt }
|
||||||
|
: {}),
|
||||||
environmentId: normalizedEnvironmentId,
|
environmentId: normalizedEnvironmentId,
|
||||||
projectId: projectId as ProjectId,
|
projectId: projectId as ProjectId,
|
||||||
logicalProjectKey:
|
logicalProjectKey:
|
||||||
@@ -1595,6 +1660,7 @@ function normalizePersistedDraftThreads(
|
|||||||
worktreePath: null,
|
worktreePath: null,
|
||||||
envMode: "local",
|
envMode: "local",
|
||||||
startFromOrigin: false,
|
startFromOrigin: false,
|
||||||
|
tabClosedAt: null,
|
||||||
promotedTo: null,
|
promotedTo: null,
|
||||||
};
|
};
|
||||||
} else if (
|
} else if (
|
||||||
@@ -1907,9 +1973,33 @@ function partializeComposerDraftStoreState(
|
|||||||
};
|
};
|
||||||
persistedDraftsByThreadKey[threadKey] = persistedDraft;
|
persistedDraftsByThreadKey[threadKey] = persistedDraft;
|
||||||
}
|
}
|
||||||
|
const persistedDraftThreadsByThreadKey = Object.fromEntries(
|
||||||
|
Object.entries(state.draftThreadsByThreadKey).map(([draftId, draft]) => [
|
||||||
|
draftId,
|
||||||
|
{
|
||||||
|
threadId: draft.threadId,
|
||||||
|
...(draft.workspaceTaskId !== undefined ? { workspaceTaskId: draft.workspaceTaskId } : {}),
|
||||||
|
...(draft.tabLabel !== undefined ? { tabLabel: draft.tabLabel } : {}),
|
||||||
|
...(draft.tabPosition !== undefined ? { tabPosition: draft.tabPosition } : {}),
|
||||||
|
...(draft.forkProvenance !== undefined ? { forkProvenance: draft.forkProvenance } : {}),
|
||||||
|
...(draft.tabClosedAt !== null ? { tabClosedAt: draft.tabClosedAt } : {}),
|
||||||
|
environmentId: draft.environmentId,
|
||||||
|
projectId: draft.projectId,
|
||||||
|
logicalProjectKey: draft.logicalProjectKey,
|
||||||
|
createdAt: draft.createdAt,
|
||||||
|
runtimeMode: draft.runtimeMode,
|
||||||
|
interactionMode: draft.interactionMode,
|
||||||
|
branch: draft.branch,
|
||||||
|
worktreePath: draft.worktreePath,
|
||||||
|
envMode: draft.envMode,
|
||||||
|
startFromOrigin: draft.startFromOrigin,
|
||||||
|
...(draft.promotedTo !== undefined ? { promotedTo: draft.promotedTo } : {}),
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
) as PersistedComposerDraftStoreState["draftThreadsByThreadKey"];
|
||||||
return {
|
return {
|
||||||
draftsByThreadKey: persistedDraftsByThreadKey,
|
draftsByThreadKey: persistedDraftsByThreadKey,
|
||||||
draftThreadsByThreadKey: state.draftThreadsByThreadKey,
|
draftThreadsByThreadKey: persistedDraftThreadsByThreadKey,
|
||||||
logicalProjectDraftThreadKeyByLogicalProjectKey:
|
logicalProjectDraftThreadKeyByLogicalProjectKey:
|
||||||
state.logicalProjectDraftThreadKeyByLogicalProjectKey,
|
state.logicalProjectDraftThreadKeyByLogicalProjectKey,
|
||||||
stickyModelSelectionByProvider: compactModelSelectionByProvider(
|
stickyModelSelectionByProvider: compactModelSelectionByProvider(
|
||||||
@@ -2149,6 +2239,11 @@ function toHydratedDraftThreadState(
|
|||||||
): DraftThreadState {
|
): DraftThreadState {
|
||||||
return {
|
return {
|
||||||
threadId: persistedDraftThread.threadId,
|
threadId: persistedDraftThread.threadId,
|
||||||
|
workspaceTaskId: persistedDraftThread.workspaceTaskId,
|
||||||
|
tabLabel: persistedDraftThread.tabLabel ?? null,
|
||||||
|
tabPosition: persistedDraftThread.tabPosition ?? 0,
|
||||||
|
forkProvenance: persistedDraftThread.forkProvenance ?? null,
|
||||||
|
tabClosedAt: persistedDraftThread.tabClosedAt ?? null,
|
||||||
environmentId: persistedDraftThread.environmentId as EnvironmentId,
|
environmentId: persistedDraftThread.environmentId as EnvironmentId,
|
||||||
projectId: persistedDraftThread.projectId,
|
projectId: persistedDraftThread.projectId,
|
||||||
logicalProjectKey:
|
logicalProjectKey:
|
||||||
@@ -2285,9 +2380,17 @@ const composerDraftStore = create<ComposerDraftStoreState>()(
|
|||||||
previousThreadKeyForLogicalProject === undefined
|
previousThreadKeyForLogicalProject === undefined
|
||||||
? undefined
|
? undefined
|
||||||
: nextDraftThreadsByThreadKey[previousThreadKeyForLogicalProject];
|
: nextDraftThreadsByThreadKey[previousThreadKeyForLogicalProject];
|
||||||
|
const sharesWorkspaceTask =
|
||||||
|
previousDraftThread?.workspaceTaskId !== undefined &&
|
||||||
|
nextDraftThread.workspaceTaskId !== undefined &&
|
||||||
|
previousDraftThread.workspaceTaskId === nextDraftThread.workspaceTaskId;
|
||||||
|
const previousDraftIsClosed = previousDraftThread?.tabClosedAt != null;
|
||||||
if (
|
if (
|
||||||
previousThreadKeyForLogicalProject &&
|
previousThreadKeyForLogicalProject &&
|
||||||
previousThreadKeyForLogicalProject !== draftId &&
|
previousThreadKeyForLogicalProject !== draftId &&
|
||||||
|
options?.retainPreviousDraft !== true &&
|
||||||
|
!sharesWorkspaceTask &&
|
||||||
|
!previousDraftIsClosed &&
|
||||||
!isComposerThreadKeyInUse(
|
!isComposerThreadKeyInUse(
|
||||||
nextLogicalProjectDraftThreadKeyByLogicalProjectKey,
|
nextLogicalProjectDraftThreadKeyByLogicalProjectKey,
|
||||||
previousThreadKeyForLogicalProject,
|
previousThreadKeyForLogicalProject,
|
||||||
@@ -2359,6 +2462,12 @@ const composerDraftStore = create<ComposerDraftStoreState>()(
|
|||||||
: options.startFromOrigin;
|
: options.startFromOrigin;
|
||||||
const nextDraftThread: DraftThreadState = {
|
const nextDraftThread: DraftThreadState = {
|
||||||
threadId: existing.threadId,
|
threadId: existing.threadId,
|
||||||
|
workspaceTaskId: existing.workspaceTaskId,
|
||||||
|
tabLabel: existing.tabLabel,
|
||||||
|
tabPosition: existing.tabPosition,
|
||||||
|
forkProvenance: existing.forkProvenance,
|
||||||
|
tabClosedAt:
|
||||||
|
options.tabClosedAt === undefined ? existing.tabClosedAt : options.tabClosedAt,
|
||||||
environmentId: nextProjectRef.environmentId,
|
environmentId: nextProjectRef.environmentId,
|
||||||
projectId: nextProjectRef.projectId,
|
projectId: nextProjectRef.projectId,
|
||||||
logicalProjectKey: existing.logicalProjectKey,
|
logicalProjectKey: existing.logicalProjectKey,
|
||||||
@@ -2387,6 +2496,7 @@ const composerDraftStore = create<ComposerDraftStoreState>()(
|
|||||||
nextDraftThread.createdAt === existing.createdAt &&
|
nextDraftThread.createdAt === existing.createdAt &&
|
||||||
nextDraftThread.runtimeMode === existing.runtimeMode &&
|
nextDraftThread.runtimeMode === existing.runtimeMode &&
|
||||||
nextDraftThread.interactionMode === existing.interactionMode &&
|
nextDraftThread.interactionMode === existing.interactionMode &&
|
||||||
|
nextDraftThread.tabClosedAt === existing.tabClosedAt &&
|
||||||
nextDraftThread.branch === existing.branch &&
|
nextDraftThread.branch === existing.branch &&
|
||||||
nextDraftThread.worktreePath === existing.worktreePath &&
|
nextDraftThread.worktreePath === existing.worktreePath &&
|
||||||
nextDraftThread.envMode === existing.envMode &&
|
nextDraftThread.envMode === existing.envMode &&
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
scopeProjectRef,
|
scopeProjectRef,
|
||||||
scopeThreadRef,
|
scopeThreadRef,
|
||||||
} from "@t3tools/client-runtime/environment";
|
} from "@t3tools/client-runtime/environment";
|
||||||
import { DEFAULT_RUNTIME_MODE, type ScopedProjectRef } from "@t3tools/contracts";
|
import { DEFAULT_RUNTIME_MODE, type ScopedProjectRef, WorkspaceTaskId } from "@t3tools/contracts";
|
||||||
import { useParams, useRouter } from "@tanstack/react-router";
|
import { useParams, useRouter } from "@tanstack/react-router";
|
||||||
import { useCallback, useMemo } from "react";
|
import { useCallback, useMemo } from "react";
|
||||||
import {
|
import {
|
||||||
@@ -249,6 +249,7 @@ export function useNewThreadHandler() {
|
|||||||
return (async () => {
|
return (async () => {
|
||||||
setLogicalProjectDraftThreadId(logicalProjectKey, projectRef, draftId, {
|
setLogicalProjectDraftThreadId(logicalProjectKey, projectRef, draftId, {
|
||||||
threadId,
|
threadId,
|
||||||
|
workspaceTaskId: WorkspaceTaskId.make(String(threadId)),
|
||||||
createdAt,
|
createdAt,
|
||||||
branch: options?.branch ?? null,
|
branch: options?.branch ?? null,
|
||||||
worktreePath: options?.worktreePath ?? null,
|
worktreePath: options?.worktreePath ?? null,
|
||||||
|
|||||||
@@ -0,0 +1,465 @@
|
|||||||
|
import { useAtomValue } from "@effect/atom-react";
|
||||||
|
import {
|
||||||
|
scopedProjectKey,
|
||||||
|
scopedThreadKey,
|
||||||
|
scopeProjectRef,
|
||||||
|
scopeThreadRef,
|
||||||
|
} from "@t3tools/client-runtime/environment";
|
||||||
|
import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
|
||||||
|
import {
|
||||||
|
type ModelSelection,
|
||||||
|
type ScopedThreadRef,
|
||||||
|
type ThreadForkProvenance,
|
||||||
|
ThreadId,
|
||||||
|
ProviderInstanceId,
|
||||||
|
WorkspaceTaskId,
|
||||||
|
} from "@t3tools/contracts";
|
||||||
|
import { useParams, useRouter } from "@tanstack/react-router";
|
||||||
|
import { useCallback, useMemo, useRef } from "react";
|
||||||
|
|
||||||
|
import { DraftId, type DraftSessionState, useComposerDraftStore } from "../composerDraftStore";
|
||||||
|
import {
|
||||||
|
deriveLogicalProjectKeyFromSettings,
|
||||||
|
selectProjectGroupingSettings,
|
||||||
|
} from "../logicalProject";
|
||||||
|
import { refreshClosedTaskTabsForEnvironment, useClosedTaskTabs } from "../lib/closedTaskTabsState";
|
||||||
|
import { newDraftId, newThreadId } from "../lib/utils";
|
||||||
|
import { resolveWorkspaceTaskId } from "../lib/workspaceTasks";
|
||||||
|
import { primaryServerKeybindingsAtom } from "../state/server";
|
||||||
|
import { threadEnvironment } from "../state/threads";
|
||||||
|
import { readThreadShell, useProjects, useServerConfigs, useThreadShells } from "../state/entities";
|
||||||
|
import { useAtomCommand } from "../state/use-atom-command";
|
||||||
|
import { buildThreadRouteParams, resolveThreadRouteTarget } from "../threadRoutes";
|
||||||
|
import { useClientSettings } from "./useSettings";
|
||||||
|
|
||||||
|
export type WorkspaceTaskTab =
|
||||||
|
| {
|
||||||
|
readonly kind: "server";
|
||||||
|
readonly key: string;
|
||||||
|
readonly threadRef: ScopedThreadRef;
|
||||||
|
readonly title: string;
|
||||||
|
readonly modelSelection: ModelSelection;
|
||||||
|
readonly position: number;
|
||||||
|
readonly active: boolean;
|
||||||
|
readonly working: boolean;
|
||||||
|
readonly blocked: boolean;
|
||||||
|
readonly forkProvenance: ThreadForkProvenance | null;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
readonly kind: "draft";
|
||||||
|
readonly key: string;
|
||||||
|
readonly draftId: DraftId;
|
||||||
|
readonly threadId: ThreadId;
|
||||||
|
readonly title: string;
|
||||||
|
readonly modelSelection: ModelSelection | null;
|
||||||
|
readonly position: number;
|
||||||
|
readonly active: boolean;
|
||||||
|
readonly working: false;
|
||||||
|
readonly blocked: false;
|
||||||
|
readonly forkProvenance: ThreadForkProvenance | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ClosedWorkspaceTaskTab =
|
||||||
|
| {
|
||||||
|
readonly kind: "server";
|
||||||
|
readonly key: string;
|
||||||
|
readonly threadRef: ScopedThreadRef;
|
||||||
|
readonly title: string;
|
||||||
|
readonly position: number;
|
||||||
|
readonly forkProvenance: ThreadForkProvenance | null;
|
||||||
|
readonly closedAt: string;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
readonly kind: "draft";
|
||||||
|
readonly key: string;
|
||||||
|
readonly draftId: DraftId;
|
||||||
|
readonly threadId: ThreadId;
|
||||||
|
readonly title: string;
|
||||||
|
readonly position: number;
|
||||||
|
readonly forkProvenance: ThreadForkProvenance | null;
|
||||||
|
readonly closedAt: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
interface CurrentTaskContext {
|
||||||
|
readonly environmentId: EnvironmentThreadShell["environmentId"];
|
||||||
|
readonly projectId: EnvironmentThreadShell["projectId"];
|
||||||
|
readonly threadId: ThreadId;
|
||||||
|
readonly workspaceTaskId: WorkspaceTaskId;
|
||||||
|
readonly branch: string | null;
|
||||||
|
readonly worktreePath: string | null;
|
||||||
|
readonly runtimeMode: EnvironmentThreadShell["runtimeMode"];
|
||||||
|
readonly interactionMode: EnvironmentThreadShell["interactionMode"];
|
||||||
|
readonly modelSelection: ModelSelection;
|
||||||
|
readonly logicalProjectKey: string;
|
||||||
|
readonly sourceIsServer: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
function draftTaskId(draft: DraftSessionState): WorkspaceTaskId {
|
||||||
|
return draft.workspaceTaskId ?? WorkspaceTaskId.make(String(draft.threadId));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function waitForThreadShellState(
|
||||||
|
threadRef: ScopedThreadRef,
|
||||||
|
expectedToExist: boolean,
|
||||||
|
): Promise<void> {
|
||||||
|
const deadline = Date.now() + 3_000;
|
||||||
|
while ((readThreadShell(threadRef) !== null) !== expectedToExist && Date.now() < deadline) {
|
||||||
|
await new Promise<void>((resolve) => setTimeout(resolve, 50));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useWorkspaceTaskTabs() {
|
||||||
|
const router = useRouter();
|
||||||
|
const creatingTabRef = useRef(false);
|
||||||
|
const routeTarget = useParams({
|
||||||
|
strict: false,
|
||||||
|
select: (params) => resolveThreadRouteTarget(params),
|
||||||
|
});
|
||||||
|
const threads = useThreadShells();
|
||||||
|
const projects = useProjects();
|
||||||
|
const serverConfigs = useServerConfigs();
|
||||||
|
const projectGroupingSettings = useClientSettings(selectProjectGroupingSettings);
|
||||||
|
const draftSessions = useComposerDraftStore((state) => state.draftThreadsByThreadKey);
|
||||||
|
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
|
||||||
|
const updateThreadMetadata = useAtomCommand(threadEnvironment.updateMetadata, {
|
||||||
|
reportFailure: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const currentServerThread =
|
||||||
|
routeTarget?.kind === "server"
|
||||||
|
? (threads.find(
|
||||||
|
(thread) =>
|
||||||
|
thread.environmentId === routeTarget.threadRef.environmentId &&
|
||||||
|
thread.id === routeTarget.threadRef.threadId,
|
||||||
|
) ?? null)
|
||||||
|
: null;
|
||||||
|
const currentDraft =
|
||||||
|
routeTarget?.kind === "draft" ? (draftSessions[routeTarget.draftId] ?? null) : null;
|
||||||
|
const currentProject = currentServerThread
|
||||||
|
? (projects.find(
|
||||||
|
(project) =>
|
||||||
|
project.environmentId === currentServerThread.environmentId &&
|
||||||
|
project.id === currentServerThread.projectId,
|
||||||
|
) ?? null)
|
||||||
|
: currentDraft
|
||||||
|
? (projects.find(
|
||||||
|
(project) =>
|
||||||
|
project.environmentId === currentDraft.environmentId &&
|
||||||
|
project.id === currentDraft.projectId,
|
||||||
|
) ?? null)
|
||||||
|
: null;
|
||||||
|
|
||||||
|
const currentContext: CurrentTaskContext | null = currentServerThread
|
||||||
|
? {
|
||||||
|
environmentId: currentServerThread.environmentId,
|
||||||
|
projectId: currentServerThread.projectId,
|
||||||
|
threadId: currentServerThread.id,
|
||||||
|
workspaceTaskId: resolveWorkspaceTaskId(currentServerThread),
|
||||||
|
branch: currentServerThread.branch,
|
||||||
|
worktreePath: currentServerThread.worktreePath,
|
||||||
|
runtimeMode: currentServerThread.runtimeMode,
|
||||||
|
interactionMode: currentServerThread.interactionMode,
|
||||||
|
modelSelection: currentServerThread.modelSelection,
|
||||||
|
logicalProjectKey: currentProject
|
||||||
|
? deriveLogicalProjectKeyFromSettings(currentProject, projectGroupingSettings)
|
||||||
|
: scopedProjectKey(
|
||||||
|
scopeProjectRef(currentServerThread.environmentId, currentServerThread.projectId),
|
||||||
|
),
|
||||||
|
sourceIsServer: true,
|
||||||
|
}
|
||||||
|
: currentDraft && currentProject
|
||||||
|
? {
|
||||||
|
environmentId: currentDraft.environmentId,
|
||||||
|
projectId: currentDraft.projectId,
|
||||||
|
threadId: currentDraft.threadId,
|
||||||
|
workspaceTaskId: draftTaskId(currentDraft),
|
||||||
|
branch: currentDraft.branch,
|
||||||
|
worktreePath: currentDraft.worktreePath,
|
||||||
|
runtimeMode: currentDraft.runtimeMode,
|
||||||
|
interactionMode: currentDraft.interactionMode,
|
||||||
|
modelSelection: currentProject.defaultModelSelection ?? {
|
||||||
|
instanceId: ProviderInstanceId.make("codex"),
|
||||||
|
model: "default",
|
||||||
|
},
|
||||||
|
logicalProjectKey: currentDraft.logicalProjectKey,
|
||||||
|
sourceIsServer: false,
|
||||||
|
}
|
||||||
|
: null;
|
||||||
|
const supportsTaskTabs =
|
||||||
|
currentContext !== null &&
|
||||||
|
serverConfigs.get(currentContext.environmentId)?.environment.capabilities.workspaceTaskTabs ===
|
||||||
|
true;
|
||||||
|
const closedServerTaskTabs = useClosedTaskTabs(
|
||||||
|
supportsTaskTabs ? currentContext.environmentId : null,
|
||||||
|
);
|
||||||
|
|
||||||
|
const tabs = useMemo<ReadonlyArray<WorkspaceTaskTab>>(() => {
|
||||||
|
if (currentContext === null) return [];
|
||||||
|
const serverTabs: WorkspaceTaskTab[] = threads.flatMap((thread) => {
|
||||||
|
if (
|
||||||
|
thread.environmentId !== currentContext.environmentId ||
|
||||||
|
resolveWorkspaceTaskId(thread) !== currentContext.workspaceTaskId ||
|
||||||
|
thread.tabClosedAt != null
|
||||||
|
) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
const threadRef = scopeThreadRef(thread.environmentId, thread.id);
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
kind: "server",
|
||||||
|
key: scopedThreadKey(threadRef),
|
||||||
|
threadRef,
|
||||||
|
title: thread.tabLabel ?? (thread.tabPosition === 0 ? "Main" : thread.title),
|
||||||
|
modelSelection: thread.modelSelection,
|
||||||
|
position: thread.tabPosition ?? 0,
|
||||||
|
active:
|
||||||
|
routeTarget?.kind === "server" &&
|
||||||
|
routeTarget.threadRef.environmentId === thread.environmentId &&
|
||||||
|
routeTarget.threadRef.threadId === thread.id,
|
||||||
|
working: thread.session?.status === "running" || thread.session?.status === "starting",
|
||||||
|
blocked: thread.hasPendingApprovals || thread.hasPendingUserInput,
|
||||||
|
forkProvenance: thread.forkProvenance ?? null,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
});
|
||||||
|
const draftTabs: WorkspaceTaskTab[] = Object.entries(draftSessions).flatMap(
|
||||||
|
([rawDraftId, draft]) => {
|
||||||
|
if (
|
||||||
|
draft.environmentId !== currentContext.environmentId ||
|
||||||
|
draftTaskId(draft) !== currentContext.workspaceTaskId ||
|
||||||
|
draft.tabClosedAt != null ||
|
||||||
|
draft.promotedTo != null
|
||||||
|
) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
const draftId = DraftId.make(rawDraftId);
|
||||||
|
const composer = useComposerDraftStore.getState().getComposerDraft(draftId);
|
||||||
|
const activeProvider = composer?.activeProvider ?? null;
|
||||||
|
const modelSelection = activeProvider
|
||||||
|
? (composer?.modelSelectionByProvider[activeProvider] ?? null)
|
||||||
|
: null;
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
kind: "draft",
|
||||||
|
key: `draft:${draftId}`,
|
||||||
|
draftId,
|
||||||
|
threadId: draft.threadId,
|
||||||
|
title: draft.tabLabel ?? `Tab ${(draft.tabPosition ?? 0) + 1}`,
|
||||||
|
modelSelection,
|
||||||
|
position: draft.tabPosition ?? 0,
|
||||||
|
active: routeTarget?.kind === "draft" && routeTarget.draftId === draftId,
|
||||||
|
working: false,
|
||||||
|
blocked: false,
|
||||||
|
forkProvenance: draft.forkProvenance ?? null,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return [...serverTabs, ...draftTabs].toSorted(
|
||||||
|
(left, right) => left.position - right.position || left.key.localeCompare(right.key),
|
||||||
|
);
|
||||||
|
}, [currentContext, draftSessions, routeTarget, threads]);
|
||||||
|
|
||||||
|
const closedTabs = useMemo<ReadonlyArray<ClosedWorkspaceTaskTab>>(() => {
|
||||||
|
if (currentContext === null) return [];
|
||||||
|
const serverTabs: ClosedWorkspaceTaskTab[] = closedServerTaskTabs.flatMap((thread) => {
|
||||||
|
if (
|
||||||
|
resolveWorkspaceTaskId(thread) !== currentContext.workspaceTaskId ||
|
||||||
|
thread.tabClosedAt == null
|
||||||
|
) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
const threadRef = scopeThreadRef(currentContext.environmentId, thread.id);
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
kind: "server",
|
||||||
|
key: scopedThreadKey(threadRef),
|
||||||
|
threadRef,
|
||||||
|
title: thread.tabLabel ?? (thread.tabPosition === 0 ? "Main" : thread.title),
|
||||||
|
position: thread.tabPosition ?? 0,
|
||||||
|
forkProvenance: thread.forkProvenance ?? null,
|
||||||
|
closedAt: thread.tabClosedAt,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
});
|
||||||
|
const draftTabs: ClosedWorkspaceTaskTab[] = Object.entries(draftSessions).flatMap(
|
||||||
|
([rawDraftId, draft]) => {
|
||||||
|
if (
|
||||||
|
draft.environmentId !== currentContext.environmentId ||
|
||||||
|
draftTaskId(draft) !== currentContext.workspaceTaskId ||
|
||||||
|
draft.tabClosedAt == null ||
|
||||||
|
draft.promotedTo != null
|
||||||
|
) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
const draftId = DraftId.make(rawDraftId);
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
kind: "draft",
|
||||||
|
key: `draft:${draftId}`,
|
||||||
|
draftId,
|
||||||
|
threadId: draft.threadId,
|
||||||
|
title: draft.tabLabel ?? `Tab ${(draft.tabPosition ?? 0) + 1}`,
|
||||||
|
position: draft.tabPosition ?? 0,
|
||||||
|
forkProvenance: draft.forkProvenance ?? null,
|
||||||
|
closedAt: draft.tabClosedAt,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return [...serverTabs, ...draftTabs].toSorted(
|
||||||
|
(left, right) =>
|
||||||
|
right.closedAt.localeCompare(left.closedAt) ||
|
||||||
|
left.position - right.position ||
|
||||||
|
left.key.localeCompare(right.key),
|
||||||
|
);
|
||||||
|
}, [closedServerTaskTabs, currentContext, draftSessions]);
|
||||||
|
|
||||||
|
const navigateToTab = useCallback(
|
||||||
|
(tab: WorkspaceTaskTab | ClosedWorkspaceTaskTab) => {
|
||||||
|
if (tab.kind === "server") {
|
||||||
|
return router.navigate({
|
||||||
|
to: "/$environmentId/$threadId",
|
||||||
|
params: buildThreadRouteParams(tab.threadRef),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return router.navigate({
|
||||||
|
to: "/draft/$draftId",
|
||||||
|
params: { draftId: tab.draftId },
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[router],
|
||||||
|
);
|
||||||
|
|
||||||
|
const createTab = useCallback(
|
||||||
|
async (mode: "fresh" | "portable" = "fresh") => {
|
||||||
|
if (currentContext === null || !supportsTaskTabs) return;
|
||||||
|
if (mode === "portable" && !currentContext.sourceIsServer) return;
|
||||||
|
if (creatingTabRef.current) return;
|
||||||
|
creatingTabRef.current = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const draftId = newDraftId();
|
||||||
|
const threadId = newThreadId();
|
||||||
|
const createdAt = new Date().toISOString();
|
||||||
|
const position =
|
||||||
|
[...tabs, ...closedTabs].reduce((max, tab) => Math.max(max, tab.position), -1) + 1;
|
||||||
|
const forkProvenance: ThreadForkProvenance = {
|
||||||
|
mode,
|
||||||
|
sourceThreadId: mode === "portable" ? currentContext.threadId : null,
|
||||||
|
createdAt,
|
||||||
|
};
|
||||||
|
const store = useComposerDraftStore.getState();
|
||||||
|
const currentComposer =
|
||||||
|
routeTarget?.kind === "server"
|
||||||
|
? store.getComposerDraft(routeTarget.threadRef)
|
||||||
|
: routeTarget?.kind === "draft"
|
||||||
|
? store.getComposerDraft(routeTarget.draftId)
|
||||||
|
: null;
|
||||||
|
const activeProvider = currentComposer?.activeProvider ?? null;
|
||||||
|
const carriedModelSelection =
|
||||||
|
(activeProvider
|
||||||
|
? currentComposer?.modelSelectionByProvider[activeProvider]
|
||||||
|
: undefined) ?? currentContext.modelSelection;
|
||||||
|
|
||||||
|
store.setLogicalProjectDraftThreadId(
|
||||||
|
currentContext.logicalProjectKey,
|
||||||
|
scopeProjectRef(currentContext.environmentId, currentContext.projectId),
|
||||||
|
draftId,
|
||||||
|
{
|
||||||
|
threadId,
|
||||||
|
workspaceTaskId: currentContext.workspaceTaskId,
|
||||||
|
tabPosition: position,
|
||||||
|
tabLabel: null,
|
||||||
|
forkProvenance,
|
||||||
|
createdAt,
|
||||||
|
branch: currentContext.branch,
|
||||||
|
worktreePath: currentContext.worktreePath,
|
||||||
|
envMode: currentContext.worktreePath ? "worktree" : "local",
|
||||||
|
startFromOrigin: false,
|
||||||
|
runtimeMode: currentContext.runtimeMode,
|
||||||
|
interactionMode: currentContext.interactionMode,
|
||||||
|
retainPreviousDraft: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
store.applyStickyState(draftId);
|
||||||
|
store.setModelSelection(draftId, carriedModelSelection, { replaceOptions: true });
|
||||||
|
|
||||||
|
await router.navigate({
|
||||||
|
to: "/draft/$draftId",
|
||||||
|
params: { draftId },
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
creatingTabRef.current = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[closedTabs, currentContext, routeTarget, router, supportsTaskTabs, tabs],
|
||||||
|
);
|
||||||
|
|
||||||
|
const closeTab = useCallback(
|
||||||
|
async (tab: WorkspaceTaskTab) => {
|
||||||
|
if (tabs.length <= 1 || tab.working || tab.blocked) return;
|
||||||
|
const index = tabs.findIndex((candidate) => candidate.key === tab.key);
|
||||||
|
const fallback = tabs[index + 1] ?? tabs[index - 1] ?? null;
|
||||||
|
if (tab.kind === "draft") {
|
||||||
|
useComposerDraftStore
|
||||||
|
.getState()
|
||||||
|
.setDraftThreadContext(tab.draftId, { tabClosedAt: new Date().toISOString() });
|
||||||
|
} else {
|
||||||
|
const result = await updateThreadMetadata({
|
||||||
|
environmentId: tab.threadRef.environmentId,
|
||||||
|
input: {
|
||||||
|
threadId: tab.threadRef.threadId,
|
||||||
|
tabClosedAt: new Date().toISOString(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (result._tag === "Failure") return;
|
||||||
|
await waitForThreadShellState(tab.threadRef, false);
|
||||||
|
refreshClosedTaskTabsForEnvironment(tab.threadRef.environmentId);
|
||||||
|
}
|
||||||
|
if (tab.active && fallback) {
|
||||||
|
await navigateToTab(fallback);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[navigateToTab, tabs, updateThreadMetadata],
|
||||||
|
);
|
||||||
|
|
||||||
|
const reopenTab = useCallback(
|
||||||
|
async (tab: ClosedWorkspaceTaskTab) => {
|
||||||
|
if (tab.kind === "draft") {
|
||||||
|
useComposerDraftStore.getState().setDraftThreadContext(tab.draftId, { tabClosedAt: null });
|
||||||
|
} else {
|
||||||
|
const result = await updateThreadMetadata({
|
||||||
|
environmentId: tab.threadRef.environmentId,
|
||||||
|
input: {
|
||||||
|
threadId: tab.threadRef.threadId,
|
||||||
|
tabClosedAt: null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (result._tag === "Failure") return;
|
||||||
|
await waitForThreadShellState(tab.threadRef, true);
|
||||||
|
refreshClosedTaskTabsForEnvironment(tab.threadRef.environmentId);
|
||||||
|
}
|
||||||
|
await navigateToTab(tab);
|
||||||
|
},
|
||||||
|
[navigateToTab, updateThreadMetadata],
|
||||||
|
);
|
||||||
|
|
||||||
|
const reopenLastClosedTab = useCallback(async () => {
|
||||||
|
const lastClosed = closedTabs[0];
|
||||||
|
if (lastClosed) await reopenTab(lastClosed);
|
||||||
|
}, [closedTabs, reopenTab]);
|
||||||
|
|
||||||
|
return {
|
||||||
|
tabs,
|
||||||
|
closedTabs,
|
||||||
|
keybindings,
|
||||||
|
hasTask: currentContext !== null && supportsTaskTabs,
|
||||||
|
canForkContext: currentContext?.sourceIsServer === true && supportsTaskTabs,
|
||||||
|
createTab,
|
||||||
|
closeTab,
|
||||||
|
reopenTab,
|
||||||
|
reopenLastClosedTab,
|
||||||
|
navigateToTab,
|
||||||
|
} as const;
|
||||||
|
}
|
||||||
@@ -124,6 +124,7 @@ const DEFAULT_BINDINGS = compile([
|
|||||||
whenAst: whenNot(whenIdentifier("terminalFocus")),
|
whenAst: whenNot(whenIdentifier("terminalFocus")),
|
||||||
},
|
},
|
||||||
{ shortcut: modShortcut("o", { shiftKey: true }), command: "chat.new" },
|
{ shortcut: modShortcut("o", { shiftKey: true }), command: "chat.new" },
|
||||||
|
{ shortcut: modShortcut("t", { shiftKey: true }), command: "chat.reopenClosedTab" },
|
||||||
{ shortcut: modShortcut("n", { shiftKey: true }), command: "chat.newLocal" },
|
{ shortcut: modShortcut("n", { shiftKey: true }), command: "chat.newLocal" },
|
||||||
{ shortcut: modShortcut("o"), command: "editor.openFavorite" },
|
{ shortcut: modShortcut("o"), command: "editor.openFavorite" },
|
||||||
{ shortcut: modShortcut("[", { shiftKey: true }), command: "thread.previous" },
|
{ shortcut: modShortcut("[", { shiftKey: true }), command: "thread.previous" },
|
||||||
@@ -318,6 +319,10 @@ describe("shortcutLabelForCommand", () => {
|
|||||||
"⌘B",
|
"⌘B",
|
||||||
);
|
);
|
||||||
assert.strictEqual(shortcutLabelForCommand(DEFAULT_BINDINGS, "chat.new", "MacIntel"), "⇧⌘O");
|
assert.strictEqual(shortcutLabelForCommand(DEFAULT_BINDINGS, "chat.new", "MacIntel"), "⇧⌘O");
|
||||||
|
assert.strictEqual(
|
||||||
|
shortcutLabelForCommand(DEFAULT_BINDINGS, "chat.reopenClosedTab", "MacIntel"),
|
||||||
|
"⇧⌘T",
|
||||||
|
);
|
||||||
assert.strictEqual(shortcutLabelForCommand(DEFAULT_BINDINGS, "diff.toggle", "Linux"), "Ctrl+D");
|
assert.strictEqual(shortcutLabelForCommand(DEFAULT_BINDINGS, "diff.toggle", "Linux"), "Ctrl+D");
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
shortcutLabelForCommand(DEFAULT_BINDINGS, "rightPanel.toggle", "MacIntel"),
|
shortcutLabelForCommand(DEFAULT_BINDINGS, "rightPanel.toggle", "MacIntel"),
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import { useAtomValue } from "@effect/atom-react";
|
||||||
|
import type { EnvironmentId, OrchestrationThreadShell } from "@t3tools/contracts";
|
||||||
|
import * as Option from "effect/Option";
|
||||||
|
import { AsyncResult, Atom } from "effect/unstable/reactivity";
|
||||||
|
|
||||||
|
import { appAtomRegistry } from "../rpc/atomRegistry";
|
||||||
|
import { orchestrationEnvironment } from "../state/orchestration";
|
||||||
|
|
||||||
|
const EMPTY_CLOSED_TASK_TABS: ReadonlyArray<OrchestrationThreadShell> = Object.freeze([]);
|
||||||
|
const EMPTY_CLOSED_TASK_TABS_ATOM = Atom.make(AsyncResult.success(EMPTY_CLOSED_TASK_TABS)).pipe(
|
||||||
|
Atom.withLabel("web:closed-task-tabs:empty"),
|
||||||
|
);
|
||||||
|
|
||||||
|
function closedTaskTabsAtom(environmentId: EnvironmentId) {
|
||||||
|
return orchestrationEnvironment.closedTaskTabs({
|
||||||
|
environmentId,
|
||||||
|
input: {},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function refreshClosedTaskTabsForEnvironment(environmentId: EnvironmentId): void {
|
||||||
|
appAtomRegistry.refresh(closedTaskTabsAtom(environmentId));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useClosedTaskTabs(
|
||||||
|
environmentId: EnvironmentId | null,
|
||||||
|
): ReadonlyArray<OrchestrationThreadShell> {
|
||||||
|
const result = useAtomValue(
|
||||||
|
environmentId === null ? EMPTY_CLOSED_TASK_TABS_ATOM : closedTaskTabsAtom(environmentId),
|
||||||
|
);
|
||||||
|
return Option.getOrElse(AsyncResult.value(result), () => EMPTY_CLOSED_TASK_TABS);
|
||||||
|
}
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
import { describe, expect, it } from "@effect/vitest";
|
||||||
|
|
||||||
|
import {
|
||||||
|
describeTaskTabContexts,
|
||||||
|
taskTabDisplayTitle,
|
||||||
|
type TaskTabContextSource,
|
||||||
|
} from "./taskTabContext";
|
||||||
|
|
||||||
|
function tab(
|
||||||
|
overrides: Partial<TaskTabContextSource> & { threadId: string },
|
||||||
|
): TaskTabContextSource {
|
||||||
|
return {
|
||||||
|
kind: "server",
|
||||||
|
title: overrides.threadId,
|
||||||
|
position: 0,
|
||||||
|
forkProvenance: null,
|
||||||
|
...overrides,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
describe("task tab context descriptors", () => {
|
||||||
|
it("labels the first tab Main and gives it its own context", () => {
|
||||||
|
const [main] = describeTaskTabContexts([tab({ threadId: "root", title: "Tab 1" })]);
|
||||||
|
expect(main?.title).toBe("Main");
|
||||||
|
expect(main?.kind).toBe("main");
|
||||||
|
expect(main?.label).toBe("Independent");
|
||||||
|
expect(main?.detail).toBe("Separate chat history.");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("keeps an explicit tab label on the first tab", () => {
|
||||||
|
expect(taskTabDisplayTitle(tab({ threadId: "root", title: "Reviewer" }))).toBe("Reviewer");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("describes an unsent draft tab as starting empty", () => {
|
||||||
|
const [, draft] = describeTaskTabContexts([
|
||||||
|
tab({ threadId: "root", title: "Main" }),
|
||||||
|
tab({
|
||||||
|
threadId: "draft-thread",
|
||||||
|
kind: "draft",
|
||||||
|
title: "Tab 2",
|
||||||
|
position: 1,
|
||||||
|
forkProvenance: { mode: "fresh", sourceThreadId: null },
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
expect(draft?.kind).toBe("empty");
|
||||||
|
expect(draft?.label).toBe("Empty");
|
||||||
|
expect(draft?.detail).toBe("No chat history.");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("describes a started sibling tab as independent, not shared", () => {
|
||||||
|
const [, started] = describeTaskTabContexts([
|
||||||
|
tab({ threadId: "root", title: "Main" }),
|
||||||
|
tab({
|
||||||
|
threadId: "second",
|
||||||
|
title: "Tab 2",
|
||||||
|
position: 1,
|
||||||
|
forkProvenance: { mode: "fresh", sourceThreadId: null },
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
expect(started?.kind).toBe("own");
|
||||||
|
expect(started?.label).toBe("Independent");
|
||||||
|
expect(started?.detail).toBe("Separate chat history.");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("resolves a portable fork's source to the sibling tab label", () => {
|
||||||
|
const [, fork] = describeTaskTabContexts([
|
||||||
|
tab({ threadId: "root", title: "Tab 1" }),
|
||||||
|
tab({
|
||||||
|
threadId: "fork",
|
||||||
|
kind: "draft",
|
||||||
|
title: "Tab 2",
|
||||||
|
position: 1,
|
||||||
|
forkProvenance: { mode: "portable", sourceThreadId: "root" },
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
expect(fork?.kind).toBe("snapshot");
|
||||||
|
expect(fork?.sourceTitle).toBe("Main");
|
||||||
|
expect(fork?.label).toBe("From Main");
|
||||||
|
expect(fork?.detail).toBe("Copies Main once on send.");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("describes a started fork in the past tense once it owns a thread", () => {
|
||||||
|
const [, fork] = describeTaskTabContexts([
|
||||||
|
tab({ threadId: "root", title: "Main" }),
|
||||||
|
tab({
|
||||||
|
threadId: "fork",
|
||||||
|
title: "Retry",
|
||||||
|
position: 1,
|
||||||
|
forkProvenance: { mode: "portable", sourceThreadId: "root" },
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
expect(fork?.label).toBe("From Main");
|
||||||
|
expect(fork?.detail).toBe("Started from Main; now independent.");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("falls back to a neutral phrase when the source tab is gone", () => {
|
||||||
|
const [fork] = describeTaskTabContexts([
|
||||||
|
tab({
|
||||||
|
threadId: "fork",
|
||||||
|
title: "Retry",
|
||||||
|
position: 1,
|
||||||
|
forkProvenance: { mode: "portable", sourceThreadId: "closed-thread" },
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
expect(fork?.sourceTitle).toBeNull();
|
||||||
|
expect(fork?.label).toBe("From other tab");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("never invents message counts", () => {
|
||||||
|
const descriptors = describeTaskTabContexts([
|
||||||
|
tab({ threadId: "root", title: "Tab 1" }),
|
||||||
|
tab({
|
||||||
|
threadId: "fork",
|
||||||
|
title: "Tab 2",
|
||||||
|
position: 1,
|
||||||
|
forkProvenance: { mode: "portable", sourceThreadId: "root" },
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
for (const descriptor of descriptors) {
|
||||||
|
expect(`${descriptor.label} ${descriptor.detail}`).not.toMatch(/\d/);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
/**
|
||||||
|
* Honest, metadata-only descriptions of what conversation context a task tab
|
||||||
|
* has. Tabs in one workspace task share a project/worktree/branch but never a
|
||||||
|
* live conversation, so the copy here must never imply synced history:
|
||||||
|
* - Main and any started tab own their transcript outright.
|
||||||
|
* - A fresh tab is literally empty until its first message.
|
||||||
|
* - A portable fork receives one bounded snapshot of its source tab on the
|
||||||
|
* first provider call, then continues on its own.
|
||||||
|
*
|
||||||
|
* Nothing here counts messages or tokens — only shape is known client-side.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export type TaskTabContextKind = "main" | "empty" | "own" | "snapshot";
|
||||||
|
|
||||||
|
export interface TaskTabContextSource {
|
||||||
|
/** Server tabs have a real thread; drafts have not sent a message yet. */
|
||||||
|
readonly kind: "server" | "draft";
|
||||||
|
readonly threadId: string;
|
||||||
|
readonly title: string;
|
||||||
|
readonly position: number;
|
||||||
|
readonly forkProvenance: {
|
||||||
|
readonly mode: "fresh" | "portable";
|
||||||
|
readonly sourceThreadId: string | null;
|
||||||
|
} | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TaskTabContextDescriptor {
|
||||||
|
readonly kind: TaskTabContextKind;
|
||||||
|
/** Tab name as rendered in the strip. */
|
||||||
|
readonly title: string;
|
||||||
|
/** Short inline label, e.g. "From Main". */
|
||||||
|
readonly label: string;
|
||||||
|
/** One sentence expanding the label, for tooltips. */
|
||||||
|
readonly detail: string;
|
||||||
|
/** Resolved sibling tab title for portable forks, when still present. */
|
||||||
|
readonly sourceTitle: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const FALLBACK_SOURCE_TITLE = "other tab";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mirrors the legacy strip fallback: the first tab reads as "Main" even when a
|
||||||
|
* draft was persisted before tab labels existed.
|
||||||
|
*/
|
||||||
|
export function taskTabDisplayTitle(tab: TaskTabContextSource): string {
|
||||||
|
if (tab.position === 0 && (tab.title === "Tab 1" || tab.title.trim() === "")) return "Main";
|
||||||
|
return tab.title;
|
||||||
|
}
|
||||||
|
|
||||||
|
function describeOne(
|
||||||
|
tab: TaskTabContextSource,
|
||||||
|
sourceTitle: string | null,
|
||||||
|
): TaskTabContextDescriptor {
|
||||||
|
const title = taskTabDisplayTitle(tab);
|
||||||
|
const base = { title, sourceTitle } as const;
|
||||||
|
|
||||||
|
if (tab.forkProvenance?.mode === "portable") {
|
||||||
|
const from = sourceTitle ?? FALLBACK_SOURCE_TITLE;
|
||||||
|
return {
|
||||||
|
...base,
|
||||||
|
kind: "snapshot",
|
||||||
|
label: `From ${from}`,
|
||||||
|
detail:
|
||||||
|
tab.kind === "draft"
|
||||||
|
? `Copies ${from} once on send.`
|
||||||
|
: `Started from ${from}; now independent.`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tab.kind === "draft") {
|
||||||
|
return {
|
||||||
|
...base,
|
||||||
|
kind: "empty",
|
||||||
|
label: "Empty",
|
||||||
|
detail: "No chat history.",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tab.position === 0) {
|
||||||
|
return {
|
||||||
|
...base,
|
||||||
|
kind: "main",
|
||||||
|
label: "Independent",
|
||||||
|
detail: "Separate chat history.",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...base,
|
||||||
|
kind: "own",
|
||||||
|
label: "Independent",
|
||||||
|
detail: "Separate chat history.",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Describes every tab in one pass so a portable fork can name its source by
|
||||||
|
* the label that source currently shows in the strip. A source that was closed
|
||||||
|
* (or lives outside this task) degrades to "another tab" rather than leaking a
|
||||||
|
* thread id.
|
||||||
|
*/
|
||||||
|
export function describeTaskTabContexts(
|
||||||
|
tabs: ReadonlyArray<TaskTabContextSource>,
|
||||||
|
): ReadonlyArray<TaskTabContextDescriptor> {
|
||||||
|
const titleByThreadId = new Map(tabs.map((tab) => [tab.threadId, taskTabDisplayTitle(tab)]));
|
||||||
|
return tabs.map((tab) => {
|
||||||
|
const sourceThreadId = tab.forkProvenance?.sourceThreadId ?? null;
|
||||||
|
const sourceTitle =
|
||||||
|
sourceThreadId !== null && sourceThreadId !== tab.threadId
|
||||||
|
? (titleByThreadId.get(sourceThreadId) ?? null)
|
||||||
|
: null;
|
||||||
|
return describeOne(tab, sourceTitle);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
import { describe, expect, it } from "@effect/vitest";
|
||||||
|
import {
|
||||||
|
EnvironmentId,
|
||||||
|
ProjectId,
|
||||||
|
ProviderInstanceId,
|
||||||
|
ThreadId,
|
||||||
|
WorkspaceTaskId,
|
||||||
|
type OrchestrationThreadShell,
|
||||||
|
} from "@t3tools/contracts";
|
||||||
|
import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
|
||||||
|
|
||||||
|
import { groupThreadsByWorkspaceTask, taskPresentationThread } from "./workspaceTasks";
|
||||||
|
|
||||||
|
function makeThread(
|
||||||
|
id: string,
|
||||||
|
overrides: Partial<OrchestrationThreadShell & { environmentId: EnvironmentId }> = {},
|
||||||
|
): EnvironmentThreadShell {
|
||||||
|
return {
|
||||||
|
id: ThreadId.make(id),
|
||||||
|
environmentId: EnvironmentId.make("local"),
|
||||||
|
projectId: ProjectId.make("project-1"),
|
||||||
|
title: id,
|
||||||
|
modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5" },
|
||||||
|
runtimeMode: "full-access",
|
||||||
|
interactionMode: "default",
|
||||||
|
branch: "main",
|
||||||
|
worktreePath: "/tmp/task",
|
||||||
|
latestTurn: null,
|
||||||
|
createdAt: "2026-07-24T00:00:00.000Z",
|
||||||
|
updatedAt: "2026-07-24T00:00:00.000Z",
|
||||||
|
archivedAt: null,
|
||||||
|
settledOverride: null,
|
||||||
|
settledAt: null,
|
||||||
|
snoozedUntil: null,
|
||||||
|
snoozedAt: null,
|
||||||
|
session: null,
|
||||||
|
latestUserMessageAt: null,
|
||||||
|
hasPendingApprovals: false,
|
||||||
|
hasPendingUserInput: false,
|
||||||
|
hasActionableProposedPlan: false,
|
||||||
|
...overrides,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
describe("workspace task grouping", () => {
|
||||||
|
it("backfills legacy shells to one-task/one-tab groups", () => {
|
||||||
|
const groups = groupThreadsByWorkspaceTask([makeThread("legacy")]);
|
||||||
|
expect(groups).toHaveLength(1);
|
||||||
|
expect(groups[0]?.id).toBe("legacy");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("orders sibling tabs and aggregates task status under the root title", () => {
|
||||||
|
const taskId = WorkspaceTaskId.make("task-1");
|
||||||
|
const groups = groupThreadsByWorkspaceTask([
|
||||||
|
makeThread("child", {
|
||||||
|
workspaceTaskId: taskId,
|
||||||
|
title: "Alternative",
|
||||||
|
tabPosition: 1,
|
||||||
|
hasPendingApprovals: true,
|
||||||
|
updatedAt: "2026-07-24T01:00:00.000Z",
|
||||||
|
}),
|
||||||
|
makeThread("root", {
|
||||||
|
workspaceTaskId: taskId,
|
||||||
|
title: "Task title",
|
||||||
|
tabPosition: 0,
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
const group = groups[0]!;
|
||||||
|
const presentation = taskPresentationThread(group, null);
|
||||||
|
|
||||||
|
expect(group.tabs.map((thread) => thread.id)).toEqual(["root", "child"]);
|
||||||
|
expect(presentation.title).toBe("Task title");
|
||||||
|
expect(presentation.hasPendingApprovals).toBe(true);
|
||||||
|
expect(presentation.updatedAt).toBe("2026-07-24T01:00:00.000Z");
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
|
||||||
|
import { scopedThreadKey, scopeThreadRef } from "@t3tools/client-runtime/environment";
|
||||||
|
import { WorkspaceTaskId } from "@t3tools/contracts";
|
||||||
|
|
||||||
|
export interface WorkspaceTaskGroup {
|
||||||
|
readonly id: WorkspaceTaskId;
|
||||||
|
readonly key: string;
|
||||||
|
readonly tabs: ReadonlyArray<EnvironmentThreadShell>;
|
||||||
|
readonly root: EnvironmentThreadShell;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function resolveWorkspaceTaskId(
|
||||||
|
thread: Pick<EnvironmentThreadShell, "id" | "workspaceTaskId">,
|
||||||
|
): WorkspaceTaskId {
|
||||||
|
return thread.workspaceTaskId ?? WorkspaceTaskId.make(String(thread.id));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function workspaceTaskKey(
|
||||||
|
thread: Pick<EnvironmentThreadShell, "environmentId" | "id" | "workspaceTaskId">,
|
||||||
|
): string {
|
||||||
|
return `${thread.environmentId}:${resolveWorkspaceTaskId(thread)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function groupThreadsByWorkspaceTask(
|
||||||
|
threads: ReadonlyArray<EnvironmentThreadShell>,
|
||||||
|
): ReadonlyArray<WorkspaceTaskGroup> {
|
||||||
|
const grouped = new Map<string, EnvironmentThreadShell[]>();
|
||||||
|
for (const thread of threads) {
|
||||||
|
const key = workspaceTaskKey(thread);
|
||||||
|
const existing = grouped.get(key);
|
||||||
|
if (existing) {
|
||||||
|
existing.push(thread);
|
||||||
|
} else {
|
||||||
|
grouped.set(key, [thread]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [...grouped.entries()].map(([key, unsortedTabs]) => {
|
||||||
|
const tabs = unsortedTabs.toSorted(
|
||||||
|
(left, right) =>
|
||||||
|
(left.tabPosition ?? 0) - (right.tabPosition ?? 0) ||
|
||||||
|
left.createdAt.localeCompare(right.createdAt) ||
|
||||||
|
left.id.localeCompare(right.id),
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
id: resolveWorkspaceTaskId(tabs[0]!),
|
||||||
|
key,
|
||||||
|
tabs,
|
||||||
|
root: tabs[0]!,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function representativePriority(thread: EnvironmentThreadShell): number {
|
||||||
|
if (thread.hasPendingApprovals) return 5;
|
||||||
|
if (thread.hasPendingUserInput) return 4;
|
||||||
|
if (thread.session?.status === "error") return 3;
|
||||||
|
if (thread.session?.status === "running" || thread.session?.status === "starting") return 2;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function taskPresentationThread(
|
||||||
|
task: WorkspaceTaskGroup,
|
||||||
|
activeThreadKey: string | null,
|
||||||
|
): EnvironmentThreadShell {
|
||||||
|
const activeTab =
|
||||||
|
activeThreadKey === null
|
||||||
|
? null
|
||||||
|
: (task.tabs.find(
|
||||||
|
(thread) =>
|
||||||
|
scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)) === activeThreadKey,
|
||||||
|
) ?? null);
|
||||||
|
const representative = [...task.tabs].toSorted(
|
||||||
|
(left, right) =>
|
||||||
|
representativePriority(right) - representativePriority(left) ||
|
||||||
|
right.updatedAt.localeCompare(left.updatedAt),
|
||||||
|
)[0]!;
|
||||||
|
const source =
|
||||||
|
activeTab && representativePriority(activeTab) >= representativePriority(representative)
|
||||||
|
? activeTab
|
||||||
|
: representative;
|
||||||
|
const updatedAt = task.tabs.reduce(
|
||||||
|
(latest, thread) => (thread.updatedAt > latest ? thread.updatedAt : latest),
|
||||||
|
task.root.updatedAt,
|
||||||
|
);
|
||||||
|
const latestUserMessageAt = task.tabs.reduce<string | null>(
|
||||||
|
(latest, thread) =>
|
||||||
|
thread.latestUserMessageAt !== null &&
|
||||||
|
(latest === null || thread.latestUserMessageAt > latest)
|
||||||
|
? thread.latestUserMessageAt
|
||||||
|
: latest,
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
...source,
|
||||||
|
// Task title and workspace identity are owned by the root tab. Status and
|
||||||
|
// recency are aggregated from every sibling tab.
|
||||||
|
id: task.root.id,
|
||||||
|
environmentId: task.root.environmentId,
|
||||||
|
title: task.root.title,
|
||||||
|
projectId: task.root.projectId,
|
||||||
|
branch: task.root.branch,
|
||||||
|
worktreePath: task.root.worktreePath,
|
||||||
|
workspaceTaskId: task.id,
|
||||||
|
tabLabel: null,
|
||||||
|
tabPosition: 0,
|
||||||
|
updatedAt,
|
||||||
|
latestUserMessageAt,
|
||||||
|
hasPendingApprovals: task.tabs.some((thread) => thread.hasPendingApprovals),
|
||||||
|
hasPendingUserInput: task.tabs.some((thread) => thread.hasPendingUserInput),
|
||||||
|
hasActionableProposedPlan: task.tabs.some((thread) => thread.hasActionableProposedPlan),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function workspaceTaskTabCountByThread(
|
||||||
|
tasks: ReadonlyArray<WorkspaceTaskGroup>,
|
||||||
|
): ReadonlyMap<string, number> {
|
||||||
|
const counts = new Map<string, number>();
|
||||||
|
for (const task of tasks) {
|
||||||
|
for (const thread of task.tabs) {
|
||||||
|
counts.set(
|
||||||
|
scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)),
|
||||||
|
task.tabs.length,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return counts;
|
||||||
|
}
|
||||||
@@ -21,6 +21,7 @@ import { selectActiveRightPanel, useRightPanelStore } from "../rightPanelStore";
|
|||||||
import { useThreadSelectionStore } from "../threadSelectionStore";
|
import { useThreadSelectionStore } from "../threadSelectionStore";
|
||||||
import { stackedThreadToast, toastManager } from "~/components/ui/toast";
|
import { stackedThreadToast, toastManager } from "~/components/ui/toast";
|
||||||
import { primaryServerKeybindingsAtom } from "~/state/server";
|
import { primaryServerKeybindingsAtom } from "~/state/server";
|
||||||
|
import { useWorkspaceTaskTabs } from "../hooks/useWorkspaceTaskTabs";
|
||||||
|
|
||||||
function ChatRouteGlobalShortcuts() {
|
function ChatRouteGlobalShortcuts() {
|
||||||
const clearSelection = useThreadSelectionStore((state) => state.clearSelection);
|
const clearSelection = useThreadSelectionStore((state) => state.clearSelection);
|
||||||
@@ -29,6 +30,7 @@ function ChatRouteGlobalShortcuts() {
|
|||||||
useHandleNewThread();
|
useHandleNewThread();
|
||||||
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
|
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
|
||||||
const sidebarV2Enabled = useClientSettings((settings) => settings.sidebarV2Enabled);
|
const sidebarV2Enabled = useClientSettings((settings) => settings.sidebarV2Enabled);
|
||||||
|
const workspaceTaskTabs = useWorkspaceTaskTabs();
|
||||||
const projectGroupingSettings = useClientSettings(selectProjectGroupingSettings);
|
const projectGroupingSettings = useClientSettings(selectProjectGroupingSettings);
|
||||||
const projects = useProjects();
|
const projects = useProjects();
|
||||||
const primaryEnvironmentId = usePrimaryEnvironmentId();
|
const primaryEnvironmentId = usePrimaryEnvironmentId();
|
||||||
@@ -108,6 +110,22 @@ function ChatRouteGlobalShortcuts() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (command === "chat.newTab") {
|
||||||
|
if (!sidebarV2Enabled || !workspaceTaskTabs.hasTask) return;
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
void workspaceTaskTabs.createTab("fresh");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (command === "chat.reopenClosedTab") {
|
||||||
|
if (!sidebarV2Enabled || workspaceTaskTabs.closedTabs.length === 0) return;
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
void workspaceTaskTabs.reopenLastClosedTab();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (command === "preview.toggle") {
|
if (command === "preview.toggle") {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
@@ -169,6 +187,7 @@ function ChatRouteGlobalShortcuts() {
|
|||||||
selectedThreadKeysSize,
|
selectedThreadKeysSize,
|
||||||
sidebarV2Enabled,
|
sidebarV2Enabled,
|
||||||
terminalOpen,
|
terminalOpen,
|
||||||
|
workspaceTaskTabs,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -20,5 +20,9 @@ export function createOrchestrationEnvironmentAtoms<R, E>(
|
|||||||
label: "environment-data:orchestration:archived-shell-snapshot",
|
label: "environment-data:orchestration:archived-shell-snapshot",
|
||||||
tag: ORCHESTRATION_WS_METHODS.getArchivedShellSnapshot,
|
tag: ORCHESTRATION_WS_METHODS.getArchivedShellSnapshot,
|
||||||
}),
|
}),
|
||||||
|
closedTaskTabs: createEnvironmentRpcQueryAtomFamily(runtime, {
|
||||||
|
label: "environment-data:orchestration:closed-task-tabs",
|
||||||
|
tag: ORCHESTRATION_WS_METHODS.getClosedTaskTabs,
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -29,6 +29,8 @@ const makeEntityId = <Brand extends string>(brand: Brand) => {
|
|||||||
|
|
||||||
export const ThreadId = makeEntityId("ThreadId");
|
export const ThreadId = makeEntityId("ThreadId");
|
||||||
export type ThreadId = typeof ThreadId.Type;
|
export type ThreadId = typeof ThreadId.Type;
|
||||||
|
export const WorkspaceTaskId = makeEntityId("WorkspaceTaskId");
|
||||||
|
export type WorkspaceTaskId = typeof WorkspaceTaskId.Type;
|
||||||
export const ProjectId = makeEntityId("ProjectId");
|
export const ProjectId = makeEntityId("ProjectId");
|
||||||
export type ProjectId = typeof ProjectId.Type;
|
export type ProjectId = typeof ProjectId.Type;
|
||||||
export const EnvironmentId = makeEntityId("EnvironmentId");
|
export const EnvironmentId = makeEntityId("EnvironmentId");
|
||||||
|
|||||||
@@ -47,6 +47,9 @@ export const ExecutionEnvironmentCapabilities = Schema.Struct({
|
|||||||
/** Server understands thread.snooze / thread.unsnooze commands. Same
|
/** Server understands thread.snooze / thread.unsnooze commands. Same
|
||||||
version-skew contract as threadSettlement. */
|
version-skew contract as threadSettlement. */
|
||||||
threadSnooze: Schema.optionalKey(Schema.Boolean),
|
threadSnooze: Schema.optionalKey(Schema.Boolean),
|
||||||
|
/** Server persists workspace-task tab metadata and portable context-fork
|
||||||
|
provenance. Missing means clients must keep the legacy one-thread UI. */
|
||||||
|
workspaceTaskTabs: Schema.optionalKey(Schema.Boolean),
|
||||||
/** The update path clients should offer for this server. Absent on
|
/** The update path clients should offer for this server. Absent on
|
||||||
servers that must be relaunched manually (dev checkouts, Windows
|
servers that must be relaunched manually (dev checkouts, Windows
|
||||||
foreground runs, pre-update servers). */
|
foreground runs, pre-update servers). */
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ import type {
|
|||||||
OrchestrationGetTurnDiffInput,
|
OrchestrationGetTurnDiffInput,
|
||||||
OrchestrationGetTurnDiffResult,
|
OrchestrationGetTurnDiffResult,
|
||||||
OrchestrationShellSnapshot,
|
OrchestrationShellSnapshot,
|
||||||
|
OrchestrationThreadShell,
|
||||||
OrchestrationShellStreamItem,
|
OrchestrationShellStreamItem,
|
||||||
OrchestrationSubscribeThreadInput,
|
OrchestrationSubscribeThreadInput,
|
||||||
OrchestrationThreadStreamItem,
|
OrchestrationThreadStreamItem,
|
||||||
@@ -1245,6 +1246,7 @@ export interface EnvironmentApi {
|
|||||||
input: OrchestrationGetFullThreadDiffInput,
|
input: OrchestrationGetFullThreadDiffInput,
|
||||||
) => Promise<OrchestrationGetFullThreadDiffResult>;
|
) => Promise<OrchestrationGetFullThreadDiffResult>;
|
||||||
getArchivedShellSnapshot: () => Promise<OrchestrationShellSnapshot>;
|
getArchivedShellSnapshot: () => Promise<OrchestrationShellSnapshot>;
|
||||||
|
getClosedTaskTabs: () => Promise<ReadonlyArray<OrchestrationThreadShell>>;
|
||||||
subscribeShell: (
|
subscribeShell: (
|
||||||
callback: (event: OrchestrationShellStreamItem) => void,
|
callback: (event: OrchestrationShellStreamItem) => void,
|
||||||
options?: {
|
options?: {
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ const STATIC_KEYBINDING_COMMANDS = [
|
|||||||
"commandPalette.toggle",
|
"commandPalette.toggle",
|
||||||
"chat.new",
|
"chat.new",
|
||||||
"chat.newLocal",
|
"chat.newLocal",
|
||||||
|
"chat.newTab",
|
||||||
|
"chat.reopenClosedTab",
|
||||||
"editor.openFavorite",
|
"editor.openFavorite",
|
||||||
...MODEL_PICKER_KEYBINDING_COMMANDS,
|
...MODEL_PICKER_KEYBINDING_COMMANDS,
|
||||||
...THREAD_KEYBINDING_COMMANDS,
|
...THREAD_KEYBINDING_COMMANDS,
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import {
|
|||||||
ThreadId,
|
ThreadId,
|
||||||
TrimmedNonEmptyString,
|
TrimmedNonEmptyString,
|
||||||
TurnId,
|
TurnId,
|
||||||
|
WorkspaceTaskId,
|
||||||
} from "./baseSchemas.ts";
|
} from "./baseSchemas.ts";
|
||||||
import { ProviderInstanceId } from "./providerInstance.ts";
|
import { ProviderInstanceId } from "./providerInstance.ts";
|
||||||
|
|
||||||
@@ -28,6 +29,7 @@ export const ORCHESTRATION_WS_METHODS = {
|
|||||||
getFullThreadDiff: "orchestration.getFullThreadDiff",
|
getFullThreadDiff: "orchestration.getFullThreadDiff",
|
||||||
replayEvents: "orchestration.replayEvents",
|
replayEvents: "orchestration.replayEvents",
|
||||||
getArchivedShellSnapshot: "orchestration.getArchivedShellSnapshot",
|
getArchivedShellSnapshot: "orchestration.getArchivedShellSnapshot",
|
||||||
|
getClosedTaskTabs: "orchestration.getClosedTaskTabs",
|
||||||
subscribeShell: "orchestration.subscribeShell",
|
subscribeShell: "orchestration.subscribeShell",
|
||||||
subscribeThread: "orchestration.subscribeThread",
|
subscribeThread: "orchestration.subscribeThread",
|
||||||
} as const;
|
} as const;
|
||||||
@@ -342,9 +344,28 @@ export const OrchestrationLatestTurn = Schema.Struct({
|
|||||||
});
|
});
|
||||||
export type OrchestrationLatestTurn = typeof OrchestrationLatestTurn.Type;
|
export type OrchestrationLatestTurn = typeof OrchestrationLatestTurn.Type;
|
||||||
|
|
||||||
|
export const ThreadForkProvenance = Schema.Struct({
|
||||||
|
mode: Schema.Literals(["fresh", "portable"]),
|
||||||
|
sourceThreadId: Schema.NullOr(ThreadId),
|
||||||
|
createdAt: IsoDateTime,
|
||||||
|
});
|
||||||
|
export type ThreadForkProvenance = typeof ThreadForkProvenance.Type;
|
||||||
|
|
||||||
|
const ThreadTaskFields = {
|
||||||
|
// Optional at the wire boundary so a task-aware client remains compatible
|
||||||
|
// with pre-task servers. New servers always materialize these fields and
|
||||||
|
// legacy rows are backfilled to one task with one tab.
|
||||||
|
workspaceTaskId: Schema.optional(WorkspaceTaskId),
|
||||||
|
tabLabel: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
||||||
|
tabPosition: Schema.optional(NonNegativeInt),
|
||||||
|
tabClosedAt: Schema.optional(Schema.NullOr(IsoDateTime)),
|
||||||
|
forkProvenance: Schema.optional(Schema.NullOr(ThreadForkProvenance)),
|
||||||
|
} as const;
|
||||||
|
|
||||||
export const OrchestrationThread = Schema.Struct({
|
export const OrchestrationThread = Schema.Struct({
|
||||||
id: ThreadId,
|
id: ThreadId,
|
||||||
projectId: ProjectId,
|
projectId: ProjectId,
|
||||||
|
...ThreadTaskFields,
|
||||||
title: TrimmedNonEmptyString,
|
title: TrimmedNonEmptyString,
|
||||||
modelSelection: ModelSelection,
|
modelSelection: ModelSelection,
|
||||||
runtimeMode: RuntimeMode,
|
runtimeMode: RuntimeMode,
|
||||||
@@ -401,6 +422,7 @@ export type OrchestrationProjectShell = typeof OrchestrationProjectShell.Type;
|
|||||||
export const OrchestrationThreadShell = Schema.Struct({
|
export const OrchestrationThreadShell = Schema.Struct({
|
||||||
id: ThreadId,
|
id: ThreadId,
|
||||||
projectId: ProjectId,
|
projectId: ProjectId,
|
||||||
|
...ThreadTaskFields,
|
||||||
title: TrimmedNonEmptyString,
|
title: TrimmedNonEmptyString,
|
||||||
modelSelection: ModelSelection,
|
modelSelection: ModelSelection,
|
||||||
runtimeMode: RuntimeMode,
|
runtimeMode: RuntimeMode,
|
||||||
@@ -427,6 +449,9 @@ export const OrchestrationThreadShell = Schema.Struct({
|
|||||||
});
|
});
|
||||||
export type OrchestrationThreadShell = typeof OrchestrationThreadShell.Type;
|
export type OrchestrationThreadShell = typeof OrchestrationThreadShell.Type;
|
||||||
|
|
||||||
|
export const OrchestrationClosedTaskTabs = Schema.Array(OrchestrationThreadShell);
|
||||||
|
export type OrchestrationClosedTaskTabs = typeof OrchestrationClosedTaskTabs.Type;
|
||||||
|
|
||||||
export const OrchestrationShellSnapshot = Schema.Struct({
|
export const OrchestrationShellSnapshot = Schema.Struct({
|
||||||
snapshotSequence: NonNegativeInt,
|
snapshotSequence: NonNegativeInt,
|
||||||
projects: Schema.Array(OrchestrationProjectShell),
|
projects: Schema.Array(OrchestrationProjectShell),
|
||||||
@@ -546,6 +571,7 @@ const ThreadCreateCommand = Schema.Struct({
|
|||||||
commandId: CommandId,
|
commandId: CommandId,
|
||||||
threadId: ThreadId,
|
threadId: ThreadId,
|
||||||
projectId: ProjectId,
|
projectId: ProjectId,
|
||||||
|
...ThreadTaskFields,
|
||||||
title: TrimmedNonEmptyString,
|
title: TrimmedNonEmptyString,
|
||||||
modelSelection: ModelSelection,
|
modelSelection: ModelSelection,
|
||||||
runtimeMode: RuntimeMode,
|
runtimeMode: RuntimeMode,
|
||||||
@@ -621,6 +647,9 @@ const ThreadMetaUpdateCommand = Schema.Struct({
|
|||||||
branch: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
branch: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
||||||
expectedBranch: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
expectedBranch: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
||||||
worktreePath: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
worktreePath: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
||||||
|
tabLabel: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
||||||
|
tabPosition: Schema.optional(NonNegativeInt),
|
||||||
|
tabClosedAt: Schema.optional(Schema.NullOr(IsoDateTime)),
|
||||||
});
|
});
|
||||||
|
|
||||||
const ThreadRuntimeModeSetCommand = Schema.Struct({
|
const ThreadRuntimeModeSetCommand = Schema.Struct({
|
||||||
@@ -641,6 +670,7 @@ const ThreadInteractionModeSetCommand = Schema.Struct({
|
|||||||
|
|
||||||
const ThreadTurnStartBootstrapCreateThread = Schema.Struct({
|
const ThreadTurnStartBootstrapCreateThread = Schema.Struct({
|
||||||
projectId: ProjectId,
|
projectId: ProjectId,
|
||||||
|
...ThreadTaskFields,
|
||||||
title: TrimmedNonEmptyString,
|
title: TrimmedNonEmptyString,
|
||||||
modelSelection: ModelSelection,
|
modelSelection: ModelSelection,
|
||||||
runtimeMode: RuntimeMode,
|
runtimeMode: RuntimeMode,
|
||||||
@@ -940,6 +970,7 @@ export const ProjectDeletedPayload = Schema.Struct({
|
|||||||
export const ThreadCreatedPayload = Schema.Struct({
|
export const ThreadCreatedPayload = Schema.Struct({
|
||||||
threadId: ThreadId,
|
threadId: ThreadId,
|
||||||
projectId: ProjectId,
|
projectId: ProjectId,
|
||||||
|
...ThreadTaskFields,
|
||||||
title: TrimmedNonEmptyString,
|
title: TrimmedNonEmptyString,
|
||||||
modelSelection: ModelSelection,
|
modelSelection: ModelSelection,
|
||||||
runtimeMode: RuntimeMode.pipe(Schema.withDecodingDefault(Effect.succeed(DEFAULT_RUNTIME_MODE))),
|
runtimeMode: RuntimeMode.pipe(Schema.withDecodingDefault(Effect.succeed(DEFAULT_RUNTIME_MODE))),
|
||||||
@@ -1003,6 +1034,9 @@ export const ThreadMetaUpdatedPayload = Schema.Struct({
|
|||||||
modelSelection: Schema.optional(ModelSelection),
|
modelSelection: Schema.optional(ModelSelection),
|
||||||
branch: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
branch: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
||||||
worktreePath: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
worktreePath: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
||||||
|
tabLabel: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
||||||
|
tabPosition: Schema.optional(NonNegativeInt),
|
||||||
|
tabClosedAt: Schema.optional(Schema.NullOr(IsoDateTime)),
|
||||||
updatedAt: IsoDateTime,
|
updatedAt: IsoDateTime,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1392,6 +1426,10 @@ export const OrchestrationRpcSchemas = {
|
|||||||
input: Schema.Struct({}),
|
input: Schema.Struct({}),
|
||||||
output: OrchestrationShellSnapshot,
|
output: OrchestrationShellSnapshot,
|
||||||
},
|
},
|
||||||
|
getClosedTaskTabs: {
|
||||||
|
input: Schema.Struct({}),
|
||||||
|
output: OrchestrationClosedTaskTabs,
|
||||||
|
},
|
||||||
subscribeThread: {
|
subscribeThread: {
|
||||||
input: OrchestrationSubscribeThreadInput,
|
input: OrchestrationSubscribeThreadInput,
|
||||||
output: OrchestrationThreadStreamItem,
|
output: OrchestrationThreadStreamItem,
|
||||||
|
|||||||
@@ -646,6 +646,15 @@ export const WsOrchestrationGetArchivedShellSnapshotRpc = Rpc.make(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const WsOrchestrationGetClosedTaskTabsRpc = Rpc.make(
|
||||||
|
ORCHESTRATION_WS_METHODS.getClosedTaskTabs,
|
||||||
|
{
|
||||||
|
payload: OrchestrationRpcSchemas.getClosedTaskTabs.input,
|
||||||
|
success: OrchestrationRpcSchemas.getClosedTaskTabs.output,
|
||||||
|
error: Schema.Union([OrchestrationGetSnapshotError, EnvironmentAuthorizationError]),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
export const WsOrchestrationSubscribeShellRpc = Rpc.make(ORCHESTRATION_WS_METHODS.subscribeShell, {
|
export const WsOrchestrationSubscribeShellRpc = Rpc.make(ORCHESTRATION_WS_METHODS.subscribeShell, {
|
||||||
payload: OrchestrationRpcSchemas.subscribeShell.input,
|
payload: OrchestrationRpcSchemas.subscribeShell.input,
|
||||||
success: OrchestrationRpcSchemas.subscribeShell.output,
|
success: OrchestrationRpcSchemas.subscribeShell.output,
|
||||||
@@ -767,6 +776,7 @@ export const WsRpcGroup = RpcGroup.make(
|
|||||||
WsOrchestrationGetFullThreadDiffRpc,
|
WsOrchestrationGetFullThreadDiffRpc,
|
||||||
WsOrchestrationReplayEventsRpc,
|
WsOrchestrationReplayEventsRpc,
|
||||||
WsOrchestrationGetArchivedShellSnapshotRpc,
|
WsOrchestrationGetArchivedShellSnapshotRpc,
|
||||||
|
WsOrchestrationGetClosedTaskTabsRpc,
|
||||||
WsOrchestrationSubscribeShellRpc,
|
WsOrchestrationSubscribeShellRpc,
|
||||||
WsOrchestrationSubscribeThreadRpc,
|
WsOrchestrationSubscribeThreadRpc,
|
||||||
);
|
);
|
||||||
@@ -36,6 +36,8 @@ export const DEFAULT_KEYBINDINGS: ReadonlyArray<KeybindingRule> = [
|
|||||||
{ key: "mod+0", command: "preview.resetZoom", when: "previewFocus" },
|
{ key: "mod+0", command: "preview.resetZoom", when: "previewFocus" },
|
||||||
{ key: "mod+k", command: "commandPalette.toggle", when: "!terminalFocus" },
|
{ key: "mod+k", command: "commandPalette.toggle", when: "!terminalFocus" },
|
||||||
{ key: "mod+n", command: "chat.new", when: "!terminalFocus" },
|
{ key: "mod+n", command: "chat.new", when: "!terminalFocus" },
|
||||||
|
{ key: "mod+t", command: "chat.newTab", when: "!terminalFocus" },
|
||||||
|
{ key: "mod+shift+t", command: "chat.reopenClosedTab", when: "!terminalFocus" },
|
||||||
{ key: "mod+shift+o", command: "chat.new", when: "!terminalFocus" },
|
{ key: "mod+shift+o", command: "chat.new", when: "!terminalFocus" },
|
||||||
{ key: "mod+shift+n", command: "chat.newLocal", when: "!terminalFocus" },
|
{ key: "mod+shift+n", command: "chat.newLocal", when: "!terminalFocus" },
|
||||||
{ key: "mod+shift+m", command: "modelPicker.toggle", when: "!terminalFocus" },
|
{ key: "mod+shift+m", command: "modelPicker.toggle", when: "!terminalFocus" },
|
||||||
|
|||||||
Reference in new issue
Block a user