-
Notifications
You must be signed in to change notification settings - Fork 0
feat(ui): make What's Next feed scrollable beyond 5 items #354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 bugs: When the section is collapsed (isOpen=false) and reopened, showAll retains its previous state. Similarly, if items shrink below 5 (e.g. SSE update removes items), showAll stays true but hasMore becomes false — the button correctly hides, and showAll=true with <=5 items is a no-op (slice returns all), so no actual bug. Just noting the state isn't reset. |
||
| 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(); | ||
|
|
@@ -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); | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 missing_tests: The new show-more/show-less toggle in the component has no component-level tests. The hook test verifies the cap was removed, but there's no test for the UI slicing logic (DEFAULT_VISIBLE_COUNT), the toggle state, or that the button text changes correctly. This is consistent with the existing lack of component tests for AttentionFeed, so it's not a regression — but worth noting for a feature that introduces interactive UI state. |
||
| const hasMore = items.length > DEFAULT_VISIBLE_COUNT; | ||
|
|
||
| return ( | ||
| <div className="attention-section"> | ||
| <button className="overview-header" onClick={toggleOpen}> | ||
|
|
@@ -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> | ||
|
|
||
There was a problem hiding this comment.
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),
showAllstays true buthasMorebecomes 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]