refactor(settings): consolidate per-page skeletons and extract page helpers - #655
Merged
Merged
Conversation
…letonStack permission-center, health-center, and about each hand-wrote a near-identical maka-skeleton-stack with aria-busy/aria-label. Extract SettingsSkeletonStack (label + optional lines, snapshot preset default) and route the three pages through it. SettingsSkeleton (settings-surface shell) is untouched. The about-page loading contract asserted the literal aria-label source text; synced it to the new label= prop form (same intent: skeleton carries the accessible label while loading).
…odule The 11 React-free label/format/filter helpers (memoryOriginLabel, memoryStatusLabel, memoryStatusTone, filterLocalMemoryEntries, the backup summarizers, etc.) lived at the tail of memory-settings-page.tsx. Move them to memory-settings-labels.ts and import them back. memory-settings-labels.ts is registered in SETTINGS_SOURCE_REPO_PATHS right after memory-settings-page.tsx so the contract source mirror still contains the same code and the MemoryEntryList .. filterLocalMemoryEntries block boundary still resolves (now across the two files).
BotWeChatFields, WeChatScanLoginModal, and WechatQrLoginModal (the self-contained WeChat scan/QR login flow, ~370 lines) lived inside bot-chat-settings-page.tsx. Move them to bot-wechat-login.tsx and import them back, dropping the now-unused X / DialogRoot / DialogContent / WechatBridgeQrCodeResult imports from the host page. bot-wechat-login.tsx is registered in SETTINGS_SOURCE_REPO_PATHS right after bot-chat-settings-page.tsx so the contract source mirror still contains the WeChat modal code.
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
Three small, behavior-preserving refactors consolidating duplicated and inlined code in the settings surface. No user-visible change; rendered DOM is equivalent.
permission-center,health-center, andabouteach hand-wrote a near-identicalmaka-skeleton-stackwitharia-busy/aria-label. ExtractedSettingsSkeletonStack(label+ optionallines, snapshot preset as default) and routed the three pages through it.SettingsSkeleton(the settings-surface shell) is untouched.memory-settings-page.tsx(~115 lines) moved tomemory-settings-labels.tsand imported back.BotWeChatFields,WeChatScanLoginModal, andWechatQrLoginModal(~370 lines of self-contained scan/QR login) moved frombot-chat-settings-page.tsxtobot-wechat-login.tsx; dropped the now-unusedX/DialogRoot/DialogContent/WechatBridgeQrCodeResultimports from the host page.Why
The three largest settings pages each carried a chunk of code that was either duplicated across pages or self-contained enough to live on its own. This trims
bot-chat-settings-page.tsx(1323 → 937) andmemory-settings-page.tsx(1213 → 1096) and removes the per-page skeleton copy-paste.app-shell.tsx(1687) andchat-view.tsx(1744) were intentionally left alone — both already have extensive sibling modules and are large because they are coordination hubs, not because they are under-factored.Scope
Changed:
settings-skeleton.tsx— addedSettingsSkeletonStackpermission-center-page.tsx,health-center-page.tsx,about-settings-page.tsx— route throughSettingsSkeletonStackmemory-settings-labels.ts(new) +memory-settings-page.tsxbot-wechat-login.tsx(new) +bot-chat-settings-page.tsxsettings-contract-source-helpers.ts— registered the two new files inSETTINGS_SOURCE_REPO_PATHSsettings-app-info-contract.test.ts— synced one assertion literalNot included:
app-shell.tsx,chat-view.tsx,ProvidersPanelloading state (different pattern, not amaka-skeleton-stack).Verification
npm run build:main(tsc typecheck) — passnpm run build:renderer(vite) — passnode --test "dist/main/**/*.test.js"— 2262 pass, 0 failnpm run test:checks(console / a11y / copy) — passUser-facing impact
None. Pure refactor.
Reviewer notes
SETTINGS_SOURCE_REPO_PATHSright after their host pages, so the concatenated mirror contains the same code and theblockBetweenboundaries still resolve — some now span two files (e.g.MemoryEntryList … filterLocalMemoryEntries), which the non-greedy match handles fine.settings-app-info-contractmatched the literalaria-label="正在加载关于页"source; synced tolabel="正在加载关于页"to follow the new component prop. Same intent: the skeleton carries that accessible label while loading.data-sizevalues render to the same markup.Checklist