From 47773b5bd1fc33ecbe96d11824d4aa4b97ae2438 Mon Sep 17 00:00:00 2001 From: wizardchen Date: Sat, 26 Sep 2026 13:22:38 +0800 Subject: [PATCH] fix(frontend): initialize chat citation popover after botmsg props useCitationPopover watches its cache-scope getter, so Vue evaluates the sessionId getter synchronously during setup. botmsg.vue called useChatCitationPopover above defineProps, hitting the TDZ on `props` and logging "Cannot access 'props' before initialization" whenever an existing chat session rendered assistant messages. Move the call below defineProps and add a test that compiles every SFC calling a citation popover composable and runs its setup against the real popover chain, so a caller reading props too early fails in CI. --- .../citationPopoverCallers.test.ts | 99 +++++++++++++++++++ frontend/src/views/chat/components/botmsg.vue | 9 +- 2 files changed, 104 insertions(+), 4 deletions(-) create mode 100644 frontend/src/composables/citationPopoverCallers.test.ts diff --git a/frontend/src/composables/citationPopoverCallers.test.ts b/frontend/src/composables/citationPopoverCallers.test.ts new file mode 100644 index 00000000..f7135c24 --- /dev/null +++ b/frontend/src/composables/citationPopoverCallers.test.ts @@ -0,0 +1,99 @@ +import assert from 'node:assert/strict' +import { readdirSync, readFileSync } from 'node:fs' +import { join, relative } from 'node:path' +import { fileURLToPath } from 'node:url' +import { runInNewContext } from 'node:vm' +import test from 'node:test' +import ts from 'typescript' +import * as vue from 'vue' +import { compileScript, parse } from 'vue/compiler-sfc' + +// The popover watches its cache-scope getter, so Vue evaluates it during +// setup; callers must not read props that