Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion frontend/src/components/AttentionFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,25 @@ function AttentionCard({

// ─── Main component ────────────────────────────────────────────────────────

const DEFAULT_VISIBLE_COUNT = 5;

export function AttentionFeed() {
const { items, tier1Count, loading } = useAttentionFeed();
const navigate = useNavigate();

const hasUrgent = tier1Count > 0;
const [manualOpen, setManualOpen] = useState<boolean | null>(null);
const [showAll, setShowAll] = useState(false);
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 bugs: If the user clicks 'Show all' and items subsequently shrink below DEFAULT_VISIBLE_COUNT (e.g., a todo is completed), showAll stays true but hasMore becomes false, hiding the button. The user can never click 'Show less' — they're stuck with showAll=true, though it's functionally harmless since slice(0, 5) on fewer items returns all of them anyway. Not a real bug, but the state is stale. [fixable]

const isOpen = manualOpen ?? true; // always open by default

const toggleOpen = useCallback(() => {
setManualOpen((prev) => !(prev ?? true));
}, []);

const toggleShowAll = useCallback(() => {
setShowAll((prev) => !prev);
}, []);

const handleTap = useCallback(
(item: AttentionItem) => {
selectionChanged();
Expand All @@ -69,6 +76,9 @@ export function AttentionFeed() {
const t2Count = items.filter((i) => i.tier === 2).length;
if (t2Count > 0) summaryParts.push(`${t2Count} in focus`);

const visibleItems = showAll ? items : items.slice(0, DEFAULT_VISIBLE_COUNT);
const hasMore = items.length > DEFAULT_VISIBLE_COUNT;

return (
<div className="attention-section">
<button className="overview-header" onClick={toggleOpen}>
Expand All @@ -86,9 +96,14 @@ export function AttentionFeed() {
{!loading && items.length === 0 && (
<div className="attention-empty">Nothing needs your attention right now.</div>
)}
{items.map((item) => (
{visibleItems.map((item) => (
<AttentionCard key={item.id} item={item} onTap={handleTap} />
))}
{!loading && hasMore && (
<button className="attention-show-more" onClick={toggleShowAll}>
{showAll ? 'Show less' : `Show all ${items.length}`}
</button>
)}
</div>
)}
</div>
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/hooks/__tests__/useAttentionFeed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ describe('useAttentionFeed', () => {
expect(result.current.items[1].tier).toBe(2);
});

it('caps output at 5 items', async () => {
it('returns all items without capping', async () => {
const items = Array.from({ length: 10 }, (_, i) =>
makeTodo({ id: `t${i}`, summary: `Item ${i}`, starred: true, urgency: 0.9 }),
);
Expand All @@ -190,7 +190,8 @@ describe('useAttentionFeed', () => {
expect(result.current.loading).toBe(false);
});

expect(result.current.items).toHaveLength(5);
expect(result.current.items).toHaveLength(10);
expect(result.current.tier1Count).toBe(10);
});

it('subscribes to SSE events for live updates', () => {
Expand Down
5 changes: 1 addition & 4 deletions frontend/src/hooks/useAttentionFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,6 @@

// ─── Hook ──────────────────────────────────────────────────────────────────

const MAX_ITEMS = 5;

export interface UseAttentionFeedReturn {
items: AttentionItem[];
tier1Count: number;
Expand Down Expand Up @@ -253,7 +251,7 @@
}, []);

// ATB tasks from store
const tasks = useMitzoStore((s) => s.tasks.tree);

Check failure on line 254 in frontend/src/hooks/useAttentionFeed.ts

View workflow job for this annotation

GitHub Actions / ci

frontend/src/pages/__tests__/SessionList.test.tsx > SessionList hash and tokens > renders token count when totalTokens is present

Error: useMitzoStore must be used within a <MitzoStoreProvider> ❯ useAttentionFeed frontend/src/hooks/useAttentionFeed.ts:254:17 ❯ AttentionFeed frontend/src/components/AttentionFeed.tsx:49:42 ❯ Object.react_stack_bottom_frame node_modules/react-dom/cjs/react-dom-client.development.js:25904:20 ❯ renderWithHooks node_modules/react-dom/cjs/react-dom-client.development.js:7662:22 ❯ updateFunctionComponent node_modules/react-dom/cjs/react-dom-client.development.js:10166:19 ❯ beginWork node_modules/react-dom/cjs/react-dom-client.development.js:11778:18 ❯ runWithFiberInDEV node_modules/react-dom/cjs/react-dom-client.development.js:874:13 ❯ performUnitOfWork node_modules/react-dom/cjs/react-dom-client.development.js:17641:22 ❯ workLoopSync node_modules/react-dom/cjs/react-dom-client.development.js:17469:41

Check failure on line 254 in frontend/src/hooks/useAttentionFeed.ts

View workflow job for this annotation

GitHub Actions / ci

frontend/src/pages/__tests__/SessionList.test.tsx > SessionList hash and tokens > renders session hash (last 6 chars) in session item

Error: useMitzoStore must be used within a <MitzoStoreProvider> ❯ useAttentionFeed frontend/src/hooks/useAttentionFeed.ts:254:17 ❯ AttentionFeed frontend/src/components/AttentionFeed.tsx:49:42 ❯ Object.react_stack_bottom_frame node_modules/react-dom/cjs/react-dom-client.development.js:25904:20 ❯ renderWithHooks node_modules/react-dom/cjs/react-dom-client.development.js:7662:22 ❯ updateFunctionComponent node_modules/react-dom/cjs/react-dom-client.development.js:10166:19 ❯ beginWork node_modules/react-dom/cjs/react-dom-client.development.js:11778:18 ❯ runWithFiberInDEV node_modules/react-dom/cjs/react-dom-client.development.js:874:13 ❯ performUnitOfWork node_modules/react-dom/cjs/react-dom-client.development.js:17641:22 ❯ workLoopSync node_modules/react-dom/cjs/react-dom-client.development.js:17469:41

Check failure on line 254 in frontend/src/hooks/useAttentionFeed.ts

View workflow job for this annotation

GitHub Actions / ci

frontend/src/pages/__tests__/SessionList.test.tsx > SessionList status dot > does not render dot for inactive session

Error: useMitzoStore must be used within a <MitzoStoreProvider> ❯ useAttentionFeed frontend/src/hooks/useAttentionFeed.ts:254:17 ❯ AttentionFeed frontend/src/components/AttentionFeed.tsx:49:42 ❯ Object.react_stack_bottom_frame node_modules/react-dom/cjs/react-dom-client.development.js:25904:20 ❯ renderWithHooks node_modules/react-dom/cjs/react-dom-client.development.js:7662:22 ❯ updateFunctionComponent node_modules/react-dom/cjs/react-dom-client.development.js:10166:19 ❯ beginWork node_modules/react-dom/cjs/react-dom-client.development.js:11778:18 ❯ runWithFiberInDEV node_modules/react-dom/cjs/react-dom-client.development.js:874:13 ❯ performUnitOfWork node_modules/react-dom/cjs/react-dom-client.development.js:17641:22 ❯ workLoopSync node_modules/react-dom/cjs/react-dom-client.development.js:17469:41

Check failure on line 254 in frontend/src/hooks/useAttentionFeed.ts

View workflow job for this annotation

GitHub Actions / ci

frontend/src/pages/__tests__/SessionList.test.tsx > SessionList status dot > renders orange dot for active+detached session

Error: useMitzoStore must be used within a <MitzoStoreProvider> ❯ useAttentionFeed frontend/src/hooks/useAttentionFeed.ts:254:17 ❯ AttentionFeed frontend/src/components/AttentionFeed.tsx:49:42 ❯ Object.react_stack_bottom_frame node_modules/react-dom/cjs/react-dom-client.development.js:25904:20 ❯ renderWithHooks node_modules/react-dom/cjs/react-dom-client.development.js:7662:22 ❯ updateFunctionComponent node_modules/react-dom/cjs/react-dom-client.development.js:10166:19 ❯ beginWork node_modules/react-dom/cjs/react-dom-client.development.js:11778:18 ❯ runWithFiberInDEV node_modules/react-dom/cjs/react-dom-client.development.js:874:13 ❯ performUnitOfWork node_modules/react-dom/cjs/react-dom-client.development.js:17641:22 ❯ workLoopSync node_modules/react-dom/cjs/react-dom-client.development.js:17469:41

Check failure on line 254 in frontend/src/hooks/useAttentionFeed.ts

View workflow job for this annotation

GitHub Actions / ci

frontend/src/pages/__tests__/SessionList.test.tsx > SessionList status dot > renders green dot for active+attached session

Error: useMitzoStore must be used within a <MitzoStoreProvider> ❯ useAttentionFeed frontend/src/hooks/useAttentionFeed.ts:254:17 ❯ AttentionFeed frontend/src/components/AttentionFeed.tsx:49:42 ❯ Object.react_stack_bottom_frame node_modules/react-dom/cjs/react-dom-client.development.js:25904:20 ❯ renderWithHooks node_modules/react-dom/cjs/react-dom-client.development.js:7662:22 ❯ updateFunctionComponent node_modules/react-dom/cjs/react-dom-client.development.js:10166:19 ❯ beginWork node_modules/react-dom/cjs/react-dom-client.development.js:11778:18 ❯ runWithFiberInDEV node_modules/react-dom/cjs/react-dom-client.development.js:874:13 ❯ performUnitOfWork node_modules/react-dom/cjs/react-dom-client.development.js:17641:22 ❯ workLoopSync node_modules/react-dom/cjs/react-dom-client.development.js:17469:41
const loadTasks = useMitzoStore((s) => s.loadTasks);

useEffect(() => {
Expand Down Expand Up @@ -286,8 +284,7 @@
const telosItems = telosToAttention(todos);
const atbItems = atbToAttention(tasks);
const sessionItems = sessionsToAttention(activities);
const all = sortAttention([...telosItems, ...atbItems, ...sessionItems]);
return all.slice(0, MAX_ITEMS);
return sortAttention([...telosItems, ...atbItems, ...sessionItems]);
}, [todos, tasks, activities]);

const tier1Count = useMemo(() => feed.filter((i) => i.tier === 1).length, [feed]);
Expand Down
20 changes: 20 additions & 0 deletions frontend/src/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,26 @@ textarea:focus {
text-align: center;
}

.attention-show-more {
width: 100%;
padding: var(--space-2) var(--space-4);
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius-md);
font-size: var(--text-xs);
color: var(--primary);
font-family: inherit;
font-weight: 600;
cursor: pointer;
text-align: center;
-webkit-tap-highlight-color: transparent;
transition: background 0.15s;
}

.attention-show-more:active {
background: var(--hover);
}

.service-status {
display: flex;
gap: var(--space-4);
Expand Down
Loading