diff --git a/apps/mobile/src/features/home/HomeScreen.tsx b/apps/mobile/src/features/home/HomeScreen.tsx index c84c4da154817..a6ae59f36ddb3 100644 --- a/apps/mobile/src/features/home/HomeScreen.tsx +++ b/apps/mobile/src/features/home/HomeScreen.tsx @@ -556,6 +556,7 @@ export function HomeScreen(props: HomeScreenProps) { onNewThreadOnBranch={props.onNewThreadOnBranch} thread={thread} variant={item.item.variant} + inProjectFolder={item.inProjectFolder} hasQueuedMessages={item.hasQueuedMessages} snoozed={item.item.snoozed} pinned={item.item.pinned} diff --git a/apps/mobile/src/features/settings/ThreadSettingsSections.tsx b/apps/mobile/src/features/settings/ThreadSettingsSections.tsx index 9a906827982aa..740767846d903 100644 --- a/apps/mobile/src/features/settings/ThreadSettingsSections.tsx +++ b/apps/mobile/src/features/settings/ThreadSettingsSections.tsx @@ -19,7 +19,11 @@ import { DEFAULT_SERVER_SETTINGS } from "@t3tools/contracts"; import { supportsSharedSettingsSync } from "@t3tools/client-runtime/state/shared-settings"; import { AppText as Text } from "../../components/ui/AppText"; import { useEnvironments } from "../../state/environments"; -import { mobilePreferencesAtom, saveMobilePreferences } from "../../state/preferences"; +import { + mobilePreferencesAtom, + saveMobilePreferences, + threadListPullRequestBadgesEnabledAtom, +} from "../../state/preferences"; import { serverEnvironment } from "../../state/server"; import { useAtomCommand } from "../../state/use-atom-command"; import { ListChoiceRow as SettingsChoiceRow } from "../../components/ui/ListChoiceRow"; @@ -216,6 +220,7 @@ export function WorkingSectionSettings() { const gt = useGT(); const savePreferences = useAtomCommand(saveMobilePreferences); const preferences = useAtomValue(mobilePreferencesAtom); + const showPullRequestBadges = useAtomValue(threadListPullRequestBadgesEnabledAtom); const loaded = AsyncResult.isSuccess(preferences); const projectFoldersEnabled = loaded && preferences.value.threadListProjectFoldersEnabled === true; @@ -236,6 +241,15 @@ export function WorkingSectionSettings() { void savePreferences({ threadListProjectFoldersEnabled: value }); }} /> + { + void savePreferences({ threadListPullRequestBadgesEnabled: value }); + }} + /> { if (pr) onOpenThreadPullRequests(thread, pr); @@ -866,6 +870,8 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { const sidebarPane = props.pane === "sidebar"; const selected = props.selected === true; const rowAppearance = getThreadListV2RowAppearance(theme, sidebarPane, selected); + const projectIndent = props.inProjectFolder ? 16 : 0; + const projectIndentStyle = props.inProjectFolder ? { marginStart: projectIndent } : undefined; const rawStatus = resolveThreadListV2Status(thread); const status = resolveThreadListV2RowStatus(thread); @@ -1754,10 +1760,14 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { ); if (!canOperateThread) - return {rowContent(() => {})}; + return ( + + {rowContent(() => {})} + + ); return ( - + {customSnoozeOpen && ( setCustomSnoozeOpen(false)} onSnooze={handleSnooze} /> )} @@ -1769,7 +1779,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { containerStyle={rowAppearance.swipeContainerStyle} enableTrackpadSwipe fullSwipeAction="primary" - fullSwipeWidth={props.fullSwipeWidth ?? windowWidth - 32} + fullSwipeWidth={(props.fullSwipeWidth ?? windowWidth - 32) - projectIndent} listAnimatesLayout onDelete={handleDelete} onSwipeableClose={props.onSwipeableClose} diff --git a/apps/mobile/src/features/threads/threadListV2.ts b/apps/mobile/src/features/threads/threadListV2.ts index 7f1b5dac1f41b..d6bd8c80b0497 100644 --- a/apps/mobile/src/features/threads/threadListV2.ts +++ b/apps/mobile/src/features/threads/threadListV2.ts @@ -439,6 +439,7 @@ export interface ThreadListV2ThreadListItem { readonly type: "v2-thread"; readonly key: string; readonly item: ThreadListV2Item; + readonly inProjectFolder?: boolean; readonly snoozeWakeLabelText: string | undefined; readonly timeLabel: string; readonly snoozePresetMinute: string | undefined; @@ -528,6 +529,7 @@ export function threadListV2ListItemsAreEqual( previous.item.snoozed === item.item.snoozed && previous.item.pinned === item.item.pinned && previous.item.wokeAt === item.item.wokeAt && + previous.inProjectFolder === item.inProjectFolder && previous.snoozeWakeLabelText === item.snoozeWakeLabelText && previous.timeLabel === item.timeLabel && previous.snoozePresetMinute === item.snoozePresetMinute && @@ -718,7 +720,7 @@ export function buildThreadListV2ListItems(input: { continue; } const folderItems = itemsByFolder.get(scope.key) ?? []; - folderItems.push(item); + folderItems.push({ ...item, inProjectFolder: true }); itemsByFolder.set(scope.key, folderItems); } const collapsedKeys = new Set(input.collapsedProjectKeys); diff --git a/apps/mobile/src/i18n/translations/de.json b/apps/mobile/src/i18n/translations/de.json index c406dc237cc18..1c085e1de7694 100644 --- a/apps/mobile/src/i18n/translations/de.json +++ b/apps/mobile/src/i18n/translations/de.json @@ -5787,5 +5787,7 @@ "7367ac6d7473df6c": "{project}, {count} ausgeblendete Threads", "5af190a4b64e6d6f": "{project}, {count} ausgeblendete Threads, {status}", "1acf5ae561eb2754": "Klappt das Projekt ein", - "793a282af8116867": "Klappt das Projekt aus" + "793a282af8116867": "Klappt das Projekt aus", + "f53591648d8bb1ec": "Pull-Request-Badges anzeigen", + "29feb17e28bbb67b": "Git-Status" } diff --git a/apps/mobile/src/i18n/translations/en.json b/apps/mobile/src/i18n/translations/en.json index f10021b8d4c6d..d353e252716c4 100644 --- a/apps/mobile/src/i18n/translations/en.json +++ b/apps/mobile/src/i18n/translations/en.json @@ -5789,5 +5789,7 @@ "7367ac6d7473df6c": "{project}, {count} hidden threads", "5af190a4b64e6d6f": "{project}, {count} hidden threads, {status}", "1acf5ae561eb2754": "Collapses the project", - "793a282af8116867": "Expands the project" + "793a282af8116867": "Expands the project", + "f53591648d8bb1ec": "Show pull request badges", + "29feb17e28bbb67b": "git status" } diff --git a/apps/mobile/src/i18n/translations/es.json b/apps/mobile/src/i18n/translations/es.json index aff292bd8ba63..ada37c3971502 100644 --- a/apps/mobile/src/i18n/translations/es.json +++ b/apps/mobile/src/i18n/translations/es.json @@ -5781,5 +5781,7 @@ "7367ac6d7473df6c": "{project}, {count} hilos ocultos", "5af190a4b64e6d6f": "{project}, {count} hilos ocultos, {status}", "1acf5ae561eb2754": "Contrae el proyecto", - "793a282af8116867": "Expande el proyecto" + "793a282af8116867": "Expande el proyecto", + "f53591648d8bb1ec": "Mostrar indicadores de pull requests", + "29feb17e28bbb67b": "estado de Git" } diff --git a/apps/mobile/src/i18n/translations/fr.json b/apps/mobile/src/i18n/translations/fr.json index 39a54c35124d6..d7c4749da6978 100644 --- a/apps/mobile/src/i18n/translations/fr.json +++ b/apps/mobile/src/i18n/translations/fr.json @@ -5781,5 +5781,7 @@ "7367ac6d7473df6c": "{project}, {count} conversations masquées", "5af190a4b64e6d6f": "{project}, {count} conversations masquées, {status}", "1acf5ae561eb2754": "Replie le projet", - "793a282af8116867": "Déplie le projet" + "793a282af8116867": "Déplie le projet", + "f53591648d8bb1ec": "Afficher les badges de pull request", + "29feb17e28bbb67b": "état Git" } diff --git a/apps/mobile/src/i18n/translations/ja.json b/apps/mobile/src/i18n/translations/ja.json index 4c33623baf249..159e783a5246f 100644 --- a/apps/mobile/src/i18n/translations/ja.json +++ b/apps/mobile/src/i18n/translations/ja.json @@ -5761,5 +5761,7 @@ "7367ac6d7473df6c": "{project}、非表示のスレッド {count} 件", "5af190a4b64e6d6f": "{project}、非表示のスレッド {count} 件、{status}", "1acf5ae561eb2754": "プロジェクトを折りたたみます", - "793a282af8116867": "プロジェクトを展開します" + "793a282af8116867": "プロジェクトを展開します", + "f53591648d8bb1ec": "プルリクエストのバッジを表示", + "29feb17e28bbb67b": "Git の状態" } diff --git a/apps/mobile/src/i18n/translations/ko.json b/apps/mobile/src/i18n/translations/ko.json index 33c4665b3440d..1c16327ae41ec 100644 --- a/apps/mobile/src/i18n/translations/ko.json +++ b/apps/mobile/src/i18n/translations/ko.json @@ -5767,5 +5767,7 @@ "7367ac6d7473df6c": "{project}, 숨겨진 스레드 {count}개", "5af190a4b64e6d6f": "{project}, 숨겨진 스레드 {count}개, {status}", "1acf5ae561eb2754": "프로젝트를 접습니다", - "793a282af8116867": "프로젝트를 펼칩니다" + "793a282af8116867": "프로젝트를 펼칩니다", + "f53591648d8bb1ec": "풀 리퀘스트 배지 표시", + "29feb17e28bbb67b": "Git 상태" } diff --git a/apps/mobile/src/i18n/translations/pt-BR.json b/apps/mobile/src/i18n/translations/pt-BR.json index c62ea6456ba87..575f01cd06c66 100644 --- a/apps/mobile/src/i18n/translations/pt-BR.json +++ b/apps/mobile/src/i18n/translations/pt-BR.json @@ -5781,5 +5781,7 @@ "7367ac6d7473df6c": "{project}, {count} threads ocultas", "5af190a4b64e6d6f": "{project}, {count} threads ocultas, {status}", "1acf5ae561eb2754": "Recolhe o projeto", - "793a282af8116867": "Expande o projeto" + "793a282af8116867": "Expande o projeto", + "f53591648d8bb1ec": "Mostrar selos de pull request", + "29feb17e28bbb67b": "status do Git" } diff --git a/apps/mobile/src/i18n/translations/ru.json b/apps/mobile/src/i18n/translations/ru.json index ba2979541fdf1..7557028f009e7 100644 --- a/apps/mobile/src/i18n/translations/ru.json +++ b/apps/mobile/src/i18n/translations/ru.json @@ -5861,5 +5861,7 @@ "7367ac6d7473df6c": "{project}, скрыто тредов: {count}", "5af190a4b64e6d6f": "{project}, скрыто тредов: {count}, {status}", "1acf5ae561eb2754": "Сворачивает проект", - "793a282af8116867": "Разворачивает проект" + "793a282af8116867": "Разворачивает проект", + "f53591648d8bb1ec": "Показывать значки пул-реквестов", + "29feb17e28bbb67b": "статус Git" } diff --git a/apps/mobile/src/i18n/translations/sv.json b/apps/mobile/src/i18n/translations/sv.json index c98716f181ce5..d6887546aa871 100644 --- a/apps/mobile/src/i18n/translations/sv.json +++ b/apps/mobile/src/i18n/translations/sv.json @@ -5787,5 +5787,7 @@ "7367ac6d7473df6c": "{project}, {count} dolda trådar", "5af190a4b64e6d6f": "{project}, {count} dolda trådar, {status}", "1acf5ae561eb2754": "Fäller ihop projektet", - "793a282af8116867": "Fäller ut projektet" + "793a282af8116867": "Fäller ut projektet", + "f53591648d8bb1ec": "Visa märken för pull requests", + "29feb17e28bbb67b": "Git-status" } diff --git a/apps/mobile/src/i18n/translations/zh.json b/apps/mobile/src/i18n/translations/zh.json index db16ee10c5281..4810839bfdc26 100644 --- a/apps/mobile/src/i18n/translations/zh.json +++ b/apps/mobile/src/i18n/translations/zh.json @@ -5771,5 +5771,7 @@ "7367ac6d7473df6c": "{project},{count} 个隐藏会话", "5af190a4b64e6d6f": "{project},{count} 个隐藏会话,{status}", "1acf5ae561eb2754": "折叠项目", - "793a282af8116867": "展开项目" + "793a282af8116867": "展开项目", + "f53591648d8bb1ec": "显示拉取请求徽章", + "29feb17e28bbb67b": "Git 状态" } diff --git a/apps/mobile/src/persistence/mobile-preferences.ts b/apps/mobile/src/persistence/mobile-preferences.ts index b88f331467292..84d26dce17a18 100644 --- a/apps/mobile/src/persistence/mobile-preferences.ts +++ b/apps/mobile/src/persistence/mobile-preferences.ts @@ -173,6 +173,7 @@ export interface Preferences { readonly toolCallVisibility?: ToolCallVisibility; readonly workingShelfEnabled?: boolean; readonly threadListProjectFoldersEnabled?: boolean; + readonly threadListPullRequestBadgesEnabled?: boolean; readonly useLastProjectForNewThreads?: boolean; readonly lastThreadProject?: typeof ThreadProject.Type; readonly modelFavorites?: ReadonlyArray<{ @@ -266,6 +267,7 @@ function sanitizePreferences(parsed: Preferences): Preferences { toolCallVisibility?: ToolCallVisibility; workingShelfEnabled?: boolean; threadListProjectFoldersEnabled?: boolean; + threadListPullRequestBadgesEnabled?: boolean; useLastProjectForNewThreads?: boolean; lastThreadProject?: typeof ThreadProject.Type; modelFavorites?: Preferences["modelFavorites"]; @@ -410,6 +412,9 @@ function sanitizePreferences(parsed: Preferences): Preferences { if (typeof parsed.threadListProjectFoldersEnabled === "boolean") { preferences.threadListProjectFoldersEnabled = parsed.threadListProjectFoldersEnabled; } + if (typeof parsed.threadListPullRequestBadgesEnabled === "boolean") { + preferences.threadListPullRequestBadgesEnabled = parsed.threadListPullRequestBadgesEnabled; + } if (typeof parsed.useLastProjectForNewThreads === "boolean") { preferences.useLastProjectForNewThreads = parsed.useLastProjectForNewThreads; } diff --git a/apps/mobile/src/state/preferences.ts b/apps/mobile/src/state/preferences.ts index 67cec9845a86c..5b3c92c44e43c 100644 --- a/apps/mobile/src/state/preferences.ts +++ b/apps/mobile/src/state/preferences.ts @@ -123,3 +123,11 @@ const mobilePreferencesState = createMobilePreferencesState(mobilePreferencesRun export const mobilePreferencesAtom = mobilePreferencesState.preferencesAtom; export const saveMobilePreferences = mobilePreferencesState.savePreferences; + +export const threadListPullRequestBadgesEnabledAtom = mobilePreferencesAtom.pipe( + Atom.map( + (preferences) => + !AsyncResult.isSuccess(preferences) || + preferences.value.threadListPullRequestBadgesEnabled !== false, + ), +); diff --git a/apps/mobile/src/state/use-thread-pr.demand.test.tsx b/apps/mobile/src/state/use-thread-pr.demand.test.tsx index b3e6965531f63..f9a2fb50de4ed 100644 --- a/apps/mobile/src/state/use-thread-pr.demand.test.tsx +++ b/apps/mobile/src/state/use-thread-pr.demand.test.tsx @@ -164,9 +164,17 @@ const setup = Effect.fn("TestThreadPr.setup")(function* () { const container = document.createElement("div"); const root = createRoot(container); let mounts = 0; - function Row({ value, name }: { value: EnvironmentThreadShell; name: string }) { + function Row({ + value, + name, + badgeEnabled = true, + }: { + value: EnvironmentThreadShell; + name: string; + badgeEnabled?: boolean; + }) { const [passive] = useState(() => ++mounts); - const pr = useThreadPr(value); + const pr = useThreadPr(value, badgeEnabled); return ( {pr?.accessibilityLabel ?? "none"} @@ -201,11 +209,13 @@ const setup = Effect.fn("TestThreadPr.setup")(function* () { value = thread(), shared = false, activity = "visible", + badgeEnabled = true, }: { visible?: boolean; value?: EnvironmentThreadShell; shared?: boolean; activity?: "visible" | "hidden"; + badgeEnabled?: boolean; } = {}) { await act(async () => root.render( @@ -213,7 +223,7 @@ const setup = Effect.fn("TestThreadPr.setup")(function* () { @@ -284,6 +294,24 @@ it.effect("does not start a fallback query for a sidebar first mounted hidden", }), ); +it.effect("hides cached badges and stops refreshing them until badges are enabled again", () => + Effect.gen(function* () { + using h = yield* setup(); + yield* Effect.promise(async () => { + await h.render(); + expect(h.badge()).toBe("#12 pull request open"); + await h.render({ badgeEnabled: false }); + expect(h.badge()).toBe("none"); + await h.advance(10_000); + const afterGrace = h.requests.length; + await h.advance(180_000); + expect(h.requests).toHaveLength(afterGrace); + await h.render(); + expect(h.badge()).toBe("#12 pull request open"); + }); + }), +); + it.effect("keeps a shared visible reader polling while its sidebar reader is hidden", () => Effect.gen(function* () { using h = yield* setup(); diff --git a/apps/mobile/src/state/use-thread-pr.ts b/apps/mobile/src/state/use-thread-pr.ts index 573a41c408764..6460c76f4c3b1 100644 --- a/apps/mobile/src/state/use-thread-pr.ts +++ b/apps/mobile/src/state/use-thread-pr.ts @@ -78,25 +78,31 @@ export function withKnownPullRequestSummary< return initialSummary === undefined ? params : { ...params, initialSummary }; } -export function useThreadPr(thread: EnvironmentThreadShell): ThreadPrPresentation | null { +export function useThreadPr( + thread: EnvironmentThreadShell, + badgeEnabled = true, +): ThreadPrPresentation | null { const demand = use(ThreadPrDemandContext); const resolve = useMessages(); const supportsLinks = useAtomValue( serverEnvironment.configValueAtom(thread.environmentId), (config) => config !== null, ); - const { linkedPresentation, pullRequestRef } = useMemo( + const source = useMemo( () => - resolveThreadPrSource( - { - pullRequests: thread.pullRequests, - linkedPullRequest: thread.linkedPullRequest, - branchPullRequest: thread.branchPullRequest, - }, - supportsLinks, - resolve, - ), + badgeEnabled + ? resolveThreadPrSource( + { + pullRequests: thread.pullRequests, + linkedPullRequest: thread.linkedPullRequest, + branchPullRequest: thread.branchPullRequest, + }, + supportsLinks, + resolve, + ) + : null, [ + badgeEnabled, thread.pullRequests, thread.linkedPullRequest, thread.branchPullRequest, @@ -104,6 +110,7 @@ export function useThreadPr(thread: EnvironmentThreadShell): ThreadPrPresentatio resolve, ], ); + const pullRequestRef = source?.pullRequestRef ?? null; const key = pullRequestRef === null ? null : snapshotKey(thread.environmentId, pullRequestRef); // Select this row's entry so answers for other pull requests do not re-render it. const snapshot = useAtomValue(pullRequestSnapshotsAtom, (current) => @@ -135,5 +142,5 @@ export function useThreadPr(thread: EnvironmentThreadShell): ThreadPrPresentatio }, resolve, ); - return linkedPresentation ?? summaryPresentation; + return source?.linkedPresentation ?? summaryPresentation; } diff --git a/docs/user/thread-sidebar.md b/docs/user/thread-sidebar.md index 03f88abd79e49..da9b6dd9003f0 100644 --- a/docs/user/thread-sidebar.md +++ b/docs/user/thread-sidebar.md @@ -167,6 +167,9 @@ On mobile, turn on **Settings → General → Sidebar → Group threads by proje project layout. Your Working section preference is preserved and returns when you turn project layout off. Searching shows matching threads across folders, including collapsed ones. +Turn off **Show pull request badges** in the same Sidebar settings to hide pull request badges +from the mobile thread list. + ## Settle finished work Choose **Settle thread** from its menu to move finished work out of the active list