Skip to content

Commit 0fed439

Browse files
authored
Merge branch 'main' into main
2 parents c988d11 + 849bac8 commit 0fed439

51 files changed

Lines changed: 4561 additions & 870 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/VOUCHED.td‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ github:shivamhwp
3737
github:jappyjan
3838
github:justsomelegs
3939
github:UtkarshUsername
40+
github:SunkenInTime

‎apps/mobile/src/features/home/HomeRouteScreen.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export function HomeRouteScreen() {
4545
pinThread,
4646
unpinThread,
4747
movePinnedThread,
48+
regenerateThreadTitle,
4849
unsettleThread,
4950
} = useThreadListActions();
5051
const pendingTasks = usePendingNewTasks();
@@ -186,6 +187,7 @@ export function HomeRouteScreen() {
186187
onPinThread={pinThread}
187188
onUnpinThread={unpinThread}
188189
onMovePinnedThread={movePinnedThread}
190+
onRegenerateThreadTitle={regenerateThreadTitle}
189191
onEnvironmentChange={setSelectedEnvironmentId}
190192
onProjectChange={setSelectedProjectKey}
191193
onOpenSettings={() =>

‎apps/mobile/src/features/home/HomeScreen.tsx‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ interface HomeScreenProps {
115115
thread: EnvironmentThreadShell,
116116
direction: "up" | "down",
117117
) => Promise<boolean>;
118+
readonly onRegenerateThreadTitle: (thread: EnvironmentThreadShell) => Promise<boolean>;
118119
readonly onSelectPendingTask: (pendingTask: PendingNewTask) => void;
119120
readonly onDeletePendingTask: (pendingTask: PendingNewTask) => void;
120121
readonly onNewThreadInProject: (project: EnvironmentProject) => void;
@@ -538,6 +539,12 @@ export function HomeScreen(props: HomeScreenProps) {
538539
},
539540
[props.onUnpinThread],
540541
);
542+
const handleRegenerateThreadTitle = useCallback(
543+
(thread: EnvironmentThreadShell) => {
544+
void props.onRegenerateThreadTitle(thread);
545+
},
546+
[props.onRegenerateThreadTitle],
547+
);
541548
const handleDeleteThread = props.onDeleteThread;
542549
const handleUnsettleThread = props.onUnsettleThread;
543550
// The settled tail renders in pages; expansion resets when the filter
@@ -615,6 +622,15 @@ export function HomeScreen(props: HomeScreenProps) {
615622
}
616623
return supported;
617624
}, [serverConfigs]);
625+
const titleRegenerationEnvironmentIds = useMemo(() => {
626+
const supported = new Set<EnvironmentId>();
627+
for (const [environmentId, config] of serverConfigs) {
628+
if (config.environment.capabilities.threadTitleRegeneration === true) {
629+
supported.add(environmentId);
630+
}
631+
}
632+
return supported;
633+
}, [serverConfigs]);
618634
// Canonical arranged pinned order (reorder-capable threads only) for the
619635
// Move up/down position flags. Computed from all shells, not the rendered
620636
// list, so search/scope filtering never disables or misdirects a move.
@@ -811,6 +827,8 @@ export function HomeScreen(props: HomeScreenProps) {
811827
onSelectThread={props.onSelectThread}
812828
onDeleteThread={handleDeleteThread}
813829
onArchiveThread={props.onArchiveThread}
830+
onRegenerateThreadTitle={handleRegenerateThreadTitle}
831+
titleRegenerationSupported={titleRegenerationEnvironmentIds.has(thread.environmentId)}
814832
settlementSupported={settlementEnvironmentIds.has(thread.environmentId)}
815833
onSettleThread={handleSettleThread}
816834
snoozeSupported={snoozeEnvironmentIds.has(thread.environmentId)}
@@ -842,6 +860,7 @@ export function HomeScreen(props: HomeScreenProps) {
842860
arrangedPinnedKeys,
843861
handleMovePinnedThread,
844862
handlePinThread,
863+
handleRegenerateThreadTitle,
845864
handleSettleThread,
846865
handleSnoozeThread,
847866
handleUnpinThread,
@@ -863,6 +882,7 @@ export function HomeScreen(props: HomeScreenProps) {
863882
snoozeEnvironmentIds,
864883
threadListV2Items,
865884
threadSearchMatchByKey,
885+
titleRegenerationEnvironmentIds,
866886
toggleSettledShelf,
867887
toggleSnoozedShelf,
868888
v2ProjectTitleByProjectKey,
@@ -967,6 +987,8 @@ export function HomeScreen(props: HomeScreenProps) {
967987
searchQuery={props.searchQuery}
968988
onArchiveThread={props.onArchiveThread}
969989
onDeleteThread={props.onDeleteThread}
990+
onRegenerateThreadTitle={handleRegenerateThreadTitle}
991+
titleRegenerationSupported={titleRegenerationEnvironmentIds.has(thread.environmentId)}
970992
onSelectThread={props.onSelectThread}
971993
onSwipeableClose={handleSwipeableClose}
972994
onSwipeableWillOpen={handleSwipeableWillOpen}
@@ -988,6 +1010,7 @@ export function HomeScreen(props: HomeScreenProps) {
9881010
[
9891011
handleSwipeableClose,
9901012
handleSwipeableWillOpen,
1013+
handleRegenerateThreadTitle,
9911014
projectCwdByKey,
9921015
props.onArchiveThread,
9931016
props.onDeletePendingTask,
@@ -998,6 +1021,7 @@ export function HomeScreen(props: HomeScreenProps) {
9981021
props.searchQuery,
9991022
props.savedConnectionsById,
10001023
threadSearchMatchByKey,
1024+
titleRegenerationEnvironmentIds,
10011025
updateGroupDisplay,
10021026
],
10031027
);

‎apps/mobile/src/features/home/useThreadListActions.ts‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ function environmentSupportsPinReorder(environmentId: EnvironmentThreadShell["en
4848
);
4949
}
5050

51+
function environmentSupportsTitleRegeneration(
52+
environmentId: EnvironmentThreadShell["environmentId"],
53+
) {
54+
return (
55+
appAtomRegistry.get(environmentServerConfigsAtom).get(environmentId)?.environment.capabilities
56+
.threadTitleRegeneration === true
57+
);
58+
}
59+
5160
type ThreadListAction = "archive" | "unarchive" | "delete" | "settle" | "unsettle";
5261

5362
const ACTION_VERBS: Record<ThreadListAction, string> = {
@@ -227,13 +236,18 @@ export function useThreadListActions(): {
227236
thread: EnvironmentThreadShell,
228237
direction: "up" | "down",
229238
) => Promise<boolean>;
239+
readonly regenerateThreadTitle: (thread: EnvironmentThreadShell) => Promise<boolean>;
230240
} {
231241
const executeAction = useThreadActionExecutor();
232242
const snoozeMutation = useAtomCommand(threadEnvironment.snooze, { reportFailure: false });
233243
const unsnoozeMutation = useAtomCommand(threadEnvironment.unsnooze, { reportFailure: false });
234244
const pinMutation = useAtomCommand(threadEnvironment.pin, { reportFailure: false });
235245
const unpinMutation = useAtomCommand(threadEnvironment.unpin, { reportFailure: false });
246+
const updateThreadMetadata = useAtomCommand(threadEnvironment.updateMetadata, {
247+
reportFailure: false,
248+
});
236249
const snoozeInFlightThreadKeys = useRef(new Set<string>());
250+
const titleRegenerationInFlightThreadKeys = useRef(new Set<string>());
237251

238252
const archiveThread = useCallback(
239253
(thread: EnvironmentThreadShell) => {
@@ -405,6 +419,47 @@ export function useThreadListActions(): {
405419
},
406420
[unpinMutation],
407421
);
422+
const regenerateThreadTitle = useCallback(
423+
async (thread: EnvironmentThreadShell) => {
424+
const key = scopedThreadKey(thread.environmentId, thread.id);
425+
if (
426+
thread.titleRegeneration != null ||
427+
titleRegenerationInFlightThreadKeys.current.has(key)
428+
) {
429+
return false;
430+
}
431+
if (!environmentSupportsTitleRegeneration(thread.environmentId)) {
432+
Alert.alert(
433+
"Could not regenerate title",
434+
"This environment's server does not support title regeneration yet. Update the server to regenerate thread titles.",
435+
);
436+
return false;
437+
}
438+
439+
titleRegenerationInFlightThreadKeys.current.add(key);
440+
selectionHaptic();
441+
try {
442+
const result = await updateThreadMetadata({
443+
environmentId: thread.environmentId,
444+
input: { threadId: thread.id, regenerateTitle: true },
445+
});
446+
if (result._tag === "Failure") {
447+
const error = Cause.squash(result.cause);
448+
Alert.alert(
449+
"Could not regenerate title",
450+
error instanceof Error && error.message.trim().length > 0
451+
? error.message
452+
: "The thread title could not be regenerated.",
453+
);
454+
return false;
455+
}
456+
return true;
457+
} finally {
458+
titleRegenerationInFlightThreadKeys.current.delete(key);
459+
}
460+
},
461+
[updateThreadMetadata],
462+
);
408463

409464
// Move up / Move down for the pinned block. Computed against the CANONICAL
410465
// keyed pinned order (not the rendered list), so the move is valid even
@@ -497,6 +552,7 @@ export function useThreadListActions(): {
497552
pinThread,
498553
unpinThread,
499554
movePinnedThread,
555+
regenerateThreadTitle,
500556
};
501557
}
502558

‎apps/mobile/src/features/threads/ThreadFeed.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ import { useMarkdownCodeHighlight } from "./markdownCodeHighlightState";
104104
import { useAssetUrl } from "../../state/assets";
105105
import { resolveWorkspaceRelativeFilePath } from "../files/filePath";
106106

107+
const WIDE_MARKDOWN_BLOCK_OPTIONS = {
108+
includeOrderedLists: Platform.OS === "android",
109+
} as const;
110+
107111
const MESSAGE_TIME_FORMATTER = new Intl.DateTimeFormat(undefined, {
108112
hour: "numeric",
109113
minute: "2-digit",
@@ -888,7 +892,7 @@ function renderFeedEntry(
888892
// children during the unclamped pass and never moves them once the width
889893
// is clamped, so the paragraphs around the block end up drawn on top of
890894
// each other. Pinning the width removes that pass.
891-
const hasWideBlock = hasWideMarkdownBlock(message.text);
895+
const hasWideBlock = hasWideMarkdownBlock(message.text, WIDE_MARKDOWN_BLOCK_OPTIONS);
892896
const assistantTurnStillInProgress =
893897
message.role === "assistant" &&
894898
props.unsettledTurnId !== null &&

‎apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ function ThreadNavigationSidebarPane(
211211
pinThread,
212212
unpinThread,
213213
movePinnedThread,
214+
regenerateThreadTitle,
214215
} = useThreadListActions();
215216
const threadListV2Enabled = useThreadListV2Enabled();
216217
const pendingTasks = usePendingNewTasks();
@@ -505,6 +506,15 @@ function ThreadNavigationSidebarPane(
505506
}
506507
return supported;
507508
}, [serverConfigs]);
509+
const titleRegenerationEnvironmentIds = useMemo(() => {
510+
const supported = new Set<EnvironmentId>();
511+
for (const [environmentId, config] of serverConfigs) {
512+
if (config.environment.capabilities.threadTitleRegeneration === true) {
513+
supported.add(environmentId);
514+
}
515+
}
516+
return supported;
517+
}, [serverConfigs]);
508518
// Canonical arranged pinned order for Move up/down flags — computed from
509519
// all shells so search/scope filtering never disables a valid move.
510520
const arrangedPinnedKeys = useMemo(() => {
@@ -950,6 +960,8 @@ function ThreadNavigationSidebarPane(
950960
onSelectThread={handleSelectThread}
951961
onDeleteThread={confirmDeleteThread}
952962
onArchiveThread={archiveThread}
963+
onRegenerateThreadTitle={regenerateThreadTitle}
964+
titleRegenerationSupported={titleRegenerationEnvironmentIds.has(thread.environmentId)}
953965
settlementSupported={settlementEnvironmentIds.has(thread.environmentId)}
954966
onSettleThread={settleThread}
955967
snoozeSupported={snoozeEnvironmentIds.has(thread.environmentId)}
@@ -1067,6 +1079,8 @@ function ThreadNavigationSidebarPane(
10671079
fullSwipeWidth={props.width - 20}
10681080
onArchiveThread={archiveThread}
10691081
onDeleteThread={confirmDeleteThread}
1082+
onRegenerateThreadTitle={regenerateThreadTitle}
1083+
titleRegenerationSupported={titleRegenerationEnvironmentIds.has(thread.environmentId)}
10701084
onSelectThread={handleSelectThread}
10711085
onSwipeableClose={handleSwipeableClose}
10721086
onSwipeableWillOpen={handleSwipeableWillOpen}
@@ -1103,13 +1117,15 @@ function ThreadNavigationSidebarPane(
11031117
projectByKey,
11041118
projectCwdByKey,
11051119
projectTitleByProjectKey,
1120+
regenerateThreadTitle,
11061121
props.onNewThreadInProject,
11071122
props.searchQuery,
11081123
props.selectedThreadKey,
11091124
props.width,
11101125
savedConnectionsById,
11111126
serverConfigs,
11121127
threadSearchMatchByKey,
1128+
titleRegenerationEnvironmentIds,
11131129
settleThread,
11141130
settlementEnvironmentIds,
11151131
showMoreSettled,

‎apps/mobile/src/features/threads/thread-list-items.tsx‎

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import type { PendingNewTask } from "../../state/use-pending-new-tasks";
2222
import { useThreadPr, type ThreadPr } from "../../state/use-thread-pr";
2323
import type { HomeGroupDisplayAction } from "../home/homeListItems";
2424
import { ThreadSwipeable } from "../home/thread-swipe-actions";
25+
import { buildThreadTitleRegenerationMenuItems } from "./thread-title-regeneration-menu";
2526
import { resolveThreadStatus } from "./threadPresentation";
2627
import { ThreadSearchMatchExcerpt } from "./thread-search-match";
2728

@@ -430,6 +431,8 @@ export const ThreadListRow = memo(function ThreadListRow(props: {
430431
readonly onSelectThread: (thread: EnvironmentThreadShell) => void;
431432
readonly onArchiveThread: (thread: EnvironmentThreadShell) => void;
432433
readonly onDeleteThread: (thread: EnvironmentThreadShell) => void;
434+
readonly onRegenerateThreadTitle: (thread: EnvironmentThreadShell) => void;
435+
readonly titleRegenerationSupported: boolean;
433436
readonly onSwipeableWillOpen: (methods: SwipeableMethods) => void;
434437
readonly onSwipeableClose: (methods: SwipeableMethods) => void;
435438
readonly simultaneousSwipeGesture?: ComponentProps<
@@ -451,7 +454,8 @@ export const ThreadListRow = memo(function ThreadListRow(props: {
451454
const pressedBackgroundColor = useThemeColor("--color-subtle");
452455
const selectedBackgroundColor = useThemeColor("--color-user-bubble");
453456

454-
const { thread, onSelectThread, onArchiveThread, onDeleteThread } = props;
457+
const { thread, onSelectThread, onArchiveThread, onDeleteThread, onRegenerateThreadTitle } =
458+
props;
455459
const status = resolveThreadStatus(thread);
456460
const pr = useThreadPr(thread, props.projectCwd);
457461
const timestamp = relativeTime(
@@ -471,6 +475,21 @@ export const ThreadListRow = memo(function ThreadListRow(props: {
471475

472476
const handleDelete = useCallback(() => onDeleteThread(thread), [onDeleteThread, thread]);
473477
const handleArchive = useCallback(() => onArchiveThread(thread), [onArchiveThread, thread]);
478+
const handleRegenerateTitle = useCallback(
479+
() => onRegenerateThreadTitle(thread),
480+
[onRegenerateThreadTitle, thread],
481+
);
482+
const menuActions = useMemo<MenuAction[]>(
483+
() => [
484+
THREAD_ROW_MENU_ACTIONS[0]!,
485+
...buildThreadTitleRegenerationMenuItems({
486+
supported: props.titleRegenerationSupported,
487+
isRegenerating: thread.titleRegeneration != null,
488+
}),
489+
THREAD_ROW_MENU_ACTIONS[1]!,
490+
],
491+
[props.titleRegenerationSupported, thread.titleRegeneration],
492+
);
474493
const primaryAction = useMemo(
475494
() => ({
476495
accessibilityLabel: `Archive ${thread.title}`,
@@ -483,9 +502,10 @@ export const ThreadListRow = memo(function ThreadListRow(props: {
483502
const handleMenuAction = useCallback(
484503
({ nativeEvent }: { readonly nativeEvent: { readonly event: string } }) => {
485504
if (nativeEvent.event === "archive") handleArchive();
505+
if (nativeEvent.event === "regenerate-title") handleRegenerateTitle();
486506
if (nativeEvent.event === "delete") handleDelete();
487507
},
488-
[handleArchive, handleDelete],
508+
[handleArchive, handleDelete, handleRegenerateTitle],
489509
);
490510

491511
const statusPill = effectiveStatus ? (
@@ -674,7 +694,7 @@ export const ThreadListRow = memo(function ThreadListRow(props: {
674694
// ControlPillMenu injects onLongPress into the row and anchors the
675695
// token-styled dropdown to it; taps and swipes are untouched.
676696
<ControlPillMenu
677-
actions={THREAD_ROW_MENU_ACTIONS}
697+
actions={menuActions}
678698
onPressAction={handleMenuAction}
679699
shouldOpenOnLongPress
680700
>

0 commit comments

Comments
 (0)