Skip to content

refactor(web): optimize list lookup paths - #482

Open
Yevanchen wants to merge 1 commit into
mainfrom
refactor/web-list-lookups
Open

refactor(web): optimize list lookup paths#482
Yevanchen wants to merge 1 commit into
mainfrom
refactor/web-list-lookups

Conversation

@Yevanchen

Copy link
Copy Markdown
Collaborator

Summary

  • Optimized thread list actions by indexing allThreads once per list update instead of scanning on each pin/archive/delete action.
  • Normalized the Files search query once per view-model build instead of once per file.

Why

  • The complexity scan found several list-processing hotspots. These two web list paths are user-facing and safe to improve without changing behavior.

Verification

  • Commands:
    • python3 /Users/evanmore/multica_workspaces_desktop-api.multica.ai/baf2a510-889b-4b05-b7c8-c079f5c28938/c87b99f0/codex-home/skills/complexity-optimizer/scripts/analyze_complexity.py /Users/evanmore/multica_workspaces_desktop-api.multica.ai/baf2a510-889b-4b05-b7c8-c079f5c28938/c87b99f0/workdir/mosoo --format markdown
    • just test-file apps/web/tests/files-list-model.test.ts
    • just tc-package @mosoo/web
    • just test-package @mosoo/web
    • just fmt-check-path apps/web/src/routes/files/files-list-model.ts
    • just fmt-check-path apps/web/src/routes/threads/model/use-actions.ts
    • bun run --filter @mosoo/web lint
    • just commit-check
  • Manual steps: N/A
  • Not run: full just check

Impact

  • User/API/contract changes: no API or contract changes; UI behavior preserved.
  • Generated files / GraphQL / DB / lockfile: no generated files, GraphQL output, DB migrations, or lockfile changes.
  • Env or config changes: none.
  • Risk and rollback: low; rollback by reverting this commit.

Review

  • Closest review areas: Files list filtering; Threads pin/archive/delete actions.
  • Known trade-offs: The thread ID map costs one O(n) rebuild when allThreads changes, then gives O(1) action lookup.

@Yevanchen

Yevanchen commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator Author

Review verdict: the Thread-index portion duplicates #462 and has no measured user impact. The API caps the view at 100 active plus 100 archived Threads; a local Bun check measured worst-case find at about 0.72 microseconds versus about 8.12 microseconds to build the Map and perform one lookup. Please do not merge both PRs. Split or drop the Thread change and keep the Files normalization only if a real profile shows it matters.

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