Skip to content

Conversation

@waterbang
Copy link
Collaborator

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 calling get_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

  • Blob 404 fix: Message attachments now use the event's original group_id for 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 roles
  • src/cccc/kernel/context.py - Cache raw YAML data
  • web/src/types.ts - Add group_id to LedgerEvent type
  • web/src/components/MessageBubble.tsx - Use event's group_id for blob URLs
  • web/src/services/api.ts - Add optional includeUnread parameter
  • web/src/stores/useGroupStore.ts - Deferred unread counts loading

Test Plan

  • TypeScript compilation passes
  • Vite build succeeds
  • Manual test: Group switching feels snappy
  • Manual test: Blob images load correctly across groups
  • Manual test: Unread counts appear after brief delay

The actor idle detection was only checking ledger events (messages sent),
which caused false positives when an agent was actively working in the
terminal but hadn't sent any messages.

Changes:
- Add _last_output_at tracking to PtySession
- Add idle_seconds() method to PtySession and PtySupervisor
- Update _check_actor_idle to use PTY idle time as primary signal
- Fall back to ledger activity for headless runners

This fixes the issue where foreman was reported as "idle for 4 hours"
while actively processing messages and executing commands.
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