Repository navigation
fix(build): support consolidated Dashboard chat preferences - #196
Merged
Merged
Conversation
There was a problem hiding this comment.
Hey - I've found 4 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="scripts/prepare-resources/desktop-bridge-expectations.mjs" line_range="71" />
<code_context>
+ const file = path.join(dashboardDir, ...relativePath.split('/'));
+ await mkdir(path.dirname(file), { recursive: true });
+ await writeFile(file, source, 'utf8');
+ };
+
+ await writeSource(
</code_context>
<issue_to_address>
**Tagged builds miss seeded transport default**
When a tagged Dashboard uses consolidated preferences without a working migration and strict bridge checks are disabled, `shouldEnforceDesktopBridgeExpectation` returns false for the required migration, so `verifyDesktopBridgeArtifacts` only warns and the build continues; consolidated preferences do not import the bridge-seeded WebSocket default, so the chat UI uses the wrong transport default.
Make required migration expectations enforceable for tagged builds even when strict bridge checks are disabled.
Also at `scripts/prepare-resources/desktop-bridge-expectations.mjs:127`.
</issue_to_address>
### Comment 2
<location path="scripts/prepare-resources/desktop-bridge-expectations.mjs" line_range="126" />
<code_context>
filePath: ['src', 'components', 'chat', 'Chat.vue'],
- pattern: DESKTOP_BRIDGE_PATTERNS.chatTransportPreferenceRead,
+ pattern: DESKTOP_BRIDGE_PATTERNS.legacyChatTransportPreferenceRead,
+ fallbackPattern: DESKTOP_BRIDGE_PATTERNS.chatTransportPreferenceRead,
+ fallbackRequirement: CHAT_TRANSPORT_MIGRATION,
label: 'chat transport preference read',
</code_context>
<issue_to_address>
**Mixed preferences drift apart**
When an upstream Dashboard updates only one chat component to `chatPreferences()` while another still reads the legacy key, the verifier accepts each component’s format independently, so a Dashboard with consolidated preferences in `Chat.vue` and legacy storage in `StandaloneChat.vue` passes after the helper migration is checked. When the user changes the transport in `Chat.vue`, the consolidated preference changes but the standalone component still reads the old storage value, so the two chat views use different transports.
Require both chat components to use the same preference format, or otherwise verify that writes keep both formats synchronized.
Also at `scripts/prepare-resources/desktop-bridge-expectations.mjs:136`, `scripts/prepare-resources/desktop-bridge-expectations.mjs:144`.
</issue_to_address>
### Comment 3
<location path="scripts/prepare-resources/desktop-bridge-checks.mjs" line_range="143" />
<code_context>
- } else {
- console.warn(`${message} (compatibility check skipped)`);
- }
+ if (expectation.pattern.test(source)) continue;
+ if (expectation.fallbackPattern?.test(source)) {
+ expectations.add(expectation.fallbackRequirement);
</code_context>
<issue_to_address>
**Broken migration passes bridge validation**
When a component retains matching legacy storage access while also using `chatPreferences()`, `verifyDesktopBridgeArtifacts` matches the legacy pattern and continues before checking the fallback pattern, so it never queues the migration requirement; validation passes with a broken migration and consolidated preferences can miss the bridge-seeded WebSocket default.
Check for consolidated preference usage and queue its migration requirement even when the legacy pattern also matches.
</issue_to_address>
### Comment 4
<location path="scripts/prepare-resources/desktop-bridge-expectations.mjs" line_range="58-61" />
<code_context>
+ ),
+ chatTransportPreferenceWrite:
+ /chatPreferences\(\s*\(\s*(\w+)\s*\)\s*=>\s*\{\s*\1\.global\.transportMode\s*=/,
+ chatTransportPreferenceMigration: new RegExp(
+ String.raw`["']${CHAT_TRANSPORT_STORAGE_KEY_PATTERN}["']\s*:\s*["']transportMode["']` +
+ String.raw`[\s\S]*?target\.getItem\(key\)[\s\S]*?preferences\.global\[field\]\s*\?\?=\s*value` +
+ String.raw`[\s\S]*?target\.setItem\(CHAT_PREFERENCES_KEY,`,
+ ),
+};
</code_context>
<issue_to_address>
**Unrelated helper snippets satisfy migration check**
When the expected mapping, assignment, and persistence expressions appear in separate or inactive code, the migration regex scans the whole helper source without verifying that these operations belong to the same reachable migration path, so the verifier accepts a broken helper and desktop builds can ship without persisting the seeded WebSocket preference.
Verify that the mapping, assignment, and persistence operations occur together on the reachable migration path.
</issue_to_address>Sourcery assessment
Approval pending. 4 findings to address first.
Blocking findings: scripts/prepare-resources/desktop-bridge-expectations.mjs:71, scripts/prepare-resources/desktop-bridge-expectations.mjs:126, scripts/prepare-resources/desktop-bridge-checks.mjs:143, scripts/prepare-resources/desktop-bridge-expectations.mjs:61
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary / 改动概述
AstrBot Core moved chat transport preferences into
chatPreferences(). The desktop resource verifier still expected directlocalStoragereads and writes in the chat components, which stopped all six platform jobs during the November 20 nightly build for Corefeb3e82.chatPreferences(), require evidence that it imports and persists the legacy transport key that the desktop bridge seeds for the WebSocket default. Validate the shared helper once.Verification / 验证方式
pnpm run prepare:webuicompleted on Windows against the exact Core SHA from the failed nightly and producedresources/webui/index.html.v4.29.4andfeb3e82.807c5ebon this machine.Checklist / 检查清单
Summary by Sourcery
Update desktop bridge validation to support consolidated Dashboard chat preferences while preserving compatibility with the legacy transport storage key.
Bug Fixes:
Enhancements:
Build:
Tests: