GeezerVison is showing github.com — feat(mobile): beta Working section hides busy threads until they need… · pingdotgg/t3code@8d84666
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/home/HomeScreen.tsx +37-2Lines changed: 37 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -44,13 +44,15 @@ import { | 44 | 44 | ThreadListV2SettledShelfHeader, | 45 | 45 | ThreadListV2ShowMoreRow, | 46 | 46 | ThreadListV2SnoozedShelfHeader, | | 47 | + ThreadListV2WorkingShelfHeader, | 47 | 48 | } from "../threads/thread-list-v2-items"; | 48 | 49 | import { useThreadRowProviderInstanceResolver } from "../threads/thread-provider-instance"; | 49 | 50 | import { | 50 | 51 | buildThreadListV2Items, | 51 | 52 | getThreadListV2OrderedSection, | 52 | 53 | buildThreadListV2ListItems, | 53 | 54 | threadListV2ListItemsAreEqual, | | 55 | + threadListInboxReturns, | 54 | 56 | THREAD_LIST_V2_SETTLED_INITIAL_COUNT, | 55 | 57 | THREAD_LIST_V2_SETTLED_PAGE_COUNT, | 56 | 58 | type ThreadListV2ListItem, | @@ -466,8 +468,11 @@ export function HomeScreen(props: HomeScreenProps) { | 466 | 468 | loaded: shelfPreferencesLoaded, | 467 | 469 | settledShelfExpanded, | 468 | 470 | snoozedShelfExpanded, | | 471 | + workingShelfEnabled, | | 472 | + workingShelfExpanded, | 469 | 473 | toggleSettledShelf, | 470 | 474 | toggleSnoozedShelf, | | 475 | + toggleWorkingShelf, | 471 | 476 | } = useThreadListV2ShelfPreferences(); | 472 | 477 | // The queued-start and snooze helpers need a clock while the list stays open. | 473 | 478 | const [nowMinute, setNowMinute] = useState(() => new Date().toISOString().slice(0, 16)); | @@ -520,8 +525,13 @@ export function HomeScreen(props: HomeScreenProps) { | 520 | 525 | queuedThreadKeys, | 521 | 526 | }), | 522 | 527 | }); | 523 | | - return new Map([...sectionAvailability("pinned"), ...sectionAvailability("active")]); | | 528 | + // The Working beta orders the inbox by time, so only pins can move. | | 529 | + return new Map([ | | 530 | + ...sectionAvailability("pinned"), | | 531 | + ...(workingShelfEnabled ? [] : sectionAvailability("active")), | | 532 | + ]); | 524 | 533 | }, [ | | 534 | + workingShelfEnabled, | 525 | 535 | pinReorderEnvironmentIds, | 526 | 536 | activeReorderEnvironmentIds, | 527 | 537 | props.threads, | @@ -533,6 +543,7 @@ export function HomeScreen(props: HomeScreenProps) { | 533 | 543 | snoozeWakeTick, | 534 | 544 | ]); | 535 | 545 | const threadListV2Layout = useMemo(() => { | | 546 | + threadListInboxReturns.observe(workingShelfEnabled ? props.threads : null); | 536 | 547 | // Settled threads are live shells; archived threads keep their original | 537 | 548 | // "hidden from lists" meaning. | 538 | 549 | return buildThreadListV2Items({ | @@ -547,11 +558,16 @@ export function HomeScreen(props: HomeScreenProps) { | 547 | 558 | queuedThreadKeys, | 548 | 559 | settledLimit: settledVisibleCount, | 549 | 560 | now: new Date().toISOString(), | | 561 | + workingShelfEnabled, | | 562 | + workingShelfExpanded, | | 563 | + inboxReturnAt: threadListInboxReturns.returnedAt, | 550 | 564 | snoozedShelfExpanded, | 551 | 565 | settledShelfExpanded, | 552 | 566 | selectedThreadKey: null, | 553 | 567 | }); | 554 | 568 | }, [ | | 569 | + workingShelfEnabled, | | 570 | + workingShelfExpanded, | 555 | 571 | pendingOrder, | 556 | 572 | queuedThreadKeys, | 557 | 573 | nowMinute, | @@ -606,6 +622,9 @@ export function HomeScreen(props: HomeScreenProps) { | 606 | 622 | buildThreadListV2ListItems({ | 607 | 623 | items: threadListV2Layout.items, | 608 | 624 | pendingTasks: v2PendingTasks, | | 625 | + workingCount: threadListV2Layout.workingCount, | | 626 | + workingShelfExpanded, | | 627 | + workingShelfHeaderIndex: threadListV2Layout.workingShelfHeaderIndex, | 609 | 628 | snoozedCount: threadListV2Layout.snoozedCount, | 610 | 629 | snoozedShelfExpanded, | 611 | 630 | snoozedShelfHeaderIndex: threadListV2Layout.snoozedShelfHeaderIndex, | @@ -628,6 +647,7 @@ export function HomeScreen(props: HomeScreenProps) { | 628 | 647 | snoozeEnvironmentIds, | 629 | 648 | threadListV2Layout, | 630 | 649 | v2PendingTasks, | | 650 | + workingShelfExpanded, | 631 | 651 | ], | 632 | 652 | ); | 633 | 653 |
| @@ -662,6 +682,16 @@ export function HomeScreen(props: HomeScreenProps) { | 662 | 682 | /> | 663 | 683 | ); | 664 | 684 | } | | 685 | + if (item.type === "v2-working-shelf") { | | 686 | + return ( | | 687 | + <ThreadListV2WorkingShelfHeader | | 688 | + count={item.count} | | 689 | + disabled={item.disabled} | | 690 | + expanded={item.expanded} | | 691 | + onToggle={toggleWorkingShelf} | | 692 | + /> | | 693 | + ); | | 694 | + } | 665 | 695 | if (item.type === "v2-snoozed-shelf") { | 666 | 696 | return ( | 667 | 697 | <ThreadListV2SnoozedShelfHeader | @@ -730,7 +760,7 @@ export function HomeScreen(props: HomeScreenProps) { | 730 | 760 | reorderSupported={ | 731 | 761 | item.item.pinned | 732 | 762 | ? pinReorderEnvironmentIds.has(thread.environmentId) | 733 | | - : activeReorderEnvironmentIds.has(thread.environmentId) | | 763 | + : !workingShelfEnabled && activeReorderEnvironmentIds.has(thread.environmentId) | 734 | 764 | } | 735 | 765 | canMoveUp={item.canMoveUp} | 736 | 766 | canMoveDown={item.canMoveDown} | @@ -782,8 +812,10 @@ export function HomeScreen(props: HomeScreenProps) { | 782 | 812 | titleRegenerationEnvironmentIds, | 783 | 813 | toggleSettledShelf, | 784 | 814 | toggleSnoozedShelf, | | 815 | + toggleWorkingShelf, | 785 | 816 | v2ProjectTitleByProjectKey, | 786 | 817 | props.searchQuery, | | 818 | + workingShelfEnabled, | 787 | 819 | ], | 788 | 820 | ); | 789 | 821 | const v2KeyExtractor = useCallback((item: ThreadListV2ListItem) => item.key, []); | @@ -800,6 +832,8 @@ export function HomeScreen(props: HomeScreenProps) { | 800 | 832 | savedConnectionsById: props.savedConnectionsById, | 801 | 833 | searchQuery: props.searchQuery, | 802 | 834 | threadSearchMatchByKey, | | 835 | + // Rows read it for their reorder menu items. | | 836 | + workingShelfEnabled, | 803 | 837 | }), | 804 | 838 | [ | 805 | 839 | projectByKey, | @@ -808,6 +842,7 @@ export function HomeScreen(props: HomeScreenProps) { | 808 | 842 | listEnvironments, | 809 | 843 | threadSearchMatchByKey, | 810 | 844 | v2ProjectTitleByProjectKey, | | 845 | + workingShelfEnabled, | 811 | 846 | ], | 812 | 847 | ); | 813 | 848 |
| |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/settings/SettingsThreadsRouteScreen.tsx +30Lines changed: 30 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -45,6 +45,7 @@ export function SettingsThreadsRouteScreen() { | 45 | 45 | contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }} | 46 | 46 | > | 47 | 47 | <AutoSettleSettingsRows /> | | 48 | + <BetaSettingsSection /> | 48 | 49 | <LegacySettingsSection /> | 49 | 50 | </ScrollView> | 50 | 51 | </SettingsScreen> | @@ -239,6 +240,35 @@ function AutoSettleSettingsRows() { | 239 | 240 | ); | 240 | 241 | } | 241 | 242 |
| | 243 | +/** | | 244 | + * Device-local beta toggles, the counterpart of web's Working section (beta) | | 245 | + * in Settings → General. | | 246 | + */ | | 247 | +function BetaSettingsSection() { | | 248 | + const savePreferences = useAtomSet(updateMobilePreferencesAtom); | | 249 | + const preferences = useAtomValue(mobilePreferencesAtom); | | 250 | + const workingShelfEnabled = | | 251 | + AsyncResult.isSuccess(preferences) && preferences.value.workingShelfEnabled === true; | | 252 | + | | 253 | + return ( | | 254 | + <View className="gap-3"> | | 255 | + <SettingsSection title="Beta"> | | 256 | + <SettingsSwitchRow | | 257 | + icon="bolt.circle" | | 258 | + label="Working section" | | 259 | + value={workingShelfEnabled} | | 260 | + onValueChange={(value) => savePreferences({ workingShelfEnabled: value })} | | 261 | + /> | | 262 | + </SettingsSection> | | 263 | + <Text className="px-2 text-sm text-foreground-muted"> | | 264 | + Fold working and monitoring threads into a Working section. They return to the top of the | | 265 | + list when they need you. While this is on, active threads are ordered by time and cannot be | | 266 | + moved. | | 267 | + </Text> | | 268 | + </View> | | 269 | + ); | | 270 | +} | | 271 | + | 242 | 272 | /** | 243 | 273 | * Device-local legacy toggles. Mobile has no client-settings sync, so this is | 244 | 274 | * the counterpart of web's Settings → General → Legacy features backed by | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/ThreadArrangementSheet.tsx +13-5Lines changed: 13 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2,6 +2,7 @@ import { appAtomRegistry } from "../../state/atom-registry"; | 2 | 2 | import { useAtomValue } from "@effect/atom-react"; | 3 | 3 | import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell"; | 4 | 4 | import { effectiveSnoozed } from "@t3tools/client-runtime/state/thread-settled"; | | 5 | +import { sortInboxThreadsByReturn } from "@t3tools/client-runtime/state/thread-inbox"; | 5 | 6 | import { type ReactNode, useEffect, useMemo, useRef, useState } from "react"; | 6 | 7 | import { Animated, FlatList, Modal, Pressable, View } from "react-native"; | 7 | 8 | import { Gesture, GestureDetector, GestureHandlerRootView } from "react-native-gesture-handler"; | @@ -26,7 +27,8 @@ import { | 26 | 27 | threadDragAction, | 27 | 28 | type ThreadMoveDestination, | 28 | 29 | } from "./threadOrder"; | 29 | | -import { getThreadListV2OrderedSection } from "./threadListV2"; | | 30 | +import { getThreadListV2OrderedSection, threadListInboxReturns } from "./threadListV2"; | | 31 | +import { useThreadListV2ShelfPreferences } from "./use-thread-list-v2-shelf-preferences"; | 30 | 32 |
| 31 | 33 | const ROW_HEIGHT = 56; | 32 | 34 | const HEADER_HEIGHT = 48; | @@ -154,6 +156,7 @@ export function ThreadArrangementSheet(props: { onClose: () => void }) { | 154 | 156 | const pendingOrder = useAtomValue(pendingThreadOrderAtom); | 155 | 157 | const dropBusy = useAtomValue(threadDropBusyAtom); | 156 | 158 | const { moveThread } = useThreadListActions(); | | 159 | + const { workingShelfEnabled } = useThreadListV2ShelfPreferences(); | 157 | 160 | const [now, setNow] = useState(() => new Date().toISOString()); | 158 | 161 | const [expanded, setExpanded] = useState({ snoozed: false, settled: false }); | 159 | 162 | useEffect(() => { | @@ -195,31 +198,36 @@ export function ThreadArrangementSheet(props: { onClose: () => void }) { | 195 | 198 | ); | 196 | 199 | return { | 197 | 200 | pinned, | 198 | | - active, | | 201 | + // The Working beta orders the inbox by time; show that order here too. | | 202 | + active: workingShelfEnabled | | 203 | + ? sortInboxThreadsByReturn(active, threadListInboxReturns.returnedAt) | | 204 | + : active, | 199 | 205 | snoozed: parked.filter((thread) => effectiveSnoozed(thread, { now })), | 200 | 206 | settled: parked.filter((thread) => !effectiveSnoozed(thread, { now })), | 201 | 207 | }; | 202 | | - }, [threads, configs, now, queuedThreadKeys, pendingOrder]); | | 208 | + }, [threads, configs, now, queuedThreadKeys, pendingOrder, workingShelfEnabled]); | 203 | 209 | const planners = useMemo(() => { | 204 | 210 | const planner = (section: "pinned" | "active") => | 205 | 211 | createThreadMovePlanner({ | 206 | 212 | ordered: sections[section], | 207 | 213 | allThreads: threads, | 208 | 214 | section, | | 215 | + // A time-ordered inbox has no slots, so Active takes no drops while | | 216 | + // the Working beta is on. The saved arrangement stays untouched. | 209 | 217 | reorderableEnvironmentIds: new Set( | 210 | 218 | [...configs].flatMap(([id, config]) => | 211 | 219 | ( | 212 | 220 | section === "pinned" | 213 | 221 | ? config.environment.capabilities.threadPinReorder | 214 | | - : config.environment.capabilities.threadActiveReorder | | 222 | + : !workingShelfEnabled && config.environment.capabilities.threadActiveReorder | 215 | 223 | ) | 216 | 224 | ? [id] | 217 | 225 | : [], | 218 | 226 | ), | 219 | 227 | ), | 220 | 228 | }); | 221 | 229 | return { pinned: planner("pinned"), active: planner("active") }; | 222 | | - }, [sections, threads, configs]); | | 230 | + }, [sections, threads, configs, workingShelfEnabled]); | 223 | 231 | const rows = useMemo(() => { | 224 | 232 | const result: Row[] = []; | 225 | 233 | let offset = 0; | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx +37-2Lines changed: 37 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -61,6 +61,7 @@ import { | 61 | 61 | ThreadListV2SettledShelfHeader, | 62 | 62 | ThreadListV2ShowMoreRow, | 63 | 63 | ThreadListV2SnoozedShelfHeader, | | 64 | + ThreadListV2WorkingShelfHeader, | 64 | 65 | } from "./thread-list-v2-items"; | 65 | 66 | import { useThreadRowProviderInstanceResolver } from "./thread-provider-instance"; | 66 | 67 | import { | @@ -69,6 +70,7 @@ import { | 69 | 70 | buildThreadListV2ListItems, | 70 | 71 | isThreadListV2ListItem, | 71 | 72 | threadListV2ListItemsAreEqual, | | 73 | + threadListInboxReturns, | 72 | 74 | THREAD_LIST_V2_SETTLED_INITIAL_COUNT, | 73 | 75 | THREAD_LIST_V2_SETTLED_PAGE_COUNT, | 74 | 76 | type ThreadListV2ListItem, | @@ -291,8 +293,11 @@ function ThreadNavigationSidebarPane( | 291 | 293 | loaded: shelfPreferencesLoaded, | 292 | 294 | settledShelfExpanded, | 293 | 295 | snoozedShelfExpanded, | | 296 | + workingShelfEnabled, | | 297 | + workingShelfExpanded, | 294 | 298 | toggleSettledShelf, | 295 | 299 | toggleSnoozedShelf, | | 300 | + toggleWorkingShelf, | 296 | 301 | } = useThreadListV2ShelfPreferences(); | 297 | 302 | // The queued-start and snooze helpers need a clock while the pane stays open. | 298 | 303 | const [nowMinute, setNowMinute] = useState(() => new Date().toISOString().slice(0, 16)); | @@ -343,8 +348,13 @@ function ThreadNavigationSidebarPane( | 343 | 348 | queuedThreadKeys, | 344 | 349 | }), | 345 | 350 | }); | 346 | | - return new Map([...sectionAvailability("pinned"), ...sectionAvailability("active")]); | | 351 | + // The Working beta orders the inbox by time, so only pins can move. | | 352 | + return new Map([ | | 353 | + ...sectionAvailability("pinned"), | | 354 | + ...(workingShelfEnabled ? [] : sectionAvailability("active")), | | 355 | + ]); | 347 | 356 | }, [ | | 357 | + workingShelfEnabled, | 348 | 358 | pinReorderEnvironmentIds, | 349 | 359 | activeReorderEnvironmentIds, | 350 | 360 | threads, | @@ -356,6 +366,7 @@ function ThreadNavigationSidebarPane( | 356 | 366 | snoozeWakeTick, | 357 | 367 | ]); | 358 | 368 | const threadListV2Layout = useMemo(() => { | | 369 | + threadListInboxReturns.observe(workingShelfEnabled ? threads : null); | 359 | 370 | return buildThreadListV2Items({ | 360 | 371 | pendingOrder, | 361 | 372 | threads: threads.filter((thread) => thread.archivedAt === null), | @@ -368,11 +379,16 @@ function ThreadNavigationSidebarPane( | 368 | 379 | queuedThreadKeys, | 369 | 380 | settledLimit: settledVisibleCount, | 370 | 381 | now: new Date().toISOString(), | | 382 | + workingShelfEnabled, | | 383 | + workingShelfExpanded, | | 384 | + inboxReturnAt: threadListInboxReturns.returnedAt, | 371 | 385 | snoozedShelfExpanded, | 372 | 386 | settledShelfExpanded, | 373 | 387 | selectedThreadKey: props.selectedThreadKey ?? null, | 374 | 388 | }); | 375 | 389 | }, [ | | 390 | + workingShelfEnabled, | | 391 | + workingShelfExpanded, | 376 | 392 | pendingOrder, | 377 | 393 | queuedThreadKeys, | 378 | 394 | nowMinute, | @@ -424,6 +440,9 @@ function ThreadNavigationSidebarPane( | 424 | 440 | const items: SidebarListItem[] = buildThreadListV2ListItems({ | 425 | 441 | items: threadListV2Layout.items, | 426 | 442 | pendingTasks: v2PendingTasks, | | 443 | + workingCount: threadListV2Layout.workingCount, | | 444 | + workingShelfExpanded, | | 445 | + workingShelfHeaderIndex: threadListV2Layout.workingShelfHeaderIndex, | 427 | 446 | snoozedCount: threadListV2Layout.snoozedCount, | 428 | 447 | snoozedShelfExpanded, | 429 | 448 | snoozedShelfHeaderIndex: threadListV2Layout.snoozedShelfHeaderIndex, | @@ -457,6 +476,7 @@ function ThreadNavigationSidebarPane( | 457 | 476 | snoozedShelfExpanded, | 458 | 477 | snoozeEnvironmentIds, | 459 | 478 | threadListV2Layout, | | 479 | + workingShelfExpanded, | 460 | 480 | ]); | 461 | 481 | const listMenuActions = useMemo<MenuAction[]>( | 462 | 482 | () => [ | @@ -587,6 +607,8 @@ function ThreadNavigationSidebarPane( | 587 | 607 | savedConnectionsById, | 588 | 608 | listEnvironments, | 589 | 609 | threadSearchMatchByKey, | | 610 | + // Rows read it for their reorder menu items. | | 611 | + workingShelfEnabled, | 590 | 612 | }), | 591 | 613 | [ | 592 | 614 | props.selectedThreadKey, | @@ -595,6 +617,7 @@ function ThreadNavigationSidebarPane( | 595 | 617 | savedConnectionsById, | 596 | 618 | listEnvironments, | 597 | 619 | threadSearchMatchByKey, | | 620 | + workingShelfEnabled, | 598 | 621 | ], | 599 | 622 | ); | 600 | 623 | useThreadJumpShortcuts(listItems, handleSelectThread); | @@ -712,7 +735,7 @@ function ThreadNavigationSidebarPane( | 712 | 735 | reorderSupported={ | 713 | 736 | item.item.pinned | 714 | 737 | ? pinReorderEnvironmentIds.has(thread.environmentId) | 715 | | - : activeReorderEnvironmentIds.has(thread.environmentId) | | 738 | + : !workingShelfEnabled && activeReorderEnvironmentIds.has(thread.environmentId) | 716 | 739 | } | 717 | 740 | canMoveUp={item.canMoveUp} | 718 | 741 | canMoveDown={item.canMoveDown} | @@ -729,6 +752,16 @@ function ThreadNavigationSidebarPane( | 729 | 752 | /> | 730 | 753 | ); | 731 | 754 | } | | 755 | + case "v2-working-shelf": | | 756 | + return ( | | 757 | + <ThreadListV2WorkingShelfHeader | | 758 | + count={item.count} | | 759 | + disabled={item.disabled} | | 760 | + expanded={item.expanded} | | 761 | + onToggle={toggleWorkingShelf} | | 762 | + pane="sidebar" | | 763 | + /> | | 764 | + ); | 732 | 765 | case "v2-snoozed-shelf": | 733 | 766 | return ( | 734 | 767 | <ThreadListV2SnoozedShelfHeader | @@ -797,9 +830,11 @@ function ThreadNavigationSidebarPane( | 797 | 830 | snoozeThread, | 798 | 831 | toggleSettledShelf, | 799 | 832 | toggleSnoozedShelf, | | 833 | + toggleWorkingShelf, | 800 | 834 | unpinThread, | 801 | 835 | unsettleThread, | 802 | 836 | unsnoozeThread, | | 837 | + workingShelfEnabled, | 803 | 838 | ], | 804 | 839 | ); | 805 | 840 | // The list ignores sort/group options, so only the environment and project | |
|