Skip to content

Refactor/web app domain architecture - #12299

Open
Yny4ii wants to merge 8 commits into
BasedHardware:mainfrom
Yny4ii:refactor/web-app-domain-architecture
Open

Refactor/web app domain architecture#12299
Yny4ii wants to merge 8 commits into
BasedHardware:mainfrom
Yny4ii:refactor/web-app-domain-architecture

Conversation

@Yny4ii

@Yny4ii Yny4ii commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

What changed and why

Web app product code now lives in src/features/<domain>/{api,model,ui} plus src/shared, instead of a flat components/ + lib/api.ts. Writable lists and chat session state use moonshine signal stores (peek() rollback, session ownership). After the folder move, Tailwind only scanned src/app and src/components, so feature class names vanished from styles.csstailwind.config.ts content is now src/**.

Product invariants affected

INV-MEM-1 (path glob web/app/src/features/memories/**). Tier vocabulary and default access policy are unchanged; memories CRUD, IndexedDB hydrate, and chunked bulk delete keep the same behavior.

How it was verified

  • cd web/app && bun run typecheck — clean.
  • cd web/app && bun run test — 7 bun smoke/import-guard tests + 359 vitest tests, all pass.
  • bun scripts/check-feature-imports.tsok: 323 files.
  • Did not walk settings / conversations / tasks / memories / home in a browser. Compiling and the suite passing is not a substitute for that. Layout after the Tailwind glob fix was the original failure mode; confirm destinations visually before merge.

Tests

  • Domain colocate: existing UI tests retargeted at features/; scripts/check-feature-imports.test.ts for the import guard.
  • Tailwind miss: scripts/moonshine-smoke.test.ts asserts tailwind.config.ts includes src/** (reads the file as text so tsc does not load the config).
  • Signal stores: useActionItems, usePeople, useConversations, useRecaps, useConversation, useSearchConversations, useMemories, useKnowledgeGraph, plus existing useChat / useGeminiLive / useGoalDetail ownership tests.
  • Recap month grouping: conversationTimeline.test.ts.
  • Notification routes: notifications/__tests__/notificationRoute.test.ts (/recaps/conversations?recap=).

Failure class (fixes)

Failure-Class: none

New guards (only when adding a check or ratchet)

web/app/scripts/check-feature-imports.ts (in bun run check) would have caught a post-colocate import of @/features/foo/ui/DeepFile from outside that feature, or shared importing features. It is not a repo-wide primitive: it encodes this app’s @/features / src/shared layout.

Scoped cleanups (optional)

  • chore(web-app): remove unused components and leftover UI packages — dead UI and npm deps, same PR, its own commit.

Review in cubic

Yny4ii and others added 8 commits August 27, 2026 16:15
Nothing in the live route tree imported these screens, barrels, or shadcn wrappers, so drop them with the radix/window deps that only they used.

Co-authored-by: Cursor <cursoragent@cursor.com>
Move destinations into src/features/<domain>/{api,model,ui}, split HTTP off lib/api.ts onto a shared fetch client, and guard public-index imports so callers cannot reach deep UI files.

INV-MEM-1: memories path globs follow the new feature folder; tier behavior is unchanged.
Co-authored-by: Cursor <cursoragent@cursor.com>
After the colocate, utilities used only under src/features were omitted from styles.css, so layout classes never reached the page.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ores

React state cannot roll back an optimistic write: peek() can. Lists, chat,
search, notifications, and live session UI now follow createGoalsStore so
failed mutations restore the committed value and a switched id cannot land
the previous request.

Co-authored-by: Cursor <cursoragent@cursor.com>
Layout already imports features, so it cannot live in shared. Toast, dialogs,
and the other primitives do not, and putting them under shared matches the
import guard: shared must not reach into features.

Co-authored-by: Cursor <cursoragent@cursor.com>
Home's pill and the overlay panel both upload drafts the same way. One hook
owns MAX_FILES, previews, and rollback so those paths cannot fork, without
forcing the two composers into one visual control.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep incoming chat, home, tasks, and meeting-screenshot behavior after those files moved into src/features. Do not restore the deleted lib/api.ts barrel.

Co-authored-by: Cursor <cursoragent@cursor.com>
The merge kept the old @/components/tasks import after BulkActionBar moved.

Co-authored-by: Cursor <cursoragent@cursor.com>

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Yny4ii — this is a careful piece of work. The move is verifiably faithful: the 2,685-line lib/api.ts is split into per-domain features/*/api.ts over a shared src/shared/api/client.ts kernel with the auth/token handling intact, the 37 deleted files (MobileBlockOverlay, OmiOrb wrapper, PlansSheet, FilterSheet, AppSelector, unused shadcn primitives, …) have no remaining importers on main, and the dependency diff is removal-only (unused radix packages, class-variance-authority, the react-window family). The new scripts/check-feature-imports.ts boundary guard is real, tested, and correctly wired into bun run check and the web-app-checks triggers in .github/checks-manifest.yaml, and the Tailwind content: src/** fix in tailwind.config.ts addresses exactly the failure mode you called out (with a smoke test that reads the config as text). The verification section's honesty about not walking the UI in a browser is appreciated — please do keep that visual pass before merge.

One blocking item:

  1. Hygiene is red because web/app/AGENTS.md now exceeds the agents-md-lean budget: 64 lines / 2,866 bytes vs 55 / 2,400. The ratchet requires detail to move one level down rather than growing the file, and you already built the right home: web/app/ARCHITECTURE.md. Please move the layout/import-rules detail and the 13-domain enumeration out of AGENTS.md into ARCHITECTURE.md (keep AGENTS.md to a short pointer + the setup/testing essentials) so the file lands back under budget.

Two smaller asks:

  1. Please drop the two unrelated backend edits — the reformat in backend/utils/subscription.py (a BYOK security-sensitive module) and the blank-line removal in backend/tests/unit/test_byok_security.py. They are behavior-neutral (verified formatting-only), but they add review surface to a security-sensitive area in a web-app PR.
  2. web/app/src/features/fair-use/api.ts carries ~9 unused imports from the api.ts split (getIdToken, getWebDeviceIdHash, the @/lib/cache helpers, fetchAuthorizedBlob, getAudioAuthHeaders); worth trimming while you're in there.

For clarity on the other red checks: the Backend unit suite failure is pyright reportUnusedImport in backend/utils/stt/streaming.py (not touched here, and already fixed on main), and the Desktop Swift failure is GlassPanelHitRegionTests legacy-sidebar assertions, also outside this PR's surface — a rebase onto current main should clear both. Hygiene is the only failure this PR owns.

Beyond the mechanical fix: the features/ + import-guard contract and the rewritten AGENTS.md/ARCHITECTURE.md guidance will steer every future change in web/app — human and AI-authored alike — so I'd like a maintainer to sign off on the convention itself (and the AGENTS.md/ARCHITECTURE.md content split) before this merges. Leaving for human maintainer review on that architecture decision.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added needs-maintainer-review Needs a human maintainer to sign off before merge web labels Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-maintainer-review Needs a human maintainer to sign off before merge web

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants