Maestro icon indicating copy to clipboard operation
Maestro copied to clipboard

feat: Unified Inbox as Encore Feature with Focus Mode

Open felipeggv opened this issue 9 months ago • 13 comments

Summary

Refactors the Unified Inbox to follow the Encore Features pattern, as requested in PR #379 review.

  • Encore Feature gate: unifiedInbox flag in EncoreFeatureFlags — disabled by default, toggle in Settings > Encore tab
  • Unified Inbox modal: Aggregates unread notifications from all active sessions with keyboard-first navigation
  • Focus Mode: Inline reply, mark as read, toggle thinking mode — all without leaving the inbox
  • Integration points: Keyboard shortcut (Option+I), command palette action, hamburger menu entry
  • Polish: Director's Notes token alignment, auto-scroll fix, CodeRabbit feedback fixes, redundant star icon removal

Changes

17 commits, touching ~15 files with ~3500 lines added. All inbox functionality gated behind the unifiedInbox Encore feature flag.

Addresses feedback from @pedramamini in #379:

can you refactor unified inbox to fit the [Encore Features] pattern?

Test plan

  • [x] ESLint clean — zero errors
  • [x] Pre-existing CodexSessionStorage timeouts documented (not introduced by this PR)
  • [ ] Manual: Enable Unified Inbox in Settings > Encore
  • [ ] Manual: Press Option+I to open inbox, verify keyboard navigation
  • [ ] Manual: Test Focus Mode quick reply, mark as read, toggle thinking
  • [ ] Manual: Verify command palette and hamburger menu entries appear only when enabled

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Unified Inbox modal (List + Focus), lazy-loaded and gated by a new Encore feature flag (off by default). Opens via Alt+I, hamburger menu, Quick Actions, and programmatic modal controls; prioritized in modal stack.
  • UI/UX Improvements

    • Rich focus-mode detail UI with resizable sidebar, reply composer, proximity-aware auto-scroll, keyboard navigation, and visual alignment updates.
  • Bug Fixes

    • Group header keyboard accessibility, scoped collapse filtering, and selection sync after collapse.
  • Settings

    • Unified Inbox toggle added under Encore Features.

felipeggv avatar Feb 26 '26 18:02 felipeggv

[!NOTE]

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • [ ] ▶️ Resume reviews
  • [ ] 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a gated "Unified Inbox": feature flag and default, new AgentInbox UI (list + focus), a useAgentInbox hook, modal state/actions and priority, App & UI wiring (SessionList, QuickActions, Settings), keyboard shortcut, type defs, and playbook docs.

Changes

Cohort / File(s) Summary
Feature flags & core types
src/renderer/types/index.ts, src/renderer/types/agent-inbox.ts, src/renderer/stores/settingsStore.ts
Added unifiedInbox: boolean to EncoreFeatureFlags and DEFAULT_ENCORE_FEATURES; added agent-inbox types (InboxItem, sort/filter/view unions, status maps).
Agent Inbox UI components
src/renderer/components/AgentInbox/index.tsx, src/renderer/components/AgentInbox/InboxListView.tsx, src/renderer/components/AgentInbox/FocusModeView.tsx
New AgentInbox modal with list and focus views, virtualization (@tanstack/react-virtual), grouping/collapse, keyboard navigation, focus management, reply composer, and extensive UI/ARIA adjustments.
Data hook
src/renderer/hooks/useAgentInbox.ts
New hook to aggregate/filter/sort per-tab inbox items; exports helpers (truncate, generateSmartSummary) and exposes items for the UI.
Modal state & priorities
src/renderer/stores/modalStore.ts, src/renderer/constants/modalPriorities.ts
Added agentInbox modal id and AgentInboxModalData; new actions/selectors (setAgentInboxOpen, updateAgentInboxData, agentInboxOpen); added AGENT_INBOX: 555 priority.
App integration & handlers
src/renderer/App.tsx, src/renderer/hooks/keyboard/useMainKeyboardHandler.ts
Lazy-loads AgentInbox, surfaces agentInboxOpen/setAgentInboxOpen, adds navigation/quick-reply/mark-read/toggle-thinking handlers, and registers keyboard shortcut (Alt+I).
SessionList & prop threading
src/renderer/components/SessionList.tsx, src/renderer/hooks/props/useSessionListProps.ts
Threaded setAgentInboxOpen?: (open:boolean)=>void through hooks/components; added Inbox icon and hamburger menu entry to open the inbox.
Quick actions & modals wiring
src/renderer/components/QuickActionsModal.tsx, src/renderer/components/AppModals.tsx
Added onOpenUnifiedInbox prop and Quick Actions entry; AppModals props extended to pass handler through to QuickActionsModal.
Settings & shortcuts
src/renderer/components/SettingsModal.tsx, src/renderer/constants/shortcuts.ts
Added Unified Inbox toggle UI under Encore Features and registered agentInbox shortcut (Alt+I).
Hooking & selection fixes
src/renderer/components/AgentInbox/InboxListView.tsx, src/renderer/components/AgentInbox/FocusModeView.tsx
Bug fixes: keyboard-accessible group headers, collapse-scoped filtering, selection sync after collapse; proximity-based auto-scroll in FocusModeView.
Playbooks / docs & lint gates
playbooks/agent-inbox/.../ENCORE-INBOX-*.md
Added/updated playbooks documenting migration, lint/test gates, UI alignment, verification steps, and final gate checklist.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant UI as Session UI
    participant App as App.tsx
    participant ModalStore as Modal Store
    participant AgentInbox as AgentInbox
    participant InboxHook as useAgentInbox
    participant Sessions as Session Data

    User->>UI: Click "Unified Inbox" / press Alt+I
    UI->>App: call setAgentInboxOpen(true)
    App->>ModalStore: openModal('agentInbox')
    ModalStore->>App: agentInboxOpen = true
    App->>AgentInbox: lazy render modal (props)
    AgentInbox->>InboxHook: useAgentInbox(sessions, groups, filter, sort)
    InboxHook->>Sessions: read sessions & tabs
    InboxHook-->>AgentInbox: return InboxItem[]
    AgentInbox->>User: render list / focus UI

    User->>AgentInbox: navigate/reply/toggle
    AgentInbox->>App: onNavigateToSession/onQuickReply/onToggleThinking
    App->>Sessions: update session/tab state
    App-->>AgentInbox: updated state reflected via hook

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

  • RunMaestro/Maestro#440: touches AppModals.tsx and keyboard handler wiring; likely overlaps modal/shortcut integrations.
  • RunMaestro/Maestro#470: modifies App.tsx, SessionList.tsx, and useSessionListProps.ts; likely intersects with prop-threading and modal wiring.
  • RunMaestro/Maestro#460: overlaps on App.tsx and useSessionListProps changes where setAgentInboxOpen/modal state are introduced.
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 64.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: Unified Inbox as Encore Feature with Focus Mode' clearly summarizes the main changes: introducing a Unified Inbox feature with Focus Mode capabilities, gated behind the Encore feature flag.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

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

coderabbitai[bot] avatar Feb 26 '26 18:02 coderabbitai[bot]

Greptile Summary

Implements Unified Inbox as an Encore Feature following the established pattern from Director's Notes. The feature aggregates unread notifications and agent status across all active sessions into a single modal with keyboard-first navigation and inline reply capabilities.

Key changes:

  • Feature gating: unifiedInbox flag in EncoreFeatureFlags, disabled by default, configurable in Settings → Encore
  • Core components: Three-layer architecture with AgentInbox (shell), InboxListView (list mode), and FocusModeView (detail mode)
  • Data aggregation: useAgentInbox hook filters/sorts across all sessions and tabs with smart summary generation
  • Focus Mode: Inline reply with two strategies — Quick Reply (background send) and Open & Reply (navigate with prefilled input)
  • Integration points: Alt+I shortcut, command palette entry, hamburger menu item — all gated by feature flag
  • Previously reported issues: All handler props and inboxProcessInputRef assignment issues from previous review threads have been resolved

Code quality:

  • Follows existing patterns for Encore Features, modal layer stack, and keyboard shortcuts
  • Proper focus restoration, frozen snapshot logic for stable ordering in Focus Mode
  • Proximity-based auto-scroll only when near bottom
  • Virtual scrolling for performance with large item counts

TODO remaining: Cost badge placeholder at FocusModeView.tsx:861 — awaiting InboxItem.cost field

Confidence Score: 5/5

  • Safe to merge — well-structured refactor following established patterns with comprehensive feature gating
  • All previously reported integration issues have been fixed. The implementation follows the Encore Features pattern correctly, with proper feature flag checks at all entry points. Code is well-architected with clear separation of concerns, proper state management, and defensive coding (session existence checks, frozen snapshot fallbacks). Only a single TODO comment for a future enhancement.
  • No files require special attention — all integration points properly wired

Important Files Changed

Filename Overview
src/renderer/App.tsx Adds Unified Inbox handlers and integration - all previously reported issues with missing props and unassigned refs are now fixed
src/renderer/components/AgentInbox/index.tsx Core Unified Inbox component with view mode state management, frozen snapshot logic for Focus Mode, and proper modal layer integration
src/renderer/components/AgentInbox/FocusModeView.tsx Focus Mode detail view with resizable sidebar, proximity-based auto-scroll, reply composer, and proper keyboard event handling
src/renderer/components/AgentInbox/InboxListView.tsx Virtual scrolling list view with collapsible group headers, filter/sort controls, and keyboard navigation
src/renderer/hooks/useAgentInbox.ts Data aggregation hook that filters and sorts inbox items from all sessions/tabs with proper memoization
src/renderer/stores/modalStore.ts Adds agentInbox modal with persisted filter/sort/expand state and proper action creators
src/renderer/components/SettingsModal.tsx Adds Unified Inbox toggle to Encore Features section with Beta badge and description

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User triggers inbox<br/>Alt+I / Menu / Cmd+K] --> B{encoreFeatures.unifiedInbox?}
    B -->|false| C[Feature disabled]
    B -->|true| D[modalStore opens agentInbox]
    D --> E[AgentInbox modal renders]
    E --> F[useAgentInbox hook aggregates data]
    F --> G[Filter sessions/tabs by mode]
    G --> H[Sort by mode: newest/oldest/grouped/byAgent]
    H --> I{View Mode?}
    I -->|list| J[InboxListView<br/>Virtual scroll + keyboard nav]
    I -->|focus| K[FocusModeView<br/>Conversation + reply composer]
    J -->|F key / Enter| K
    K -->|Esc / Back| J
    K --> L{User action?}
    L -->|Quick Reply| M[handleAgentInboxQuickReply<br/>Temp switch session + processInput]
    L -->|Open & Reply| N[handleAgentInboxOpenAndReply<br/>Navigate + prefill input]
    L -->|Mark Read| O[handleAgentInboxMarkAsRead<br/>Clear hasUnread flag]
    L -->|Toggle Thinking| P[handleAgentInboxToggleThinking<br/>Cycle off→on→sticky]
    M --> Q[Close inbox, restore focus]
    N --> Q
    O --> Q
    P --> K

Last reviewed commit: d5ec10f

greptile-apps avatar Feb 26 '26 19:02 greptile-apps

All review feedback addressed: inboxProcessInputRef binding, handler prop wiring, tabId navigation, resize listener cleanup, byAgent group key collision (sessionId), listbox a11y, terminology (session->agent), MAX_MESSAGE_LENGTH alignment, read filter fix, Encore toggle a11y (role=switch), shortcut guard, sidebar keyboard a11y, context threshold label, header style override, playbook doc corrections. Requesting re-review. @coderabbitai review @greptile review

felipeggv avatar Feb 26 '26 22:02 felipeggv

@felipeggv Thank you for addressing all the review feedback! I can see you've made comprehensive fixes across accessibility, terminology, data handling, and UI polish. I'll trigger a fresh review of the PR now.

/ᐠ。ꞈ。ᐟ\

Ready to review!

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

coderabbitai[bot] avatar Feb 26 '26 22:02 coderabbitai[bot]

Addressed remaining review feedback on Unified Inbox: byAgent key collision fixed with stable sessionId grouping, quick-reply timing made deterministic (no nested rAF), truncate now preserves max length contract, list keyboard delegation guarded against double handling, modal store first-open data merge fixed, focus/listbox a11y and agent-facing copy aligned. Requesting re-review. @coderabbitai review @greptile review

felipeggv avatar Feb 27 '26 07:02 felipeggv

@felipeggv Thank you for the detailed follow-up! I can see you've addressed a comprehensive set of refinements across data integrity (sessionId grouping, modal store merge), timing/determinism (quick-reply rAF), API contracts (truncate max length), accessibility (focus/listbox, agent-facing copy), and keyboard handling (delegation guards). The thoroughness of these fixes is excellent. I'll trigger a fresh review now.

  /ᐠ。ꞈ。ᐟ\
 Re-reviewing!
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

