Skip to content
Open
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
5 changes: 4 additions & 1 deletion src/agent/dsh-native-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,10 @@ function parseCtxStatus(raw: unknown): CtxStatus | undefined {
panelPresent: o.panel !== undefined,
sessionId: typeof o.sessionId === "string" && o.sessionId.length > 0 ? o.sessionId : null,
conversationId: typeof o.conversationId === "string" && o.conversationId.length > 0 ? o.conversationId : null,
viaFallback: o.viaFallback === true,
// #6968: the wire key is `fallback` (src/plugin.ts handlePluginStatus),
// not `viaFallback` — the internal variable name. Reading the wrong
// key made sessionOurs a constant true and the ownership gate dead.
viaFallback: o.fallback === true,
};
}

Expand Down
32 changes: 31 additions & 1 deletion tests/dsh-settings-ui.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1963,7 +1963,10 @@ test("#3862: conversation.view Context tab embeds the web UI session page, polls
fetch: async (url: string) => {
const u = String(url);
if (u.endsWith("/bili/origin")) return { ok: true, json: async () => ({ origin: ORIGIN }) };
if (u.endsWith(statusUrl)) return { ok: true, json: async () => ({ ok: true, panel: "x", sessionId: "sub-session-id", conversationId: "some-other-conversation", viaFallback: true }) };
// #6968: the REAL wire key is `fallback` (src/plugin.ts), not
// `viaFallback` — the pre-fix test simulated a response the
// server never sends, so the ownership gate was never exercised.
if (u.endsWith(statusUrl)) return { ok: true, json: async () => ({ ok: true, panel: "x", sessionId: "sub-session-id", conversationId: "some-other-conversation", fallback: true }) };
if (u.endsWith("/__bili/?embed=1")) return htmlOk();
throw new Error(`unexpected fetch: ${u}`);
},
Expand All @@ -1977,6 +1980,33 @@ test("#3862: conversation.view Context tab embeds the web UI session page, polls
assert.equal(findTag(hm.component() as ElementNode, "iframe"), undefined, "no frame for someone else's session");
hm.runCleanups();
}
{
// #6968 negative direction (#3617): a fallback that resolves to OUR OWN
// session (conversationId === hostSessionId) is trusted — the ownership
// gate must NOT fire. The gate triggers on FOREIGN fallback rows only;
// pinning this direction stops a future over-tight gate from refusing
// our own fallback-resolved session (the pre-first-request case the
// fallback exists for).
const om = await mountClient({
__BILI__: { origin: ORIGIN },
open: (_url: string) => {},
fetch: async (url: string) => {
const u = String(url);
if (u.endsWith("/bili/origin")) return { ok: true, json: async () => ({ origin: ORIGIN }) };
if (u.endsWith(statusUrl)) return { ok: true, json: async () => ({ ok: true, panel: "x", sessionId: "own-session-id", conversationId: HOST_CONVERSATION_ID, fallback: true }) };
if (u.endsWith("/__bili/?embed=1")) return htmlOk();
throw new Error(`unexpected fetch: ${u}`);
},
...noopTimers,
}, "conversation.view", { sessionId: HOST_CONVERSATION_ID });
om.resetHooks();
om.component();
await tick();
const ot = textOf(om.component() as ElementNode);
assert.ok(!ot.includes("暂无上下文数据"), "own-session fallback is framed, not the not-yet hint");
assert.ok(findTag(om.component() as ElementNode, "iframe") !== undefined, "frame for our own fallback-resolved session");
om.runCleanups();
}
{
// The URL answered but not with our contract shape: degrade honestly.
const st = await subMount({ something: "else" });
Expand Down
Loading