Compare commits

...
Author SHA1 Message Date
Mohamed BoudraandSammy Patenotte a8873686e3 Say the 0.18 requirement is on the app, not the daemon
Co-authored-by: Sammy Patenotte <sammy.patenotte@yahoo.com>
2026-11-25 10:27:27 +01:00
Mohamed BoudraandSammy Patenotte 9cd2d70155 Let plugins nest dispatched workspaces under the workspace that created them
Workspace snapshots now carry parentWorkspace, the ref of the workspace whose
agent created this one on the same host. A sidebar view can nest dispatched
workspaces with useWorkspaces({ where: (item) => item.parentWorkspace?.key ===
reference.key }), the same way the nested example nests agents by parentAgent.
It is null for root workspaces and on hosts that do not record the link.

Based on #10330 by Sammy Patenotte, reshaped from a host-local id to a ref so
it matches parentAgent and project and works in views spanning hosts.

Co-authored-by: Sammy Patenotte <sammy.patenotte@yahoo.com>
2026-11-25 10:22:40 +01:00
10 changed files with 75 additions and 4 deletions
@@ -130,6 +130,16 @@ describe("sidebar entity snapshots", () => {
);
});
it("points a dispatched workspace at its parent's ref, and a root workspace at null", () => {
const parent = createPluginWorkspaceSnapshot(workspace, "host-1");
const child = createPluginWorkspaceSnapshot(
{ ...workspace, id: "workspace-2", parentWorkspaceId: workspace.id },
"host-1",
);
expect(parent.parentWorkspace).toBeNull();
expect(child.parentWorkspace).toBe(parent.ref);
});
it("reads projects without requiring a workspace", () => {
const project = {
projectId: "empty",
@@ -51,6 +51,9 @@ export function createPluginWorkspaceSnapshot(
createdAt: serializeTimestamp(workspace.createdAt),
lastPromptAt: serializeTimestamp(workspace.lastUserMessageAt),
parentAgent,
parentWorkspace: workspace.parentWorkspaceId
? entityRefs.workspace(hostId, workspace.parentWorkspaceId)
: null,
indicator,
indicatorLabel: i18n.t(indicatorLabelKeys[indicator]),
id: workspace.id,
@@ -56,6 +56,19 @@ function SelectedWorkspace({ reference }: { reference: WorkspaceRef }) {
</div>
);
}
function DispatchedWorkspaces({ parent }: { parent: WorkspaceRef }) {
const children = useWorkspaces({
where: (item) => item.parentWorkspace?.key === parent.key,
orderBy: "name",
});
return (
<div>
{children.map((reference) => (
<WorkspaceRow key={reference.key} reference={reference} />
))}
</div>
);
}
function AgentRow({ reference }: { reference: AgentRef }) {
const item = useAgent(reference);
return <div>{item?.title}</div>;
@@ -364,6 +377,39 @@ describe("sidebar data hooks through the app store and plugin provider", () => {
});
}
});
it("nests a dispatched workspace under its parent on the same host only", () => {
seedHost("host-1");
seedHost("host-2");
const dispatched = (name: string) =>
new Map([
[
"workspace-1",
{ ...workspace, id: "workspace-1", status: "done" as const, name: "Parent" },
],
[
"workspace-2",
{
...workspace,
id: "workspace-2",
status: "done" as const,
name,
parentWorkspaceId: "workspace-1",
},
],
]);
const store = useSessionStore.getState();
store.setWorkspaces("host-1", dispatched("Child here"));
store.setWorkspaces("host-2", dispatched("Child elsewhere"));
const hosts = new ConnectedHosts();
act(() => hosts.connect("host-2"));
const parent = createEntityRefs().workspace("host-1", "workspace-1");
const source = mount(<DispatchedWorkspaces parent={parent} />, hosts);
expect(container?.textContent).toBe("Child here:running");
const parentSnapshot = source
.getSnapshot()
.workspaces.find((item) => item.ref.key === parent.key);
expect(parentSnapshot?.parentWorkspace).toBeNull();
});
it("adds a newly connected host and exposes projects with no workspaces", () => {
seedHost("host-1");
seedHost("host-2");
@@ -25,6 +25,7 @@ const workspace: PluginWorkspaceSnapshot = {
createdAt: null,
lastPromptAt: null,
parentAgent: null,
parentWorkspace: null,
indicator: "running",
indicatorLabel: "Running",
id: "workspace-1",
+1 -1
View File
@@ -176,7 +176,7 @@ export function normalizeWorkspaceDescriptor(
projectKind: payload.projectKind,
workspaceKind: payload.workspaceKind,
background: payload.background ?? false,
parentWorkspaceId: payload.parentWorkspaceId,
parentWorkspaceId: normalizeWorkspaceOpaqueId(payload.parentWorkspaceId) ?? undefined,
name: payload.name,
title: payload.title ?? null,
pinnedAt: payload.pinnedAt ?? null,
+5
View File
@@ -34,6 +34,11 @@ export interface PluginWorkspaceSnapshot {
readonly createdAt: string | null;
readonly lastPromptAt: string | null;
readonly parentAgent: AgentRef | null;
/**
* The workspace whose agent created this one, on the same host. Null when the host records no
* parent, as for root workspaces. The parent may be archived, so `useWorkspace` can return null.
*/
readonly parentWorkspace: WorkspaceRef | null;
readonly indicator: WorkspaceIndicator;
readonly indicatorLabel: string | null;
readonly id: string;
+1
View File
@@ -1895,6 +1895,7 @@ Workspace snapshot fields:
| `statusEnteredAt` | ISO timestamp or `null` |
| `archivingAt` | ISO timestamp or `null` |
| `diffStat` | `{ additions: number; deletions: number } \| null` |
| `parentWorkspace` | `WorkspaceRef \| null` |
Agent snapshot fields:
+1
View File
@@ -1552,6 +1552,7 @@ const [state, setState] = useTabState(tab, schema, { view: "preview" });
| `statusEnteredAt` | ISO 时间戳或 `null` |
| `archivingAt` | ISO 时间戳或 `null` |
| `diffStat` | `{ additions: number; deletions: number } \| null` |
| `parentWorkspace` | `WorkspaceRef \| null` |
Agent 快照字段:
+6 -2
View File
@@ -116,8 +116,12 @@ Existing workspace panels can continue passing a host-local string ID to `useWor
`serverId`, `label` and connection `status` fields.
Workspace snapshots include `project`, `pinnedAt`, `labels`, `background`, `branch`,
`lastPromptAt`, `parentAgent` and `createdAt` (null on older hosts). Use `indicator` and the
localized `indicatorLabel` to display the status Paseo shows. `status` remains the raw daemon
`lastPromptAt`, `parentAgent` and `createdAt` (null on older hosts). `parentWorkspace` is the ref
of the workspace whose agent created this one, on the same host. The app requires Paseo 0.18.
It is null when the host records no parent, as for root workspaces. The parent may be archived, so `useWorkspace` can
return null for it. Nest dispatched workspaces with
`useWorkspaces({ where: (item) => item.parentWorkspace?.key === reference.key })`. Use
`indicator` and the localized `indicatorLabel` to display the status Paseo shows. `status` remains the raw daemon
status. Agent snapshots include their workspace and parent refs, `background`, and
`backgroundWork.count`. Project snapshots provide
`displayName`, `rootPath`, `kind` and `iconRevision`.
+1 -1
View File
@@ -92,7 +92,7 @@ const selected = useWorkspace(ref, selector, equals);
没有选择器时,自定义相等比较函数接收快照;有选择器时接收选择结果。现有工作区面板仍可向 `useWorkspace` 和 `useAgent` 传入主机本地的字符串 ID。跨主机视图应使用引用。`useHosts()` 保留现有的 `serverId`、`label` 和连接 `status` 字段。
工作区快照包含 `project`、`pinnedAt`、`labels`、`background`、`branch`、`lastPromptAt`、`parentAgent` 和 `createdAt`(旧主机上为 null)。使用 `indicator` 和本地化的 `indicatorLabel` 显示 Paseo 的状态。`status` 保持 daemon 原始状态。Agent 快照包含工作区和父 Agent 引用、`background` 和 `backgroundWork.count`。项目快照提供 `displayName`、`rootPath`、`kind` 和 `iconRevision`。
工作区快照包含 `project`、`pinnedAt`、`labels`、`background`、`branch`、`lastPromptAt`、`parentAgent` 和 `createdAt`(旧主机上为 null)。`parentWorkspace` 是同一主机上创建该工作区的 Agent 所在工作区的引用。应用需要 Paseo 0.18。主机未记录父工作区时(例如根工作区)为 null。父工作区可能已归档,因此 `useWorkspace` 对它可能返回 null。用 `useWorkspaces({ where: (item) => item.parentWorkspace?.key === reference.key })` 嵌套派生的工作区。使用 `indicator` 和本地化的 `indicatorLabel` 显示 Paseo 的状态。`status` 保持 daemon 原始状态。Agent 快照包含工作区和父 Agent 引用、`background` 和 `backgroundWork.count`。项目快照提供 `displayName`、`rootPath`、`kind` 和 `iconRevision`。
## 列出终端 {#list-terminals}