mirror of
https://gitee.com/mateos/mateclaw.git
synced 2026-09-15 11:58:34 +08:00
fix(chat): drop stale workspace agentId from chat URL on remount (#465)
This commit is contained in:
parent
91a7842393
commit
b6d60cd946
@ -1465,8 +1465,24 @@ async function refreshCurrentConversationMessages(conversationId: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function hydrateStateFromRoute() {
|
async function hydrateStateFromRoute() {
|
||||||
const agentId = route.query.agentId ? String(route.query.agentId) : ''
|
let agentId = route.query.agentId ? String(route.query.agentId) : ''
|
||||||
const conversationId = String(route.query.conversationId || '')
|
let conversationId = String(route.query.conversationId || '')
|
||||||
|
|
||||||
|
// The URL can outlive its workspace: switching workspaces remounts this view
|
||||||
|
// (via the router-view key) but keeps the query string, so agentId /
|
||||||
|
// conversationId may still point at entities of the previous workspace. An
|
||||||
|
// agentId missing from the workspace-scoped agent list is such a leftover —
|
||||||
|
// drop it so the default-select below picks a real employee instead of the
|
||||||
|
// picker rendering the unresolvable raw id.
|
||||||
|
if (agentId && agents.value.length > 0 && !agents.value.some(a => String(a.id) === agentId)) {
|
||||||
|
agentId = ''
|
||||||
|
// Only follow the paired conversationId when it resolves locally (e.g. a
|
||||||
|
// Sessions-page jump within this workspace); otherwise it is equally stale
|
||||||
|
// and would attach the fallback agent to a foreign conversation.
|
||||||
|
if (!conversations.value.some(conv => conv.conversationId === conversationId)) {
|
||||||
|
conversationId = ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (agentId && agentId !== String(selectedAgentId.value)) {
|
if (agentId && agentId !== String(selectedAgentId.value)) {
|
||||||
selectedAgentId.value = agentId
|
selectedAgentId.value = agentId
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user