Repository navigation
fix: persist WebChat chat preferences - #10324
C10H14N2O5 wants to merge 4 commits into
Conversation
|
The unit test failures on Linux, macOS, and Windows are pre-existing upstream failures, rather than regressions introduced by this PR. I compared this PR’s CI run with the upstream master CI run following #10307. Each platform reports the same five failing tests and identical pass counts:
The failures concern the plugin Pages → Views rename: outdated bridge and metadata assertions, plus OpenAPI artifacts that have not been regenerated. This PR changes only two Vue components and one Node test file; it does not modify the affected Python tests, backend implementation, or OpenAPI artifacts. The Dashboard CI run passed. |
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="dashboard/src/components/chat/StandaloneChat.vue" line_range="331-341" />
<code_context>
: "sse",
);
+watch(enableStreaming, (enabled) => {
+ localStorage.setItem("chat.enableStreaming", String(enabled));
+});
+
+watch(enableReasoning, (enabled) => {
</code_context>
<issue_to_address>
**issue (broader_impact):** The two chat entry points only read `localStorage` during component setup, so their reactive preference state becomes stale when the other entry point changes a preference. `FullLayout` keeps `Chat` mounted with `v-show`; after a user changes settings in `StandaloneChat`, navigating back to WebChat displays the still-mounted `Chat` instance with the old values and sends requests using those old preferences.
**Triggers:** When WebChat has already been mounted and the user changes preferences in the configuration page's test chat before returning to WebChat.
**Suggested fix:** Synchronize the reactive state on activation or use a shared preference store/storage-event listener so both mounted entry points update when the persisted values change.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: dashboard/src/components/chat/StandaloneChat.vue:341
|
Following up on the earlier CI failures: the upstream issues were fixed in #10319, and I have merged the latest upstream master into this branch in commit 81c6371. |
TL;DR
localStorageinitialization and watcher pattern in both chat entry points.Background
Fixes #10316.
In WebChat's Settings → Chat menu, disabling streaming output or reasoning visibility, or selecting
Shift+Enteras the send shortcut, only applied to the current page. Reloading restored both toggles to enabled and the send shortcut toEnter. The neighboring SSE / WebSocket transport preference already survived reloads.These options reflect personal chat preferences. This fix retains the user's choices using the same browser-local persistence approach as the transport preference.
Modifications / 改动点
Chat preferences
Update
dashboard/src/components/chat/Chat.vueanddashboard/src/components/chat/StandaloneChat.vueto read saved preferences when initializing their reactive state and write changes through Vue watchers.chat.enableStreamingchat.enableReasoningchat.sendShortcutEnterBoth the main WebChat and the configuration page's test chat use these keys, so newly opened chat entry points read the same preferences on the same browser origin.
The main WebChat remains mounted while other pages are open. When it becomes active again, it reloads the three saved preferences so changes made in the configuration page's test chat are reflected when returning to WebChat.
Regression tests
Add
dashboard/tests/chatPreferencesPersistence.test.mjs, following the existing lightweight Node / TypeScript / Vue test style. The five tests execute the components' initialization and watcher code to cover:Shift+Enter, then restoring them when either chat component is initialized again.chat.transportModevalue.No documentation update is needed because this fix preserves the existing navigation, page structure, and labels. No new dependencies are introduced.
Screenshots or Test Results / 运行截图或测试结果
Verification steps
Shift+Enteras the send shortcut.Manual acceptance testing on the isolated local AstrBot instance passed. The instance serves the frontend built from this working tree and uses a separate runtime data directory. This validation covers settings persistence; no external LLM provider was configured.
Streaming output preference
Reasoning visibility preference
Send shortcut preference
Automated validation
From
dashboard/:Result: 9 passed — five persistence tests and four existing IME input tests.
Result: passed, including TypeScript checks and the production build. The command-line override used the installed dependencies without triggering a reinstall by the local pnpm runtime.
From the repository root:
Results: 514 files left unchanged, All checks passed, and no whitespace errors.
Runtime smoke checks also passed: login, chat session/configuration endpoints, and serving assets matching the freshly built frontend.
After merging the latest upstream
masterin commit81c637165, all GitHub Actions checks passed: Unit Tests on Linux, macOS, and Windows; Dashboard CI; Code Format Check; Smoke Test; and CodeQL.Checklist / 检查清单
Summary by Sourcery
Persist WebChat chat preferences locally so user settings survive reloads and remain synchronized across chat entry points.
Bug Fixes:
Enhancements:
Tests: