#1

WIP: wire real space file/chat counts

Opencalledforthwants to merge intofrom

Summary

  • Replace mocked homepage space counts with real backend-derived values.
  • Extend spaces:list to include fileCount (filesystem count) and chatCount (thread DB count).
  • Keep this PR scoped to count plumbing only (no custom delete toast work).

Test plan

  • Run npm run build
  • Verify space card counts match actual files/chats
  • Create/remove files and threads, then refresh spaces to confirm counts update

NOTE

Low Risk Read-only count plumbing for the spaces list; no auth or destructive behavior, though listing spaces may be slower on large vaults due to per-space filesystem walks.

Overview Space cards on the homepage now show real file and chat totals instead of slug/title-based mock values.

Backend: VaultService.listSpaces() adds fileCount by recursively counting files under each space (dotfiles skipped). The spaces:list IPC handler takes ChatDb, merges vault results, and sets chatCount from listThreads(space.slug).length. SpaceListItem gains optional fileCount and chatCount.

UI: SpacesPage reads those fields with ?? 0 for the card badges.

Reviewed by Cursor Bugbot for commit c95a1cae098eb8bdf4bf44e7c3134a435bb932ca. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • New Features
    • Space listings now display the actual number of files and chats in each space.
    • File counts include visible files within nested folders.
    • Chat counts reflect the threads associated with each space.
  • Bug Fixes
    • Replaced placeholder file and chat totals with accurate, up-to-date counts.
    • Spaces without available count data now display zero instead of misleading values.

Activity

4
coderabbitai[bot]3mo ago

📝 Walkthrough

Walkthrough

Space listings now include computed file and chat counts from the vault and chat database, and SpaceCard renders those values instead of mock counts.

Changes

Space count enrichment

Layer / File(s)Summary
Space metadata and file counting
src/types.ts, electron/vault/service.ts
SpaceListItem supports optional file and chat counts, while VaultService recursively counts non-hidden files for each space.
IPC chat count integration
electron/ipc/registerSpacesIpc.ts, electron/main.ts
The spaces IPC registration receives ChatDb and adds each space’s thread count to spaces:list responses.
Space count rendering
src/pages/SpacesPage.tsx
SpaceCard displays the returned counts and defaults missing values to zero.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SpacesPage
  participant SpacesIPC
  participant VaultService
  participant ChatDb
  SpacesPage->>SpacesIPC: request spaces:list
  SpacesIPC->>VaultService: listSpaces()
  VaultService-->>SpacesIPC: spaces with fileCount
  SpacesIPC->>ChatDb: listThreads(space.slug)
  ChatDb-->>SpacesIPC: threads
  SpacesIPC-->>SpacesPage: spaces with fileCount and chatCount
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title clearly matches the main change: replacing mocked space counts with real file and chat counts.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/cb4233e5

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

cursor[bot]reviewed3mo ago
cursor[bot]3mo ago

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c95a1cae098eb8bdf4bf44e7c3134a435bb932ca. Configure here.

coderabbitai[bot]reviewed3mo ago
coderabbitai[bot]3mo ago

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@electron/ipc/registerSpacesIpc.ts`:
- Around line 10-17: Update registerSpacesIpc to use a new
ChatDb.countThreads(spaceSlug: string): number method instead of
listThreads(...).length. Implement countThreads with a SELECT COUNT(*) query
filtered by space_slug, returning the numeric count while avoiding full thread
record retrieval.

In `@electron/vault/service.ts`:
- Around line 109-126: Update countFilesInSpace’s recursive countIn helper to
catch fs.readdir failures, including ENOENT from concurrently deleted
directories, and return 0 for that directory so spaces:list continues. Also
process recursive directory counts concurrently with Promise.all while
preserving the existing hidden-entry and file-counting behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 538ea035-a7da-4525-a996-d25154416d06

📥 Commits

Reviewing files that changed from the base of the PR and between b1ebb08c44f3995253e4dbaa918f57b454a2f364 and c95a1cae098eb8bdf4bf44e7c3134a435bb932ca.

📒 Files selected for processing (5)
  • electron/ipc/registerSpacesIpc.ts
  • electron/main.ts
  • electron/vault/service.ts
  • src/pages/SpacesPage.tsx
  • src/types.ts