Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ assigned at release.

## Unreleased

- Added: the dashboard session catalog route passes relaygate's owning-group
label (`relaygate: {gid, label}`, from relaygate's `groupLabels` policy)
through when the session read API is relaygate; only those two validated
fields pass. Session list items already carried it unchanged.
- Added: Replicas failure paths (migration 0070). The environment MCP create
intent is persisted on the policy and, while it is set, every sync or
enable (startup run, periodic sync, the sync and enable routes, a plain
Expand Down
17 changes: 17 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9766,6 +9766,23 @@ components:
type: object
truncated:
type: boolean
relaygate:
$ref: "#/components/schemas/RelaygateGroupLabel"
RelaygateGroupLabel:
type: object
description: |
Present only when the session read API is relaygate and its policy
labels the session's owning group (relaygate `groupLabels`). Display
only; passed through from the read API with just these two fields.
Session list items carry the same field unchanged.
required: [gid, label]
properties:
gid:
type: integer
minimum: 0
label:
type: string
maxLength: 24
RunStatus:
enum: [pending, running, completed, failed, cancelled]
EnrollmentTokenSummary:
Expand Down
16 changes: 16 additions & 0 deletions src/sessions/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,21 @@ function sessionItem(value: unknown): Record<string, unknown> {
};
}

/**
* relaygate's owning-group label for one session (`relaygate: {gid, label}`,
* relaygate docs/contract.md "Group labels"), when the read API is relaygate
* and the session's group has one. Only the two known fields pass; anything
* else is dropped.
*/
function groupLabelOf(body: Record<string, unknown>): { relaygate?: { gid: number; label: string } } {
const value = body.relaygate;
if (!isRecord(value)) return {};
const { gid, label } = value;
if (!Number.isSafeInteger(gid) || (gid as number) < 0) return {};
if (typeof label !== "string" || !/^[A-Za-z0-9](?:[A-Za-z0-9 ._-]{0,22}[A-Za-z0-9._-])?$/.test(label)) return {};
return { relaygate: { gid: gid as number, label } };
}

function eventItem(value: unknown): Record<string, unknown> {
if (
!isRecord(value) ||
Expand Down Expand Up @@ -609,6 +624,7 @@ async function routeSessions(ctx: SessionRouteContext): Promise<boolean> {
children: list(body.children),
commitLinks: list(body.commitLinks),
truncated: body.truncated === true,
...groupLabelOf(body),
});
return true;
}
Expand Down
33 changes: 33 additions & 0 deletions test/sessions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,39 @@ test("members: names for the dashboard without a History read", async (t) => {
assert.equal(anonymous.status, 401);
});

test("relaygate group labels reach the dashboard on the list and the catalog, and nothing else of it", async (t) => {
const env = await setup(t);
const token = await env.login(env.ownerId, env.alpha);
const base = `/cloud/api/v1/workspaces/${env.alpha}`;
env.history.overrides.set("/v1/sessions", () => ({
body: {
sessions: [
{ sessionId: "alpha-1", source: "codex", relaygate: { gid: 22, label: "pit" } },
{ sessionId: "alpha-2", source: "codex" },
],
nextCursor: null,
},
}));
const list = await call(env.origin, `${base}/sessions?metadata=deferred`, { token });
assert.equal(list.status, 200);
assert.deepEqual(list.body.items[0].relaygate, { gid: 22, label: "pit" });
assert(!("relaygate" in list.body.items[1]));

const catalogBody = (relaygate: unknown) => ({
body: { sessionId: "alpha-1", workspaceId: env.alpha, catalog: { title: "t" }, parents: [], children: [], relaygate },
});
env.history.overrides.set("/v1/sessions/alpha-1/catalog", () => catalogBody({ gid: 22, label: "pit", owner: "someone" }));
const labeled = await call(env.origin, `${base}/sessions/alpha-1/catalog?source=codex`, { token });
assert.equal(labeled.status, 200);
assert.deepEqual(labeled.body.relaygate, { gid: 22, label: "pit" });
for (const bad of [{ gid: "22", label: "pit" }, { gid: 22, label: "<b>pit</b>" }, { gid: -1, label: "pit" }, "pit"]) {
env.history.overrides.set("/v1/sessions/alpha-1/catalog", () => catalogBody(bad));
const refused = await call(env.origin, `${base}/sessions/alpha-1/catalog?source=codex`, { token });
assert.equal(refused.status, 200);
assert(!("relaygate" in refused.body), JSON.stringify(bad));
}
});

test("list, search, transcript, timing, and subagent catalog for the dashboard", async (t) => {
const env = await setup(t);
const token = await env.login(env.ownerId, env.alpha);
Expand Down
Loading