Fix notifications opening the wrong workspace (#2331)

* fix(app): open notifications on the right host

Agent notifications previously omitted workspace ownership, so a cold target host was treated as missing and fell back to its empty home route. Carry the authoritative workspace and keep older notifications on a target-host resolver until lookup is conclusive.

* fix(app): separate notification and agent URL routing

Notifications use their authoritative workspace target directly. Stable agent URLs remain server-and-agent targets whose workspace is resolved by the agent route.

* fix(protocol): preserve notification workspace targets

Both attention message variants retain workspaceId through outbound validation so notification clicks receive the authoritative route target.

* test(app): use workspace-scoped notification target

* test(server): give notification agents workspace targets

* test(app): target notification workspace in navigation e2e
This commit is contained in:
Mohamed Boudra
2026-07-23 03:32:28 +08:00
committed by GitHub
parent de69b2a2af
commit 5dfe50ca74
19 changed files with 627 additions and 110 deletions
@@ -6,10 +6,27 @@ import {
} from "./agent-attention-notification.js";
describe("buildAgentAttentionNotificationPayload", () => {
it("carries the workspace needed to open a cold agent destination", () => {
const payload = buildAgentAttentionNotificationPayload({
reason: "finished",
serverId: "srv-1",
workspaceId: "workspace-1",
agentId: "agent-1",
});
expect(payload.data).toEqual({
serverId: "srv-1",
workspaceId: "workspace-1",
agentId: "agent-1",
reason: "finished",
});
});
it("builds finished notifications from markdown assistant text", () => {
const payload = buildAgentAttentionNotificationPayload({
reason: "finished",
serverId: "srv-1",
workspaceId: "workspace-1",
agentId: "agent-1",
assistantMessage: "**Done**. Updated `README.md` and [link](https://example.com).",
});
@@ -19,6 +36,7 @@ describe("buildAgentAttentionNotificationPayload", () => {
body: "Done. Updated README.md and link.",
data: {
serverId: "srv-1",
workspaceId: "workspace-1",
agentId: "agent-1",
reason: "finished",
},
@@ -29,6 +47,7 @@ describe("buildAgentAttentionNotificationPayload", () => {
const payload = buildAgentAttentionNotificationPayload({
reason: "permission",
serverId: "srv-2",
workspaceId: "workspace-2",
agentId: "agent-2",
permissionRequest: {
id: "perm-1",
@@ -45,6 +64,7 @@ describe("buildAgentAttentionNotificationPayload", () => {
body: "Approve command - Run git push",
data: {
serverId: "srv-2",
workspaceId: "workspace-2",
agentId: "agent-2",
reason: "permission",
},
@@ -55,6 +75,7 @@ describe("buildAgentAttentionNotificationPayload", () => {
const payload = buildAgentAttentionNotificationPayload({
reason: "error",
serverId: "srv-3",
workspaceId: "workspace-3",
agentId: "agent-3",
});
@@ -63,6 +84,7 @@ describe("buildAgentAttentionNotificationPayload", () => {
body: "Encountered an error.",
data: {
serverId: "srv-3",
workspaceId: "workspace-3",
agentId: "agent-3",
reason: "error",
},