Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
cacf444
Refine archived settings panel UX
Quicksaver Jun 24, 2026
57a1e76
Move archived project actions into context menu
Quicksaver Jun 25, 2026
67a0477
Add archive thread search and ranked filtering
Quicksaver Jun 25, 2026
da19562
Scope archive bulk actions to visible threads
Quicksaver Jun 25, 2026
5d9ac5a
Fix archive project bulk actions during search
Quicksaver Jun 25, 2026
d8cb38b
Scope archive bulk actions to visible rows
Quicksaver Jun 25, 2026
1b02962
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jun 25, 2026
74fcff2
Respect archive delete confirmation setting
Quicksaver Jun 25, 2026
6167a3d
Clarify archived bulk failure toasts
Quicksaver Jun 25, 2026
9653b5b
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jun 25, 2026
5455c7e
Port archive settings review fix
Quicksaver Jun 25, 2026
b6ad57b
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jun 25, 2026
e493576
Address archive settings review follow-ups
Quicksaver Jun 26, 2026
8405c06
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jun 26, 2026
7d9e19f
Refactor archived settings logic
Quicksaver Jun 26, 2026
8fb00f4
Fix archived project bulk action errors
Quicksaver Jun 26, 2026
a5b1b97
Fix archived settings review issues
Quicksaver Jun 26, 2026
0c08df9
Fix archived confirmation fallback
Quicksaver Jun 26, 2026
a579f7e
Fix archived project grouping keys
Quicksaver Jun 26, 2026
5ff0c25
Fix archived project UI keys
Quicksaver Jun 26, 2026
5d8b2f3
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jun 27, 2026
b07ae41
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jun 27, 2026
6ae2079
Move archived settings into a dedicated panel
Quicksaver Jun 27, 2026
39e2452
Fix archived project action access
Quicksaver Jun 27, 2026
19e1ffa
Align archived thread rows with headers
Quicksaver Jun 27, 2026
9ccfdce
Fix archived settings review issues
Quicksaver Jun 27, 2026
3c509f3
Fix archive action confirmation fallback
Quicksaver Jun 27, 2026
0d07f3a
Handle archive bulk action exceptions
Quicksaver Jun 27, 2026
10632e1
Fetch archive settings across all environments
Quicksaver Jun 27, 2026
26eea31
Clarify filtered archive bulk menu actions
Quicksaver Jun 27, 2026
5c7e395
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jun 29, 2026
c8e2721
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 1, 2026
c7dacda
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 3, 2026
69785d4
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 4, 2026
26733f7
Merge remote-tracking branch 'refs/remotes/upstream/main' into split/…
Quicksaver Jul 5, 2026
e27d68a
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 10, 2026
ee7557c
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 13, 2026
0cfc5ee
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 15, 2026
d6355b5
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 16, 2026
9d1de46
Add archive settings branch details
Quicksaver Jul 17, 2026
7e60c51
Remove unrelated archive behavior claim
Quicksaver Jul 17, 2026
d13a277
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 18, 2026
7c4995d
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 19, 2026
f5e2450
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 19, 2026
89256c8
Expand native archived threads management
Quicksaver Jul 19, 2026
5fe8242
Document native archive settings UX behavior
Quicksaver Jul 19, 2026
4c4555c
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 19, 2026
d8f7c59
Configure pnpm virtual store and Effect Vitest peers
Quicksaver Jul 19, 2026
5629fc9
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 20, 2026
556df7c
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 20, 2026
0babd24
Fix archive sorting and failure feedback
Quicksaver Jul 20, 2026
7aa53f0
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 20, 2026
bf242fd
Fix archive review regressions
Quicksaver Jul 20, 2026
7e257a4
Surface mobile archive bulk failure details
Quicksaver Jul 20, 2026
6f38d10
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 21, 2026
fd6316d
Show environment labels in archived project headers
Quicksaver Jul 21, 2026
8463f78
Add multi-environment archive label coverage
Quicksaver Jul 21, 2026
30e519e
Distinguish skipped archive actions
Quicksaver Jul 21, 2026
2485e27
Preserve archive search ranking tiers
Quicksaver Jul 21, 2026
2dd5fe6
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 22, 2026
355171e
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 22, 2026
eceaec8
Test merged mobile thread action contract
Quicksaver Jul 22, 2026
cb1b9ed
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 23, 2026
64667ad
Adapt archive UX to current upstream
Quicksaver Jul 23, 2026
92e2c41
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 23, 2026
ad79c99
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 23, 2026
6937933
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 23, 2026
6dc2e6a
Test archived-only project deletion safeguard
Quicksaver Jul 23, 2026
b23d02c
Strengthen archived project deletion test
Quicksaver Jul 23, 2026
1f4de96
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 23, 2026
19d8ffb
Prevent overlapping web archive mutations
Quicksaver Jul 23, 2026
565d10a
Refine web archive action feedback
Quicksaver Jul 23, 2026
53dd9a0
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 23, 2026
d465583
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 23, 2026
293c010
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 23, 2026
ab00425
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 24, 2026
e42c5a8
Test snoozed threads stay out of archives
Quicksaver Jul 24, 2026
bfde736
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 24, 2026
15dc499
Fix mobile archive action reservations
Quicksaver Jul 24, 2026
6ba8c8f
Preserve archive action and search state
Quicksaver Jul 24, 2026
9235306
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 24, 2026
8fe838a
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 25, 2026
81483c3
Make mobile thread action keys collision-safe
Quicksaver Jul 26, 2026
2eaa900
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 27, 2026
3441204
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 27, 2026
c403a81
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Quicksaver Jul 27, 2026
963f2cb
Merge commit '96398e3775fc6c74525e4a211e75e580c6cf4225' into split/ar…
Quicksaver Jul 27, 2026
cf2996a
Merge commit '32843c2551bd5832d436ef46bff5ab1198cdc39c' into split/ar…
Quicksaver Jul 27, 2026
c281ad8
Merge commit '887dd6e455bb969c1a0c9659a6bdf2baceac030d' into split/ar…
Jul 28, 2026
79e5efb
Fix ascending archive project ordering
Jul 28, 2026
80ffdfb
Avoid spreading archive project timestamps
Jul 28, 2026
6dabe11
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Jul 28, 2026
8eeb294
docs: document archive workflows
Jul 28, 2026
e18c872
docs: track archive documentation surface
Jul 28, 2026
a95f995
Merge commit '2919147c80e4daae326a25f870a1c7b19cd16f42' into split/ar…
Jul 28, 2026
f0b32c3
Merge commit '8650f05f95ac9f19254de679fdf4b380c37d7b94' into split/ar…
Jul 29, 2026
978a077
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Jul 29, 2026
ca09d03
Refactor shared native settings contract
Jul 29, 2026
46db3ae
Document shared native settings contract
Jul 29, 2026
b27b142
Remove unused waitlist alias target
Jul 29, 2026
d39a858
Merge commit '1b4830ff06bf80e505dbf669deef189af85f77d7' into split/ar…
Jul 29, 2026
e2c15bc
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Jul 29, 2026
e699a4c
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Jul 29, 2026
495783b
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Jul 29, 2026
90745da
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Jul 29, 2026
3d969ba
Merge remote-tracking branch 'upstream/main' into split/archive-setti…
Jul 30, 2026
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
41 changes: 41 additions & 0 deletions BRANCH_DETAILS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Archive Settings UX

