fix: preserve full chat embed mode navigation
This commit is contained in:
1 parent
4450f342d8
commit
e52261fc3d
3 files changed
+71
-9
No files matched your search
@@ -3,6 +3,7 @@ import test from "node:test";
|
||||
|
||||
import {
|
||||
buildStandardChatRedirectPath,
|
||||
buildFullChatNavigationPath,
|
||||
buildEmbeddedIframeRedirectPath,
|
||||
buildChatsIframeRedirectPath,
|
||||
buildChatsIframeThreadPath,
|
||||
@@ -280,6 +281,27 @@ test("builds a standard full-chat URL without leaking the legacy marker", () =>
|
||||
);
|
||||
});
|
||||
|
||||
test("keeps full-chat presentation flags when the sidebar opens an agent or thread", () => {
|
||||
assert.equal(
|
||||
buildFullChatNavigationPath(
|
||||
"/page/workspace/chats/new?agent=agent-1",
|
||||
"?hideChrome=1&chatMode=full",
|
||||
),
|
||||
"/page/workspace/chats/new?agent=agent-1&hideChrome=1&chatMode=full",
|
||||
);
|
||||
assert.equal(
|
||||
buildFullChatNavigationPath(
|
||||
"/page/workspace/chats/thread-123",
|
||||
"?embed=1&theme=dark-blue&chatMode=full",
|
||||
),
|
||||
"/page/workspace/chats/thread-123?embed=1&theme=dark-blue&chatMode=full",
|
||||
);
|
||||
assert.equal(
|
||||
buildFullChatNavigationPath("/page/workspace/chats/new", ""),
|
||||
"/page/workspace/chats/new",
|
||||
);
|
||||
});
|
||||
|
||||
test("preserves explicit Brainy iframe mode and theme across redirects", () => {
|
||||
assert.equal(
|
||||
buildChatsIframeRedirectPath("?chatMode=iframe&theme=dark-blue&ticket=secret"),
|
||||
|
||||
@@ -107,6 +107,26 @@ export function buildStandardChatRedirectPath(
|
||||
return query ? `${pathname}?${query}` : pathname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep an explicitly selected standard-chat presentation while navigating
|
||||
* between `/chats/new` and a concrete chat thread. Without this, a click in
|
||||
* the full-chat sidebar drops `hideChrome=1&chatMode=full`; an iframe host
|
||||
* then looks like the legacy bare integration and is incorrectly redirected
|
||||
* to the private AgentSelector workspace.
|
||||
*
|
||||
* This deliberately whitelists presentation flags through
|
||||
* `buildStandardChatRedirectPath` instead of copying arbitrary login/query
|
||||
* values into user-facing chat URLs.
|
||||
*/
|
||||
export function buildFullChatNavigationPath(
|
||||
destinationPath: string,
|
||||
search: string,
|
||||
): string {
|
||||
return hasIframePresentationOverride(search) || isExplicitFullChatMode(search)
|
||||
? buildStandardChatRedirectPath(search, destinationPath)
|
||||
: destinationPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Preserve only the presentation parameters consumed by the iframe workspace.
|
||||
* Login credentials must never be copied into the post-login address bar.
|
||||
|
||||
Reference in new issue
Block a user