Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/mobile/src/features/home/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
16 changes: 15 additions & 1 deletion apps/mobile/src/features/settings/ThreadSettingsSections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand All @@ -236,6 +241,15 @@ export function WorkingSectionSettings() {
void savePreferences({ threadListProjectFoldersEnabled: value });
}}
/>
<SettingsSwitchRow
icon="arrow.triangle.branch"
label={gt("Show pull request badges")}
value={showPullRequestBadges}
disabled={!loaded}
onValueChange={(value) => {
void savePreferences({ threadListPullRequestBadgesEnabled: value });
}}
/>
<SettingsSwitchRow
icon="bolt.circle"
label={gt("Working section")}
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/src/features/settings/settings-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ const SETTINGS_SEARCH_TERMS = {
msg("working section", { $context: "settings search keyword" }),
msg("group threads by project", { $context: "settings search keyword" }),
msg("project folders", { $context: "settings search keyword" }),
msg("Show pull request badges"),
msg("git status", { $context: "settings search keyword" }),
msg("new threads", { $context: "settings search keyword" }),
msg("last project", { $context: "settings search keyword" }),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) {
onNewThreadOnBranch={props.onNewThreadOnBranch}
thread={thread}
variant={item.item.variant}
inProjectFolder={item.inProjectFolder}
hasQueuedMessages={item.hasQueuedMessages}
snoozed={item.item.snoozed}
pinned={item.item.pinned}
Expand Down
18 changes: 14 additions & 4 deletions apps/mobile/src/features/threads/thread-list-v2-items.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as Dialog from "../../components/ui/Dialog";
import { useAtomValue } from "@effect/atom-react";
import type { ThreadRowProviderInstance } from "./thread-provider-instance";
import {
THREAD_LIST_V2_MONO_FONT as MONO_FONT,
Expand Down Expand Up @@ -70,6 +71,7 @@ import {
type ThreadPrPresentation,
} from "../../state/thread-pr-presentation";
import { useThreadPr } from "../../state/use-thread-pr";
import { threadListPullRequestBadgesEnabledAtom } from "../../state/preferences";
import { useSwipeRowDormant } from "../home/swipe-row-activation";
import { ThreadSwipeable } from "../home/thread-swipe-actions";
import { buildThreadTitleRegenerationMenuItems } from "./thread-title-regeneration-menu";
Expand Down Expand Up @@ -745,6 +747,7 @@ export const ThreadListV2PendingRow = memo(function ThreadListV2PendingRow(props
export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
readonly thread: EnvironmentThreadShell;
readonly variant: "card" | "slim";
readonly inProjectFolder?: boolean;
readonly hasQueuedMessages?: boolean;
readonly snoozed?: boolean;
readonly pinned?: boolean;
Expand Down Expand Up @@ -856,7 +859,8 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
showBadge: providerInstance.showBadge,
})
: null;
const pr = useThreadPr(thread);
const showPullRequestBadges = useAtomValue(threadListPullRequestBadgesEnabledAtom);
const pr = useThreadPr(thread, showPullRequestBadges);
const prBadgeLabel = pr ? resolveThreadPrBadgeAction(pr, m).accessibilityLabel : null;
const handleOpenPullRequests = useCallback(() => {
if (pr) onOpenThreadPullRequests(thread, pr);
Expand All @@ -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);
Expand Down Expand Up @@ -1754,10 +1760,14 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
);

if (!canOperateThread)
return <View style={rowAppearance.swipeContainerStyle}>{rowContent(() => {})}</View>;
return (
<View style={[rowAppearance.swipeContainerStyle, projectIndentStyle]}>
{rowContent(() => {})}
</View>
);

return (
<View collapsable={false}>
<View collapsable={false} style={projectIndentStyle}>
{customSnoozeOpen && (
<CustomSnoozeSheet onClose={() => setCustomSnoozeOpen(false)} onSnooze={handleSnooze} />
)}
Expand All @@ -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}
Expand Down
4 changes: 3 additions & 1 deletion apps/mobile/src/features/threads/threadListV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 &&
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion apps/mobile/src/i18n/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
4 changes: 3 additions & 1 deletion apps/mobile/src/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
4 changes: 3 additions & 1 deletion apps/mobile/src/i18n/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
4 changes: 3 additions & 1 deletion apps/mobile/src/i18n/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
4 changes: 3 additions & 1 deletion apps/mobile/src/i18n/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -5761,5 +5761,7 @@
"7367ac6d7473df6c": "{project}、非表示のスレッド {count} 件",
"5af190a4b64e6d6f": "{project}、非表示のスレッド {count} 件、{status}",
"1acf5ae561eb2754": "プロジェクトを折りたたみます",
"793a282af8116867": "プロジェクトを展開します"
"793a282af8116867": "プロジェクトを展開します",
"f53591648d8bb1ec": "プルリクエストのバッジを表示",
"29feb17e28bbb67b": "Git の状態"
}
4 changes: 3 additions & 1 deletion apps/mobile/src/i18n/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -5767,5 +5767,7 @@
"7367ac6d7473df6c": "{project}, 숨겨진 스레드 {count}개",
"5af190a4b64e6d6f": "{project}, 숨겨진 스레드 {count}개, {status}",
"1acf5ae561eb2754": "프로젝트를 접습니다",
"793a282af8116867": "프로젝트를 펼칩니다"
"793a282af8116867": "프로젝트를 펼칩니다",
"f53591648d8bb1ec": "풀 리퀘스트 배지 표시",
"29feb17e28bbb67b": "Git 상태"
}
4 changes: 3 additions & 1 deletion apps/mobile/src/i18n/translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
4 changes: 3 additions & 1 deletion apps/mobile/src/i18n/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -5861,5 +5861,7 @@
"7367ac6d7473df6c": "{project}, скрыто тредов: {count}",
"5af190a4b64e6d6f": "{project}, скрыто тредов: {count}, {status}",
"1acf5ae561eb2754": "Сворачивает проект",
"793a282af8116867": "Разворачивает проект"
"793a282af8116867": "Разворачивает проект",
"f53591648d8bb1ec": "Показывать значки пул-реквестов",
"29feb17e28bbb67b": "статус Git"
}
4 changes: 3 additions & 1 deletion apps/mobile/src/i18n/translations/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
4 changes: 3 additions & 1 deletion apps/mobile/src/i18n/translations/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -5771,5 +5771,7 @@
"7367ac6d7473df6c": "{project},{count} 个隐藏会话",
"5af190a4b64e6d6f": "{project},{count} 个隐藏会话,{status}",
"1acf5ae561eb2754": "折叠项目",
"793a282af8116867": "展开项目"
"793a282af8116867": "展开项目",
"f53591648d8bb1ec": "显示拉取请求徽章",
"29feb17e28bbb67b": "Git 状态"
}
5 changes: 5 additions & 0 deletions apps/mobile/src/persistence/mobile-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<{
Expand Down Expand Up @@ -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"];
Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 8 additions & 0 deletions apps/mobile/src/state/preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
);
34 changes: 31 additions & 3 deletions apps/mobile/src/state/use-thread-pr.demand.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<output data-name={name} data-passive={passive}>
{pr?.accessibilityLabel ?? "none"}
Expand Down Expand Up @@ -201,19 +209,21 @@ 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(
<RegistryContext value={registry}>
<Activity mode={activity}>
<div hidden={!visible} style={{ width: 320 }}>
<ThreadPrDemandProvider visible={visible}>
<Row value={value} name="sidebar" />
<Row value={value} name="sidebar" badgeEnabled={badgeEnabled} />
</ThreadPrDemandProvider>
</div>
</Activity>
Expand Down Expand Up @@ -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();
Expand Down
Loading
Loading