coderabbitai[bot] avatar Feb 27 '26 07:02 coderabbitai[bot]

Follow-up push applied on top of the re-review request: keyboard delegate guard in AgentInbox list mode () and user-facing copy update (). Please re-run review on latest commit d5ec10f2. @coderabbitai review @greptile review

felipeggv avatar Feb 27 '26 07:02 felipeggv

Follow-up push applied on top of the re-review request: added keyboard delegate guard in AgentInbox list mode (check defaultPrevented and target===currentTarget) and updated user-facing copy to "Agent no longer available". Please review latest commit d5ec10f2. @coderabbitai review @greptile review

felipeggv avatar Feb 27 '26 07:02 felipeggv

@felipeggv Thank you for the follow-up fixes! I can see you've applied the keyboard delegate guard in AgentInbox list mode and the user-facing copy update on commit d5ec10f2. I'll trigger a fresh review of the latest changes now.

  /ᐠ。ꞈ。ᐟ\
 Reviewing!
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

coderabbitai[bot] avatar Feb 27 '26 07:02 coderabbitai[bot]

@felipeggv Thank you for the follow-up! I can see you've added the keyboard delegate guard (checking defaultPrevented and target===currentTarget) in AgentInbox list mode and updated the user-facing copy to "Agent no longer available". I'll trigger a review of the latest commit d5ec10f2 now.

  /ᐠ。ꞈ。ᐟ\
 Reviewing d5ec10f2!
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

coderabbitai[bot] avatar Feb 27 '26 07:02 coderabbitai[bot]

@felipeggv please run the following on your machine for this PR so it can move toward acceptance.

Here is the prompt you should run:

You are responsible for getting this PR in RunMaestro/Maestro to an accept-ready state.

PR: https://github.com/RunMaestro/Maestro/pull/468
Branch/Head: inspect the PR branch locally before making changes.

Goal:
Drive this PR to zero unresolved CodeRabbit and Greptile review threads.

Process:
1. Fetch the PR locally and work from a clean git worktree on the PR branch.
2. List all unresolved CodeRabbit and Greptile review threads for this PR.
3. For each unresolved bot thread:
   - verify whether the issue is still real on the current PR head
   - if it is already fixed or the thread is outdated, resolve the GitHub review thread immediately
   - if it is real, implement the smallest correct fix on the PR branch
4. After each fix batch:
   - run the relevant validation commands locally
   - push the branch
   - re-poll the PR’s unresolved CodeRabbit/Greptile threads
   - resolve any newly stale/fixed bot threads
5. Repeat until this PR has zero unresolved CodeRabbit and Greptile threads.

Rules:
- Resolve bot threads only when the current branch state actually fixes them.
- Do not resolve human review threads unless explicitly asked.
- Be surgical. Do not broaden scope beyond the review findings.
- If local validation differs from CI because of environment issues, state the exact failing test/check and the exact missing dependency/file/path.
- If a bot comment is a design tradeoff rather than a bug, explain why and leave it unresolved only if it truly still applies.

Definition of done:
- zero unresolved CodeRabbit threads
- zero unresolved Greptile threads
- branch pushed
- latest validation/check status re-polled
- concise summary written with:
  - PR URL
  - commits pushed
  - threads resolved
  - any remaining blockers

Keep looping until the PR is clean.

jeffscottward avatar Mar 14 '26 17:03 jeffscottward

Thanks for the great work on this, @felipeggv! The refactor to the Encore Features pattern looks solid and the Focus Mode polish is nice.

Unfortunately this branch has merge conflicts with main right now (mergeStateStatus: DIRTY). Could you kindly rebase against main and resolve the conflicts so we can get a clean merge? Once that's done and any outstanding CodeRabbit feedback is addressed, we'll do another pass and get this landed.

Thanks again! 🙏

pedramamini avatar Apr 24 '26 00:04 pedramamini

Hi @felipeggv — friendly ping on this one! 👋

Thanks again for all your work refactoring the Unified Inbox to the Encore Features pattern. The branch still has merge conflicts with main (mergeStateStatus: DIRTY), so we're blocked from another review pass until that's resolved.

When you have a moment, could you kindly rebase against main and resolve the conflicts? Once that's done we'll happily take another look and get this landed.

Thanks! 🙏

pedramamini avatar May 26 '26 16:05 pedramamini