-
Notifications
You must be signed in to change notification settings - Fork 3.6k
fix(mobile): move the thread sync indicator into the header #5000
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
Closed
carTloyal123
wants to merge
1
commit into
pingdotgg:main
from
carTloyal123:fix/mobile-sync-indicator-header
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
apps/mobile/src/features/home/WorkspaceSyncStatusButton.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| import { ActivityIndicator, Pressable, View } from "react-native"; | ||
|
|
||
| import { SymbolView, type SFSymbol } from "../../components/AppSymbol"; | ||
| import { cn } from "../../lib/cn"; | ||
| import { useThemeColor } from "../../lib/useThemeColor"; | ||
| import type { WorkspaceState } from "../../state/workspaceModel"; | ||
| import { useSettledWorkspaceSyncTone } from "./use-settled-workspace-sync-tone"; | ||
| import { | ||
| workspaceConnectionStatusLabel, | ||
| type WorkspaceSyncTone, | ||
| } from "./workspace-connection-status"; | ||
|
|
||
| /** | ||
| * SF Symbol for a settled tone, or null when the tone is shown as a spinner | ||
| * instead. Exported so the iOS native header-item builders (which can only | ||
| * carry an icon name, not a React child) can style their own button the same way. | ||
| */ | ||
| export function workspaceSyncToneSymbol(tone: WorkspaceSyncTone): SFSymbol | null { | ||
| switch (tone) { | ||
| case "offline": | ||
| return "wifi.slash"; | ||
| case "error": | ||
| case "disconnected": | ||
| return "exclamationmark.triangle"; | ||
| case "connecting": | ||
| case "syncing": | ||
| // Rendered as an ActivityIndicator in React headers; native header items | ||
| // fall back to this icon since they can't host a spinner. | ||
| return "arrow.clockwise"; | ||
| case "idle": | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Header button reporting workspace connection / thread-sync state. | ||
| * | ||
| * Replaces the old inline WorkspaceConnectionStatus row that lived inside the | ||
| * thread list's scroll view, where every sync-state flip mounted and unmounted | ||
| * a list header — flashing the indicator and reflowing every row beneath it. | ||
| * Here the button's slot is always occupied (idle renders an empty box of the | ||
| * same size), so state changes swap the icon without moving anything, and the | ||
| * tone itself is settled first (see useSettledWorkspaceSyncTone) so the | ||
| * inherently bouncy sync signal can't strobe the header. | ||
| */ | ||
| export function WorkspaceSyncStatusButton(props: { | ||
| readonly state: WorkspaceState; | ||
| readonly onPress: () => void; | ||
| /** | ||
| * "home" matches the Android home header's circular 44pt buttons; | ||
| * "sidebar-grouped" matches the split-view sidebar's shared capsule group. | ||
| */ | ||
| readonly variant?: "home" | "sidebar-grouped"; | ||
| }) { | ||
| const tone = useSettledWorkspaceSyncTone(props.state); | ||
| const iconColor = useThemeColor("--color-icon"); | ||
| const pressedBackgroundColor = useThemeColor("--color-subtle"); | ||
| const variant = props.variant ?? "home"; | ||
| const isGrouped = variant === "sidebar-grouped"; | ||
| const sizeClassName = isGrouped ? "h-11 w-[50px] rounded-[22px]" : "size-11 rounded-full"; | ||
| const symbol = workspaceSyncToneSymbol(tone); | ||
| const isBusy = tone === "connecting" || tone === "syncing"; | ||
|
|
||
| // Idle keeps the slot — an empty box the exact size of the button — so the | ||
| // neighbouring header controls never shift when sync state changes. | ||
| if (tone === "idle") { | ||
| return <View className={sizeClassName} pointerEvents="none" />; | ||
| } | ||
|
|
||
| const label = workspaceConnectionStatusLabel(props.state); | ||
|
|
||
| return ( | ||
| <Pressable | ||
| accessibilityHint="Opens environment settings" | ||
| accessibilityLabel={label} | ||
| accessibilityRole="button" | ||
| hitSlop={4} | ||
| onPress={props.onPress} | ||
| // Home mirrors the sibling filter/settings circles (bg-subtle); the | ||
| // sidebar variant drops its own chrome to sit inside the shared capsule. | ||
| className={cn(sizeClassName, "items-center justify-center", !isGrouped && "bg-subtle")} | ||
| style={({ pressed }) => (pressed ? { backgroundColor: pressedBackgroundColor } : undefined)} | ||
| > | ||
| {isBusy ? ( | ||
| <ActivityIndicator color={iconColor} size="small" /> | ||
| ) : symbol ? ( | ||
| <SymbolView | ||
| name={symbol} | ||
| size={isGrouped ? 20 : 18} | ||
| tintColor={iconColor} | ||
| type="monochrome" | ||
| /> | ||
| ) : null} | ||
| </Pressable> | ||
| ); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🟡 Medium
home/HomeHeader.tsx:324The native iOS sync button's accessibility label (
syncLabel) is derived from rawprops.catalogState, while its icon (syncSymbol) is derived from the settledsyncTone. During the 900 ms minimum-visible hold after syncing completes, the button still displays the syncing icon butworkspaceConnectionStatusLabelalready returns"Not connected", so VoiceOver announces a status that contradicts the visible indicator. Derive the label from the same settled tone as the icon, or settle the label alongside it.Also found in 2 other location(s)
apps/mobile/src/features/home/WorkspaceSyncStatusButton.tsx:70apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx:1040🤖 Copy this AI Prompt to have your agent fix this: