Skip to content

refactor(web): consolidate storage and split root state and app shell into composables - #979

Merged
wbxl2000 merged 9 commits into
mainfrom
refactor/web-task-poller
Jun 22, 2026
Merged

refactor(web): consolidate storage and split root state and app shell into composables#979
wbxl2000 merged 9 commits into
mainfrom
refactor/web-task-poller

Conversation

@wbxl2000

Copy link
Copy Markdown
Collaborator

Related Issue

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

Problem

apps/kimi-web had two large hotspots that made changes risky:

  • useKimiWebClient.ts (~4.5k lines) acted as the global store, API wrapper, storage layer, theme/notification manager, task poller and side-chat host all at once.
  • App.vue (~1.5k lines) held the detail panel, file preview, sidebar layout, page title and auth gate directly.
  • localStorage access was inlined across ~8 files with duplicated try/catch and no single key registry.
  • Hot state fields (sessions, activeSessionId, messagesBySession) were mutated from many places, so "where does this field change?" had no single answer.

What changed

Pure structure refactor — no runtime behavior change; the public useKimiWebClient facade and component templates are unchanged.

  • Add a safe storage helper and route all localStorage access through it with centralized key constants.
  • Split useKimiWebClient into focused client composables (appearance, notification, task polling, model/provider, side chat, workspace) behind the existing facade (useKimiWebClient.ts 4529 → 2057 lines).
  • Extract App.vue page-title, auth gate, sidebar layout, detail panel and file-preview logic into composables (App.vue 1563 → 1166 lines; template and style blocks byte-for-byte unchanged).
  • Funnel sessions, activeSessionId and messagesBySession mutations through named setters owned by the facade, so each hot field has one mutation entry point.

Verified with typecheck, test (22), build and oxlint (0 errors) at every step.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works. (Added storage-logic.test.ts for the new storage helper; otherwise pure refactor covered by existing tests.)
  • Ran gen-changesets skill, or this PR needs no changeset. (Patch on @moonshot-ai/kimi-code; @moonshot-ai/kimi-web is ignored and bundled into the CLI.)
  • Ran gen-docs skill, or this PR needs no doc update. (No user-facing behavior change.)

@changeset-bot

changeset-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ea4856d

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

# Conflicts:
#	apps/kimi-web/src/App.vue
#	apps/kimi-web/src/composables/useKimiWebClient.ts
@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@ea4856d
npx https://pkg.pr.new/@moonshot-ai/kimi-code@ea4856d

commit: ea4856d

@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: ea4856d1af

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@wbxl2000
wbxl2000 merged commit 8c6cade into main Jun 22, 2026
8 checks passed
@wbxl2000
wbxl2000 deleted the refactor/web-task-poller branch June 22, 2026 15:56
@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