The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { useAtomValue } from "@effect/atom-react"; |
| 2 | import { msg } from "gt-react-native"; |
| 3 | import { AsyncResult } from "effect/reactivity"; |
| 4 | import { Platform } from "react-native"; |
| 5 | import { |
| 6 | NAVIGATION_TAB_LABELS, |
| 7 | navigationCustomizationAvailable, |
| 8 | resolveHiddenNavigationTabs, |
| 9 | enabledNavigationTabs, |
| 10 | sharedSlotAbsentee, |
| 11 | type NavigationTab, |
| 12 | } from "./navigation-tab-order"; |
| 13 | import type { AppSymbolName } from "../../../components/ui/AppSymbol"; |
| 14 | import { mobilePreferencesAtom } from "../../../state/preferences"; |
| 15 | import { PullRequestGlyph } from "../../pull-requests/pullRequestGlyphs"; |
| 16 | import { useWorkspaceTabs } from "./WorkspaceTabsContext"; |
| 17 | import { resolveWorkspaceTabOrder } from "./workspace-tabs-state"; |
| 18 | |
| 19 | export const WORKSPACE_TAB_LABELS = { |
| 20 | ...NAVIGATION_TAB_LABELS, |
| 21 | ...(Platform.OS === "ios" |
| 22 | ? { |
| 23 | threads: msg("Chats", { $context: "navigation tab, list of chat threads" }), |
| 24 | pullRequests: msg("PRs", { $context: "navigation tab, pull requests" }), |
| 25 | } |
| 26 | : {}), |
| 27 | }; |
| 28 | |
| 29 | export const NAVIGATION_TAB_ICONS = { |
| 30 | threads: "text.bubble", |
| 31 | pullRequests: PullRequestGlyph.pullRequest, |
| 32 | issues: "git.issue", |
| 33 | usage: "chart.bar.xaxis", |
| 34 | } as const satisfies Readonly<Record<NavigationTab, AppSymbolName>>; |
| 35 | |
| 36 | export function useNavigationTabOrder() { |
| 37 | const preferences = useAtomValue(mobilePreferencesAtom); |
| 38 | const saved = AsyncResult.isSuccess(preferences) |
| 39 | ? preferences.value.navigationTabOrder |
| 40 | : undefined; |
| 41 | return resolveWorkspaceTabOrder(saved); |
| 42 | } |
| 43 | |
| 44 | export function useHiddenNavigationTabs() { |
| 45 | const preferences = useAtomValue(mobilePreferencesAtom); |
| 46 | const selected = useWorkspaceTabs()?.state.selectedTab ?? "threads"; |
| 47 | const saved = AsyncResult.isSuccess(preferences) ? preferences.value : undefined; |
| 48 | return [ |
| 49 | ...(navigationCustomizationAvailable() |
| 50 | ? resolveHiddenNavigationTabs(saved?.hiddenNavigationTabs) |
| 51 | : []), |
| 52 | sharedSlotAbsentee(selected, saved?.sharedSlotTab), |
| 53 | ]; |
| 54 | } |
| 55 | |
| 56 | export function useEnabledNavigationTabs() { |
| 57 | const order = useNavigationTabOrder(); |
| 58 | const hidden = useHiddenNavigationTabs(); |
| 59 | return enabledNavigationTabs(order, hidden); |
| 60 | } |