The settings Archive panel uses a dense layout so large archives remain scannable. The native mobile Archived Threads screen mirrors the same information hierarchy and behavior with mobile-native project sections, swipe actions, long-press menus, and header controls.

Expected behavior:

- Archived conversations are grouped by project, and each project group is collapsed by default.
- The Archive panel fetches archived thread snapshots from all configured environments, not only environments that currently have active projects, so archived-only workspaces remain visible, while active rows returned in those snapshots remain excluded from archive content and empty-state counts.
- Web project headers show environment labels whenever multiple environments are configured and keep a sole remote environment labeled, while a sole primary environment remains implicit. Native project sections show environment labels and the header controls can filter the archive to all environments or one configured environment.
- Native Settings exposes `Archived Threads` in both local-only and T3 Connect-configured modes through a shared `General`, `Appearance`, `Beta`, `Archive`, and `App` tail, preserving that order while each mode keeps its own account and configuration controls. The native settings contract owns the `SettingsArchive` route name, link, and title plus the legacy `SettingsWaitlist` alias metadata, while the native stack keeps that distinct alias pointed at `SettingsAuth`.
- The page includes a search box that filters archived thread titles across all projects case-insensitively. Multi-word searches match any term, rank exact phrase matches first, rank titles matching every term ahead of partial term matches, and auto-open matching project groups while search is active. Native incremental search updates the existing list without remounting it for every keystroke, preserving scroll position and transient row state.
- Expanded project headers include sortable `Archived` and `Created` columns; clicking either header toggles ascending/descending order for the conversations inside each group, with `Archived` descending as the default.
- Native project-section ordering follows the selected archive sort field and direction. Invalid archived timestamps fall back to the conversation's created timestamp for sorting and display on both surfaces.
- Native row and bulk actions share collision-safe per-thread reservations and action-executor identity keys, reserve bulk targets before confirmation, expose busy state only after confirmation, disable overlapping swipe/menu controls while reserved, and distinguish rows skipped because the same thread action is already in progress from commands that actually fail.
- Web row and project actions reserve collision-safe per-thread locks before confirmation, expose busy state only for the threads owned by actions that have started after confirmation, disable overlapping controls while mutations run, give explicit feedback for rejected duplicates, and refresh archived snapshots once after bulk attempts instead of between concurrent mutations.
- Conversation rows show only the relative archived and created ages inline with the title by default. On web row hover or keyboard focus, those age labels fade out and icon-only unarchive/delete actions appear as a right-side overlay with tooltips, matching the sidebar and source-control list-row action pattern. Native rows keep both age columns visible and expose the same actions through swipe gestures and the standard long-press context menu.
- Archived conversations can be deleted directly from the Archive panel without unarchiving first. Web delete actions respect the shared `confirmThreadDelete` client setting, while native keeps its standard guarded delete flow.
- Project group context menus expose `unarchive all` and `delete all` actions. While search is active, those bulk actions apply to the visible matching archived conversations and use matching-specific menu labels; otherwise they apply to all archived conversations in the project. Delete confirmations respect `confirmThreadDelete` on web and remain explicitly guarded on native; unarchive bulk actions remain guarded on both surfaces, and partial failures surface as not-fully-completed feedback instead of implying every archived thread failed.
- Archive grouping, search ranking, sort state, and project bulk-action concurrency live in `apps/web/src/components/settings/SettingsPanels.logic.ts` on web and `apps/mobile/src/features/archive/archivedThreadList.ts` on native so the dense Archive behavior stays covered without growing the React components. Project groups expose and reuse collision-safe keys so project ids containing separator characters do not collapse expansion state or React row identity. Bulk actions stop scheduling new work after thrown failures, wait for active workers to settle, preserve the completed success/failure/skipped outcome counts, show incomplete-operation feedback, and surface the underlying exception messages instead of only a generic aggregate error. The Archive surfaces refresh archived threads after bulk unarchive/delete attempts even when the action runner throws.
- The user guide documents Archive as a reversible thread-lifecycle action, covers the web, desktop, and mobile controls and safeguards, and explains that search scopes project bulk actions to visible matches. The documentation index links the guide, and the encyclopedia defines the Archive term separately from permanent deletion.

