Skip to content

Commit 6f4fcb4

Browse files
authored
fix: keep dashboards and task rails on the selected agent (#134714)
* fix(ui): keep auxiliary dashboards scoped to their session owner * fix: retain canonical dashboard owners through storage * test: refresh plugin activation after module resets * test: repair credential mocks and prebuild Gateway readiness fixture * fix: select release inventory before buffering Git output * test: drop superseded runtime prerequisite coverage
1 parent d469d48 commit 6f4fcb4

51 files changed

Lines changed: 1781 additions & 940 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎AGENTS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ Skills own workflows; root owns hard policy and routing. Product direction and m
115115
- Storage default: SQLite only. Do not add JSON/JSONL/TXT/sidecar files for OpenClaw-owned runtime state, caches, queues, registries, indexes, cursors, checkpoints, or plugin scratch data. File storage is only for named product artifacts: import/export, user attachment, log, backup, or external tool contract. Schema and migration reference: `docs/reference/database-schemas.md`.
116116
- Any SQLite schema change requires explicit approval in chat before implementation.
117117
- Material SQLite or persistent-store changes need explicit user or maintainer discussion and acceptance before implementation. This includes schema-version bumps and same-version changes to tables, projections, indexing, retention, concurrency, recovery, or user-visible persistence semantics. Agents must not advance SQLite schema versions or implement a material store design autonomously. Follow `docs/reference/database-schemas.md#review-checkpoint-for-material-changes`.
118+
- Routing existing canonical identifiers and owners to the correct store is an implementation repair, not a database or protocol change, when schemas, stored representations, migrations, and public contracts stay unchanged. Continue under existing fix authorization; do not ask for additional approval merely because the repair touches persistence code.
118119
- Additive SQLite surface may stay at the same schema version only when downgraded readers stay safe — exact criteria (new tables; bare nullable `STRICT`-datatype existing-table columns, zero constraints): `docs/reference/database-schemas.md`. Declare it in the canonical schema plus a one-time idempotent lazy ensure on first feature use; fold it into the migration path at the next natural bump.
119120
- SQLite runtime access uses Kysely helpers, not raw SQL statement strings, except schema DDL, migrations, low-level DB bootstrap, or narrowly justified SQLite primitives.
120121
- SQLite write transactions are synchronous commit sections only. Finish async planning, filesystem access, plugin hooks, and predicates before `BEGIN`; then reread and validate authoritative rows before writing. Never return a Promise or execute `await` from a transaction callback.

‎docs/web/control-ui.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,8 @@ Capability toggles stay disabled until the Gateway, session, and runtime config
600600

601601
## Chat behavior
602602

603+
Session dashboards and the Background tasks rail follow the selected conversation's agent, including when multiple agents each use a `global` session. Split panes keep their owners separate; panes showing the same agent and conversation share dashboard updates.
604+
603605
Automatic session titles describe the topic or intended task in your first message.
604606
They are generated separately from the agent's work, so a title is not a completion
605607
status or a report of tool access. Existing titles and manual names are left

‎scripts/release-plan-producer-core.mts‎

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -219,37 +219,44 @@ function withCandidateSnapshot<T>(
219219
): T {
220220
const snapshotRoot = mkdtempSync(join(tmpdir(), "openclaw-release-candidate-"));
221221
try {
222-
// Enumerate package directories, then metadata only. Recursive runtime listings
223-
// grow with unrelated source files and can overflow the child-process buffer.
224-
const metadataPaths = ["package.json"];
225-
for (const directory of git(repoRoot, [
226-
"ls-tree",
227-
"-d",
228-
"-z",
229-
"--name-only",
230-
candidateSha,
231-
"--",
232-
"extensions/",
233-
"packages/",
234-
])
235-
.split("\0")
236-
.filter(Boolean)) {
237-
metadataPaths.push(`${directory}/package.json`);
238-
if (directory.startsWith("extensions/")) {
239-
metadataPaths.push(`${directory}/README.md`);
240-
}
241-
}
242-
const tree = execFileSync("git", ["ls-tree", "-z", candidateSha, "--", ...metadataPaths], {
243-
cwd: repoRoot,
244-
}).toString("utf8");
222+
// Select metadata inside Git before buffering or decoding paths: directory-name
223+
// decoding can silently omit non-UTF-8 inventory, while source trees can exceed stdout limits.
224+
// Latin1 preserves raw bytes until mode filtering; only retained blob paths need UTF-8.
225+
const patterns = [
226+
"package.json",
227+
"extensions/*/package.json",
228+
"extensions/*/README.md",
229+
"packages/*/package.json",
230+
];
231+
const entries = execFileSync(
232+
"git",
233+
[
234+
"diff-tree",
235+
"--raw",
236+
"-r",
237+
"-z",
238+
"--no-renames",
239+
"--no-ext-diff",
240+
"--no-textconv",
241+
"--no-color",
242+
git(repoRoot, ["hash-object", "-t", "tree", "--stdin"]),
243+
candidateSha,
244+
"--",
245+
...patterns.flatMap((path) => [`:(top,glob)${path}`, `:(top,glob,exclude)${path}/**`]),
246+
],
247+
{ cwd: repoRoot },
248+
)
249+
.toString("latin1")
250+
.split("\0");
251+
const decoder = new TextDecoder("utf-8", { fatal: true });
245252
const inventoryPaths: string[] = [];
246-
for (const entry of tree.split("\0").filter(Boolean)) {
247-
const [metadata, path] = entry.split("\t");
248-
if (metadata?.startsWith("120000 ")) {
253+
for (let index = 0; index + 1 < entries.length; index += 2) {
254+
const mode = entries[index]?.split(" ")[1];
255+
if (mode === "120000") {
249256
throw new Error("candidate package inventory must not contain symbolic links");
250257
}
251-
if (metadata?.startsWith("100") && path) {
252-
inventoryPaths.push(path);
258+
if (mode?.startsWith("100")) {
259+
inventoryPaths.push(decoder.decode(Buffer.from(entries[index + 1]!, "latin1")));
253260
}
254261
}
255262
if (!inventoryPaths.includes("package.json")) {

‎src/agents/github-exec-credential.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
55
import { mockProcessPlatform } from "../test-utils/vitest-spies.js";
66

77
const permissions = vi.hoisted(() => ({ inspect: vi.fn(), read: vi.fn() }));
8-
vi.mock("@openclaw/fs-safe/permissions", () => ({ inspectPathPermissions: permissions.inspect }));
9-
vi.mock("@openclaw/fs-safe/secure-file", () => ({ readSecureFile: permissions.read }));
8+
vi.mock("../infra/permissions.js", () => ({ inspectPathPermissions: permissions.inspect }));
9+
vi.mock("../infra/fs-safe.js", () => ({ readSecureFile: permissions.read }));
1010

1111
import { readGitHubExecToken } from "./github-exec-credential.js";
1212

‎src/boards/board-generated-identity.test.ts‎

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ describe("generated BoardStore identity", () => {
7171
});
7272
expect(plain.resolvedWidgetName).toBe("cafe-menu-bbbbbbbb");
7373
expect(plain.widgets.map((widget) => widget.name)).toEqual(["cafe-menu", "cafe-menu-bbbbbbbb"]);
74-
expect(store.readWidgetHtml("agent:main:board", "cafe-menu")?.html).toContain(
74+
expect(store.readWidgetHtml({ sessionKey: "agent:main:board" }, "cafe-menu")?.html).toContain(
7575
"accented revised",
7676
);
7777

@@ -115,7 +115,9 @@ describe("generated BoardStore identity", () => {
115115
});
116116
expect(generatedAfterTakeover.resolvedWidgetName).toBe("release-status-cccccccc");
117117
expect(generatedAfterTakeover.widgets).toHaveLength(2);
118-
expect(store.readWidgetHtml("agent:main:board", "release-status")?.html).toContain("manual");
118+
expect(
119+
store.readWidgetHtml({ sessionKey: "agent:main:board" }, "release-status")?.html,
120+
).toContain("manual");
119121
});
120122

121123
it("fails closed instead of overwriting an occupied deterministic fallback", () => {
@@ -142,7 +144,7 @@ describe("generated BoardStore identity", () => {
142144
generatedIdentity: generatedIdentity("d", "status-dddddddd"),
143145
}),
144146
).toThrow("generated widget fallback name is already in use");
145-
expect(store.getSnapshot("agent:main:board").widgets).toHaveLength(2);
147+
expect(store.getSnapshot({ sessionKey: "agent:main:board" }).widgets).toHaveLength(2);
146148
});
147149

148150
it("rejects a fallback that is not distinct even on an empty board", () => {
@@ -182,13 +184,15 @@ it("preserves a beta.5-format unmarked explicit row and reuses the generated fal
182184
declared: { tools: ["menu.refresh"] },
183185
});
184186
store.grant(
185-
sessionKey,
187+
{ sessionKey },
186188
"cafe-menu",
187189
"granted",
188190
1,
189191
legacy.widgets.find((widget) => widget.name === "cafe-menu")?.instanceId,
190192
);
191-
store.applyOps(sessionKey, [{ kind: "widget_resize", name: "cafe-menu", sizeW: 8, sizeH: 6 }]);
193+
store.applyOps({ sessionKey }, [
194+
{ kind: "widget_resize", name: "cafe-menu", sizeW: 8, sizeH: 6 },
195+
]);
192196
const seededDatabase = openOpenClawAgentDatabase({ agentId: "main", env });
193197
seededDatabase.db
194198
.prepare(
@@ -216,7 +220,7 @@ it("preserves a beta.5-format unmarked explicit row and reuses the generated fal
216220
sizeH: 6,
217221
position: 1,
218222
});
219-
expect(reopened.readWidgetHtml(sessionKey, "cafe-menu")?.html).toContain("approved");
223+
expect(reopened.readWidgetHtml({ sessionKey }, "cafe-menu")?.html).toContain("approved");
220224

221225
closeOpenClawAgentDatabasesForTest();
222226
closeOpenClawStateDatabaseForTest();
@@ -233,12 +237,12 @@ it("preserves a beta.5-format unmarked explicit row and reuses the generated fal
233237
expect(reused.widgets.find((widget) => widget.name === "cafe-menu-eeeeeeee")).toMatchObject({
234238
revision: 2,
235239
});
236-
expect(durable.readWidgetHtml(sessionKey, "cafe-menu")?.html).toContain("approved");
240+
expect(durable.readWidgetHtml({ sessionKey }, "cafe-menu")?.html).toContain("approved");
237241
closeOpenClawAgentDatabasesForTest();
238242

239243
expect(
240244
new SqliteBoardStore(options)
241-
.getSnapshot(sessionKey)
245+
.getSnapshot({ sessionKey })
242246
.widgets.find((widget) => widget.name === "cafe-menu"),
243247
).toMatchObject({
244248
name: "cafe-menu",
@@ -290,7 +294,7 @@ it("does not infer generated ownership from a canonical unmarked title match", (
290294
});
291295
expect(generated.resolvedWidgetName).toBe("widget-f62b28f7");
292296
expect(generated.widgets).toHaveLength(2);
293-
expect(reopened.readWidgetHtml(sessionKey, "widget-e3b21956")?.html).toContain("legacy");
297+
expect(reopened.readWidgetHtml({ sessionKey }, "widget-e3b21956")?.html).toContain("legacy");
294298
});
295299

296300
it("preserves unmarked rows whose absent or capped titles are ambiguous", () => {
@@ -339,8 +343,8 @@ it("preserves unmarked rows whose absent or capped titles are ambiguous", () =>
339343

340344
expect(untitled.resolvedWidgetName).toBe("status-bbbbbbbb");
341345
expect(long.resolvedWidgetName).toBe("report-cccccccc");
342-
expect(reopened.readWidgetHtml(sessionKey, "status")?.html).toContain("manual untitled");
343-
expect(reopened.readWidgetHtml(sessionKey, "report")?.html).toContain("legacy long");
346+
expect(reopened.readWidgetHtml({ sessionKey }, "status")?.html).toContain("manual untitled");
347+
expect(reopened.readWidgetHtml({ sessionKey }, "report")?.html).toContain("legacy long");
344348
});
345349

346350
it("persists explicit ownership across restart", () => {
@@ -368,5 +372,5 @@ it("persists explicit ownership across restart", () => {
368372
generatedIdentity: generatedIdentity("d", "status-dddddddd"),
369373
});
370374
expect(generated.resolvedWidgetName).toBe("status-dddddddd");
371-
expect(reopened.readWidgetHtml(sessionKey, "status")?.html).toContain("manual");
375+
expect(reopened.readWidgetHtml({ sessionKey }, "status")?.html).toContain("manual");
372376
});

‎src/boards/board-notices.ts‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { truncateUtf16Safe } from "@openclaw/normalization-core/utf16-slice";
2+
import { withSystemEventOwner } from "../infra/system-event-ownership.js";
23
import { enqueueSystemEvent } from "../infra/system-events.js";
34

45
const BOARD_EVENT_MAX_BYTES = 8 * 1024;
@@ -36,6 +37,7 @@ function formatNotice(widget: string, summary: string): string {
3637

3738
export function appendBoardEventNotice(params: {
3839
sessionKey: string;
40+
agentId?: string;
3941
widget: string;
4042
payload: unknown;
4143
now?: number;
@@ -45,7 +47,8 @@ export function appendBoardEventNotice(params: {
4547
throw new BoardEventPayloadError(`board event payload exceeds ${BOARD_EVENT_MAX_BYTES} bytes`);
4648
}
4749
const now = params.now ?? Date.now();
48-
const key = `${params.sessionKey}\0${params.widget}`;
50+
// Global session keys and widget names can coincide across different owners.
51+
const key = `${params.agentId ?? ""}\0${params.sessionKey}\0${params.widget}`;
4952
const recent = recentNotices.get(key);
5053
if (recent?.summary === summary && now - recent.at < BOARD_EVENT_DEDUPE_MS) {
5154
return false;
@@ -56,10 +59,14 @@ export function appendBoardEventNotice(params: {
5659
recentNotices.delete(candidate);
5760
}
5861
}
59-
return enqueueSystemEvent(formatNotice(params.widget, summary), {
62+
const options = {
6063
sessionKey: params.sessionKey,
6164
contextKey: `dashboard:${params.widget}:${now}`,
62-
});
65+
};
66+
return enqueueSystemEvent(
67+
formatNotice(params.widget, summary),
68+
params.agentId ? withSystemEventOwner(options, params.agentId) : options,
69+
);
6370
}
6471

6572
export function resetBoardEventNoticeStateForTest(): void {

0 commit comments

Comments
 (0)