Skip to content

refactor(web): consolidate localStorage access and split appearance/notification modules - #973

Merged
wbxl2000 merged 1 commit into
mainfrom
refactor/web-storage-appearance-notification
Jun 22, 2026
Merged

refactor(web): consolidate localStorage access and split appearance/notification modules#973
wbxl2000 merged 1 commit into
mainfrom
refactor/web-storage-appearance-notification

Conversation

@wbxl2000

Copy link
Copy Markdown
Collaborator

Related Issue

N/A — internal refactor with no user-facing behavior change.

Problem

  • apps/kimi-web/src/composables/useKimiWebClient.ts had grown to ~4500 lines, acting as a god composable that mixed global state, API wrapping, localStorage persistence, theme/notification management, and more.
  • localStorage reads/writes were scattered across 8+ files, each with duplicated try/catch and ad-hoc key constants.
  • There was no centralized storage helper, making future refactors error-prone.

What changed

  • Added apps/kimi-web/src/lib/storage.ts with safe get/set/remove/JSON helpers and centralized key constants. Existing key names are preserved unchanged (including the legacy kimi-active-workspace naming).
  • Migrated all localStorage usage in useKimiWebClient.ts, App.vue, Composer.vue, ConversationPane.vue, OpenInMenu.vue, useResizable.ts, i18n/index.ts, api/config.ts, and debug/trace.ts to use storage.ts.
  • Added apps/kimi-web/test/storage-logic.test.ts with 13 pure-logic test cases (no jsdom).
  • Extracted composables/client/useAppearance.ts and composables/client/useNotification.ts from useKimiWebClient.ts.
  • Reshaped maybeNotifyCompletion so useNotification does not read rawState; useWorkspaceState will pass in pre-computed context (isActiveAndVisible, sessionTitle, onClick) in future PRs.
  • Kept useKimiWebClient() as a facade: its return shape, fields, and type exports (Theme, ColorScheme, Accent) are unchanged; no component or call site was modified.

Verification

  • pnpm --filter @moonshot-ai/kimi-web typecheck
  • pnpm --filter @moonshot-ai/kimi-web test ✅ (22 tests passed)
  • pnpm --filter @moonshot-ai/kimi-web build
  • useKimiWebClient.ts: 4529 → 4233 lines.

Checklist

  • I have read the CONTRIBUTING document.
  • I have explained the problem above (no related issue for this internal refactor).
  • I have added tests that prove the storage helpers work.
  • Ran gen-changesets skill.
  • This PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 38861e0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jun 22, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@38861e0
npx https://pkg.pr.new/@moonshot-ai/kimi-code@38861e0

commit: 38861e0

@wbxl2000
wbxl2000 merged commit 3b9938b into main Jun 22, 2026
9 checks passed
@wbxl2000
wbxl2000 deleted the refactor/web-storage-appearance-notification branch June 22, 2026 09:21
@github-actions github-actions Bot mentioned this pull request Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant