Skip to content

Commit e1120f0

Browse files
committed
fix(ui): gate task global metadata by scope
1 parent 9050e12 commit e1120f0

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

‎ui/src/pages/chat/components/chat-task-detail.test.ts‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ describe("task detail panel", () => {
136136
it.each([
137137
{
138138
name: "uses qualified child session archive attribution",
139+
scope: "per-sender" as const,
139140
sessionsResultAgentId: "main",
140141
childRow: {
141142
key: "agent:work:task-child",
@@ -150,6 +151,7 @@ describe("task detail panel", () => {
150151
},
151152
{
152153
name: "uses raw global child metadata for the owning agent",
154+
scope: "global" as const,
153155
sessionsResultAgentId: "work",
154156
childRow: {
155157
key: "global",
@@ -162,8 +164,24 @@ describe("task detail panel", () => {
162164
childSessionKey: "agent:work:main",
163165
expected: "Archived by Global Owner",
164166
},
167+
{
168+
name: "rejects raw global child metadata in per-sender scope",
169+
scope: "per-sender" as const,
170+
sessionsResultAgentId: "work",
171+
childRow: {
172+
key: "global",
173+
kind: "global",
174+
updatedAt: 2_000,
175+
archived: true,
176+
archivedAt: 2_000,
177+
archivedBy: { type: "human", id: "per-sender-owner", label: "Per-Sender Owner" },
178+
} satisfies GatewaySessionRow,
179+
childSessionKey: "agent:work:main",
180+
expected: undefined,
181+
},
165182
{
166183
name: "rejects raw global child metadata from a different agent",
184+
scope: "global" as const,
167185
sessionsResultAgentId: "main",
168186
childRow: {
169187
key: "global",
@@ -176,7 +194,7 @@ describe("task detail panel", () => {
176194
childSessionKey: "agent:work:main",
177195
expected: undefined,
178196
},
179-
])("$name", async ({ sessionsResultAgentId, childRow, childSessionKey, expected }) => {
197+
])("$name", async ({ scope, sessionsResultAgentId, childRow, childSessionKey, expected }) => {
180198
const task: TaskSummary = {
181199
id: "task-child",
182200
taskId: "task-child",
@@ -200,6 +218,7 @@ describe("task detail panel", () => {
200218
client: createGatewayBrowserClientFixture({ request }),
201219
connected: true,
202220
hello: null,
221+
agentsList: { defaultId: "main", mainKey: "main", scope },
203222
sessionsResultAgentId,
204223
};
205224
const parentRow: GatewaySessionRow = {
@@ -249,7 +268,7 @@ describe("task detail panel", () => {
249268
if (expected) {
250269
expect(container.textContent).toContain(expected);
251270
} else {
252-
expect(container.textContent).not.toContain("Wrong Owner");
271+
expect(container.textContent).not.toContain(`Archived by ${childRow.archivedBy.label}`);
253272
}
254273
transcript.hostDisconnected();
255274
});

‎ui/src/pages/chat/components/chat-task-detail.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { renderPanelLoadingSkeleton } from "../../../components/panel-loading-sk
66
import { t } from "../../../i18n/index.ts";
77
import {
88
canonicalUiSessionKeyForPersistence,
9+
isUiGlobalScopeConfigured,
910
normalizeAgentId,
1011
uiSessionRowMatchesSelectedChat,
1112
} from "../../../lib/sessions/session-key.ts";
@@ -163,8 +164,9 @@ function renderTaskTranscript(params: {
163164
const selectedSession = params.chat.sessions?.sessions.find(
164165
(row) =>
165166
(row.key !== "global" ||
166-
normalizeAgentId(params.host.sessionsResultAgentId ?? "") ===
167-
normalizeAgentId(params.task.agentId)) &&
167+
(isUiGlobalScopeConfigured(params.host) &&
168+
normalizeAgentId(params.host.sessionsResultAgentId ?? "") ===
169+
normalizeAgentId(params.task.agentId))) &&
168170
uiSessionRowMatchesSelectedChat(params.host, row.key, params.sessionKey),
169171
);
170172
return html`<div class="sidebar-content chat-task-detail__content">

0 commit comments

Comments
 (0)