perf: optimize group switching and fix blob 404 errors #41
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves group switching performance and fixes blob attachment loading issues.
Performance Optimizations
Deferred unread counts loading: Initial group load no longer waits for unread message counts. Actors are loaded immediately, and unread counts are fetched 300ms later in the background. This significantly improves perceived switching speed for groups with large ledgers (10k+ messages).
Pre-computed actor roles (A1):
batch_unread_counts()now pre-computes actor roles once instead of callingget_effective_role()repeatedly for each event, reducing O(n×m) role lookups.Cached context data (B1): Context and task YAML data is now cached after initial parsing, eliminating redundant file I/O when computing version hashes. For 50 tasks, this reduces file reads from 102 to 51.
Bug Fixes
group_idfor blob URLs instead of the currently viewed group. This fixes 404 errors when viewing messages that were sent from a different group.Files Changed
src/cccc/kernel/inbox.py- Pre-compute actor rolessrc/cccc/kernel/context.py- Cache raw YAML dataweb/src/types.ts- Addgroup_idto LedgerEvent typeweb/src/components/MessageBubble.tsx- Use event's group_id for blob URLsweb/src/services/api.ts- Add optionalincludeUnreadparameterweb/src/stores/useGroupStore.ts- Deferred unread counts loadingTest Plan