@@ -319,6 +338,13 @@ export function ThreadDetailsPanel(props: ThreadDetailsPanelProps) {
threadId={props.threadId}
showLineage={visible.lineage}
showSideChats={visible.sideChats}
+ extraGroup={
+ boardTask && taskHasRelatedWork(boardTask) ? (
+
+
+
+ ) : undefined
+ }
/>
) : null}
diff --git a/apps/web/src/components/chat/ThreadPanelHostContext.ts b/apps/web/src/components/chat/ThreadPanelHostContext.ts
new file mode 100644
index 0000000000000..d72eff10bb1d8
--- /dev/null
+++ b/apps/web/src/components/chat/ThreadPanelHostContext.ts
@@ -0,0 +1,9 @@
+import { createContext, useContext } from "react";
+import type { ScopedThreadRef } from "@t3tools/contracts";
+
+/**
+ * A containing workspace whose own thread keeps the panels while it shows a related thread in its
+ * place: that thread's view shows the host thread's right panel and details panel, not its own.
+ */
+export const ThreadPanelHostContext = createContext(null);
+export const useThreadPanelHost = () => useContext(ThreadPanelHostContext);
diff --git a/apps/web/src/components/chat/ThreadRelationshipsControl.browser.test.tsx b/apps/web/src/components/chat/ThreadRelationshipsControl.browser.test.tsx
index 7f153ed048b4c..013a907ee73b3 100644
--- a/apps/web/src/components/chat/ThreadRelationshipsControl.browser.test.tsx
+++ b/apps/web/src/components/chat/ThreadRelationshipsControl.browser.test.tsx
@@ -2,6 +2,7 @@ import "~/index.css";
import { ThreadInspectionContext } from "./ThreadInspectionContext";
import * as DateTime from "effect/DateTime";
import { EnvironmentId, NodeId, ThreadId } from "@t3tools/contracts";
+import type { ReactNode } from "react";
import * as Cause from "effect/Cause";
import { AsyncResult } from "effect/reactivity";
import { expect, it, vi } from "vite-plus/test";
@@ -177,6 +178,36 @@ it.each([
}
});
+it("shows a group its host adds after the lineage's own, even where the thread has no other", async () => {
+ setup();
+ state.projection = {
+ ...(state.projection as object),
+ thread: {
+ id: threadId,
+ title: "Task conversation",
+ activeProviderThreadId: null,
+ lineage: { parentThreadId: null },
+ forkedFrom: null,
+ },
+ };
+ const panel = (extraGroup?: ReactNode, showLineage = true) => (
+
+ );
+ await using screen = await render(panel());
+ expect(screen.container.querySelector("[data-thread-relationships-panel]")).toBeNull();
+ await screen.rerender(panel(
Child tasks of the host
));
+ await expect.element(screen.getByText("Child tasks of the host")).toBeVisible();
+ // Lineage switched off hides the host's group with it.
+ await screen.rerender(panel(
Child tasks of the host
, false));
+ await expect.element(screen.getByText("Child tasks of the host")).not.toBeInTheDocument();
+});
+
it("opens an idle child beside the thread, and in its place with the modifier", async () => {
setup();
const projection = makeThreadProjectionFixture();
diff --git a/apps/web/src/components/chat/ThreadRelationshipsControl.tsx b/apps/web/src/components/chat/ThreadRelationshipsControl.tsx
index ae2ea727de208..eba91b3e8445a 100644
--- a/apps/web/src/components/chat/ThreadRelationshipsControl.tsx
+++ b/apps/web/src/components/chat/ThreadRelationshipsControl.tsx
@@ -487,6 +487,8 @@ export function ThreadRelationshipsPanel(props: {
readonly threadId: ThreadId;
readonly showLineage: boolean;
readonly showSideChats: boolean;
+ /** A group the host adds after the lineage's own, such as a board task's child tasks. */
+ readonly extraGroup?: ReactNode;
}) {
const gt = useGT();
const m = useMessages();
@@ -677,7 +679,8 @@ export function ThreadRelationshipsPanel(props: {
const lineageVisible =
props.showLineage &&
- (related.length > 0 ||
+ (props.extraGroup !== undefined ||
+ related.length > 0 ||
active.length > 0 ||
previous.length > 0 ||
runningCount > 0 ||
@@ -1144,6 +1147,7 @@ export function ThreadRelationshipsPanel(props: {
}
))}
+ {props.extraGroup}
) : null}
{sideChatsVisible ? (
diff --git a/apps/web/src/components/chat/threadDetailsItems.test.ts b/apps/web/src/components/chat/threadDetailsItems.test.ts
index 6e3e746fd7648..6c90b31ed930c 100644
--- a/apps/web/src/components/chat/threadDetailsItems.test.ts
+++ b/apps/web/src/components/chat/threadDetailsItems.test.ts
@@ -1,13 +1,16 @@
import { describe, expect, it } from "vite-plus/test";
import {
+ isDefaultThreadDetailsVisibility,
resolveThreadDetailsVisibility,
+ RESET_THREAD_DETAILS_ITEMS,
setThreadDetailsItem,
THREAD_DETAILS_ITEMS,
} from "./threadDetailsItems";
const usage = THREAD_DETAILS_ITEMS.find((item) => item.id === "usage")!;
const servers = THREAD_DETAILS_ITEMS.find((item) => item.id === "servers")!;
+const task = THREAD_DETAILS_ITEMS.find((item) => item.id === "task")!;
describe("thread details items", () => {
it.each([
@@ -33,4 +36,21 @@ describe("thread details items", () => {
const hidden = { threadDetailsItems: { servers: false }, threadDetailsUsageEnabled: false };
expect(setThreadDetailsItem(hidden, servers, true)).toEqual({});
});
+
+ it("shows the Task item by default, keeps it off once switched off, and resets it to on", () => {
+ const fresh = { threadDetailsItems: {}, threadDetailsUsageEnabled: false };
+ expect(resolveThreadDetailsVisibility(fresh).task).toBe(true);
+ expect(isDefaultThreadDetailsVisibility(resolveThreadDetailsVisibility(fresh))).toBe(true);
+
+ const off = setThreadDetailsItem(fresh, task, false);
+ expect(off).toEqual({ task: false });
+ const switchedOff = { threadDetailsItems: off, threadDetailsUsageEnabled: false };
+ expect(resolveThreadDetailsVisibility(switchedOff).task).toBe(false);
+ expect(isDefaultThreadDetailsVisibility(resolveThreadDetailsVisibility(switchedOff))).toBe(
+ false,
+ );
+ expect(setThreadDetailsItem(switchedOff, task, true)).toEqual({});
+
+ expect(resolveThreadDetailsVisibility(RESET_THREAD_DETAILS_ITEMS).task).toBe(true);
+ });
});
diff --git a/apps/web/src/components/chat/threadDetailsItems.ts b/apps/web/src/components/chat/threadDetailsItems.ts
index 9f8f05449c550..d1f0c3cd3c500 100644
--- a/apps/web/src/components/chat/threadDetailsItems.ts
+++ b/apps/web/src/components/chat/threadDetailsItems.ts
@@ -3,6 +3,12 @@ import { msg } from "gt-react";
// Ids are stored in client settings, so never rename one.
export const THREAD_DETAILS_ITEMS = [
+ // Shown only where a board task's view hosts the thread; any other thread has nothing for it.
+ {
+ id: "task",
+ label: msg("Task", { $context: "thread details item: the board task a thread belongs to" }),
+ defaultVisible: true,
+ },
{ id: "environment", label: msg("Environment and worktree"), defaultVisible: true },
{ id: "openIn", label: msg("Open in editor"), defaultVisible: true },
{ id: "scripts", label: msg("Project scripts"), defaultVisible: true },
diff --git a/apps/web/src/components/delivery/ArchivedBoardThreads.logic.test.ts b/apps/web/src/components/delivery/ArchivedBoardThreads.logic.test.ts
index 2a8e2e9db26c5..b340216b8e82d 100644
--- a/apps/web/src/components/delivery/ArchivedBoardThreads.logic.test.ts
+++ b/apps/web/src/components/delivery/ArchivedBoardThreads.logic.test.ts
@@ -1,7 +1,11 @@
import { ProjectId, ThreadId } from "@t3tools/contracts";
import { expect, it } from "vite-plus/test";
-import { archivedThreadsOfBoard, archivedThreadTaskNote } from "./ArchivedBoardThreads.logic";
+import {
+ archivedThreadsOfBoard,
+ archivedThreadTarget,
+ archivedThreadTaskNote,
+} from "./ArchivedBoardThreads.logic";
const thread = (board: string, taskId: string, archivedAt: string) => ({
threadId: ThreadId.make(`thread-${taskId}`),
@@ -39,3 +43,20 @@ it("offers a restore only for a task that can take the thread back, and says why
);
expect(archivedThreadTaskNote({ ...row, task: "held" })).toBe("The task is held elsewhere.");
});
+
+it("opens a restorable task's conversation in the task's view, and a deleted task's on its own", () => {
+ const row = thread("work", "task-a", "2026-11-20T10:00:00.000Z");
+ // The task comes from what the server serves for the row, never from the thread itself.
+ expect(archivedThreadTarget(row)).toEqual({ kind: "task", taskId: "task-a" });
+ expect(archivedThreadTarget({ ...row, task: "deleted" })).toEqual({
+ kind: "thread",
+ threadId: row.threadId,
+ });
+ // A task held elsewhere or not checked cannot take the thread back, so neither has a view here.
+ for (const task of ["held", "unknown"] as const) {
+ expect(archivedThreadTarget({ ...row, task })).toEqual({
+ kind: "thread",
+ threadId: row.threadId,
+ });
+ }
+});
diff --git a/apps/web/src/components/delivery/ArchivedBoardThreads.logic.ts b/apps/web/src/components/delivery/ArchivedBoardThreads.logic.ts
index 97bb55c17389d..49d050d4b9f9b 100644
--- a/apps/web/src/components/delivery/ArchivedBoardThreads.logic.ts
+++ b/apps/web/src/components/delivery/ArchivedBoardThreads.logic.ts
@@ -15,6 +15,16 @@ export function archivedThreadsOfBoard(
.toSorted((a, b) => b.archivedAt.localeCompare(a.archivedAt));
}
+/**
+ * Where a row opens. A task that can take its conversation back has a view on the board, where
+ * the conversation opens with it; a row whose task cannot has no task view, so it opens alone.
+ */
+export function archivedThreadTarget(thread: ArchivedBoardThread) {
+ return thread.task === "open"
+ ? ({ kind: "task", taskId: thread.taskId } as const)
+ : ({ kind: "thread", threadId: thread.threadId } as const);
+}
+
/**
* What the archive says under a thread whose task cannot take it back, or null for one that can
* and is offered a restore. A restored thread of any other task holds nothing and is archived
diff --git a/apps/web/src/components/delivery/ArchivedBoardThreads.tsx b/apps/web/src/components/delivery/ArchivedBoardThreads.tsx
index 1f19afd36d8f7..95d9bb77e4195 100644
--- a/apps/web/src/components/delivery/ArchivedBoardThreads.tsx
+++ b/apps/web/src/components/delivery/ArchivedBoardThreads.tsx
@@ -14,6 +14,7 @@ import { Popover, PopoverPopup, PopoverTitle, PopoverTrigger } from "../ui/popov
import { toastManager } from "../ui/toast";
import {
archivedThreadsOfBoard,
+ archivedThreadTarget,
archivedThreadTaskNote,
type ArchivedBoardThread,
} from "./ArchivedBoardThreads.logic";
@@ -111,15 +112,22 @@ export function ArchivedBoardThreads(props: {
diff --git a/apps/web/src/components/delivery/BoardSidebarPanel.logic.test.ts b/apps/web/src/components/delivery/BoardSidebarPanel.logic.test.ts
new file mode 100644
index 0000000000000..1ff5bc39eda72
--- /dev/null
+++ b/apps/web/src/components/delivery/BoardSidebarPanel.logic.test.ts
@@ -0,0 +1,77 @@
+import { EnvironmentId, ThreadId } from "@t3tools/contracts";
+import { describe, expect, it } from "vite-plus/test";
+
+import { parseCard, type TaskBrief } from "../../lib/delivery";
+import { NO_FILTERS } from "../../lib/deliveryBoard";
+import { panelCards, switcherGroups, type SwitcherRow } from "./BoardSidebarPanel.logic";
+
+const card = (id: string, number: number, extra: Record = {}) =>
+ parseCard({ id, number, title: `Task ${number}`, lane: "ready", state: "ready", ...extra });
+const brief = (id: string, number: number): TaskBrief => ({
+ id,
+ number,
+ title: `Task ${number}`,
+ state: "ready",
+ lane: "ready",
+});
+const seatThread = { environmentId: EnvironmentId.make("env"), threadId: ThreadId.make("seat") };
+const seat = { seat: "builder", activity: "active", thread: seatThread };
+
+/** A row as its id and depth, the open task marked: what the column draws, in order. */
+const shape = (rows: ReadonlyArray) =>
+ rows.map((row) =>
+ row.kind === "seat"
+ ? `seat:${row.seat}@${row.depth}`
+ : `${row.brief.id}@${row.depth}${row.current ? "*" : ""}`,
+ );
+
+describe("the board's column", () => {
+ it("lists by the board's filters on the board, and by its own search alone while a task is open", () => {
+ const cards = [card("a", 1, { tags: ["sync"] }), card("b", 2, { priority: "high" })];
+ const filters = { ...NO_FILTERS, tags: ["sync"], lanes: ["queue"], priority: "low" as const };
+ expect(panelCards(cards, filters, false)).toEqual([]);
+ expect(panelCards(cards, filters, true)).toEqual(cards);
+ });
+
+ it("nests the open task's current children and seat conversations under its row, each task once", () => {
+ const cards = [card("t1", 1), card("t2", 2), card("t3", 3)];
+ const rows = switcherGroups(cards, {
+ open: cards[0]!,
+ parent: null,
+ children: [brief("t2", 2)],
+ seats: [seat],
+ });
+ expect(shape(rows.open)).toEqual(["t1@0*", "t2@1", "seat:builder@1", "t3@0"]);
+ });
+
+ it("puts the parent's row above the open task, nested under it, and the task's own family one deeper", () => {
+ const cards = [card("t1", 1), card("t2", 2), card("t4", 4)];
+ const rows = switcherGroups(cards, {
+ open: cards[1]!,
+ parent: brief("t1", 1),
+ children: [brief("t4", 4)],
+ seats: [seat],
+ });
+ expect(shape(rows.open)).toEqual(["t1@0", "t2@1*", "t4@2", "seat:builder@2"]);
+ });
+
+ it("shows what the list did not read from the open task's own read, at the head of its group", () => {
+ // A part is off the board while its whole is on it, so the list may hold neither.
+ const waiting = { waitingOn: "person", waitsOnPerson: true };
+ const open = card("t2", 2, waiting);
+ const rows = switcherGroups([card("t9", 9, waiting)], {
+ open,
+ parent: brief("t1", 1),
+ children: [{ ...brief("t3", 3), lane: "human-review" }],
+ seats: [],
+ });
+ expect(shape(rows.waiting)).toEqual(["t1@0", "t2@1*", "t3@2", "t9@0"]);
+ // The open task waits by its own card; a task known only by its brief, by its lane.
+ expect(rows.waiting.map((row) => row.kind === "task" && row.waits)).toEqual([
+ false,
+ true,
+ true,
+ true,
+ ]);
+ });
+});
diff --git a/apps/web/src/components/delivery/BoardSidebarPanel.logic.ts b/apps/web/src/components/delivery/BoardSidebarPanel.logic.ts
new file mode 100644
index 0000000000000..85ba23c1f3f4c
--- /dev/null
+++ b/apps/web/src/components/delivery/BoardSidebarPanel.logic.ts
@@ -0,0 +1,154 @@
+import type { ScopedThreadRef } from "@t3tools/contracts";
+
+import { waitKindsOf } from "../../lib/boardLaneCards";
+import { BOARD_LANE, boardLaneOf } from "../../lib/boardLanes";
+import { seatsAtWork, type DeliveryCard, type TaskBrief } from "../../lib/delivery";
+import { matchesCard, type BoardFilters } from "../../lib/deliveryBoard";
+
+/** The column's groups, in the order they show. */
+export const PANEL_GROUPS = ["waiting", "working", "chats", "drafts", "open", "done"] as const;
+export type PanelGroup = (typeof PANEL_GROUPS)[number];
+
+/**
+ * What the column lists. On the board, the board's filters narrow it. While a task is open the
+ * column is a switcher: its own search narrows it, and the board's filters neither show nor apply,
+ * so the board still has them when the person goes back.
+ */
+export function panelCards(
+ cards: ReadonlyArray,
+ filters: BoardFilters,
+ switching: boolean,
+): ReadonlyArray {
+ return switching ? cards : cards.filter((card) => matchesCard(card, { ...filters, q: "" }));
+}
+
+const groupOf = (card: DeliveryCard): PanelGroup => {
+ if (card.lane === "completed") return "done";
+ if (card.lane === "draft") return "drafts";
+ if (card.lane === "chat") return "chats";
+ if (card.waitingOn === "person") return "waiting";
+ // Being worked on: a seat is at work. A card whose seats are all held waits with the rest.
+ return seatsAtWork(card).length > 0 ? "working" : "open";
+};
+
+/** The cards by group. Done keeps its last twenty. */
+export function panelGroups(
+ cards: ReadonlyArray,
+): Readonly>> {
+ const groups: Record = {
+ waiting: [],
+ working: [],
+ chats: [],
+ drafts: [],
+ open: [],
+ done: [],
+ };
+ for (const card of cards) groups[groupOf(card)].push(card);
+ return { ...groups, done: groups.done.slice(0, 20) };
+}
+
+/** The open task and what the switcher nests with it, all from the board's own read. */
+export interface SwitcherFamily {
+ readonly open: DeliveryCard;
+ readonly parent: TaskBrief | null;
+ /** Its current parts and QA follow-ups. */
+ readonly children: ReadonlyArray;
+ /** The seats of its conversation that have one; a seat with none has no row. */
+ readonly seats: ReadonlyArray<{
+ readonly seat: string;
+ readonly activity: string;
+ readonly thread: ScopedThreadRef;
+ }>;
+}
+
+export type SwitcherRow =
+ | {
+ readonly kind: "task";
+ readonly brief: TaskBrief;
+ /** The board's card for the task, when it was read. */
+ readonly card: DeliveryCard | null;
+ /** The needs-you dot. */
+ readonly waits: boolean;
+ readonly depth: 0 | 1 | 2;
+ readonly current: boolean;
+ }
+ | {
+ readonly kind: "seat";
+ readonly seat: string;
+ readonly activity: string;
+ readonly thread: ScopedThreadRef;
+ readonly depth: 1 | 2;
+ };
+
+const briefOf = (card: DeliveryCard): TaskBrief => ({
+ id: card.id,
+ number: card.number,
+ title: card.title,
+ state: card.state,
+ lane: card.lane,
+});
+
+/**
+ * A task's row. A task known only by its brief, such as a part, which is off the board while its
+ * whole is on it, waits on you when its lane is the board's one lane that does.
+ */
+export const taskRowOf = (
+ brief: TaskBrief,
+ card: DeliveryCard | null,
+ depth: 0 | 1 | 2,
+ current: boolean,
+): SwitcherRow => ({
+ kind: "task",
+ brief,
+ card,
+ waits: card
+ ? waitKindsOf(card).length > 0
+ : boardLaneOf(brief.lane ?? "") === BOARD_LANE.needsDecision,
+ depth,
+ current,
+});
+
+/**
+ * The switcher's rows by group, each task listed once. The open task's family sits in its
+ * root's group: under the root, its parent if it has one, then the open task, its current child
+ * tasks and its seat conversations, one level deeper each. A root the list did not read is shown
+ * from what the open task says of it, at the head of the open task's group.
+ */
+export function switcherGroups(
+ cards: ReadonlyArray,
+ family: SwitcherFamily | null,
+): Readonly>> {
+ // The open task's own read has its card when the list does not, as for a part.
+ const byId = new Map([
+ ...(family ? [[family.open.id, family.open] as const] : []),
+ ...cards.map((card) => [card.id, card] as const),
+ ]);
+ const taskRow = (brief: TaskBrief, depth: 0 | 1 | 2): SwitcherRow =>
+ taskRowOf(brief, byId.get(brief.id) ?? null, depth, family?.open.id === brief.id);
+ const nested = new Set(
+ family ? [...(family.parent ? [family.open.id] : []), ...family.children.map((c) => c.id)] : [],
+ );
+ const groups = panelGroups(cards.filter((card) => !nested.has(card.id)));
+ const rows = Object.fromEntries(
+ PANEL_GROUPS.map((group) => [group, groups[group].map((card) => taskRow(briefOf(card), 0))]),
+ ) as Record;
+ if (!family) return rows;
+
+ const rootId = family.parent?.id ?? family.open.id;
+ const under: 1 | 2 = family.parent ? 2 : 1;
+ const familyRows: SwitcherRow[] = [
+ ...(family.parent ? [taskRow(briefOf(family.open), 1)] : []),
+ ...family.children.map((child) => taskRow(child, under)),
+ ...family.seats.map((seat) => ({ kind: "seat" as const, ...seat, depth: under })),
+ ];
+ for (const group of PANEL_GROUPS) {
+ const at = rows[group].findIndex((row) => row.kind === "task" && row.brief.id === rootId);
+ if (at >= 0) {
+ rows[group].splice(at + 1, 0, ...familyRows);
+ return rows;
+ }
+ }
+ const root = family.parent ?? briefOf(family.open);
+ rows[groupOf(family.open)].unshift(taskRow(root, 0), ...familyRows);
+ return rows;
+}
diff --git a/apps/web/src/components/delivery/BoardSidebarPanel.tsx b/apps/web/src/components/delivery/BoardSidebarPanel.tsx
index 5abbbda495dcf..c3f313aab2656 100644
--- a/apps/web/src/components/delivery/BoardSidebarPanel.tsx
+++ b/apps/web/src/components/delivery/BoardSidebarPanel.tsx
@@ -1,22 +1,29 @@
import { useLocation, useNavigate, useSearch } from "@tanstack/react-router";
import type { EnvironmentId } from "@t3tools/contracts";
-import { ChevronRightIcon, PlusIcon, SearchIcon, UsersIcon, XIcon } from "lucide-react";
+import { useGT } from "gt-react";
+import {
+ ArrowLeftIcon,
+ ChevronRightIcon,
+ PlusIcon,
+ SearchIcon,
+ UsersIcon,
+ XIcon,
+} from "lucide-react";
import { useMemo, useState, type ReactNode } from "react";
import {
parseBoard,
parseCards,
+ parseTask,
TASK_PRIORITIES,
type DeliveryCard,
type TaskPriority,
crewLine,
- seatsAtWork,
} from "../../lib/delivery";
import {
activeFilters,
hasFilters,
LANE_TITLE,
- matchesCard,
PRIORITY_LABEL,
queryValue,
boardSetOf,
@@ -41,10 +48,33 @@ import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../
import { SidebarContent, SidebarGroup, useSidebar } from "../ui/sidebar";
import { APP_BUILD } from "../../branding";
import { ActiveFilterChips, LaneFilterMenu, TagFilterMenu } from "./BoardFilterControls";
+import {
+ PANEL_GROUPS,
+ panelCards,
+ panelGroups,
+ switcherGroups,
+ taskRowOf,
+ type PanelGroup,
+ type SwitcherFamily,
+ type SwitcherRow,
+} from "./BoardSidebarPanel.logic";
+import { BoardSwitcherRows } from "./BoardSwitcher";
import { Age, CardSigns, laneTone, PriorityPill } from "./taskParts";
import { BoardIcon } from "./BoardIcon";
import { EnvironmentPicker } from "./EnvironmentPicker";
import { EngineDownNotice } from "./EnginePanel";
+import { relatedTaskGroups } from "./relatedTaskGroups";
+import { useTaskConversation } from "./useTaskConversation";
+
+/** Each group's name, title and what it says when it is empty, in the order they show. */
+const GROUP_TITLES: Readonly> = {
+ waiting: "Waiting on you",
+ working: "Being worked on",
+ chats: "Team chats",
+ drafts: "Drafts",
+ open: "With the team",
+ done: "Done",
+};
const ANY = "__any__";
@@ -168,6 +198,34 @@ function Section(props: {
);
}
+/** A group of the switcher: its tasks as rows, with the open task's family nested under its root. */
+function SwitcherSection(props: {
+ readonly environmentId: EnvironmentId | null;
+ readonly name: string;
+ readonly title: string;
+ readonly rows: ReadonlyArray;
+ readonly empty?: string;
+ readonly defaultFolded?: boolean;
+ readonly list: (rows: ReadonlyArray) => ReactNode;
+}) {
+ if (props.rows.length === 0 && !props.empty) return null;
+ return (
+ row.kind === "task").length}
+ {...(props.defaultFolded ? { defaultFolded: true } : {})}
+ >
+ {props.rows.length === 0 ? (
+
{props.empty}
+ ) : (
+ props.list(props.rows)
+ )}
+
+ );
+}
+
/**
* The sidebar while the Board is open: tasks in place of
* threads. A task is started, found and opened from here, and what waits for
@@ -209,8 +267,20 @@ function EnvironmentBoardSidebar({
const { setFilters, clearFilters } = useBoardControls(environmentId);
const boardSet = boardSetOf(preferences.boardSet);
const now = useMinuteClock();
+ const gt = useGT();
+ // With a task open the column is a switcher: its search is its own, and the board's filters
+ // stay as they were for the board.
+ const openTaskId = location.pathname === "/board" ? (location.search.task ?? null) : null;
+ const switching = openTaskId !== null;
+ const [switcherQuery, setSwitcherQuery] = useState("");
+ // The switcher's search lasts from task to task; the next time a task opens it starts empty.
+ const [wasSwitching, setWasSwitching] = useState(switching);
+ if (wasSwitching !== switching) {
+ setWasSwitching(switching);
+ if (!switching) setSwitcherQuery("");
+ }
- const q = filters.q.trim();
+ const q = (switching ? switcherQuery : filters.q).trim();
// The engine looks in what is asked too, which a card does not carry.
const read = useDeliveryRead(
enabled && !shared ? environmentId : null,
@@ -246,10 +316,29 @@ function EnvironmentBoardSidebar({
() => sidebarCandidates(taskCards, boardCards, q),
[taskCards, boardCards, q],
);
- const kept = useMemo(
- () => cards.filter((card) => matchesCard(card, { ...filters, q: "" })),
- [cards, filters],
+ const kept = panelCards(cards, filters, switching);
+ // The open task as the board reads it, for its family. The task view polls this same read.
+ const taskRead = useDeliveryRead(
+ enabled && openTaskId ? environmentId : null,
+ openTaskId ? `/api/tasks/${openTaskId}` : null,
);
+ const readTask = parseTask(taskRead.body);
+ const openTask = readTask?.id === openTaskId ? readTask : null;
+ const conversation = useTaskConversation(environmentId, openTask);
+ const family: SwitcherFamily | null = openTask
+ ? {
+ open: openTask.card,
+ parent: openTask.parent,
+ children: [
+ ...relatedTaskGroups(openTask.card.parts).current,
+ ...relatedTaskGroups(openTask.followUps).current,
+ ],
+ seats: (openTask.council?.seats ?? []).flatMap((item) => {
+ const thread = conversation.seats.thread(item.seat);
+ return thread ? [{ seat: item.seat, activity: item.activity, thread }] : [];
+ }),
+ }
+ : null;
const teams = useMemo(() => [...new Set(cards.map((card) => card.team))].sort(), [cards]);
// From every card that was read, never from the ones a filter kept.
const tags = useMemo(
@@ -260,13 +349,14 @@ function EnvironmentBoardSidebar({
const close = () => {
if (isMobile) setOpenMobile(false);
};
- const open = (card: DeliveryCard) => {
+ const goToTask = (taskId: string) => {
close();
void navigate({
to: "/board",
- search: { task: card.id, ...(environmentId ? { environment: environmentId } : {}) },
+ search: { task: taskId, ...(environmentId ? { environment: environmentId } : {}) },
});
};
+ const open = (card: DeliveryCard) => goToTask(card.id);
const chooseEnvironment = (environment: string) => {
setDeliveryEnvironment(environment);
void navigate({ to: "/board", search: { environment } });
@@ -278,16 +368,26 @@ function EnvironmentBoardSidebar({
? "The engine did not answer."
: "Reading the board..."
: null;
- const searching = hasFilters(filters);
+ const searching = switching ? q !== "" : hasFilters(filters);
const filterCount = activeFilters(filters, laneTitle).filter((item) => item.key !== "q").length;
- const live = kept.filter((card) => !["completed", "draft", "chat"].includes(card.lane));
- const chats = kept.filter((card) => card.lane === "chat");
- const waiting = live.filter((card) => card.waitingOn === "person");
- // Being worked on: a seat is at work. A card whose seats are all held waits with the rest.
- const working = live.filter(
- (card) => card.waitingOn !== "person" && seatsAtWork(card).length > 0,
+ const groups = panelGroups(kept);
+ const switcherRows = switching && !searching ? switcherGroups(kept, family) : null;
+ const found = kept.map((card) => taskRowOf(card, card, 0, card.id === openTaskId));
+ const backToBoard = () => {
+ close();
+ void navigate({ to: "/board", search: environmentId ? { environment: environmentId } : {} });
+ };
+ const switcherList = (rows: ReadonlyArray) => (
+ {
+ close();
+ conversation.seats.open(thread);
+ }}
+ />
);
- const rest = live.filter((card) => card.waitingOn !== "person" && seatsAtWork(card).length === 0);
if (shared)
return (
@@ -305,6 +405,14 @@ function EnvironmentBoardSidebar({
+ );
+}
+
+/**
+ * The board's tasks as rows on the thread row's shell, while a task is open: the open one is the
+ * page, and its family is nested under its root. A task row opens its task; a seat row opens its
+ * conversation in the centre, and the task stays the page.
+ */
+export function BoardSwitcherRows(props: {
+ readonly rows: ReadonlyArray;
+ readonly openSeat: ScopedThreadRef | null;
+ readonly onOpenTask: (taskId: string) => void;
+ readonly onOpenSeat: (thread: ScopedThreadRef) => void;
+}) {
+ return (
+
+ );
+}
diff --git a/apps/web/src/components/delivery/BoardTaskContext.ts b/apps/web/src/components/delivery/BoardTaskContext.ts
new file mode 100644
index 0000000000000..41daba025e867
--- /dev/null
+++ b/apps/web/src/components/delivery/BoardTaskContext.ts
@@ -0,0 +1,31 @@
+import type { EnvironmentId, ScopedThreadRef } from "@t3tools/contracts";
+import { createContext, useContext } from "react";
+
+import type { TaskView } from "../../lib/delivery";
+import type { SeatConversations } from "./TaskTeamActivity";
+
+/** The board task a view belongs to: its id and the board's own read of it. */
+export interface BoardTask {
+ readonly environmentId: EnvironmentId | null;
+ readonly taskId: string;
+ /** Null while the first read is out, or when there is no such task. */
+ readonly task: TaskView | null;
+ /** What is shown is the last reading, not a live one: it is old, or the engine did not answer. */
+ readonly stale: boolean;
+ /** Reads the task again, after something here changed it. */
+ readonly refresh: () => void;
+ /** Opens another board task in place of this one. */
+ readonly openTask: (taskId: string) => void;
+ /** Opens a conversation in the centre, the way a seat's opens. */
+ readonly openThread: (thread: ScopedThreadRef) => void;
+ /** The seats' own conversations, which the team's rows open. */
+ readonly seats: SeatConversations;
+}
+
+/**
+ * Provided where the board's task view mounts, so what it hosts reads the task from here and never
+ * from the thread on screen, which is a seat's while one is open in the centre.
+ */
+export const BoardTaskContext = createContext(null);
+
+export const useBoardTask = () => useContext(BoardTaskContext);
diff --git a/apps/web/src/components/delivery/DecisionBar.tsx b/apps/web/src/components/delivery/DecisionBar.tsx
new file mode 100644
index 0000000000000..0c207a5667ce1
--- /dev/null
+++ b/apps/web/src/components/delivery/DecisionBar.tsx
@@ -0,0 +1,69 @@
+import type { TaskView } from "../../lib/delivery";
+import { Button } from "../ui/button";
+import { actionHelp, actionLabel } from "./taskActions";
+import { MobileHelp } from "./taskParts";
+
+/**
+ * The decisions a person makes on the task: approve what was tested, send it back with a
+ * reason, start or submit it. A lane of its own above the composer, so that what is written
+ * is never taken for a decision and the buttons are in reach on a phone.
+ */
+export function DecisionBar(props: {
+ readonly task: TaskView;
+ readonly actions: ReadonlyArray;
+ readonly busy: boolean;
+ readonly onAction: (action: string) => void;
+}) {
+ if (props.actions.length === 0) return null;
+ const deciding = props.actions.some((action) => action === "approve" || action === "reject");
+ return (
+
+
+
+ {deciding ? "Your decision" : "What you can do next"}
+ {deciding ? (
+
+ {" "}
+ Messages never count as a decision.
+
+ ) : null}
+
Permission alone never merges. Full-auto mode and the engine's independent merge checks
diff --git a/apps/web/src/components/delivery/RunPanel.tsx b/apps/web/src/components/delivery/RunPanel.tsx
new file mode 100644
index 0000000000000..cc7875e1b66f9
--- /dev/null
+++ b/apps/web/src/components/delivery/RunPanel.tsx
@@ -0,0 +1,217 @@
+import type { EnvironmentId } from "@t3tools/contracts";
+import { useState } from "react";
+
+import { repeatKeys, type TaskView } from "../../lib/delivery";
+import { harnessLabel } from "../../lib/deliverySeats";
+import { useDeliveryAct, useDeliveryRead, usePersonName } from "../../state/delivery";
+import ChatMarkdown from "../ChatMarkdown";
+import { Dialog, DialogHeader, DialogPanel, DialogPopup, DialogTitle } from "../ui/dialog";
+import { Button } from "../ui/button";
+import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select";
+import { Textarea } from "../ui/textarea";
+
+const DOCUMENT_LABEL: Record = {
+ "PLAN.md": "Plan",
+ "REVIEW.md": "Review",
+ "PACK.md": "Evidence pack",
+};
+
+/**
+ * The run under way, for a person following it: the documents it wrote, to read here or have
+ * summarised, the instructions given to it, and a way to give one. An instruction reaches the
+ * seat at work it is for, which starts its step again with it; what is asked is changed by a
+ * change, which goes through triage, not here.
+ */
+export function RunPanel(props: {
+ readonly environmentId: EnvironmentId | null;
+ readonly task: TaskView;
+ readonly onChanged: () => void;
+}) {
+ const { task } = props;
+ const council = task.council;
+ const person = usePersonName();
+ const act = useDeliveryAct(props.environmentId, "run");
+ const [reading, setReading] = useState(null);
+ const [text, setText] = useState("");
+ const [seat, setSeat] = useState("");
+ const [busy, setBusy] = useState(false);
+ const [said, setSaid] = useState(null);
+ if (!council) return null;
+ const steerable = ["running", "paused", "needs-decision"].includes(council.state);
+ const steerKeys = repeatKeys(council.steers.map((steer) => `${steer.at}:${steer.text}`));
+ const give = async () => {
+ if (!text.trim() || busy) return;
+ setBusy(true);
+ const result = await act(`/api/tasks/${task.id}/steer`, {
+ text: text.trim(),
+ seat: seat || null,
+ by: person,
+ });
+ setBusy(false);
+ if (result.ok) {
+ setText("");
+ setSaid(
+ "Given. It is in the history; the step starts again with it once its seats have stopped.",
+ );
+ } else setSaid(result.why);
+ props.onChanged();
+ };
+ const summarise = async (name: string) => {
+ setBusy(true);
+ const result = await act(`/api/tasks/${task.id}/messages`, {
+ kind: "message",
+ text: `Summarise the ${DOCUMENT_LABEL[name] ?? name} (${name}) of run ${council.run} for me in a few lines: what it says will be done, how it will be checked, and anything I should look at.`,
+ by: person,
+ });
+ setBusy(false);
+ setSaid(result.ok ? "Asked the coordinator. The answer comes in the history." : result.why);
+ props.onChanged();
+ };
+ return (
+
+
+ {staleReply
+ ? "This question is no longer waiting. Your draft is kept and cannot be sent."
+ : "Delivery is unconfirmed. Check the engine record before discarding this draft; it will not be sent again automatically."}
+
+
+ {/* Two lines are enough to say which question: the whole of it is in the history above. */}
+
+ Answering {replying.by}:{" "}
+ {replying.text}
+
+ {
+ props.onReplyTo(null);
+ setChosen("message");
+ }}
+ >
+
+
+
+ ) : waits ? (
+
+ A question of {waits.by} waits for you. Choose Answer a question below, or press Answer
+ on it.
+
+ ) : null}
+
+
+ );
+}
diff --git a/apps/web/src/components/delivery/TaskConversation.browser.test.tsx b/apps/web/src/components/delivery/TaskConversation.browser.test.tsx
index 2a1d4d5999e0f..102623466c6c9 100644
--- a/apps/web/src/components/delivery/TaskConversation.browser.test.tsx
+++ b/apps/web/src/components/delivery/TaskConversation.browser.test.tsx
@@ -8,23 +8,45 @@ import "~/index.css";
import { act, fakeTimers, render } from "../../../test/render";
import { parseTask } from "../../lib/delivery";
import type { SeatThread } from "../../lib/taskConversation";
+import {
+ selectThreadPanelOpen,
+ selectThreadRightPanelState,
+ useRightPanelStore,
+} from "../../rightPanelStore";
+import type { ChatViewSlots } from "../ChatView";
import { useThreadInspection } from "../chat/ThreadInspectionContext";
+import { useThreadPanelHost } from "../chat/ThreadPanelHostContext";
import { TaskConversation } from "./TaskConversation";
import { SEAT_LINKED_VIEW_DELAY_MS, useSteadySeat } from "./useTaskConversation";
/** Every thread the direct view was mounted for, in order. */
const mountedThreads: string[] = [];
+// The native thread view, drawing what the task view hands its header, banner, lanes and panels.
vi.mock("../ChatView", () => ({
- default: ({ threadId }: { threadId: string }) => {
+ default: ({ threadId, slots }: { threadId: string; slots?: ChatViewSlots }) => {
const inspect = useThreadInspection();
+ const panelHost = useThreadPanelHost();
useEffect(() => {
mountedThreads.push(threadId);
}, [threadId]);
return (
,
+ chrome,
};
-it("shows a queued task's text and the engine's place, with nothing to type into", async () => {
+it("shows a queued task's text and the engine's place in the native page, with nothing to type into", async () => {
await using screen = await render(
,
);
+ await expect.element(screen.getByRole("heading", { name: "#12 Fix the sync" })).toBeVisible();
+ await expect.element(screen.getByRole("button", { name: "Task menu" })).toBeVisible();
+ await expect.element(screen.getByRole("button", { name: "Task panels" })).toBeVisible();
+ await expect.element(screen.getByText("Engine notice")).toBeVisible();
await expect.element(screen.getByText("Make the sync stop dropping rows.")).toBeVisible();
await expect.element(screen.getByText(/4 of 4 slots busy/)).toBeVisible();
await expect.element(screen.getByText("#9 Holds one")).toBeVisible();
+ await expect.element(screen.getByText("Your decision")).toBeVisible();
await expect.element(screen.getByRole("textbox")).not.toBeInTheDocument();
});
+it("opens a draft's editor as the centre of the task's page, which leaves submitting to it", async () => {
+ await using screen = await render(
+ The task editor}
+ />,
+ );
+ await expect.element(screen.getByText("The task editor")).toBeVisible();
+ await expect.element(screen.getByRole("heading", { name: "#12 Fix the sync" })).toBeVisible();
+ await expect.element(screen.getByRole("button", { name: "Task menu" })).toBeVisible();
+ await expect.element(screen.getByRole("button", { name: "Task panels" })).toBeVisible();
+ await expect.element(screen.getByText("Your decision")).not.toBeInTheDocument();
+});
+
it("keeps the thread mounted and says the conversation resumes when T3 is back", async () => {
await using screen = await render(
,
@@ -109,26 +167,109 @@ it("keeps the thread mounted and says the conversation resumes when T3 is back",
await expect.element(screen.getByText("Thread view lead-thread")).toBeVisible();
});
-it("keeps the engine's log, with its composer, for a task in work with no conversation known", async () => {
+it("points a task in work with no conversation known at the engine's log in its details", async () => {
+ const showLog = vi.fn();
await using screen = await render(
- ,
+ ,
);
- await expect.element(screen.getByText("The engine log")).toBeVisible();
await expect.element(screen.getByText(/No conversation is linked/)).toBeVisible();
+ await expect.element(screen.getByText("Make the sync stop dropping rows.")).toBeVisible();
+ await expect.element(screen.getByRole("heading", { name: "#12 Fix the sync" })).toBeVisible();
+ await screen.getByRole("button", { name: "Open the engine log" }).click();
+ expect(showLog).toHaveBeenCalledOnce();
});
-it("opens the thread in the centre, with the engine log one toggle away", async () => {
+it("says a task worked on another machine is there, and mounts no thread for it", async () => {
+ mountedThreads.length = 0;
+ await using screen = await render(
+ ,
+ );
+ await expect.element(screen.getByText(/worked on another machine/)).toBeVisible();
+ await expect.element(screen.getByText("Make the sync stop dropping rows.")).toBeVisible();
+ await expect.element(screen.getByRole("button", { name: "Task menu" })).toBeVisible();
+ await expect.element(screen.getByRole("textbox")).not.toBeInTheDocument();
+ expect(mountedThreads).toEqual([]);
+});
+
+it("opens the thread as the native view, titled by the task, its tabs offered on its own panel", async () => {
+ useRightPanelStore.setState(useRightPanelStore.getInitialState());
await using screen = await render(
,
);
await expect.element(screen.getByText("Thread view lead-thread")).toBeVisible();
+ await expect.element(screen.getByRole("heading", { name: "#12 Fix the sync" })).toBeVisible();
+ await expect.element(screen.getByRole("button", { name: "Task menu" })).toBeVisible();
+ await expect.element(screen.getByText("Your decision")).toBeVisible();
await expect.element(screen.getByRole("textbox", { name: "Composer" })).toBeVisible();
- await page.getByRole("button", { name: "Engine log" }).click();
- await expect.element(screen.getByText("The engine log")).toBeVisible();
- await expect.element(screen.getByText("Thread view lead-thread")).not.toBeInTheDocument();
+ // The native toggles are the only ones, and the centre is always the conversation.
+ await expect.element(screen.getByRole("button", { name: "Task panels" })).not.toBeInTheDocument();
+ await expect.element(screen.getByRole("button", { name: "Engine log" })).not.toBeInTheDocument();
+ await expect.element(screen.getByText("Panels of lead-thread")).toBeVisible();
+ // The + menu adds the one tab it names, on the task thread's own panel.
+ await screen.getByRole("button", { name: "Add task evidence" }).click();
+ expect(selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, ref)).toMatchObject(
+ {
+ isOpen: true,
+ surfaces: [{ id: "task-evidence", kind: "task-evidence" }],
+ },
+ );
});
-it("hands a thread the conversation opens to the view, and offers the way back from a seat", async () => {
+it("puts the badges in the header when it has room, else in a row under it, opening the details where the view keeps them", async () => {
+ useRightPanelStore.setState(useRightPanelStore.getInitialState());
+ const showDetails = vi.fn();
+ const queued = { kind: "waiting", why: "queued" } as const;
+ const open = { kind: "open", ref, offline: false } as const;
+ await using screen = await render(
+ ,
+ );
+ const badges = screen.getByRole("button", { name: "Task badges" });
+ const inRow = () => badges.element().closest("[data-task-badges-row]") !== null;
+ await expect.element(badges).toBeVisible();
+ expect(inRow()).toBe(false);
+ // A page has no thread view: its details are the sheet.
+ await badges.click();
+ expect(showDetails).toHaveBeenCalledOnce();
+
+ // A thread view: the badges sit in its header and open its own details panel.
+ await screen.rerender(
+ ,
+ );
+ expect(badges.element().closest("header")).not.toBeNull();
+ await badges.click();
+ const { threadPanelVisibilityByThreadKey } = useRightPanelStore.getState();
+ expect(selectThreadPanelOpen(threadPanelVisibilityByThreadKey, ref, "inline")).toBe(true);
+ expect(showDetails).toHaveBeenCalledOnce();
+
+ // Narrow: the badges leave the header for a row of their own under it.
+ await screen.rerender(
+ ,
+ );
+ await expect.element(badges).toBeVisible();
+ expect(inRow()).toBe(true);
+ expect(badges.element().closest("header")).toBeNull();
+});
+
+it("keeps a closed task's thread to read, with no composer", async () => {
+ await using screen = await render(
+ ,
+ );
+ await expect.element(screen.getByText("Thread view lead-thread")).toBeVisible();
+ await expect.element(screen.getByText("This is closed. What was said is kept.")).toBeVisible();
+ await expect.element(screen.getByRole("textbox", { name: "Composer" })).not.toBeInTheDocument();
+});
+
+it("hands a thread the conversation opens to the view, and leads back from a seat by the breadcrumb", async () => {
+ useRightPanelStore.setState(useRightPanelStore.getInitialState());
const onOpenThread = vi.fn();
const onBackToTask = vi.fn();
await using screen = await render(
@@ -156,6 +297,38 @@ it("hands a thread the conversation opens to the view, and offers the way back f
);
await expect.element(screen.getByText("Thread view child-thread")).toBeVisible();
await expect.element(screen.getByText("Seat qa")).toBeVisible();
+ // The seat's own thread keeps its title; the task's actions stay in reach.
+ await expect
+ .element(screen.getByRole("heading", { name: "Thread title child-thread" }))
+ .toBeVisible();
+ await expect.element(screen.getByRole("button", { name: "Task menu" })).toBeVisible();
+ // The panels stay the task thread's, and its badges open the task thread's details.
+ await expect.element(screen.getByText("Panels of lead-thread")).toBeVisible();
+ await screen.getByRole("button", { name: "Task badges" }).click();
+ const { threadPanelVisibilityByThreadKey } = useRightPanelStore.getState();
+ expect(selectThreadPanelOpen(threadPanelVisibilityByThreadKey, ref, "inline")).toBe(true);
+ await page.getByRole("button", { name: "Back to task #12" }).click();
+ expect(onBackToTask).toHaveBeenCalledOnce();
+});
+
+it("opens the conversation the task was filed from in the centre, with the way back and no seat label", async () => {
+ const source = {
+ environmentId: EnvironmentId.make("env-9"),
+ threadId: ThreadId.make("filed-from"),
+ };
+ const onBackToTask = vi.fn();
+ await using screen = await render(
+ ,
+ );
+ await expect.element(screen.getByText("Thread view filed-from")).toBeVisible();
+ await expect.element(screen.getByText("Seat conversation")).not.toBeInTheDocument();
await page.getByRole("button", { name: "Back to task #12" }).click();
expect(onBackToTask).toHaveBeenCalledOnce();
});
@@ -191,6 +364,7 @@ describe("a seat in a linked environment", () => {
await using screen = await render();
await expect.element(screen.getByText("Seat qa")).toBeVisible();
await expect.element(screen.getByText("Loading the conversation...")).toBeVisible();
+ await expect.element(screen.getByRole("button", { name: "Back to task #12" })).toBeVisible();
await screen.rerender();
await expect.element(screen.getByText("Linked view of seat-thread")).toBeVisible();
expect(mountedThreads).toEqual([]);
diff --git a/apps/web/src/components/delivery/TaskConversation.tsx b/apps/web/src/components/delivery/TaskConversation.tsx
index b2f1e2522cabc..2839d4da2fc90 100644
--- a/apps/web/src/components/delivery/TaskConversation.tsx
+++ b/apps/web/src/components/delivery/TaskConversation.tsx
@@ -3,14 +3,29 @@ import { useGT } from "gt-react";
import { ArrowLeftIcon, CornerDownRightIcon } from "lucide-react";
import { lazy, Suspense, useEffect, useState, type ReactNode } from "react";
+import { isElectron } from "../../env";
import type { TaskView } from "../../lib/delivery";
-import { queueWait, type ConversationState, type SeatThread } from "../../lib/taskConversation";
+import {
+ queueWait,
+ sameThread,
+ type ConversationState,
+ type SeatThread,
+} from "../../lib/taskConversation";
+import { cn } from "../../lib/utils";
import { linkedThreadSurface } from "../../linkedThreadSurface";
+import { useRightPanelStore } from "../../rightPanelStore";
+import type { ChatViewSlots } from "../ChatView";
import { ThreadInspectionContext } from "../chat/ThreadInspectionContext";
+import { ThreadPanelHostContext } from "../chat/ThreadPanelHostContext";
import { RenderErrorBoundary } from "../RenderErrorBoundary";
import { Button } from "../ui/button";
-import { Toggle } from "../ui/toggle";
-import { ToggleGroup } from "../ui/toggle-group";
+import {
+ WorkspaceBreadcrumb,
+ WorkspaceBreadcrumbItem,
+ WorkspaceBreadcrumbSeparator,
+ WorkspaceBreadcrumbText,
+} from "../WorkspaceBreadcrumb";
+import { WorkspacePageHeader } from "../WorkspacePageHeader";
import { QueueLine } from "./BoardLaneCards";
const ChatView = lazy(() => import("../ChatView"));
@@ -18,6 +33,71 @@ const LinkedThread = lazy(() =>
import("../chat/LinkedThreadPane").then((module) => ({ default: module.LinkedThread })),
);
+/** What the task view puts around its centre, in every state. */
+export interface TaskChrome {
+ /** The task's number and title: the header's title on its own thread. */
+ readonly title: string;
+ /** The header's overflow menu of what can be done with the task. */
+ readonly actions: ReactNode;
+ /** Lines under the header: the engine's notices and the last refusal. */
+ readonly notices: ReactNode;
+ /** The task's own panel toggles on a page, whose details are the sheet; none with a thread. */
+ readonly panelControls: ReactNode;
+ /** Opens one of the task's tabs, where its right panel is. */
+ readonly openTab: (tab: "task-evidence" | "task-deployments") => void;
+ /** Opens the details sheet at the engine's log, for a page whose details are the sheet. */
+ readonly showLog: () => void;
+ /** The decisions, in the lane above the composer. */
+ readonly decisions: ReactNode;
+ /** The task's badges. `openDetails` opens the details of the view they sit in. */
+ readonly renderBadges: (openDetails: () => void, wrap: boolean) => ReactNode;
+ /** The header has no room for the badges, so they take a row of their own under it. */
+ readonly narrow: boolean;
+ /** Opens the details sheet, which holds the task's details where no thread view stands. */
+ readonly showDetails: () => void;
+ /** Back to the board, for a phone, where the board's column is a sheet behind the trigger. */
+ readonly backToBoard: () => void;
+}
+
+type Back = NonNullable;
+
+/** The task thread's native details card, opened at the Task item in either form it takes. */
+function openThreadDetails(thread: ScopedThreadRef) {
+ const store = useRightPanelStore.getState();
+ store.setThreadPanelOpen(thread, "inline", true);
+ store.setThreadPanelOpen(thread, "popover", true);
+ requestAnimationFrame(() =>
+ document
+ .querySelector("[data-thread-details-card] [data-thread-details-task]")
+ ?.scrollIntoView({ block: "start" }),
+ );
+}
+
+/** The badges in the header's actions when it has room, else in a row under the header. */
+function badgePlaces(chrome: TaskChrome, openDetails: () => void) {
+ return chrome.narrow
+ ? {
+ actions: chrome.actions,
+ row: (
+
+ {chrome.renderBadges(openDetails, true)}
+
+ ),
+ }
+ : {
+ actions: (
+ <>
+ {chrome.renderBadges(openDetails, false)}
+ {chrome.actions}
+ >
+ ),
+ row: null,
+ };
+}
+
/** The task's own words, kept on the screen whenever the conversation cannot be. */
function TaskText(props: { readonly task: TaskView }) {
const { task } = props;
@@ -71,6 +151,22 @@ function ConversationWaiting(props: { readonly task: TaskView; readonly why: "dr
);
}
+/** Worked on another machine: its words stay, and nothing here mounts or sends to its thread. */
+function ConversationElsewhere(props: { readonly task: TaskView }) {
+ const gt = useGT();
+ return (
+
+
+
+ {gt("This task is worked on another machine, or is on its way there.")}
+
+
+ );
+}
+
/**
* The thread view threw while mounting (its composer can fail to start the first time the page
* loads). The first failure mounts it again once; a second one asks the person to.
@@ -92,26 +188,125 @@ function ConversationFailed(props: { readonly attempt: number; readonly onRetry:
) : null;
}
-/** The line above a seat's conversation: whose it is, and the way back to the task. */
-function SeatBar(props: {
- readonly task: TaskView;
- readonly seatName: string | null;
+/** Whose conversation is open in the centre, beside the task's panel toggles. */
+function SeatLabel(props: { readonly seatName: string | null }) {
+ const gt = useGT();
+ return (
+
+
+
+ {props.seatName ? gt("Seat {seat}", { seat: props.seatName }) : gt("Seat conversation")}
+
+
+ );
+}
+
+/**
+ * The row under the header: the way back to the board below the width where the board's column
+ * becomes a sheet, whose conversation is open, and a page's own panel toggles. A row with nothing
+ * but the way back shows only at that width.
+ */
+function TaskBar(props: {
+ readonly controls?: ReactNode;
readonly onBack: () => void;
+ readonly phoneOnly?: boolean;
+ readonly children?: ReactNode;
}) {
const gt = useGT();
return (
+ );
+}
+
+/** The decisions, and for a closed task why nothing more can be written. */
+function Lane(props: {
+ readonly closed: boolean;
+ readonly decisions: ReactNode;
+ readonly className: string;
+}) {
+ const gt = useGT();
+ return (
+
+ {props.closed ? (
+
+ {gt("This is closed. What was said is kept.")}
+
+ ) : null}
+ {props.decisions}
+
+ );
+}
+
+/**
+ * The native page for the task when no thread view stands in the centre: the same header title
+ * and actions, the notices, the task's toggles, and the decisions at the foot.
+ */
+function TaskPage(props: {
+ readonly title: string;
+ readonly back?: Back | undefined;
+ readonly actions: ReactNode;
+ readonly banner: ReactNode;
+ readonly lane: ReactNode;
+ readonly children: ReactNode;
+}) {
+ const gt = useGT();
+ return (
+
);
}
@@ -135,10 +330,10 @@ function LinkedSeat(props: {
}
/**
- * The task's conversation in the centre, in the thread view T3 already has, its composer
- * included. A seat's conversation replaces it here with a way back, and the right panel does
- * not move. Until the lead's conversation carries what the engine still says in its log, the log
- * stays one toggle away: it is where a question waits and where a proposal is answered.
+ * The task's conversation as the native thread view, its composer included, with the task's
+ * title and actions in its header. A seat's conversation replaces it, and its parent breadcrumb
+ * leads back to the task. The panels stay the task thread's all along: its right panel with the
+ * task's tabs, and its details with the Task item, where the engine's log is.
*/
function OpenConversation(props: {
readonly task: TaskView;
@@ -147,25 +342,43 @@ function OpenConversation(props: {
readonly seat: SeatThread | null;
readonly seatResolving: boolean;
readonly seatName: string | null;
+ readonly source: ScopedThreadRef | null;
readonly onOpenThread: (thread: ScopedThreadRef) => void;
readonly onBackToTask: () => void;
- readonly log: ReactNode;
+ readonly chrome: TaskChrome;
+ readonly closed: boolean;
}) {
const gt = useGT();
- const [view, setView] = useState<"conversation" | "log">("conversation");
+ const { chrome } = props;
const [attempt, setAttempt] = useState(0);
const shown = props.seat ?? props.thread;
const inSeat = props.seat !== null || props.seatResolving;
- const loading = (
-
- {gt("Loading the conversation...")}
-
- );
- return (
-
+ // The conversation the task was filed from opens here as a seat does, but is no seat.
+ const sourceOpen = props.seat !== null && sameThread(props.seat, props.source);
+ const back: Back = {
+ title: gt("Back to task #{number}", { number: props.task.number }),
+ open: props.onBackToTask,
+ };
+ const seatTitle = props.seatName
+ ? gt("Seat {seat}", { seat: props.seatName })
+ : gt("Seat conversation");
+ // The thread view's details are the task thread's panel, whichever thread is on screen; a
+ // page's are the sheet.
+ const threadPlaces = badgePlaces(chrome, () => openThreadDetails(props.thread));
+ const pagePlaces = badgePlaces(chrome, chrome.showDetails);
+ // A seat's thread view titles itself, so the bar names the seat; a page titles it instead.
+ const seatLabel = inSeat && !sourceOpen;
+ const banner = (threadView: boolean) => (
+ <>
+ {chrome.notices}
+ {(threadView ? threadPlaces : pagePlaces).row}
+
+ {threadView && seatLabel ? : null}
+
{props.offline ? (
) : null}
- {inSeat ? (
-
- ) : (
-
- {
- const value = next[0];
- if (value === "conversation" || value === "log") setView(value);
- }}
- >
- {gt("Conversation")}
- {gt("Engine log")}
-
-
- )}
+ >
+ );
+ // Where no thread view stands, the page carries the same header, banner and lane.
+ const page = (content: ReactNode) => (
+ }
+ >
+ {content}
+
+ );
+ const loading = (
+
+ {gt("Loading the conversation...")}
+
+ );
+ return (
+
{props.seat === null && props.seatResolving ? (
// The seat is open but its links are not known yet. The task's own conversation is not
// shown in its place, and neither view is mounted only to be swapped for the other.
- loading
- ) : view === "log" && !inSeat ? (
- props.log
+ page(loading)
) : (
- setAttempt((n) => n + 1)} />
- }
- >
-
-
@@ -227,13 +444,25 @@ function OpenConversation(props: {
"This conversation is loading or is not available here. The task's facts beside it stand.",
)}
-
- }
+
,
+ )}
+ slots={{
+ ...(inSeat ? { parent: back } : { title: chrome.title }),
+ headerActions: threadPlaces.actions,
+ banner: banner(true),
+ composerLane: (
+
+ ),
+ composer: !props.closed,
+ // The + menu adds the one tab it names; a badge brings both back.
+ onAddTaskSurface: (kind) =>
+ useRightPanelStore.getState().open(props.thread, kind),
+ }}
/>
)}
-
-
-
+
+
+
)}
@@ -241,8 +470,10 @@ function OpenConversation(props: {
}
/**
- * The centre of the task view (BOARD-REVAMP-UI-SPEC section 6). Which conversation, and whether
- * T3 can serve it, are decided by `lib/taskConversation`; this only draws each case.
+ * The centre of the task view (BOARD-REVAMP-UI-SPEC section 6): the native thread view when the
+ * task has one, else the native page with the task's words, or for a draft its editor. Which
+ * conversation, and whether T3 can serve it, are decided by `lib/taskConversation`; this only
+ * draws each case.
*/
export function TaskConversation(props: {
readonly task: TaskView;
@@ -251,26 +482,64 @@ export function TaskConversation(props: {
/** A seat is open but cannot be placed yet. */
readonly seatResolving: boolean;
readonly seatName: string | null;
+ /** The conversation the task was filed from, which can be opened here too. */
+ readonly source: ScopedThreadRef | null;
readonly onOpenThread: (thread: ScopedThreadRef) => void;
readonly onBackToTask: () => void;
- /** The engine's own log and its composer, for a task whose conversation is not known yet. */
- readonly log: ReactNode;
+ /** The task editor, which is a draft's centre. Its own controls submit and discard it. */
+ readonly draft?: ReactNode;
+ readonly chrome: TaskChrome;
}) {
const gt = useGT();
- const { state, task } = props;
+ const { state, task, chrome } = props;
+ // A closed or rejected task keeps what was said, and nothing more is written to it.
+ const closed = task.state === "rejected" || task.state === "closed";
+ const places = badgePlaces(chrome, chrome.showDetails);
+ // A draft's editor carries its own controls, so its lane has no decisions.
+ const decisions = props.draft ? null : chrome.decisions;
+ const page = (content: ReactNode) => (
+
+ {chrome.notices}
+ {places.row}
+
+ >
+ }
+ lane={}
+ >
+ {content}
+
+ );
+ if (props.draft) return page(props.draft);
switch (state.kind) {
case "waiting":
- return ;
+ return page();
+ case "moved":
+ return page();
case "unlinked":
- return (
-
-
+ return page(
+
+
+
{gt(
"No conversation is linked to this task yet. The engine's log stands in until one is.",
- )}
+ )}{" "}
+
+ {gt("Open the engine log")}
+
+ );
+}
+
+/**
+ * What is needed of you, in plain words: the bottom line, then what the task is, what happened,
+ * why it stopped, and what each choice would do. The steps themselves are in the decisions lane.
+ */
+function Briefing(props: { readonly brief: TaskBriefing }) {
+ const { brief } = props;
+ const now = useMinuteClock();
+ const since = brief.since && !Number.isNaN(Date.parse(brief.since)) ? brief.since : null;
+ // Lines and actions come from the engine and can repeat: each key says which repeat it is.
+ const happenedKeys = repeatKeys(brief.happened);
+ const optionKeys = repeatKeys(brief.options.map((option) => option.action));
+ const [open, setOpen] = useState(true);
+ return (
+
+ ) : null}
+ {card.set === "qualification" ? (
+
+ the qualification's evidence, not pilot work
+
+ ) : (
+
+ {/* A board other than the suggested one is outlined in the warning tone. */}
+
+ {boards.find((item) => item.id === card.set)?.title ??
+ (card.set ? card.set : "Not on a board")}
+
+
+ )}
+
+
+
+
+ {task.body}
+
+ {task.plan ? (
+
+
+ The plan{task.plan.agreed ? ", agreed and being delivered" : ", for you to read"}
+
+ What is said on this task is its conversation with the team. A thread in the chat list is
+ a conversation of its own; it becomes a task only when you create one from it.
+
+ {task.workflow === "chat"
+ ? "A change counts from the next message on."
+ : "A run keeps the seats it started with. A change counts for the next run. A seat that is working when it is switched off is asked to stop."}
+
+
+
+ )}
+
+
+
Your name
+ setPerson(event.target.value)}
+ />
+
+
+ );
+}
diff --git a/apps/web/src/components/delivery/TaskEditor.tsx b/apps/web/src/components/delivery/TaskEditor.tsx
index 56bbc65e2de4f..62b0405560635 100644
--- a/apps/web/src/components/delivery/TaskEditor.tsx
+++ b/apps/web/src/components/delivery/TaskEditor.tsx
@@ -129,12 +129,38 @@ function Field(props: {
);
}
+/** The editor's page: its own, or for a saved draft the centre of the task's page. */
+function EditorShell(props: { readonly framed: boolean; readonly children: React.ReactNode }) {
+ return props.framed ? (
+
{props.children}
+ ) : (
+
+ {props.children}
+
+ );
+}
+
+/** The editor's controls: its own page's header, or a bar under the header of the task's page. */
+function EditorBar(props: { readonly framed: boolean; readonly children: React.ReactNode }) {
+ return props.framed ? (
+
+ {props.children}
+
+ ) : (
+
+ {props.children}
+
+ );
+}
+
/**
* Where a task is written: what is asked, what it must meet, how it is known
* to be done, and anything that helps. Saved as a draft it asks nothing of
* anyone. Submitted, the team takes it on and the engine moves it from there.
*/
export function TaskEditor(props: {
+ /** A saved draft opened in the task's page, whose header and frame it sits under. */
+ readonly framed?: boolean;
readonly environmentId: EnvironmentId | null;
/** A draft that was saved before, or null for a new task. */
readonly taskId: string | null;
@@ -480,9 +506,9 @@ export function TaskEditor(props: {
const state = !props.taskId ? "Not saved yet" : changed ? "Changed since it was saved" : "Saved";
return (
-
+
-
+
@@ -593,7 +619,7 @@ export function TaskEditor(props: {
- );
-}
diff --git a/apps/web/src/components/delivery/TaskInfo.tsx b/apps/web/src/components/delivery/TaskInfo.tsx
new file mode 100644
index 0000000000000..8886f6f6550c7
--- /dev/null
+++ b/apps/web/src/components/delivery/TaskInfo.tsx
@@ -0,0 +1,164 @@
+import type { EnvironmentId } from "@t3tools/contracts";
+
+import type { TaskView } from "../../lib/delivery";
+import { ageLabel } from "../../lib/deliveryBoard";
+import { harnessLabel } from "../../lib/deliverySeats";
+import { useMinuteClock } from "../../state/delivery";
+import { QaVotes, Row } from "./taskParts";
+import { TaskDisclosure } from "./TaskDisclosure";
+import { RunPanel } from "./RunPanel";
+
+/**
+ * The Evidence tab's body: what the run proved and what was decided on it. The task's own words,
+ * ownership and seats are in the Task item of the details, its stage and team in the badges, and
+ * its pull request and merge permission in the Deployment tab. The tab scrolls; nothing in it does.
+ */
+export function Info(props: {
+ readonly environmentId: EnvironmentId | null;
+ readonly task: TaskView;
+ readonly onChanged: () => void;
+}) {
+ const { task } = props;
+ const { card } = task;
+ const now = useMinuteClock();
+ const decided = (card.qa && card.qa.votes.length > 0) || card.findings.all > 0;
+
+ return (
+
+ );
+}
diff --git a/apps/web/src/components/delivery/TaskMenu.browser.test.tsx b/apps/web/src/components/delivery/TaskMenu.browser.test.tsx
new file mode 100644
index 0000000000000..124bd9a823271
--- /dev/null
+++ b/apps/web/src/components/delivery/TaskMenu.browser.test.tsx
@@ -0,0 +1,98 @@
+import { expect, it, vi } from "vite-plus/test";
+import { page, userEvent } from "vite-plus/test/browser";
+
+import "~/index.css";
+
+import { render } from "../../../test/render";
+import { parseTask } from "../../lib/delivery";
+import { TaskMenu } from "./TaskMenu";
+
+vi.mock(import("../../state/delivery"), async (importOriginal) => ({
+ ...(await importOriginal()),
+ usePersonName: () => "Sam",
+ useDeliveryAct: () => vi.fn(),
+ useDeliveryRead: () =>
+ ({ body: [], error: null, isPending: false, readAt: null, refresh: () => {} }) as never,
+}));
+
+const task = (extra: Record = {}) => {
+ const view = parseTask({
+ id: "t1",
+ number: 12,
+ title: "Fix the sync",
+ state: "ready",
+ lane: "ready",
+ card: { id: "t1", number: 12, title: "Fix the sync", lane: "ready" },
+ ...extra,
+ });
+ if (!view) throw new Error("the fixture did not parse");
+ return view;
+};
+
+function menu(props: Partial[0]> = {}) {
+ return (
+ {}}
+ onAllocate={() => {}}
+ onChanged={() => {}}
+ onProblem={() => {}}
+ {...props}
+ />
+ );
+}
+
+const open = () => page.getByRole("button", { name: "What can be done with this task" }).click();
+
+it("names each action with what it does, and runs it on the task", async () => {
+ const run = vi.fn();
+ const onAllocate = vi.fn();
+ const subject = task();
+ await using _screen = await render(
+ menu({ task: subject, taskActions: { busy: false, run, moveTo: vi.fn() }, onAllocate }),
+ );
+ await open();
+ await expect
+ .element(page.getByText("Choose the machine for it, or follow its move."))
+ .toBeVisible();
+ await expect
+ .element(
+ page.getByText(
+ "Nothing more is started for this task until it is resumed. A running step is stopped.",
+ ),
+ )
+ .toBeVisible();
+ await page.getByRole("menuitem", { name: /^Pause/ }).click();
+ expect(run).toHaveBeenCalledWith(subject.card, "pause");
+ await open();
+ await page.getByRole("menuitem", { name: /^Allocate/ }).click();
+ expect(onAllocate).toHaveBeenCalledOnce();
+});
+
+it("leaves the source conversation to the Task item's Made from row, even for a task filed from one", async () => {
+ await using _screen = await render(
+ menu({ task: task({ source: { kind: "thread", ref: "env-source/filed-from" } }) }),
+ );
+ await open();
+ await expect.element(page.getByRole("menuitem", { name: /^Allocate/ })).toBeVisible();
+ await expect
+ .element(page.getByRole("menuitem", { name: /Inspect source workspace/ }))
+ .not.toBeInTheDocument();
+});
+
+it("offers to make a task of a chat only while it is a chat", async () => {
+ const onCreateTask = vi.fn();
+ await using screen = await render(menu({ onCreateTask }));
+ await open();
+ await expect
+ .element(page.getByRole("menuitem", { name: /Create task from chat/ }))
+ .not.toBeInTheDocument();
+ await userEvent.keyboard("{Escape}");
+ await screen.rerender(menu({ onCreateTask, task: task({ workflow: "chat", state: "chat" }) }));
+ await open();
+ await page.getByRole("menuitem", { name: /Create task from chat/ }).click();
+ expect(onCreateTask).toHaveBeenCalledOnce();
+});
diff --git a/apps/web/src/components/delivery/TaskMenu.tsx b/apps/web/src/components/delivery/TaskMenu.tsx
new file mode 100644
index 0000000000000..10a472618dde6
--- /dev/null
+++ b/apps/web/src/components/delivery/TaskMenu.tsx
@@ -0,0 +1,248 @@
+import type { EnvironmentId } from "@t3tools/contracts";
+import { EllipsisIcon } from "lucide-react";
+import { useState, type ReactNode } from "react";
+
+import { parseTarget, type TaskView } from "../../lib/delivery";
+import { BOARD_LANES, boardLaneOf } from "../../lib/boardLanes";
+import { boardMoveIntent, LANE_TITLE } from "../../lib/deliveryBoard";
+import { boardChoiceKind, type MoveBoard } from "../../lib/deliveryMove";
+import { cn } from "../../lib/utils";
+import { useDeliveryAct, useDeliveryRead, usePersonName } from "../../state/delivery";
+import { Button } from "../ui/button";
+import {
+ Menu,
+ MenuItem,
+ MenuItemDetail,
+ MenuPopup,
+ MenuSeparator,
+ MenuSub,
+ MenuSubPopup,
+ MenuSubTrigger,
+ MenuTrigger,
+} from "../ui/menu";
+import { MoveTaskDialog } from "./MoveTaskDialog";
+import { actionHelp, actionLabel, type useTaskActions } from "./taskActions";
+import { laneTone } from "./taskParts";
+
+function Action(props: {
+ readonly label: ReactNode;
+ readonly help: ReactNode;
+ readonly disabled?: boolean;
+ readonly onClick: () => void;
+ readonly [data: `data-${string}`]: string;
+}) {
+ const { label, help, ...item } = props;
+ return (
+
+ );
+}
+
+/**
+ * Everything that can be done with the task, each with what it does, in the native header's
+ * right-hand actions. The decisions are not here: they are in the lane above the composer.
+ */
+export function TaskMenu(props: {
+ readonly environmentId: EnvironmentId | null;
+ readonly task: TaskView;
+ readonly actions: ReadonlyArray;
+ readonly taskActions: Pick, "busy" | "run" | "moveTo">;
+ readonly onCreateTask: () => void;
+ readonly onAllocate: () => void;
+ readonly onChanged: () => void;
+ /** Why a board move was refused, for the line under the header; null clears it. */
+ readonly onProblem: (why: string | null) => void;
+}) {
+ const { task, taskActions } = props;
+ const { card } = task;
+ const person = usePersonName();
+ const act = useDeliveryAct(props.environmentId, "task edit");
+ const [open, setOpen] = useState(false);
+ const [moving, setMoving] = useState(null);
+ // The boards of the person's own, read only while they can be chosen.
+ const boardsRead = useDeliveryRead(
+ props.environmentId,
+ open || moving !== null ? "/api/boards" : null,
+ );
+ const boards: ReadonlyArray = (
+ Array.isArray(boardsRead.body) ? boardsRead.body : []
+ ).flatMap((item: unknown) =>
+ item && typeof item === "object" && "id" in item && "title" in item
+ ? [
+ {
+ id: String(item.id),
+ title: String(item.title),
+ target: "target" in item ? parseTarget(item.target) : null,
+ },
+ ]
+ : [],
+ );
+ // The board triage thinks the task belongs on.
+ const suggested = task.suggestedBoard ?? card.suggestedBoard ?? null;
+ const chooseBoard = (id: string | null) => {
+ if (id === card.set) return;
+ const chosen = id === null ? null : (boards.find((item) => item.id === id) ?? null);
+ // A board done in another repository moves the task's work there, which is confirmed first.
+ if (
+ id !== null &&
+ !["chat", "non-code"].includes(task.workflow) &&
+ boardChoiceKind(task.target?.repository ?? null, chosen) === "move"
+ ) {
+ setMoving(id);
+ return;
+ }
+ props.onProblem(null);
+ void act(`/api/tasks/${task.id}/board`, { board: id, by: person }).then((result) => {
+ if (!result.ok) props.onProblem(result.why);
+ props.onChanged();
+ });
+ };
+ const here = boardLaneOf(task.lane ?? "");
+ return (
+ <>
+
+ {moving ? (
+ setMoving(null)}
+ onMoved={props.onChanged}
+ />
+ ) : null}
+ >
+ );
+}
diff --git a/apps/web/src/components/delivery/TaskPanelTab.tsx b/apps/web/src/components/delivery/TaskPanelTab.tsx
new file mode 100644
index 0000000000000..c2de80b8c8eaa
--- /dev/null
+++ b/apps/web/src/components/delivery/TaskPanelTab.tsx
@@ -0,0 +1,92 @@
+import { useGT } from "gt-react";
+
+import type { TaskView } from "../../lib/delivery";
+import { useBoardTask, type BoardTask } from "./BoardTaskContext";
+import { BoardDelivery } from "./BoardDelivery";
+import { CardDeliveryStatus } from "./CardDeliveryStatus";
+import { MergePermissionControls, MergePermissionSummary } from "./MergePermissionControls";
+import { TaskDeploymentsPanel } from "./TaskDeploymentStatus";
+import { TaskDisclosure } from "./TaskDisclosure";
+import { Info } from "./TaskInfo";
+import { PublicationRows } from "./taskParts";
+
+/** The Deployment tab: delivering the task, its pull request, merge permission and deployments. */
+function Deployment(props: { readonly board: BoardTask; readonly task: TaskView }) {
+ const gt = useGT();
+ const { board, task } = props;
+ const { environmentId } = board;
+ return (
+
+ {/* A task filed from a thread here is delivered from here. */}
+ {environmentId && task.origin.startsWith(`thread:${environmentId}/`) ? (
+
+ ) : null}
+
+ {task.publications.length > 0 || task.state === "approved" ? (
+
+
+
+ ) : null}
+
+
+
+ {/* The controls say what is set; without an environment to change it in, the summary does. */}
+ {environmentId ? (
+
+ ) : (
+
+
+
+ )}
+
+
+
+
+
+ );
+}
+
+/**
+ * A board task's tab, on its thread's right panel or on the task's own panel while it has no
+ * thread: one scroll, with sections that fold. Without a board task here it shows nothing, so an
+ * ordinary thread that somehow kept the tab gets an empty one.
+ */
+export function TaskPanelTab(props: { readonly kind: "task-evidence" | "task-deployments" }) {
+ const board = useBoardTask();
+ if (!board?.task) return null;
+ return (
+
+ );
+}
+
+/**
+ * The board tasks around this one, from the board's own read: its parent, its current parts and QA
+ * follow-ups, then completed and earlier work folded. Child tasks are board tasks, not agents, so
+ * the lineage shows them as a group of its own. Dependencies are not children; the Task item has them.
+ */
+export function TaskRelatedWork() {
+ const board = useBoardTask();
+ const task = board?.task;
+ if (!board || !task || !taskHasRelatedWork(task)) return null;
+ const parts = relatedTaskGroups(task.card.parts);
+ const followUps = relatedTaskGroups(task.followUps);
+ const completed = parts.completed.length + followUps.completed.length;
+ const historical = parts.historical.length + followUps.historical.length;
+ return (
+
+ Kept for history. Rejected or closed parts are not proof of delivery.
+
+
+
+
+ ) : null}
+
+ );
+}
diff --git a/apps/web/src/components/delivery/TaskTeamActivity.browser.test.tsx b/apps/web/src/components/delivery/TaskTeamActivity.browser.test.tsx
index bb4dd322a667b..9e7e8c8e5dfa1 100644
--- a/apps/web/src/components/delivery/TaskTeamActivity.browser.test.tsx
+++ b/apps/web/src/components/delivery/TaskTeamActivity.browser.test.tsx
@@ -43,6 +43,7 @@ const seat = (extra: Partial): CouncilSeat => ({
verdict: null,
attempts: 1,
live: null,
+ threadId: null,
...extra,
});
diff --git a/apps/web/src/components/delivery/TaskTeamActivity.test.tsx b/apps/web/src/components/delivery/TaskTeamActivity.test.tsx
index d41a091c7c367..d69af20180972 100644
--- a/apps/web/src/components/delivery/TaskTeamActivity.test.tsx
+++ b/apps/web/src/components/delivery/TaskTeamActivity.test.tsx
@@ -67,6 +67,7 @@ const seat = (extra: Partial): CouncilSeat => ({
verdict: null,
attempts: 1,
live: null,
+ threadId: null,
...extra,
});
diff --git a/apps/web/src/components/delivery/TaskTeamActivity.tsx b/apps/web/src/components/delivery/TaskTeamActivity.tsx
index 9e3243608a882..7e9936f7eb9b3 100644
--- a/apps/web/src/components/delivery/TaskTeamActivity.tsx
+++ b/apps/web/src/components/delivery/TaskTeamActivity.tsx
@@ -61,7 +61,7 @@ function SeatNow(props: { readonly live: SeatLive }) {
}
/** Where the task is in the engine's flow. It shows the step; it asks nothing. */
-function TaskPipelineStrip(props: { readonly task: TaskView }) {
+export function TaskPipelineStrip(props: { readonly task: TaskView }) {
const stage = taskPipelineStage(props.task);
// A settled step is done, so its marker shows the check the steps ahead of it show, and the
// tinted marker moves to the step after it. The step a screen reader hears as current is the
@@ -229,13 +229,14 @@ function SeatRow(props: {
}
/**
- * The task's team in the left pane, the way a thread's lineage shows its agents: one row per
- * seat with its harness and status, and above them where the task is in the flow.
+ * The task's team, the way a thread's lineage shows its agents: one row per seat with its harness
+ * and status, and above them, unless `flow` is false, where the task is in the flow.
*/
export function TaskTeamActivity(props: {
readonly environmentId: EnvironmentId | null;
readonly task: TaskView;
readonly conversations?: SeatConversations | undefined;
+ readonly flow?: boolean | undefined;
}) {
const { task } = props;
const catalog = useSeatCatalog(props.environmentId);
@@ -244,14 +245,16 @@ export function TaskTeamActivity(props: {
const team = `Team ${task.team}${task.defaults > 0 ? `, defaults r${task.defaults}` : ""}`;
return (
- );
-}
-
-// Expanded controls need both width and height: landscape phones still need room for history.
-function MobileHelp(props: {
- readonly label: string;
- readonly children: React.ReactNode;
- /** Shown on every screen, not only a small one. */
- readonly always?: boolean;
-}) {
- return (
-
-
- }
- >
-
-
-
-
{props.children}
-
-
- );
-}
-
-const DOCUMENT_LABEL: Record = {
- "PLAN.md": "Plan",
- "REVIEW.md": "Review",
- "PACK.md": "Evidence pack",
-};
-
-/**
- * The run under way, for a person following it: the documents it wrote, to read here or have
- * summarised, the instructions given to it, and a way to give one. An instruction reaches the
- * seat at work it is for, which starts its step again with it; what is asked is changed by a
- * change, which goes through triage, not here.
- */
-function RunPanel(props: {
- readonly environmentId: EnvironmentId | null;
- readonly task: TaskView;
- readonly onChanged: () => void;
-}) {
- const { task } = props;
- const council = task.council;
- const person = usePersonName();
- const act = useDeliveryAct(props.environmentId, "run");
- const [reading, setReading] = useState(null);
- const [text, setText] = useState("");
- const [seat, setSeat] = useState("");
- const [busy, setBusy] = useState(false);
- const [said, setSaid] = useState(null);
- if (!council) return null;
- const steerable = ["running", "paused", "needs-decision"].includes(council.state);
- const steerKeys = repeatKeys(council.steers.map((steer) => `${steer.at}:${steer.text}`));
- const give = async () => {
- if (!text.trim() || busy) return;
- setBusy(true);
- const result = await act(`/api/tasks/${task.id}/steer`, {
- text: text.trim(),
- seat: seat || null,
- by: person,
- });
- setBusy(false);
- if (result.ok) {
- setText("");
- setSaid(
- "Given. It is in the history; the step starts again with it once its seats have stopped.",
- );
- } else setSaid(result.why);
- props.onChanged();
- };
- const summarise = async (name: string) => {
- setBusy(true);
- const result = await act(`/api/tasks/${task.id}/messages`, {
- kind: "message",
- text: `Summarise the ${DOCUMENT_LABEL[name] ?? name} (${name}) of run ${council.run} for me in a few lines: what it says will be done, how it will be checked, and anything I should look at.`,
- by: person,
- });
- setBusy(false);
- setSaid(result.ok ? "Asked the coordinator. The answer comes in the history." : result.why);
- props.onChanged();
- };
- return (
-
-
: null}
- {reading ? (
- setReading(null)}
- />
- ) : null}
-
- );
-}
-
-/** A document a run wrote (PLAN.md, REVIEW.md, PACK.md), read in a dialog. */
-function RunDocument(props: {
- readonly environmentId: EnvironmentId | null;
- readonly run: string;
- readonly name: string;
- readonly onClose: () => void;
-}) {
- const read = useDeliveryRead(
- props.environmentId,
- `/api/runs/${props.run}/document?name=${encodeURIComponent(props.name)}`,
- );
- const body = read.body as { readonly text?: unknown; readonly cut?: unknown } | null;
- const doc = typeof body?.text === "string" ? body.text : null;
- return (
-
- );
-}
-
-/**
- * What is needed of you, in plain words: the bottom line, then what the task is, what happened,
- * why it stopped, and what each choice would do. The steps themselves are in the bar below.
- */
-function Briefing(props: { readonly brief: TaskBriefing }) {
- const { brief } = props;
- const now = useMinuteClock();
- const since = brief.since && !Number.isNaN(Date.parse(brief.since)) ? brief.since : null;
- // Lines and actions come from the engine and can repeat: each key says which repeat it is.
- const happenedKeys = repeatKeys(brief.happened);
- const optionKeys = repeatKeys(brief.options.map((option) => option.action));
- const [open, setOpen] = useState(true);
- return (
- // The whole panel, headline too, is held to part of the screen and scrolls within, so the
- // history and the composer keep their room on a phone.
-
- {staleReply
- ? "This question is no longer waiting. Your draft is kept and cannot be sent."
- : "Delivery is unconfirmed. Check the engine record before discarding this draft; it will not be sent again automatically."}
-
-
- {/* Two lines are enough to say which question: the whole of it is in the history above. */}
-
- Answering {replying.by}:{" "}
- {replying.text}
-
- {
- props.onReplyTo(null);
- setChosen("message");
- }}
- >
-
-
-
- ) : waits ? (
-
- A question of {waits.by} waits for you. Choose Answer a question below, or press Answer
- on it.
-
- ) : null}
-
-
- );
-}
-
-/**
- * The decisions a person makes on the task: approve what was tested, send it back with a
- * reason, start or submit it. Kept apart from the composer, and below every tab, so that
- * what is written is never taken for a decision and the buttons are in reach on a phone.
- */
-function DecisionBar(props: {
- readonly task: TaskView;
- readonly actions: ReadonlyArray;
- readonly busy: boolean;
- readonly onAction: (action: string) => void;
-}) {
- if (props.actions.length === 0) return null;
- const deciding = props.actions.some((action) => action === "approve" || action === "reject");
- return (
-
-
-
- {deciding ? "Your decision" : "What you can do next"}
- {deciding ? (
-
- {" "}
- Messages never count as a decision.
-
- ) : null}
-
- ) : null}
-
- ) : null}
-
-
- );
-}
-
-function Info(props: {
- readonly environmentId: EnvironmentId | null;
- readonly from: "Board" | "Orchestrator";
- readonly task: TaskView;
- readonly onChanged: () => void;
- readonly stale: boolean;
- /** Takes the task to a column, by the step that leads there; see moveIntent. */
- readonly onMoveTo: (lane: string) => void;
- /** A request is out: nothing more is sent until it returns. */
- readonly busy: boolean;
-}) {
- const { task } = props;
- const { card } = task;
- const person = usePersonName();
- const name = useBoardStore((state) => state.person);
- const setPerson = useBoardStore((state) => state.setPerson);
- const now = useMinuteClock();
- const act = useDeliveryAct(props.environmentId, "task edit");
- const [tags, setTags] = useState(null);
- const [problem, setProblem] = useState(null);
- const [problems, setProblems] = useState>([]);
- const closed = ["approved", "rejected", "closed"].includes(task.state);
- const flow = task.flows.find((item) => item.id === task.workflow) ?? null;
- const navigate = useNavigate();
- // The boards of the person's own, to move the task between, with where each one's work is done.
- const boardsRead = useDeliveryRead(props.environmentId, "/api/boards");
- const boards: ReadonlyArray = (
- Array.isArray(boardsRead.body) ? boardsRead.body : []
- ).flatMap((item: unknown) =>
- item && typeof item === "object" && "id" in item && "title" in item
- ? [
- {
- id: String(item.id),
- title: String(item.title),
- target: "target" in item ? parseTarget(item.target) : null,
- },
- ]
- : [],
- );
- // The board triage thinks the task belongs on, and the move a person is about to confirm.
- const suggested = task.suggestedBoard ?? card.suggestedBoard ?? null;
- const [moving, setMoving] = useState<{
- readonly board: string;
- } | null>(null);
- const startMove = (board: string) => setMoving({ board });
- // What is set for the task, which the switches change.
- const set = Object.fromEntries(task.settings.map((item) => [item.seat, item.set]));
- // The seat choices last sent. Until a read of the task shows it changed since (its last
- // change is later), a second switch builds on the first, instead of on a read from before
- // it, a poll included, which would undo it.
- const sentSeats = useRef<{ readonly updated: string; readonly set: typeof set } | null>(null);
- const switchSeat = async (seat: string, choice: Record) => {
- setProblems([]);
- const pending = sentSeats.current && task.updated <= sentSeats.current.updated;
- const base = pending && sentSeats.current ? sentSeats.current.set : set;
- const next = withSeatChoice(base, seat, choice);
- sentSeats.current = {
- updated: pending && sentSeats.current ? sentSeats.current.updated : task.updated,
- set: next,
- };
- const result = await act(`/api/tasks/${task.id}/edit`, {
- seats: seatSettingsToSend(task.settings, next),
- by: person,
- });
- if (!result.ok) setProblems(result.problems.length > 0 ? result.problems : [result.why]);
- props.onChanged();
- };
-
- const edit = async (patch: Record) => {
- setProblem(null);
- const result = await act(`/api/tasks/${task.id}/edit`, { ...patch, by: person });
- if (!result.ok) setProblem(result.why);
- props.onChanged();
- };
-
- return (
-
- );
-}
-
-/** The value of the board choice for a task on no board. */
-const NO_BOARD = "__no_board__";
+import { SharedTaskAllocation } from "./SharedBoard";
+import { useTaskActions } from "./taskActions";
+import { TaskBadges } from "./TaskBadges";
+import { TaskConversation } from "./TaskConversation";
+import { TaskDetailsItem } from "./TaskDetails";
+import { TaskEditor } from "./TaskEditor";
+import { TaskMenu } from "./TaskMenu";
+import { TaskPanelTab } from "./TaskPanelTab";
+import { TaskRelatedWork } from "./TaskRelatedWork";
+import { TaskWorkspacePanels } from "./TaskWorkspacePanels";
+import { forgetOpenSeat, useTaskConversation } from "./useTaskConversation";
/**
- * A task with everything about it in one place: what is asked, what was said
- * and what happened, and where it stands. The Board and the Orchestrator
- * both open this, on the same record.
+ * A board task opened as its native thread: the thread view T3 shows any thread in, with the
+ * task's number, title and actions in its header, or the native page with the task's words while
+ * it has no thread. A draft has the same page, with the task editor as its centre. The board's own
+ * read is the only source.
*/
export function TaskWorkspace(props: {
readonly environmentId: EnvironmentId | null;
@@ -2056,29 +58,31 @@ export function TaskWorkspace(props: {
onDone: read.refresh,
onDiscarded: () => props.onClose(),
});
- const detailsSheet = useMediaQuery(RIGHT_PANEL_INLINE_LAYOUT_MEDIA_QUERY);
- const [detailsOpen, setDetailsOpen] = useLocalStorage(
- `t3code:task-details:${JSON.stringify([props.environmentId, props.taskId, detailsSheet ? "sheet" : "inline"])}`,
- !detailsSheet,
- Schema.Boolean,
- );
- const [briefOpen, setBriefOpen] = useState(true);
+ const narrow = useMediaQuery(RIGHT_PANEL_INLINE_LAYOUT_MEDIA_QUERY);
+ // A thread view keeps the task's details in its own panel. Where none stands they are a sheet,
+ // closed until asked for, and fresh each time something points into them.
+ const [detailsOpen, setDetailsOpen] = useState(false);
+ const [detailsMount, setDetailsMount] = useState(0);
const [taskBrief, setTaskBrief] = useState(null);
const [creatingTask, setCreatingTask] = useState(false);
const [createProblem, setCreateProblem] = useState(null);
const [allocatingTask, setAllocatingTask] = useState(null);
- const wide = useMediaQuery("(min-width: 640px) and (min-height: 600px)");
- const conversation = useTaskConversation(task);
- // A thread opened from a panel appears in the centre, so a panel that covers it, or fills the
- // width, gives way. The right panel stays on the task otherwise.
+ const [menuProblem, setMenuProblem] = useState(null);
+ const conversation = useTaskConversation(props.environmentId, task);
+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- clears the seat this task left open in the shared store, so it opens on its own conversation next time
+ useEffect(
+ () => () => forgetOpenSeat(props.environmentId, props.taskId),
+ [props.environmentId, props.taskId],
+ );
+ // A thread opened from a panel appears in the centre, so the details sheet over it closes, and a
+ // panel that fills the width gives way. The right panel stays on the task otherwise.
const openInCentre = (thread: ScopedThreadRef) => {
conversation.open(thread);
- const panel = taskPanelRef(JSON.stringify([props.environmentId, props.taskId]));
+ const panel =
+ conversation.ref ?? taskPanelRef(JSON.stringify([props.environmentId, props.taskId]));
useRightPanelStore.getState().setMaximized(panel, false);
- if (detailsSheet) {
- useRightPanelStore.getState().close(panel);
- setDetailsOpen(false);
- }
+ setDetailsOpen(false);
+ if (narrow) useRightPanelStore.getState().close(panel);
};
// Opened and looked at, what the team said is read.
@@ -2093,233 +97,78 @@ export function TaskWorkspace(props: {
void act(`/api/tasks/${task.id}/seen`, { by: person });
}, [act, person, task, unread]);
- if (task?.isDraft) {
- return (
- props.onOpenTask(id)}
- />
- );
- }
+ // Provided where the task view mounts: what it hosts reads the board's task from here.
+ const board: BoardTask = {
+ environmentId: props.environmentId,
+ taskId: props.taskId,
+ task,
+ stale: stale || !!read.error,
+ refresh: read.refresh,
+ openTask: props.onOpenTask,
+ openThread: openInCentre,
+ seats: { ...conversation.seats, open: openInCentre },
+ };
const primary = task?.actions.filter((action) =>
["approve", "reject", "publish", "submit", "deliver", "accept-artifacts"].includes(action),
);
const others = task?.actions.filter((action) => !primary?.includes(action)) ?? [];
-
- return (
-
-
+
+
+
+
+
+ );
+}
+
+/** No task to show yet, or none by that id: the native empty state under the native header. */
+function TaskEmpty(props: {
+ readonly notices: ReactNode;
+ readonly reading: boolean;
+ readonly failed: boolean;
+}) {
+ return (
+
+
+ {props.notices}
+ {props.failed ? null : (
+
+
+
+ {props.reading ? "Reading the task." : "There is no such task."}
+
+
+
+ )}
+
);
}
diff --git a/apps/web/src/components/delivery/TaskWorkspacePanels.browser.test.tsx b/apps/web/src/components/delivery/TaskWorkspacePanels.browser.test.tsx
index 00d6d142fc0e7..7fa92e2d3014f 100644
--- a/apps/web/src/components/delivery/TaskWorkspacePanels.browser.test.tsx
+++ b/apps/web/src/components/delivery/TaskWorkspacePanels.browser.test.tsx
@@ -1,53 +1,41 @@
import { EnvironmentId, ThreadId } from "@t3tools/contracts";
-import { useState } from "react";
-import { beforeEach, expect, it, vi } from "vite-plus/test";
-import { page, userEvent } from "vite-plus/test/browser";
+import { useState, type ReactNode } from "react";
+import { beforeEach, expect, it } from "vite-plus/test";
+import { page } from "vite-plus/test/browser";
import { act, render } from "../../../test/render";
import "~/index.css";
-import { useThreadInspection } from "../chat/ThreadInspectionContext";
-import { taskPanelRef, useRightPanelStore } from "../../rightPanelStore";
+import {
+ selectThreadRightPanelState,
+ taskPanelRef,
+ useRightPanelStore,
+} from "../../rightPanelStore";
import { TaskWorkspacePanels } from "./TaskWorkspacePanels";
-vi.mock("../ChatView", () => ({
- default: ({ environmentId, threadId }: { environmentId: string; threadId: string }) => {
- const inspect = useThreadInspection();
- return (
-
+ {controls}
+ openTab("task-deployments")}>Open the deployments
+
+ )}
+ />
);
- await screen.getByRole("textbox", { name: "Bound task answer" }).fill("Task answer");
- await screen.getByRole("button", { name: "Inspect source workspace" }).click();
- await expect.element(screen.getByText("Native workspace source-env/source-thread")).toBeVisible();
- await screen.getByRole("button", { name: "Inspect child" }).click();
- await expect.element(screen.getByText("Native workspace child-env/child-thread")).toBeVisible();
- expect(screen.router?.state.location.pathname).toBe("/");
- await screen.getByRole("button", { name: "Source conversation", exact: true }).click();
- await expect.element(screen.getByText("Native workspace source-env/source-thread")).toBeVisible();
- await screen.getByRole("button", { name: "Back to task conversation" }).click();
+}
+
+it("gives a task with a thread no panel or toggles of its own, and opens its tabs on the thread's", async () => {
+ await using screen = await render();
+ await expect
+ .element(screen.getByRole("button", { name: "Toggle right panel" }))
+ .not.toBeInTheDocument();
await expect
- .element(screen.getByRole("textbox", { name: "Bound task answer" }))
- .toHaveValue("Task answer");
+ .element(screen.getByRole("button", { name: "Toggle task details panel" }))
+ .not.toBeInTheDocument();
+ await screen.getByRole("button", { name: "Open the deployments" }).click();
+ expect(threadPanel("tabs-thread")).toMatchObject({
+ isOpen: true,
+ activeSurfaceId: "task-deployments",
+ surfaces: [{ kind: "task-evidence" }, { kind: "task-deployments" }],
+ });
+ // The thread view draws them; nothing here does.
+ expect(page.getByText("Deployment rows").query()).toBeNull();
});
-it("resizes the task navigation with the native keyboard handle", async () => {
- await using screen = await render();
+it("opens a task thread's panel at its tabs on the task's first visit, once", async () => {
+ localStorage.removeItem("t3code:task-panel-first-open:owner-first-thread");
+ await using screen = await render();
+ await expect.poll(() => threadPanel("first-thread").isOpen).toBe(true);
+ expect(threadPanel("first-thread").activeSurfaceId).toBe("task-evidence");
+ await act(() => useRightPanelStore.getState().closeAllSurfaces(taskThread("first-thread")));
+ await screen.rerender();
+ expect(threadPanel("first-thread").surfaces).toEqual([]);
+});
+
+it("opens the task details as a sheet at desktop width, and closes them", async () => {
+ await using screen = await render();
+ await screen.getByRole("textbox", { name: "TaskExample reply" }).fill("Keep details draft");
await screen.getByRole("button", { name: "Toggle task details panel", exact: true }).click();
- const handle = screen.getByRole("separator", { name: "Resize task navigation" });
- await expect.element(handle).toBeVisible();
- const width = Number(handle.element().getAttribute("aria-valuenow"));
- await act(() => (handle.element() as HTMLElement).focus());
- await userEvent.keyboard("{ArrowRight}");
- await expect.element(handle).toHaveAttribute("aria-valuenow", String(width + 16));
+ await expect.element(page.getByRole("dialog")).toBeVisible();
+ await expect.element(page.getByText("TaskExample configuration")).toBeVisible();
+ await page.getByRole("button", { name: "Close task details", exact: true }).click();
+ await expect.element(page.getByText("TaskExample configuration")).not.toBeInTheDocument();
+ await expect
+ .element(screen.getByRole("textbox", { name: "TaskExample reply" }))
+ .toHaveValue("Keep details draft");
});
+
it("opens narrow-screen evidence as a sheet and restores the reply after closing", async () => {
await page.viewport(700, 800);
await using screen = await render();
@@ -193,11 +215,17 @@ it("opens the right panel on a task's first visit only when asked, and not again
{}}
details={
Details
}
- conversation={
Centre
}
+ renderConversation={({ controls }) => (
+
+ {controls}
+
Centre
+
+ )}
evidence={
Engine facts
}
deployments={
Deployments
}
/>
@@ -216,3 +244,21 @@ it("opens the right panel on a task's first visit only when asked, and not again
await expect.element(toggle).toHaveAttribute("aria-pressed", "false");
expect(page.getByText("Engine facts").query()).toBeNull();
});
+
+it("offers its tabs on an empty panel and in the + menu, adding only the one picked", async () => {
+ const ref = taskPanelRef("plus-menu-task");
+ const surfaces = () =>
+ selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, ref).surfaces;
+ await using screen = await render();
+ await act(() => useRightPanelStore.getState().show(ref));
+ await screen.getByRole("button", { name: /Deployments/ }).click();
+ await expect.element(page.getByText("Deployment rows for plus-menu-task")).toBeVisible();
+ expect(surfaces()).toEqual([{ id: "task-deployments", kind: "task-deployments" }]);
+ await page.getByRole("button", { name: "Add panel surface" }).click();
+ await page.getByRole("menuitem", { name: /Task evidence/ }).click();
+ await expect.element(page.getByText("Candidate evidence for plus-menu-task")).toBeVisible();
+ expect(surfaces()).toEqual([
+ { id: "task-deployments", kind: "task-deployments" },
+ { id: "task-evidence", kind: "task-evidence" },
+ ]);
+});
diff --git a/apps/web/src/components/delivery/TaskWorkspacePanels.tsx b/apps/web/src/components/delivery/TaskWorkspacePanels.tsx
index 83b18469cd653..1d6f0b181f51e 100644
--- a/apps/web/src/components/delivery/TaskWorkspacePanels.tsx
+++ b/apps/web/src/components/delivery/TaskWorkspacePanels.tsx
@@ -1,21 +1,14 @@
import { workspaceAreaProps } from "../../lib/workspaceFocus";
-import { FileExplorerPane } from "../files/FileExplorerPane";
-import { ThreadInspectionContext } from "../chat/ThreadInspectionContext";
+import type { ScopedThreadRef } from "@t3tools/contracts";
import type { ReactNode } from "react";
-import { ScopedThreadRef } from "@t3tools/contracts";
-const ChatView = lazy(() => import("../ChatView"));
-const ThreadRelationshipsPanel = lazy(() =>
- import("../chat/ThreadRelationshipsControl").then((module) => ({
- default: module.ThreadRelationshipsPanel,
- })),
-);
-const optionalThreadSchema = Schema.NullOr(ScopedThreadRef);
import { useAtomValue } from "@effect/atom-react";
-import { lazy, Suspense, useEffect } from "react";
+import { useEffect, useLayoutEffect, useState } from "react";
import * as Schema from "effect/Schema";
import { isElectron } from "../../env";
import { useLocalStorage } from "../../hooks/useLocalStorage";
import { useMediaQuery } from "../../hooks/useMediaQuery";
+import { observeResize } from "../../lib/observeResize";
+import { cn } from "../../lib/utils";
import { RIGHT_PANEL_INLINE_LAYOUT_MEDIA_QUERY } from "../../rightPanelLayout";
import {
selectThreadRightPanelState,
@@ -29,7 +22,11 @@ import { RightPanelSheet } from "../RightPanelSheet";
import { RightPanelTabs } from "../RightPanelTabs";
import { Button } from "../ui/button";
+type TaskTab = "task-evidence" | "task-deployments";
+
const NO_SURFACES = new Set();
+/** Below this width the task's badges leave the header for a row of their own under it. */
+const BADGES_IN_HEADER_MIN_WIDTH = 760;
const NO_PREVIEW_SESSIONS = {};
const NO_PREVIEW_DESKTOP_STATE = {};
const NO_TERMINAL_LABELS = new Map();
@@ -46,11 +43,16 @@ function getShortcutContext() {
};
}
-/** Opens a task's panel. A first open, or one after every tab was closed, brings both tabs back. */
-function openTaskPanel(owner: string, surface?: "task-evidence" | "task-deployments") {
- const ref = taskPanelRef(owner);
+const isTaskTab = (surface: RightPanelSurface) =>
+ surface.kind === "task-evidence" || surface.kind === "task-deployments";
+
+/**
+ * Opens a task's tabs on a panel: the task's own, or its thread's. A first open, or one after
+ * every task tab was closed, brings both back.
+ */
+function openTaskTabs(ref: ScopedThreadRef, surface?: TaskTab) {
const store = useRightPanelStore.getState();
- if (selectThreadRightPanelState(store.byThreadKey, ref).surfaces.length === 0) {
+ if (!selectThreadRightPanelState(store.byThreadKey, ref).surfaces.some(isTaskTab)) {
store.open(ref, "task-evidence");
store.open(ref, "task-deployments");
store.activateSurface(ref, surface ?? "task-evidence");
@@ -61,78 +63,87 @@ function openTaskPanel(owner: string, surface?: "task-evidence" | "task-deployme
}
/**
- * Task-owned panels share native sizing and sheet behavior without inventing a thread owner. The
- * right panel is T3's own tab panel, owned by `taskPanelRef`, so a thread view never shows it.
+ * Task-owned panels share native sizing and sheet behavior without inventing a thread owner. A
+ * task with a thread keeps its tabs on that thread's right panel, behind the native toggle; one
+ * without (a draft, a queued or a moved task) gets a panel owned by `taskPanelRef`, its toggles
+ * under the native header. The details open as a sheet wherever no thread view holds them.
*/
export function TaskWorkspacePanels(props: {
owner: string;
- source?: ScopedThreadRef | null;
- navigation?: ReactNode;
- /** Opens a related thread in the centre, where the task's own conversation is. Without it, a related thread opens in the full workspace view. */
- onOpenThread?: (thread: ScopedThreadRef) => void;
+ /** The task's own thread, whose right panel holds the task's tabs. */
+ thread: ScopedThreadRef | null;
/** Open the right panel the first time this task is shown. */
openFirst?: boolean;
+ /** The sheet's content: the task's details where no thread view hosts them. */
details: ReactNode;
- conversation?: ReactNode;
- renderConversation?: (showDetails: () => void) => ReactNode;
+ renderConversation: (panel: {
+ /** The task panel's toggles, for a page whose details are the sheet; none with a thread. */
+ readonly controls: ReactNode;
+ readonly showDetails: () => void;
+ readonly openTab: (tab: TaskTab) => void;
+ /** The centre is too narrow for the task's badges in its header. */
+ readonly narrow: boolean;
+ }) => ReactNode;
evidence: ReactNode;
- /** The deployments tab: the task's deployment status, one row per environment. */
+ /** The deployments tab: delivering the task and its deployments. */
deployments: ReactNode;
detailsOpen: boolean;
onDetailsOpenChange: (open: boolean) => void;
}) {
const sheet = useMediaQuery(RIGHT_PANEL_INLINE_LAYOUT_MEDIA_QUERY);
+ const [centre, setCentre] = useState(null);
+ const [narrow, setNarrow] = useState(false);
+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- follows the centre's laid-out width, which only the DOM knows, so the badges sit where they fit before the first paint
+ useLayoutEffect(() => {
+ if (!centre) return;
+ const measure = () => setNarrow(centre.clientWidth < BADGES_IN_HEADER_MIN_WIDTH);
+ measure();
+ return observeResize(centre, measure);
+ }, [centre]);
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
- const panelRef = taskPanelRef(props.owner);
+ const panelRef = props.thread ?? taskPanelRef(props.owner);
const panel = useRightPanelStore((state) =>
selectThreadRightPanelState(state.byThreadKey, panelRef),
);
- const evidenceOpen = panel.isOpen;
+ const ownPanel = props.thread === null;
+ const evidenceOpen = ownPanel && panel.isOpen;
// A task never opened before shows its engine facts beside the conversation when the width holds
- // task details, conversation and panel together. That it happened is kept apart from the tabs:
- // closing every tab empties them, and the panel must stay closed all the same.
+ // conversation and panel together. That it happened is kept apart from the tabs: closing every
+ // tab empties them, and the panel must stay closed all the same.
const roomy = useMediaQuery("(min-width: 1360px)");
const [firstOpenDone, setFirstOpenDone] = useLocalStorage(
`t3code:task-panel-first-open:${props.owner}`,
false,
Schema.Boolean,
);
- const hasTabs = panel.surfaces.length > 0;
- // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- opens the task's right panel in the external panel store on a first visit, and records in local storage that the task has had its panel
+ const hasTabs = panel.surfaces.some(isTaskTab);
+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- opens the task's tabs in the external panel store on a first visit, and records in local storage that the task has had them
useEffect(() => {
if (firstOpenDone) return;
if (hasTabs) setFirstOpenDone(true);
- else if (props.openFirst && roomy && !sheet) openTaskPanel(props.owner);
- }, [props.openFirst, firstOpenDone, hasTabs, roomy, sheet, props.owner, setFirstOpenDone]);
- const maximized = panel.isOpen && panel.maximized === true;
- const [selectedThread, setSelectedThread] = useLocalStorage(
- `t3code:task-inspected-thread:${props.owner}`,
- null as ScopedThreadRef | null,
- optionalThreadSchema,
- );
- const inspectingSource = selectedThread !== null;
- const inspectThread = (thread: ScopedThreadRef) => setSelectedThread(thread);
- const lineageThread = props.onOpenThread ?? inspectThread;
+ else if (props.openFirst && roomy && !sheet) openTaskTabs(panelRef);
+ }, [props.openFirst, firstOpenDone, hasTabs, roomy, sheet, panelRef, setFirstOpenDone]);
+ const maximized = evidenceOpen && panel.maximized === true;
const closeEvidence = () => {
useRightPanelStore.getState().close(panelRef);
useRightPanelStore.getState().setMaximized(panelRef, false);
};
- const openEvidence = () => openTaskPanel(props.owner);
const setMaximized = (next: boolean) =>
useRightPanelStore.getState().setMaximized(panelRef, next);
- const controls = (
+ const controls = ownPanel ? (
{}}
- threadPanelOpen={props.detailsOpen && !maximized && !(sheet && evidenceOpen)}
+ threadPanelOpen={props.detailsOpen && !(sheet && evidenceOpen)}
threadPanelPresentation="inline"
threadPanelShortcutLabel={null}
onToggleThreadPanel={() => {
- if (maximized || (sheet && evidenceOpen)) {
+ if (sheet && evidenceOpen) {
closeEvidence();
props.onDetailsOpenChange(true);
} else props.onDetailsOpenChange(!props.detailsOpen);
@@ -144,16 +155,16 @@ export function TaskWorkspacePanels(props: {
if (evidenceOpen) closeEvidence();
else {
if (sheet) props.onDetailsOpenChange(false);
- openEvidence();
+ openTaskTabs(panelRef);
}
}}
/>
- );
- const panelMode = sheet || inspectingSource ? "sheet" : "inline";
+ ) : null;
+ const panelMode = sheet ? "sheet" : "inline";
const activeSurface =
panel.surfaces.find((surface) => surface.id === panel.activeSurfaceId) ?? null;
const store = () => useRightPanelStore.getState();
- const evidence = (
+ const evidence = ownPanel ? (
+ // Inline, the panel's top right sits under the window's own panel toggles.
+
{panelMode === "inline" ? (
store().open(panelRef, kind)}
browserAvailable={false}
terminalAvailable={false}
diffAvailable={false}
@@ -206,172 +219,60 @@ export function TaskWorkspacePanels(props: {
pullRequestsAvailable={false}
deviceAvailable={false}
>
-
- Source conversation workspace. Tools and terminal belong to this conversation and its
- project, not an engine run.
-
-
- Loading conversation...}>
-
- This conversation is loading or unavailable in its environment. Return to the
- task to keep reading its history and evidence.
-
- }
- />
-
-
-
- {multiline ? metaLine : null}
+ {variantAction === "unsnooze" ? (
+ !props.snoozeSupported ? null : (
+
+
+
+ )
+ ) : !props.settlementSupported ? null : variantAction === "unsettle" ? (
+
+
+ }
+ >
+
+
+
+ Un-settle thread
+
+
+ ) : (
+
+
+ }
+ >
+
+
+
+ Settle thread
+
+
+ )}
+ {jumpHintLabel ? : null}
+
+ )}
+ {props.sweepAction !== null ? dragDestination : null}
{detailsTooltip}
@@ -1556,7 +1620,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
aria-current={accessibility.current}
data-testid="sidebar-row-card"
aria-busy={isRegeneratingTitle || undefined}
- className={rowSurfaceClassName}
+ className={cn(sidebarRowSurfaceClassName(rowSurface), rowStateClassName)}
onClick={handleClick}
onDoubleClick={handleDoubleClick}
onKeyDown={handleKeyDown}
diff --git a/apps/web/src/hooks/useRightPanelSurfaceClose.browser.test.tsx b/apps/web/src/hooks/useRightPanelSurfaceClose.browser.test.tsx
index 4fca86f5b87d7..c6a95821e5725 100644
--- a/apps/web/src/hooks/useRightPanelSurfaceClose.browser.test.tsx
+++ b/apps/web/src/hooks/useRightPanelSurfaceClose.browser.test.tsx
@@ -133,6 +133,35 @@ it.each([
},
);
+it("closes only the tabs a view shows, keeping the rest saved, and the panel with the last of them", async () => {
+ fixture.allowed = new Set(["environment-a"]);
+ useRightPanelStore.setState({ byThreadKey: {} });
+ const ref: ScopedThreadRef = {
+ environmentId: EnvironmentId.make("environment-a"),
+ threadId: ThreadId.make("thread-a"),
+ };
+ const store = useRightPanelStore.getState();
+ store.open(ref, "task-evidence");
+ store.open(ref, "diff");
+ store.open(ref, "files");
+ const saved = () => selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, ref);
+ const shown = saved().surfaces.filter((surface) => surface.kind !== "task-evidence");
+ function Harness() {
+ const { closeAllSurfaces } = useRightPanelSurfaceClose({
+ threadRef: ref,
+ terminalLabelsById: new Map(),
+ surfaces: shown,
+ });
+ return Close all;
+ }
+ await using screen = await render();
+ await screen.getByRole("button").click();
+ expect(saved()).toMatchObject({
+ isOpen: false,
+ surfaces: [{ id: "task-evidence", kind: "task-evidence" }],
+ });
+});
+
it.each([
{ mode: "single", outcome: "cancel" },
{ mode: "single", outcome: "revoked" },
diff --git a/apps/web/src/hooks/useRightPanelSurfaceClose.ts b/apps/web/src/hooks/useRightPanelSurfaceClose.ts
index 978090d3ee61a..04c2fc42b494d 100644
--- a/apps/web/src/hooks/useRightPanelSurfaceClose.ts
+++ b/apps/web/src/hooks/useRightPanelSurfaceClose.ts
@@ -35,6 +35,8 @@ import { useStableCallback } from "./useStableCallback";
export function useRightPanelSurfaceClose(input: {
readonly threadRef: ScopedThreadRef | null;
readonly terminalLabelsById: ReadonlyMap;
+ /** The tabs the view shows, where it leaves saved ones out; closing acts on these alone. */
+ readonly surfaces?: readonly RightPanelSurface[];
}) {
const { threadRef, terminalLabelsById } = input;
const closePreview = useAtomCommand(previewEnvironment.close, "preview close");
@@ -46,9 +48,10 @@ export function useRightPanelSurfaceClose(input: {
const previewState = useThreadPreviewState(threadRef);
const terminalActions = useThreadTerminalActions(threadRef);
const storeCloseTerminal = useTerminalUiStateStore((state) => state.closeTerminal);
- const surfaces = useRightPanelStore(
+ const savedSurfaces = useRightPanelStore(
(state) => selectThreadRightPanelState(state.byThreadKey, threadRef).surfaces,
);
+ const surfaces = input.surfaces ?? savedSurfaces;
const releaseSurfaceResources = (ref: ScopedThreadRef, surface: RightPanelSurface) => {
// Without preview access, server state remains until an authorized close or restart.
@@ -116,6 +119,14 @@ export function useRightPanelSurfaceClose(input: {
store.closeSurface(threadRef, surface.id);
releaseSurfaceResources(threadRef, surface);
}
+ // With the last shown tab gone the panel closes, as an emptied one does; hidden ones stay saved.
+ const closedIds = new Set(toClose.map((surface) => surface.id));
+ if (
+ surfaces.length < savedSurfaces.length &&
+ surfaces.every((surface) => closedIds.has(surface.id))
+ ) {
+ store.close(threadRef);
+ }
const nextActiveSurface = selectActiveRightPanelSurface(
useRightPanelStore.getState().byThreadKey,
threadRef,
diff --git a/apps/web/src/i18n/translations/de.json b/apps/web/src/i18n/translations/de.json
index 9541d893239d5..6c5f00dbecd88 100644
--- a/apps/web/src/i18n/translations/de.json
+++ b/apps/web/src/i18n/translations/de.json
@@ -5295,11 +5295,22 @@
"a1238a3f72d5dee8": "Das Gespräch des Teams beginnt, sobald diese Aufgabe gestartet wird. Bis dahin gibt es nichts zu beantworten.",
"5316704c1283635d": "Das Gespräch konnte nicht angezeigt werden.",
"8c8efe9c6cffdf66": "Zurück zu Aufgabe #{number}",
+ "e150c65e5bcc64ce": "Diese Aufgabe wird auf einem anderen Rechner bearbeitet oder ist auf dem Weg dorthin.",
+ "9d30b2961ec2769e": "Dies ist abgeschlossen. Was gesagt wurde, bleibt erhalten.",
+ "8dc6717feee920df": "Aufgabe",
+ "105a0c707d9add6a": "veraltet",
+ "ea975ec9c3886e10": "Phase: {stage}. Öffnet die Details der Aufgabe.",
+ "9b0a3bf6af79b529": "Team {team}. Zeigt, wer was macht.",
+ "e197c4963bacc746": "{count} laufen",
+ "e11e8ecb01610645": "Dies ist der letzte Stand. Die Engine hat seitdem nicht geantwortet.",
+ "b2e38b842628f3ff": "Zurück zum Board",
+ "5f6c36744f472e71": "Engine-Protokoll öffnen",
+ "cede924e4213cf78": "Den Vorschlag ansehen",
+ "fae3639874428042": "Aufgaben",
"036a05240c1069e2": "Sitz {seat}",
"15dd178ef4fc2eb4": "Gespräch des Sitzes",
"ba2f576086976840": "Gespräch wird geladen …",
"3e18ff4c1fe25356": "T3 läuft nicht, daher ist das Gespräch nicht verfügbar. Es wird fortgesetzt, sobald T3 wieder läuft. Die Engine zeichnet weiter auf, und nichts wird abgebrochen.",
- "5fa1f2d7e6dbf1b1": "Was die Mitte zeigt",
"aaff9d0e91559667": "Engine-Protokoll",
"f31a60920a4af0ef": "Dieses Gespräch wird geladen oder ist hier nicht verfügbar. Die Fakten der Aufgabe daneben gelten weiter.",
"e0504620b693ba09": "Mit dieser Aufgabe ist noch kein Gespräch verknüpft. Bis dahin steht das Protokoll der Engine an dessen Stelle.",
diff --git a/apps/web/src/i18n/translations/en.json b/apps/web/src/i18n/translations/en.json
index b0cb312f3e60b..56c394753dd55 100644
--- a/apps/web/src/i18n/translations/en.json
+++ b/apps/web/src/i18n/translations/en.json
@@ -5295,11 +5295,22 @@
"a1238a3f72d5dee8": "The team's conversation starts when this task is started. There is nothing to answer yet.",
"5316704c1283635d": "The conversation could not be shown.",
"8c8efe9c6cffdf66": "Back to task #{number}",
+ "e150c65e5bcc64ce": "This task is worked on another machine, or is on its way there.",
+ "9d30b2961ec2769e": "This is closed. What was said is kept.",
+ "8dc6717feee920df": "Task",
+ "105a0c707d9add6a": "stale",
+ "ea975ec9c3886e10": "Stage: {stage}. Opens the task's details.",
+ "9b0a3bf6af79b529": "Team {team}. Shows who is doing what.",
+ "e197c4963bacc746": "{count} running",
+ "e11e8ecb01610645": "This is the last reading. The engine has not answered since.",
+ "b2e38b842628f3ff": "Back to board",
+ "5f6c36744f472e71": "Open the engine log",
+ "cede924e4213cf78": "See the proposal",
+ "fae3639874428042": "Tasks",
"036a05240c1069e2": "Seat {seat}",
"15dd178ef4fc2eb4": "Seat conversation",
"ba2f576086976840": "Loading the conversation...",
"3e18ff4c1fe25356": "T3 is not running, so the conversation is not available. It resumes when T3 is back. The engine keeps recording and nothing is cancelled.",
- "5fa1f2d7e6dbf1b1": "What the centre shows",
"aaff9d0e91559667": "Engine log",
"f31a60920a4af0ef": "This conversation is loading or is not available here. The task's facts beside it stand.",
"e0504620b693ba09": "No conversation is linked to this task yet. The engine's log stands in until one is.",
diff --git a/apps/web/src/i18n/translations/es.json b/apps/web/src/i18n/translations/es.json
index eef0f7eb1ea70..397ff4628faae 100644
--- a/apps/web/src/i18n/translations/es.json
+++ b/apps/web/src/i18n/translations/es.json
@@ -5293,11 +5293,22 @@
"a1238a3f72d5dee8": "La conversación del equipo empieza cuando se inicia esta tarea. Todavía no hay nada que responder.",
"5316704c1283635d": "No se pudo mostrar la conversación.",
"8c8efe9c6cffdf66": "Volver a la tarea #{number}",
+ "e150c65e5bcc64ce": "Esta tarea se trabaja en otra máquina o está en camino hacia ella.",
+ "9d30b2961ec2769e": "Esto está cerrado. Lo que se dijo se conserva.",
+ "8dc6717feee920df": "Tarea",
+ "105a0c707d9add6a": "desactualizado",
+ "ea975ec9c3886e10": "Etapa: {stage}. Abre los detalles de la tarea.",
+ "9b0a3bf6af79b529": "Equipo {team}. Muestra quién hace qué.",
+ "e197c4963bacc746": "{count} en marcha",
+ "e11e8ecb01610645": "Esta es la última lectura. El motor no ha respondido desde entonces.",
+ "b2e38b842628f3ff": "Volver al tablero",
+ "5f6c36744f472e71": "Abrir el registro del motor",
+ "cede924e4213cf78": "Ver la propuesta",
+ "fae3639874428042": "Tareas",
"036a05240c1069e2": "Puesto {seat}",
"15dd178ef4fc2eb4": "Conversación del puesto",
"ba2f576086976840": "Cargando la conversación...",
"3e18ff4c1fe25356": "T3 no se está ejecutando, así que la conversación no está disponible. Se reanuda cuando T3 vuelva. El motor sigue registrando y no se cancela nada.",
- "5fa1f2d7e6dbf1b1": "Lo que muestra el centro",
"aaff9d0e91559667": "Registro del motor",
"f31a60920a4af0ef": "Esta conversación se está cargando o no está disponible aquí. Los datos de la tarea a su lado siguen vigentes.",
"e0504620b693ba09": "Todavía no hay una conversación vinculada a esta tarea. Hasta entonces, el registro del motor ocupa su lugar.",
diff --git a/apps/web/src/i18n/translations/fr.json b/apps/web/src/i18n/translations/fr.json
index f756c6d419419..71dc4f54aa8ed 100644
--- a/apps/web/src/i18n/translations/fr.json
+++ b/apps/web/src/i18n/translations/fr.json
@@ -5294,11 +5294,22 @@
"a1238a3f72d5dee8": "La conversation de l'équipe commence quand cette tâche est démarrée. Il n'y a encore rien à répondre.",
"5316704c1283635d": "La conversation n'a pas pu être affichée.",
"8c8efe9c6cffdf66": "Retour à la tâche n° {number}",
+ "e150c65e5bcc64ce": "Cette tâche est traitée sur une autre machine, ou elle est en route vers celle-ci.",
+ "9d30b2961ec2769e": "Ceci est clos. Ce qui a été dit est conservé.",
+ "8dc6717feee920df": "Tâche",
+ "105a0c707d9add6a": "obsolète",
+ "ea975ec9c3886e10": "Étape : {stage}. Ouvre les détails de la tâche.",
+ "9b0a3bf6af79b529": "Équipe {team}. Montre qui fait quoi.",
+ "e197c4963bacc746": "{count} en cours",
+ "e11e8ecb01610645": "Ceci est la dernière lecture. Le moteur n'a pas répondu depuis.",
+ "b2e38b842628f3ff": "Retour au tableau",
+ "5f6c36744f472e71": "Ouvrir le journal du moteur",
+ "cede924e4213cf78": "Voir la proposition",
+ "fae3639874428042": "Tâches",
"036a05240c1069e2": "Siège {seat}",
"15dd178ef4fc2eb4": "Conversation du siège",
"ba2f576086976840": "Chargement de la conversation...",
"3e18ff4c1fe25356": "T3 n'est pas en cours d'exécution, la conversation n'est donc pas disponible. Elle reprend quand T3 revient. Le moteur continue d'enregistrer et rien n'est annulé.",
- "5fa1f2d7e6dbf1b1": "Ce qu'affiche le centre",
"aaff9d0e91559667": "Journal du moteur",
"f31a60920a4af0ef": "Cette conversation est en cours de chargement ou n'est pas disponible ici. Les faits de la tâche à côté restent valables.",
"e0504620b693ba09": "Aucune conversation n'est encore liée à cette tâche. Le journal du moteur en tient lieu jusque-là.",
diff --git a/apps/web/src/i18n/translations/ja.json b/apps/web/src/i18n/translations/ja.json
index 2a56861321651..1e7428b79c398 100644
--- a/apps/web/src/i18n/translations/ja.json
+++ b/apps/web/src/i18n/translations/ja.json
@@ -5280,11 +5280,22 @@
"a1238a3f72d5dee8": "このタスクが開始されると、チームの会話が始まります。今はまだ返信するものはありません。",
"5316704c1283635d": "会話を表示できませんでした。",
"8c8efe9c6cffdf66": "タスク #{number} に戻る",
+ "e150c65e5bcc64ce": "このタスクは別のマシンで作業されているか、そのマシンへ移動中です。",
+ "9d30b2961ec2769e": "これは終了しています。これまでのやり取りは保存されています。",
+ "8dc6717feee920df": "タスク",
+ "105a0c707d9add6a": "古い情報",
+ "ea975ec9c3886e10": "ステージ: {stage}。タスクの詳細を開きます。",
+ "9b0a3bf6af79b529": "チーム {team}。誰が何をしているかを表示します。",
+ "e197c4963bacc746": "{count} 件実行中",
+ "e11e8ecb01610645": "これは最後に読み取った内容です。それ以降、エンジンから応答がありません。",
+ "b2e38b842628f3ff": "ボードに戻る",
+ "5f6c36744f472e71": "エンジンログを開く",
+ "cede924e4213cf78": "提案を見る",
+ "fae3639874428042": "タスク",
"036a05240c1069e2": "シート {seat}",
"15dd178ef4fc2eb4": "シートの会話",
"ba2f576086976840": "会話を読み込み中...",
"3e18ff4c1fe25356": "T3 が実行されていないため、会話は利用できません。T3 が戻ると再開します。エンジンは記録を続け、何もキャンセルされません。",
- "5fa1f2d7e6dbf1b1": "中央に表示する内容",
"aaff9d0e91559667": "エンジンログ",
"f31a60920a4af0ef": "この会話は読み込み中か、ここでは利用できません。隣のタスクの事実は引き続き有効です。",
"e0504620b693ba09": "このタスクにはまだ会話が紐づいていません。紐づくまではエンジンのログが代わりを務めます。",
diff --git a/apps/web/src/i18n/translations/ko.json b/apps/web/src/i18n/translations/ko.json
index f52b4543416bc..c359cf5611ce1 100644
--- a/apps/web/src/i18n/translations/ko.json
+++ b/apps/web/src/i18n/translations/ko.json
@@ -5277,11 +5277,22 @@
"a1238a3f72d5dee8": "이 작업이 시작되면 팀 대화가 시작됩니다. 아직 답할 내용이 없습니다.",
"5316704c1283635d": "대화를 표시할 수 없습니다.",
"8c8efe9c6cffdf66": "작업 #{number}(으)로 돌아가기",
+ "e150c65e5bcc64ce": "이 작업은 다른 머신에서 진행 중이거나 그 머신으로 옮겨지는 중입니다.",
+ "9d30b2961ec2769e": "종료되었습니다. 나눈 내용은 보존됩니다.",
+ "8dc6717feee920df": "작업",
+ "105a0c707d9add6a": "오래됨",
+ "ea975ec9c3886e10": "단계: {stage}. 작업 세부 정보를 엽니다.",
+ "9b0a3bf6af79b529": "팀 {team}. 누가 무엇을 하는지 보여 줍니다.",
+ "e197c4963bacc746": "{count}개 실행 중",
+ "e11e8ecb01610645": "마지막으로 읽은 내용입니다. 그 이후로 엔진이 응답하지 않았습니다.",
+ "b2e38b842628f3ff": "보드로 돌아가기",
+ "5f6c36744f472e71": "엔진 로그 열기",
+ "cede924e4213cf78": "제안 보기",
+ "fae3639874428042": "작업",
"036a05240c1069e2": "좌석 {seat}",
"15dd178ef4fc2eb4": "좌석 대화",
"ba2f576086976840": "대화를 불러오는 중...",
"3e18ff4c1fe25356": "T3가 실행 중이 아니므로 대화를 사용할 수 없습니다. T3가 돌아오면 다시 이어집니다. 엔진은 계속 기록하며 취소되는 것은 없습니다.",
- "5fa1f2d7e6dbf1b1": "가운데에 표시되는 내용",
"aaff9d0e91559667": "엔진 로그",
"f31a60920a4af0ef": "이 대화를 불러오는 중이거나 여기서는 사용할 수 없습니다. 옆에 있는 작업의 사실 정보는 그대로 유효합니다.",
"e0504620b693ba09": "이 작업에 연결된 대화가 아직 없습니다. 연결될 때까지는 엔진 로그가 대신합니다.",
diff --git a/apps/web/src/i18n/translations/pt-BR.json b/apps/web/src/i18n/translations/pt-BR.json
index 7f05bac96a249..5e8aaaf2b1190 100644
--- a/apps/web/src/i18n/translations/pt-BR.json
+++ b/apps/web/src/i18n/translations/pt-BR.json
@@ -5293,11 +5293,22 @@
"a1238a3f72d5dee8": "A conversa da equipe começa quando esta tarefa é iniciada. Ainda não há nada a responder.",
"5316704c1283635d": "Não foi possível mostrar a conversa.",
"8c8efe9c6cffdf66": "Voltar para a tarefa #{number}",
+ "e150c65e5bcc64ce": "Esta tarefa é trabalhada em outra máquina ou está a caminho dela.",
+ "9d30b2961ec2769e": "Isto está encerrado. O que foi dito é mantido.",
+ "8dc6717feee920df": "Tarefa",
+ "105a0c707d9add6a": "desatualizado",
+ "ea975ec9c3886e10": "Etapa: {stage}. Abre os detalhes da tarefa.",
+ "9b0a3bf6af79b529": "Equipe {team}. Mostra quem está fazendo o quê.",
+ "e197c4963bacc746": "{count} em execução",
+ "e11e8ecb01610645": "Esta é a última leitura. O mecanismo não respondeu desde então.",
+ "b2e38b842628f3ff": "Voltar ao quadro",
+ "5f6c36744f472e71": "Abrir o registro do motor",
+ "cede924e4213cf78": "Ver a proposta",
+ "fae3639874428042": "Tarefas",
"036a05240c1069e2": "Assento {seat}",
"15dd178ef4fc2eb4": "Conversa do assento",
"ba2f576086976840": "Carregando a conversa...",
"3e18ff4c1fe25356": "O T3 não está em execução, então a conversa não está disponível. Ela retoma quando o T3 voltar. O motor continua registrando e nada é cancelado.",
- "5fa1f2d7e6dbf1b1": "O que o centro mostra",
"aaff9d0e91559667": "Registro do motor",
"f31a60920a4af0ef": "Esta conversa está carregando ou não está disponível aqui. Os fatos da tarefa ao lado continuam valendo.",
"e0504620b693ba09": "Ainda não há uma conversa vinculada a esta tarefa. Até lá, o registro do motor faz as vezes dela.",
diff --git a/apps/web/src/i18n/translations/ru.json b/apps/web/src/i18n/translations/ru.json
index 3a17c122a4c92..cde834c82fe81 100644
--- a/apps/web/src/i18n/translations/ru.json
+++ b/apps/web/src/i18n/translations/ru.json
@@ -5293,11 +5293,22 @@
"a1238a3f72d5dee8": "Разговор команды начнется, когда эта задача будет запущена. Отвечать пока не на что.",
"5316704c1283635d": "Не удалось показать разговор.",
"8c8efe9c6cffdf66": "Назад к задаче #{number}",
+ "e150c65e5bcc64ce": "Над этой задачей работают на другой машине, или она переносится туда.",
+ "9d30b2961ec2769e": "Это закрыто. Сказанное сохраняется.",
+ "8dc6717feee920df": "Задача",
+ "105a0c707d9add6a": "устарело",
+ "ea975ec9c3886e10": "Этап: {stage}. Открывает подробности задачи.",
+ "9b0a3bf6af79b529": "Команда {team}. Показывает, кто чем занят.",
+ "e197c4963bacc746": "выполняется: {count}",
+ "e11e8ecb01610645": "Это последнее полученное состояние. С тех пор движок не отвечал.",
+ "b2e38b842628f3ff": "Назад к доске",
+ "5f6c36744f472e71": "Открыть журнал движка",
+ "cede924e4213cf78": "Посмотреть предложение",
+ "fae3639874428042": "Задачи",
"036a05240c1069e2": "Место {seat}",
"15dd178ef4fc2eb4": "Разговор места",
"ba2f576086976840": "Загрузка разговора...",
"3e18ff4c1fe25356": "T3 не запущен, поэтому разговор недоступен. Он возобновится, когда T3 вернется. Движок продолжает записывать, ничего не отменяется.",
- "5fa1f2d7e6dbf1b1": "Что показывает центр",
"aaff9d0e91559667": "Журнал движка",
"f31a60920a4af0ef": "Этот разговор загружается или здесь недоступен. Факты задачи рядом остаются в силе.",
"e0504620b693ba09": "С этой задачей пока не связан ни один разговор. До тех пор его заменяет журнал движка.",
diff --git a/apps/web/src/i18n/translations/sv.json b/apps/web/src/i18n/translations/sv.json
index 8c342db03c617..48a7120a9b13d 100644
--- a/apps/web/src/i18n/translations/sv.json
+++ b/apps/web/src/i18n/translations/sv.json
@@ -5294,11 +5294,22 @@
"a1238a3f72d5dee8": "Teamets konversation börjar när den här uppgiften startas. Det finns inget att svara på ännu.",
"5316704c1283635d": "Konversationen kunde inte visas.",
"8c8efe9c6cffdf66": "Tillbaka till uppgift #{number}",
+ "e150c65e5bcc64ce": "Den här uppgiften bearbetas på en annan dator eller är på väg dit.",
+ "9d30b2961ec2769e": "Detta är stängt. Det som sades sparas.",
+ "8dc6717feee920df": "Uppgift",
+ "105a0c707d9add6a": "inaktuell",
+ "ea975ec9c3886e10": "Steg: {stage}. Öppnar uppgiftens detaljer.",
+ "9b0a3bf6af79b529": "Team {team}. Visar vem som gör vad.",
+ "e197c4963bacc746": "{count} körs",
+ "e11e8ecb01610645": "Detta är den senaste avläsningen. Motorn har inte svarat sedan dess.",
+ "b2e38b842628f3ff": "Tillbaka till tavlan",
+ "5f6c36744f472e71": "Öppna motorloggen",
+ "cede924e4213cf78": "Visa förslaget",
+ "fae3639874428042": "Uppgifter",
"036a05240c1069e2": "Plats {seat}",
"15dd178ef4fc2eb4": "Platsens konversation",
"ba2f576086976840": "Läser in konversationen...",
"3e18ff4c1fe25356": "T3 körs inte, så konversationen är inte tillgänglig. Den återupptas när T3 är tillbaka. Motorn fortsätter att registrera och inget avbryts.",
- "5fa1f2d7e6dbf1b1": "Vad mitten visar",
"aaff9d0e91559667": "Motorlogg",
"f31a60920a4af0ef": "Den här konversationen läses in eller är inte tillgänglig här. Uppgiftens fakta bredvid gäller fortfarande.",
"e0504620b693ba09": "Ingen konversation är kopplad till den här uppgiften ännu. Tills dess står motorns logg i dess ställe.",
diff --git a/apps/web/src/i18n/translations/zh.json b/apps/web/src/i18n/translations/zh.json
index 63027c369986a..cecf9664d7178 100644
--- a/apps/web/src/i18n/translations/zh.json
+++ b/apps/web/src/i18n/translations/zh.json
@@ -5300,11 +5300,22 @@
"a1238a3f72d5dee8": "这个任务启动后,团队的对话才会开始。目前还没有需要回复的内容。",
"5316704c1283635d": "无法显示该对话。",
"8c8efe9c6cffdf66": "返回任务 #{number}",
+ "e150c65e5bcc64ce": "此任务正在另一台机器上处理,或正在迁移到那里。",
+ "9d30b2961ec2769e": "此项已关闭。已说过的内容会保留。",
+ "8dc6717feee920df": "任务",
+ "105a0c707d9add6a": "已过时",
+ "ea975ec9c3886e10": "阶段:{stage}。打开任务详情。",
+ "9b0a3bf6af79b529": "团队 {team}。显示谁在做什么。",
+ "e197c4963bacc746": "{count} 个运行中",
+ "e11e8ecb01610645": "这是最后一次读取的内容。此后引擎没有再响应。",
+ "b2e38b842628f3ff": "返回看板",
+ "5f6c36744f472e71": "打开引擎日志",
+ "cede924e4213cf78": "查看提案",
+ "fae3639874428042": "任务",
"036a05240c1069e2": "席位 {seat}",
"15dd178ef4fc2eb4": "席位对话",
"ba2f576086976840": "正在加载对话...",
"3e18ff4c1fe25356": "T3 没有运行,因此对话不可用。T3 恢复后对话会继续。引擎仍在记录,不会取消任何内容。",
- "5fa1f2d7e6dbf1b1": "中间显示的内容",
"aaff9d0e91559667": "引擎日志",
"f31a60920a4af0ef": "这个对话正在加载,或在此处不可用。旁边的任务事实仍然有效。",
"e0504620b693ba09": "这个任务还没有关联对话。在此之前由引擎日志代替。",
diff --git a/apps/web/src/lib/delivery.test.ts b/apps/web/src/lib/delivery.test.ts
index 8e8c3bbe1dd1f..b0f3401cec91a 100644
--- a/apps/web/src/lib/delivery.test.ts
+++ b/apps/web/src/lib/delivery.test.ts
@@ -722,6 +722,22 @@ describe("parseTask", () => {
expect(task?.defaults).toBe(3);
});
+ it("keeps the thread the engine names on a seat, and none when it is absent, null or blank", () => {
+ const seats = parseTask({
+ id: "task-3",
+ card: card({}),
+ council: {
+ seats: [
+ { seat: "builder", threadId: "thread-builder" },
+ { seat: "qa", threadId: null },
+ { seat: "reviewer", threadId: " " },
+ { seat: "lead" },
+ ],
+ },
+ })?.council?.seats;
+ expect(seats?.map((seat) => seat.threadId)).toEqual(["thread-builder", null, null, null]);
+ });
+
it("knows a draft, and is null for what is not a task", () => {
expect(
parseTask({ id: "task-2", state: "draft", card: card({ lane: "draft" }) })?.isDraft,
diff --git a/apps/web/src/lib/delivery.ts b/apps/web/src/lib/delivery.ts
index 891a1fb3fd893..c4b341629e841 100644
--- a/apps/web/src/lib/delivery.ts
+++ b/apps/web/src/lib/delivery.ts
@@ -1387,6 +1387,8 @@ export interface CouncilSeat {
readonly attempts: number;
/** What it is doing now, from its own output, while it works; null otherwise. */
readonly live: SeatLive | null;
+ /** The seat's own conversation as the engine records it, in the task's environment. */
+ readonly threadId: string | null;
}
/** What a seat at work last did: the tools it called and what it said, newest last. */
@@ -1781,6 +1783,8 @@ const parseCouncil = (council: Json): TaskCouncil => {
verdict: textOrNull(seat.verdict),
attempts: list(seat.attempts).length,
live: parseSeatLive(seat.live),
+ // Blank is none: `ThreadId` refuses a blank id.
+ threadId: text(seat.threadId).trim() || null,
})),
documents: [...new Set(strings(council.documents))],
steers: records(council.steers).map((steer) => ({
diff --git a/apps/web/src/lib/taskConversation.test.ts b/apps/web/src/lib/taskConversation.test.ts
index fd263f04ce200..c9c074bf16c2c 100644
--- a/apps/web/src/lib/taskConversation.test.ts
+++ b/apps/web/src/lib/taskConversation.test.ts
@@ -37,7 +37,7 @@ const ref = { environmentId: EnvironmentId.make("env-1"), threadId: ThreadId.mak
describe("which conversation a task has", () => {
it("is the thread the engine links the task to, in work or sent back to the queue", () => {
for (const lane of ["implementation", "queue", "completed"]) {
- expect(taskConversation({ boardThread, isDraft: false, lane })).toEqual({
+ expect(taskConversation({ boardThread, isDraft: false, lane, state: lane })).toEqual({
kind: "thread",
ref,
});
@@ -45,12 +45,11 @@ describe("which conversation a task has", () => {
});
it("has none for a draft or a queued task with no link", () => {
- expect(taskConversation({ boardThread: null, isDraft: true, lane: "draft" })).toEqual({
- kind: "none",
- why: "draft",
- });
+ expect(
+ taskConversation({ boardThread: null, isDraft: true, lane: "draft", state: "draft" }),
+ ).toEqual({ kind: "none", why: "draft" });
for (const lane of ["intake", "ready", "queue"]) {
- expect(taskConversation({ boardThread: null, isDraft: false, lane })).toEqual({
+ expect(taskConversation({ boardThread: null, isDraft: false, lane, state: lane })).toEqual({
kind: "none",
why: "queued",
});
@@ -58,10 +57,20 @@ describe("which conversation a task has", () => {
});
it("is unlinked for a task in work with no link, and never the thread it was filed from", () => {
- const task = { boardThread: null, source, isDraft: false, lane: "planning" };
+ const task = { boardThread: null, source, isDraft: false, lane: "planning", state: "planning" };
expect(taskConversation(task)).toEqual({ kind: "none", why: "unlinked" });
});
+ it("opens none for a task the engine reports moved or moving, link or not", () => {
+ for (const state of ["moved", "moving"]) {
+ for (const link of [boardThread, null]) {
+ expect(
+ taskConversation({ boardThread: link, isDraft: false, lane: "implementation", state }),
+ ).toEqual({ kind: "none", why: "moved" });
+ }
+ }
+ });
+
it("reads the link as the engine serves it, on the task and on its card", () => {
const wire = { ...boardThread, threadId: "board-task:a%3Ab:c/with:colon" };
expect(parseBoardThread(wire)).toEqual(wire);
@@ -102,7 +111,7 @@ describe("what the centre shows", () => {
expect(conversationState(conversation, false)).toEqual({ kind: "open", ref, offline: true });
});
- it("keeps a task with no conversation waiting or unlinked, whether or not T3 is running", () => {
+ it("keeps a task with no conversation waiting, unlinked or moved, whether or not T3 is running", () => {
expect(conversationState({ kind: "none", why: "queued" }, false)).toEqual({
kind: "waiting",
why: "queued",
@@ -110,6 +119,7 @@ describe("what the centre shows", () => {
expect(conversationState({ kind: "none", why: "unlinked" }, true)).toEqual({
kind: "unlinked",
});
+ expect(conversationState({ kind: "none", why: "moved" }, true)).toEqual({ kind: "moved" });
});
});
@@ -147,6 +157,17 @@ describe("a seat's conversation", () => {
expect(seatConversation(null, children, "qa")).toBeNull();
});
+ it("is the engine's thread for the seat in the task's environment, after T3's own child", () => {
+ expect(seatConversation(ref, children, "reviewer", undefined, "engine-thread")).toEqual({
+ environmentId: ref.environmentId,
+ threadId: "engine-thread",
+ });
+ expect(seatConversation(ref, children, "builder", undefined, "engine-thread")?.threadId).toBe(
+ "child-c",
+ );
+ expect(seatConversation(null, children, "reviewer", undefined, "engine-thread")).toBeNull();
+ });
+
it("opens a seat that runs in a linked environment there, or read-only through the link", () => {
const there = { environmentId: remote, threadId: "child-b" };
const throughLink = {
@@ -180,6 +201,28 @@ describe("a seat's conversation", () => {
expect(seatOfThread(ref, children, { ...ref, threadId: id("plain") })).toBeNull();
});
+ it("names the seat of a thread the engine names, as it names one T3 spawned", () => {
+ const engineSeats = [
+ { seat: "reviewer", threadId: "engine-thread" },
+ { seat: "builder", threadId: null },
+ ];
+ expect(
+ seatOfThread(ref, children, { ...ref, threadId: id("engine-thread") }, engineSeats),
+ ).toBe("reviewer");
+ // T3's own child keeps its seat, and an engine thread is only ever in the task's environment.
+ expect(seatOfThread(ref, children, { ...ref, threadId: id("child-b") }, engineSeats)).toBe(
+ "qa",
+ );
+ expect(
+ seatOfThread(
+ ref,
+ children,
+ { environmentId: remote, threadId: id("engine-thread") },
+ engineSeats,
+ ),
+ ).toBeNull();
+ });
+
it("follows the connection of a seat thread that is already open", () => {
const open = { environmentId: remote, threadId: id("child-b") };
expect(openSeatThread(ref, children, open, reach(undefined, true))?.linked).toEqual({
diff --git a/apps/web/src/lib/taskConversation.ts b/apps/web/src/lib/taskConversation.ts
index cd1abb31c2951..8461ec450b236 100644
--- a/apps/web/src/lib/taskConversation.ts
+++ b/apps/web/src/lib/taskConversation.ts
@@ -17,17 +17,21 @@ import type { DeliveryCard, TaskView } from "./delivery";
/** What a task's conversation is, before anyone asks whether it can be reached. */
export type TaskConversation =
| { readonly kind: "thread"; readonly ref: ScopedThreadRef }
- /** `draft` and `queued` have no conversation yet; `unlinked` is a task in work with none known. */
- | { readonly kind: "none"; readonly why: "draft" | "queued" | "unlinked" };
+ /**
+ * `draft` and `queued` have no conversation yet; `unlinked` is a task in work with none known;
+ * `moved` is worked on another machine, or on its way there, so none is opened here.
+ */
+ | { readonly kind: "none"; readonly why: "draft" | "queued" | "unlinked" | "moved" };
-type ConversationInput = Pick;
+type ConversationInput = Pick;
/**
* The engine's link is the conversation, wherever the task stands: a task sent back to the queue
- * keeps what was said in it. With no link a draft or a queued task has none yet, and a task in
- * work is `unlinked`. There is no other source to fall back to.
+ * keeps what was said in it. A task the engine reports moved or moving opens none here, link or
+ * not. With no link a draft or a queued task has none yet, and a task in work is `unlinked`.
*/
export function taskConversation(task: ConversationInput): TaskConversation {
+ if (task.state === "moved" || task.state === "moving") return { kind: "none", why: "moved" };
const link = task.boardThread;
if (link) {
return {
@@ -50,7 +54,9 @@ export type ConversationState =
/** No conversation yet, and none expected until the task starts. No composer. */
| { readonly kind: "waiting"; readonly why: "draft" | "queued" }
/** In work with no linked conversation: the engine's own log stands in, as it did before. */
- | { readonly kind: "unlinked" };
+ | { readonly kind: "unlinked" }
+ /** Worked on another machine: no thread is mounted and nothing is sent from here. */
+ | { readonly kind: "moved" };
export function conversationState(
conversation: TaskConversation,
@@ -59,6 +65,7 @@ export function conversationState(
if (conversation.kind === "thread") {
return { kind: "open", ref: conversation.ref, offline: !reachable };
}
+ if (conversation.why === "moved") return { kind: "moved" };
return conversation.why === "unlinked"
? { kind: "unlinked" }
: { kind: "waiting", why: conversation.why };
@@ -95,22 +102,24 @@ const LOCAL_ONLY: SeatReach = { ownConnection: () => undefined, isLinked: () =>
/**
* The child conversation of a seat. In an orchestrator team chat the lead hands each seat a
- * delegated child thread named by the seat (`teamChat.seat`), the model this slice copies. A seat
- * the lead has not handed work to has none, and its row opens nothing. A seat that runs in a
- * linked environment opens there, or read-only through the task's environment (`linked`).
+ * delegated child thread named by the seat (`teamChat.seat`), the model this slice copies. Without
+ * one, the engine's thread for the seat in the task's environment; a seat with neither opens none.
+ * A seat that runs in a linked environment opens there, or read-only through the task's (`linked`).
*/
export function seatConversation(
conversation: ScopedThreadRef | null,
children: ReadonlyArray,
seat: string,
reach: SeatReach = LOCAL_ONLY,
+ engineThreadId: string | null = null,
): SeatThread | null {
if (!conversation) return null;
- const child = children.findLast(
- (item) =>
- item.teamChat?.seat === seat &&
- (item.childThreadId !== null || item.remoteChild !== undefined),
- );
+ const child =
+ children.findLast(
+ (item) =>
+ item.teamChat?.seat === seat &&
+ (item.childThreadId !== null || item.remoteChild !== undefined),
+ ) ?? (engineThreadId ? { childThreadId: ThreadId.make(engineThreadId) } : undefined);
return child === undefined
? null
: subagentThreadTarget(child, conversation.environmentId, reach.ownConnection, reach.isLinked);
@@ -130,14 +139,21 @@ const childOfThread = (
item.remoteChild.environmentId === thread.environmentId,
);
-/** The seat a child thread was given, for the line above a seat conversation. */
+/**
+ * The seat a child thread was given, for the line above a seat conversation. A thread the engine
+ * names for a seat, in the task's environment, is that seat's as much as one T3 spawned.
+ */
export function seatOfThread(
conversation: ScopedThreadRef | null,
children: ReadonlyArray,
thread: ScopedThreadRef | null,
+ engineSeats: ReadonlyArray<{ readonly seat: string; readonly threadId: string | null }> = [],
): string | null {
if (!conversation || !thread) return null;
- return childOfThread(conversation, children, thread)?.teamChat?.seat ?? null;
+ const spawned = childOfThread(conversation, children, thread)?.teamChat?.seat;
+ if (spawned) return spawned;
+ if (thread.environmentId !== conversation.environmentId) return null;
+ return engineSeats.find((item) => item.threadId === thread.threadId)?.seat ?? null;
}
/** How an open thread is reached now, so a connection made or lost while it is open shows. */
diff --git a/apps/web/src/rightPanelStore.test.ts b/apps/web/src/rightPanelStore.test.ts
index 7a533788b6959..f8d6f3cac1749 100644
--- a/apps/web/src/rightPanelStore.test.ts
+++ b/apps/web/src/rightPanelStore.test.ts
@@ -10,10 +10,12 @@ import {
migratePersistedRightPanelState,
pullRequestSurface,
pullRequestSurfaceId,
+ savedMoveIndex,
selectActiveRightPanel,
selectActiveRightPanelSurface,
selectThreadPanelVisibility,
selectThreadRightPanelState,
+ shownRightPanelState,
taskPanelRef,
useRightPanelStore,
} from "./rightPanelStore";
@@ -1442,4 +1444,28 @@ describe("task panels", () => {
}).byThreadKey,
).toEqual({});
});
+
+ it("leaves a task's tabs out of its thread's view away from the task, where moves keep their places", () => {
+ const store = useRightPanelStore.getState();
+ const kinds = ["diff", "task-evidence", "files", "task-deployments", "pull-requests"] as const;
+ for (const kind of kinds) store.open(refA, kind);
+ const saved = () =>
+ selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, refA);
+ const ids = (surfaces: readonly { id: string }[]) => surfaces.map(({ id }) => id);
+ const shown = shownRightPanelState(saved(), false);
+ expect(ids(shown.surfaces)).toEqual(["diff", "files", "pull-requests"]);
+ expect(shownRightPanelState(saved(), false)).toBe(shown);
+ expect(shownRightPanelState(saved(), true)).toBe(saved());
+ // The diff tab dropped on the last shown place lands after it among the saved tabs.
+ store.moveSurface(refA, "diff", savedMoveIndex(saved().surfaces, shown.surfaces, 2));
+ expect(ids(saved().surfaces)).toEqual([
+ "task-evidence",
+ "files",
+ "task-deployments",
+ "pull-requests",
+ "diff",
+ ]);
+ store.activateSurface(refA, "task-evidence");
+ expect(shownRightPanelState(saved(), false).activeSurfaceId).toBe("diff");
+ });
});
diff --git a/apps/web/src/rightPanelStore.ts b/apps/web/src/rightPanelStore.ts
index b82aea02bfce0..c980f09216919 100644
--- a/apps/web/src/rightPanelStore.ts
+++ b/apps/web/src/rightPanelStore.ts
@@ -112,9 +112,9 @@ export type RightPanelSurface =
| ThreadSurface
/** A linked environment's thread, read through `viaEnvironmentId`; it has no thread here. */
| LinkedThreadSurface
- /** A board task's evidence and settings. Only a task's own panel (`taskPanelRef`) opens it. */
+ /** A board task's evidence: on its thread's panel, or on `taskPanelRef` while it has no thread. */
| { id: "task-evidence"; kind: "task-evidence" }
- /** A board task's deployment status, one row per environment. Task panels only, like evidence. */
+ /** A board task's delivery and deployments, opened where its evidence is. */
| { id: "task-deployments"; kind: "task-deployments" };
export type ThreadSurface = { id: `thread:${string}`; kind: "thread"; threadId: ThreadId };
@@ -1470,6 +1470,44 @@ export function selectThreadRightPanelState(
return byThreadKey[scopedThreadKey(ref)] ?? EMPTY_THREAD_STATE;
}
+const isBoardTaskSurface = (surface: RightPanelSurface) =>
+ surface.kind === "task-evidence" || surface.kind === "task-deployments";
+// One shown state per saved one: the panel's presence compares what it shows by reference.
+const shownStates = new WeakMap();
+
+/**
+ * The panel as a thread's view shows it. Away from a board task's view, the task's tabs stay saved
+ * but are left out, and an active one gives way to the last tab that is shown.
+ */
+export function shownRightPanelState(
+ state: ThreadRightPanelState,
+ boardTaskInView: boolean,
+): ThreadRightPanelState {
+ if (boardTaskInView || !state.surfaces.some(isBoardTaskSurface)) return state;
+ const cached = shownStates.get(state);
+ if (cached) return cached;
+ const surfaces = state.surfaces.filter((surface) => !isBoardTaskSurface(surface));
+ const activeShown = surfaces.some((surface) => surface.id === state.activeSurfaceId);
+ const shown = {
+ ...state,
+ surfaces,
+ activeSurfaceId: activeShown ? state.activeSurfaceId : (surfaces.at(-1)?.id ?? null),
+ };
+ shownStates.set(state, shown);
+ return shown;
+}
+
+/** Where a move to `toIndex` among the shown tabs lands among the saved ones. */
+export function savedMoveIndex(
+ saved: readonly RightPanelSurface[],
+ shown: readonly RightPanelSurface[],
+ toIndex: number,
+): number {
+ const target = shown[toIndex]?.id;
+ const index = saved.findIndex((surface) => surface.id === target);
+ return index < 0 ? toIndex : index;
+}
+
export function selectThreadPanelVisibility(
byThreadKey: Record,
ref: ScopedThreadRef | null | undefined,
diff --git a/apps/web/test/fakeEnvironment.ts b/apps/web/test/fakeEnvironment.ts
index 2b28e49f316bc..494c26137c075 100644
--- a/apps/web/test/fakeEnvironment.ts
+++ b/apps/web/test/fakeEnvironment.ts
@@ -241,6 +241,8 @@ export interface FakeThread {
readonly tags?: ReadonlyArray;
readonly id: ThreadId;
readonly title: string;
+ /** Defaults to the one project; one the environment does not have leaves the thread without. */
+ readonly projectId?: ProjectId;
/** Defaults to GPT-5.4 on Codex. */
readonly modelSelection?: ModelSelection;
/** The first is the thread's active provider thread. */
@@ -326,7 +328,7 @@ function shellOf(thread: FakeThread): OrchestrationV2ThreadShell {
const modelSelection = thread.modelSelection ?? MODEL;
return {
id: thread.id,
- projectId: PROJECT_ID,
+ projectId: thread.projectId ?? PROJECT_ID,
title: thread.title,
providerInstanceId: modelSelection.instanceId,
modelSelection,
diff --git a/docs/user/thread-sidebar.md b/docs/user/thread-sidebar.md
index 71a6b98efdd12..182eee2e30437 100644
--- a/docs/user/thread-sidebar.md
+++ b/docs/user/thread-sidebar.md
@@ -304,18 +304,37 @@ back the standard rows.
## Inspect a board task's conversation
-Open a board task and choose **Inspect source workspace** to read the conversation
-that created it. Its agent lineage and parent links let you inspect related
-conversations without leaving the task. **Back to task conversation** returns to
-the engine history and its question-bound drafts.
-
-Native tools and terminals belong to the inspected conversation and its project,
-not to the engine run's working folder. Two tasks from the same conversation use
-the same native tool tabs. Task evidence and settings remain available separately.
-A task with no source conversation still has its own history, configuration and
-evidence, but has no native conversation workspace to open. Forking into new work,
-opening a citation or following an explicit Open link still uses its ordinary
-destination; these actions are not lineage inspection.
+A board task opens as its own thread, titled with its number and title. The
+badges in its header show the task's stage, team, evidence and deployment. Select
+the stage to open the **Task** item of the thread details card, the team to see who
+is doing what and open a seat's conversation, and evidence or deployment to open
+its tab. On a narrow window the badges sit in a row under the header.
+
+**Task evidence** and **Deployments** are tabs on the thread's right panel. Closed,
+they come back from the panel's **+** menu, on a task's thread only. While a
+seat's conversation is open, the panel, the details and the badges stay the
+task's.
+
+The **Task** item holds what is asked, the plan, who owns the task, its seat
+settings and the engine's log. The log's composer writes to the team as notes,
+changes, status questions or answers; a proposed change is confirmed or declined
+on its entry, which **Needs you** links to while it waits. Under **Linked
+conversations**, **Made from** opens the conversation that created the task in its
+place, and **Back to task** returns to the task. The card's lineage also lists the
+task's parent, parts and follow-ups; select one to open that task. A task with no
+source conversation has no **Made from** row. Forking into new work, opening a
+citation or following an explicit Open link still uses its ordinary destination.
+
+A task with no conversation yet keeps its tabs and details on its own page: a
+saved draft opens there with its editor, a queued task shows its text and its
+place in the queue, and a task already at work links to the engine's log.
+
+While a task is open, the Board's sidebar column switches between tasks. The
+open task is highlighted, with its parent above it and its parts, follow-ups and
+seat conversations nested under it; select a seat to open its conversation in
+the task. Search there narrows only this list. **Back to board** returns to the
+board with its filters as you left them. On a phone, the arrow at the start of
+the task's bar also goes back to the board.
## Open a thread beside the one you are in