Fix chat panel token fetch: use /api/workspaces not URL slug
URL param 'mark-account' != workspace slug 'mark'. Fetch default token from /api/workspaces?include_default_token=true which resolves the real slug server-side. Made-with: Cursor
This commit is contained in:
@@ -163,13 +163,14 @@ export function ChatPanel() {
|
||||
document.documentElement.style.setProperty("--chat-panel-width", open ? "380px" : "0px");
|
||||
}, [open]);
|
||||
|
||||
// Load MCP token — prefer localStorage cache, fetch from API if missing
|
||||
// Load MCP token — prefer localStorage cache, fetch from API if missing.
|
||||
// We use /api/workspaces (not the URL param) because the URL slug
|
||||
// (e.g. "mark-account") differs from the actual workspace slug ("mark").
|
||||
useEffect(() => {
|
||||
if (!workspace || status !== "authenticated") return;
|
||||
const cached = localStorage.getItem(`vibn-mcp-token-${workspace}`);
|
||||
if (cached) { setMcpToken(cached); return; }
|
||||
// Auto-fetch the workspace's default key (created at account setup)
|
||||
fetch(`/api/workspaces/${workspace}/keys?include_default_token=true`)
|
||||
fetch("/api/workspaces?include_default_token=true")
|
||||
.then((r) => r.ok ? r.json() : null)
|
||||
.then((d) => {
|
||||
if (d?.defaultToken) {
|
||||
@@ -177,7 +178,7 @@ export function ChatPanel() {
|
||||
setMcpToken(d.defaultToken);
|
||||
}
|
||||
})
|
||||
.catch(() => {/* silent — panel works in read-only mode */});
|
||||
.catch(() => {});
|
||||
}, [workspace, status]);
|
||||
|
||||
// Load threads
|
||||
|
||||
Reference in New Issue
Block a user