Primary files:

- `apps/web/src/components/settings/ArchiveSettings.tsx`
- `apps/web/src/components/settings/SettingsPanels.tsx`
- `apps/web/src/components/settings/SettingsPanels.logic.ts`
- `apps/mobile/src/Stack.tsx`
- `apps/mobile/src/features/settings/SettingsRouteScreen.tsx`
- `apps/mobile/src/features/settings/settingsContract.ts`
- `apps/mobile/src/features/settings/settingsContract.test.ts`
- `apps/mobile/src/features/archive/ArchivedThreadsRouteScreen.tsx`
- `apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx`
- `apps/mobile/src/features/archive/archivedThreadList.ts`
- `docs/user/archive.md`
- `docs/reference/encyclopedia.md`
- `docs/README.md`

## Development Ports

- Web: `5734`
- Server/WebSocket: `13774`
16 changes: 10 additions & 6 deletions apps/mobile/src/Stack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ import { SettingsAuthRouteScreen } from "./features/settings/SettingsAuthRouteSc
import { SettingsEnvironmentsRouteScreen } from "./features/settings/SettingsEnvironmentsRouteScreen";
import { SettingsLegalRouteScreen } from "./features/settings/SettingsLegalRouteScreen";
import { SettingsRouteScreen } from "./features/settings/SettingsRouteScreen";
import {
SETTINGS_ARCHIVE_ROUTE_CONTRACT,
SETTINGS_WAITLIST_ALIAS_ROUTE_CONTRACT,
} from "./features/settings/settingsContract";
import { ShowcaseCaptureCoordinator } from "./features/showcase/ShowcaseCaptureCoordinator";
import {
SettingsLegalDocumentCloseHeaderButton,
Expand Down Expand Up @@ -160,11 +164,11 @@ const SettingsSheetStack = createNativeStackNavigator({
title: "Add Environment",
},
}),
SettingsArchive: createNativeStackScreen({
[SETTINGS_ARCHIVE_ROUTE_CONTRACT.name]: createNativeStackScreen({
screen: ArchivedThreadsRouteScreen,
linking: "archive",
linking: SETTINGS_ARCHIVE_ROUTE_CONTRACT.linking,
options: {
title: "Archived Threads",
title: SETTINGS_ARCHIVE_ROUTE_CONTRACT.title,
},
}),
SettingsAppearance: createNativeStackScreen({
Expand All @@ -188,12 +192,12 @@ const SettingsSheetStack = createNativeStackNavigator({
title: "Sign in",
},
}),
SettingsWaitlist: createNativeStackScreen({
[SETTINGS_WAITLIST_ALIAS_ROUTE_CONTRACT.name]: createNativeStackScreen({
// Keep the old deep link working after the Connect GA launch.
screen: SettingsAuthRouteScreen,
linking: "waitlist",
linking: SETTINGS_WAITLIST_ALIAS_ROUTE_CONTRACT.linking,
options: {
title: "Sign in",
title: SETTINGS_WAITLIST_ALIAS_ROUTE_CONTRACT.title,
},
}),
},
Expand Down
225 changes: 199 additions & 26 deletions apps/mobile/src/features/archive/ArchivedThreadsRouteScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,73 @@ import type { EnvironmentId } from "@t3tools/contracts";
import * as Arr from "effect/Array";
import * as Order from "effect/Order";
import { useFocusEffect } from "@react-navigation/native";
import { useCallback, useMemo, useState } from "react";
import { useCallback, useMemo, useRef, useState } from "react";
import { Alert, Platform } from "react-native";

import { showConfirmDialog } from "../../components/ConfirmDialogHost";
import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
import { useClerkSettingsSheetDetent } from "../cloud/ClerkSettingsSheetDetent";
import { useArchivedThreadListActions } from "../home/useThreadListActions";
import {
ArchivedThreadsScreen,
type ArchivedThreadsHeaderEnvironment,
} from "./ArchivedThreadsScreen";
import { buildArchivedThreadGroups, type ArchivedThreadSortOrder } from "./archivedThreadList";
import {
refreshArchivedThreadsForEnvironment,
useArchivedThreadSnapshots,
} from "./useArchivedThreadSnapshots";
archivedThreadActionExceptionDescription,
archivedThreadActionSummaryDescription,
buildArchivedThreadGroups,
parseArchivedThreadSearchInput,
releaseArchivedThreadActionLock,
runArchivedThreadActions,
tryAcquireArchivedThreadActionLock,
type ArchivedThreadSortState,
} from "./archivedThreadList";
import { useArchivedThreadSnapshots } from "./useArchivedThreadSnapshots";
import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";

function confirmArchivedProjectAction(input: {
readonly title: string;
readonly message: string;
readonly confirmText: string;
readonly destructive?: boolean;
}): Promise<boolean> {
return new Promise((resolve) => {
if (Platform.OS === "ios") {
Alert.alert(input.title, input.message, [
{ text: "Cancel", style: "cancel", onPress: () => resolve(false) },
{
text: input.confirmText,
style: input.destructive ? "destructive" : "default",
onPress: () => resolve(true),
},
]);
return;
}
showConfirmDialog({
title: input.title,
message: input.message,
confirmText: input.confirmText,
destructive: input.destructive,
onCancel: () => resolve(false),
onConfirm: () => resolve(true),
});
});
}

export function ArchivedThreadsRouteScreen() {
const { expand } = useClerkSettingsSheetDetent();
const { savedConnectionsById } = useSavedRemoteConnections();
const [searchQuery, setSearchQuery] = useState("");
const [selectedEnvironmentId, setSelectedEnvironmentId] = useState<EnvironmentId | null>(null);
const [sortOrder, setSortOrder] = useState<ArchivedThreadSortOrder>("newest");
const [sort, setSort] = useState<ArchivedThreadSortState>({
field: "archivedAt",
direction: "desc",
});
const reservedThreadKeysRef = useRef(new Set<string>());
const [reservedThreadKeys, setReservedThreadKeys] = useState<ReadonlySet<string>>(
() => new Set(),
);
const [busyThreadKeys, setBusyThreadKeys] = useState<ReadonlySet<string>>(() => new Set());
const environments = useMemo<ReadonlyArray<ArchivedThreadsHeaderEnvironment>>(
() =>
Arr.sort(
Expand All @@ -40,33 +86,155 @@ export function ArchivedThreadsRouteScreen() {
() => environments.map((environment) => environment.environmentId),
[environments],
);
const environmentLabels = useMemo(
() =>
Object.fromEntries(
environments.map((environment) => [environment.environmentId, environment.label]),
),
[environments],
);
const { error, isLoading, refresh, snapshots } = useArchivedThreadSnapshots(environmentIds);
const search = useMemo(() => parseArchivedThreadSearchInput(searchQuery), [searchQuery]);
const groups = useMemo(
() =>
buildArchivedThreadGroups({
snapshots,
environmentLabels,
environmentId: selectedEnvironmentId,
searchQuery,
sortOrder,
search,
sort,
}),
[environmentLabels, searchQuery, selectedEnvironmentId, snapshots, sortOrder],
[search, selectedEnvironmentId, snapshots, sort],
);
const refreshChangedEnvironment = useCallback(
(thread: { readonly environmentId: EnvironmentId }) => {
refreshArchivedThreadsForEnvironment(thread.environmentId);
const { unarchiveThread, deleteThread } = useArchivedThreadListActions();
const tryReserveThreadActions = useCallback(
(
threads: ReadonlyArray<EnvironmentThreadShell>,
): { readonly start: () => void; readonly finish: () => void } | null => {
const lock = tryAcquireArchivedThreadActionLock(reservedThreadKeysRef.current, threads);
if (!lock) {
Alert.alert(
"Archive action already in progress",
"Wait for the current archived thread action to finish.",
);
return null;
}
setReservedThreadKeys(new Set(reservedThreadKeysRef.current));
let started = false;
return {
start: () => {
if (started) return;
started = true;
setBusyThreadKeys((current) => {
const next = new Set(current);
for (const key of lock.keys) next.add(key);
return next;
});
},
finish: () => {
releaseArchivedThreadActionLock(reservedThreadKeysRef.current, lock);
setReservedThreadKeys(new Set(reservedThreadKeysRef.current));
if (!started) return;
setBusyThreadKeys((current) => {
const next = new Set(current);
for (const key of lock.keys) next.delete(key);
return next;
});
},
};
},
[],
);
const { unarchiveThread, confirmDeleteThread } =
useArchivedThreadListActions(refreshChangedEnvironment);
const showSkippedActionFeedback = useCallback(() => {
Alert.alert(
"Archive action already in progress",
"Wait for the current archived thread action to finish.",
);
}, []);
const handleUnarchiveThread = useCallback(
async (thread: EnvironmentThreadShell) => {
const reservation = tryReserveThreadActions([thread]);
if (!reservation) return;
reservation.start();
try {
const result = await unarchiveThread(thread);
if (result === "skipped") showSkippedActionFeedback();
} finally {
reservation.finish();
}
},
[showSkippedActionFeedback, tryReserveThreadActions, unarchiveThread],
);
const handleDeleteThread = useCallback(
async (thread: EnvironmentThreadShell) => {
const reservation = tryReserveThreadActions([thread]);
if (!reservation) return;
try {
const confirmed = await confirmArchivedProjectAction({
title: "Delete thread?",
message: `“${thread.title}” will be permanently deleted, including its terminal history.`,
confirmText: "Delete",
destructive: true,
});
if (!confirmed) return;
reservation.start();
const result = await deleteThread(thread);
if (result === "skipped") showSkippedActionFeedback();
} finally {
reservation.finish();
}
Comment thread
Quicksaver marked this conversation as resolved.
},
[deleteThread, showSkippedActionFeedback, tryReserveThreadActions],
);
const handleProjectAction = useCallback(
async (
projectTitle: string,
threads: ReadonlyArray<EnvironmentThreadShell>,
scope: "all" | "matching",
action: "unarchive" | "delete",
) => {
const reservation = tryReserveThreadActions(threads);
if (!reservation) return;
try {
const scopeLabel =
scope === "matching" ? "matching archived conversations" : "all archived conversations";
const actionLabel = action === "unarchive" ? "Unarchive" : "Delete";
const confirmed = await confirmArchivedProjectAction({
title: `${actionLabel} ${scopeLabel}?`,
message:
action === "unarchive"
? `Restore ${threads.length} conversation${threads.length === 1 ? "" : "s"} from “${projectTitle}”?`
: `Permanently delete ${threads.length} conversation${threads.length === 1 ? "" : "s"} from “${projectTitle}”? This also clears their terminal history.`,
confirmText: actionLabel,
destructive: action === "delete",
});
if (!confirmed) return;

reservation.start();
try {
const summary = await runArchivedThreadActions(threads, (thread) =>
action === "unarchive"
? unarchiveThread(thread, {
reportFailure: false,
refreshArchivedThreads: false,
})
: deleteThread(thread, {
reportFailure: false,
refreshArchivedThreads: false,
}),
);
if (summary.failed > 0 || summary.skipped > 0) {
Alert.alert(
`Archived threads not fully ${action === "unarchive" ? "unarchived" : "deleted"}`,
archivedThreadActionSummaryDescription(summary),
);
}
} catch (error) {
Alert.alert(
`Archived threads not fully ${action === "unarchive" ? "unarchived" : "deleted"}`,
archivedThreadActionExceptionDescription(error),
);
} finally {
refresh();
}
} finally {
reservation.finish();
}
},
[deleteThread, refresh, tryReserveThreadActions, unarchiveThread],
);

useFocusEffect(
useCallback(() => {
Expand All @@ -81,15 +249,20 @@ export function ArchivedThreadsRouteScreen() {
error={error}
groups={groups}
isLoading={isLoading}
onDeleteThread={confirmDeleteThread}
onDeleteThread={(thread) => void handleDeleteThread(thread)}
onEnvironmentChange={setSelectedEnvironmentId}
onProjectAction={(projectTitle, threads, scope, action) =>
void handleProjectAction(projectTitle, threads, scope, action)
}
onRefresh={refresh}
onSearchQueryChange={setSearchQuery}
onSortOrderChange={setSortOrder}
onUnarchiveThread={unarchiveThread}
onSortChange={setSort}
onUnarchiveThread={(thread) => void handleUnarchiveThread(thread)}
searchQuery={searchQuery}
selectedEnvironmentId={selectedEnvironmentId}
sortOrder={sortOrder}
sort={sort}
busyThreadKeys={busyThreadKeys}
reservedThreadKeys={reservedThreadKeys}
/>
);
}
Loading
Loading