Skip to content

Commit c27b8ea

Browse files
committed
Merge remote-tracking branch 'origin/main' into t3code/thread-sort-v2
# Conflicts: # apps/mobile/src/features/home/HomeScreen.tsx # apps/mobile/src/features/threads/ThreadArrangementSheet.tsx # apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx # apps/mobile/src/features/threads/threadListV2.ts # apps/web/src/components/Sidebar.logic.ts # apps/web/src/components/Sidebar.tsx
2 parents 95f0b03 + a976f8c commit c27b8ea

161 files changed

Lines changed: 9154 additions & 1441 deletions

File tree

Some content is hidden

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

‎apps/desktop/src/settings/DesktopAppSettings.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,34 @@ describe("DesktopSettings", () => {
357357
),
358358
);
359359

360+
it.effect("saves through a symlinked settings file without replacing the link", () =>
361+
withSettings(
362+
Effect.gen(function* () {
363+
const environment = yield* DesktopEnvironment.DesktopEnvironment;
364+
const fileSystem = yield* FileSystem.FileSystem;
365+
const settings = yield* DesktopAppSettings.DesktopAppSettings;
366+
const dotfiles = yield* fileSystem.makeTempDirectoryScoped({
367+
prefix: "t3-desktop-settings-dotfiles-",
368+
});
369+
const linkedSettingsPath = `${dotfiles}/desktop-settings.json`;
370+
yield* fileSystem.writeFileString(linkedSettingsPath, "{}\n");
371+
yield* fileSystem.makeDirectory(environment.stateDir, { recursive: true });
372+
yield* fileSystem.symlink(linkedSettingsPath, environment.desktopSettingsPath);
373+
374+
yield* settings.setServerExposureMode("network-accessible");
375+
376+
assert.equal(
377+
yield* fileSystem.readLink(environment.desktopSettingsPath),
378+
linkedSettingsPath,
379+
);
380+
const persisted = yield* decodeDesktopSettingsPatch(
381+
yield* fileSystem.readFileString(linkedSettingsPath),
382+
);
383+
assert.equal(persisted.serverExposureMode, "network-accessible");
384+
}),
385+
),
386+
);
387+
360388
it.effect("migrates legacy implicit update channels to the runtime default", () =>
361389
withSettings(
362390
Effect.gen(function* () {

‎apps/desktop/src/settings/DesktopAppSettings.ts‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
type DesktopUpdateChannel,
66
} from "@t3tools/contracts";
77
import { fromLenientJson } from "@t3tools/shared/schemaJson";
8+
import { resolveSymlinkTarget } from "@t3tools/shared/symlink";
89
import * as Context from "effect/Context";
910
import * as Crypto from "effect/Crypto";
1011
import * as Effect from "effect/Effect";
@@ -130,6 +131,7 @@ const settingsChange = (settings: DesktopSettings, changed: boolean): DesktopSet
130131

131132
const DesktopSettingsWriteOperation = Schema.Literals([
132133
"create-temporary-file-name",
134+
"resolve-symlink",
133135
"encode-document",
134136
"create-directory",
135137
"write-temporary-file",
@@ -421,8 +423,20 @@ const writeSettings = Effect.fn("desktop.settings.writeSettings")(function* (inp
421423
readonly defaultSettings: DesktopSettings;
422424
readonly suffix: string;
423425
}): Effect.fn.Return<void, DesktopSettingsWriteError> {
424-
const directory = input.path.dirname(input.settingsPath);
425-
const tempPath = `${input.settingsPath}.${process.pid}.${input.suffix}.tmp`;
426+
const targetPath = yield* resolveSymlinkTarget(input.settingsPath).pipe(
427+
Effect.provideService(FileSystem.FileSystem, input.fileSystem),
428+
Effect.provideService(Path.Path, input.path),
429+
Effect.mapError(
430+
(cause) =>
431+
new DesktopSettingsWriteError({
432+
operation: "resolve-symlink",
433+
path: input.settingsPath,
434+
cause,
435+
}),
436+
),
437+
);
438+
const directory = input.path.dirname(targetPath);
439+
const tempPath = `${targetPath}.${process.pid}.${input.suffix}.tmp`;
426440
const encoded = yield* encodeDesktopSettingsJson(
427441
toDesktopSettingsDocument(input.settings, input.defaultSettings),
428442
).pipe(
@@ -455,7 +469,7 @@ const writeSettings = Effect.fn("desktop.settings.writeSettings")(function* (inp
455469
}),
456470
),
457471
);
458-
yield* input.fileSystem.rename(tempPath, input.settingsPath).pipe(
472+
yield* input.fileSystem.rename(tempPath, targetPath).pipe(
459473
Effect.mapError(
460474
(cause) =>
461475
new DesktopSettingsWriteError({

‎apps/desktop/src/settings/DesktopClientSettings.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,34 @@ describe("DesktopClientSettings", () => {
149149
),
150150
);
151151

152+
it.effect("saves through a symlinked client settings file without replacing the link", () =>
153+
withClientSettings(
154+
Effect.gen(function* () {
155+
const environment = yield* DesktopEnvironment.DesktopEnvironment;
156+
const fileSystem = yield* FileSystem.FileSystem;
157+
const settings = yield* DesktopClientSettings.DesktopClientSettings;
158+
const dotfiles = yield* fileSystem.makeTempDirectoryScoped({
159+
prefix: "t3-desktop-client-settings-dotfiles-",
160+
});
161+
const linkedSettingsPath = `${dotfiles}/client-settings.json`;
162+
yield* fileSystem.writeFileString(linkedSettingsPath, "{}\n");
163+
yield* fileSystem.makeDirectory(environment.stateDir, { recursive: true });
164+
yield* fileSystem.symlink(linkedSettingsPath, environment.clientSettingsPath);
165+
166+
yield* settings.set(clientSettings);
167+
168+
assert.equal(
169+
yield* fileSystem.readLink(environment.clientSettingsPath),
170+
linkedSettingsPath,
171+
);
172+
assert.deepEqual(
173+
yield* decodeClientSettingsJson(yield* fileSystem.readFileString(linkedSettingsPath)),
174+
clientSettings,
175+
);
176+
}),
177+
),
178+
);
179+
152180
it.effect.each([
153181
{ label: "permission", reason: "PermissionDenied" },
154182
{ label: "I/O", reason: "Unknown" },

‎apps/desktop/src/settings/DesktopClientSettings.ts‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ClientSettingsSchema, type ClientSettings } from "@t3tools/contracts";
22
import { fromLenientJson } from "@t3tools/shared/schemaJson";
3+
import { resolveSymlinkTarget } from "@t3tools/shared/symlink";
34
import * as Context from "effect/Context";
45
import * as Crypto from "effect/Crypto";
56
import * as Effect from "effect/Effect";
@@ -41,6 +42,7 @@ export class DesktopClientSettingsReadError extends Schema.TaggedError<DesktopCl
4142

4243
const DesktopClientSettingsWriteOperation = Schema.Literals([
4344
"create-temporary-file-name",
45+
"resolve-symlink",
4446
"encode-document",
4547
"create-directory",
4648
"write-temporary-file",
@@ -126,8 +128,20 @@ const writeClientSettings = Effect.fnUntraced(function* (input: {
126128
readonly settings: ClientSettings;
127129
readonly suffix: string;
128130
}): Effect.fn.Return<void, DesktopClientSettingsWriteError> {
129-
const directory = input.path.dirname(input.settingsPath);
130-
const tempPath = `${input.settingsPath}.${process.pid}.${input.suffix}.tmp`;
131+
const targetPath = yield* resolveSymlinkTarget(input.settingsPath).pipe(
132+
Effect.provideService(FileSystem.FileSystem, input.fileSystem),
133+
Effect.provideService(Path.Path, input.path),
134+
Effect.mapError(
135+
(cause) =>
136+
new DesktopClientSettingsWriteError({
137+
operation: "resolve-symlink",
138+
path: input.settingsPath,
139+
cause,
140+
}),
141+
),
142+
);
143+
const directory = input.path.dirname(targetPath);
144+
const tempPath = `${targetPath}.${process.pid}.${input.suffix}.tmp`;
131145
const encoded = yield* encodeClientSettingsJson(input.settings).pipe(
132146
Effect.mapError(
133147
(cause) =>
@@ -158,7 +172,7 @@ const writeClientSettings = Effect.fnUntraced(function* (input: {
158172
}),
159173
),
160174
);
161-
yield* input.fileSystem.rename(tempPath, input.settingsPath).pipe(
175+
yield* input.fileSystem.rename(tempPath, targetPath).pipe(
162176
Effect.mapError(
163177
(cause) =>
164178
new DesktopClientSettingsWriteError({

‎apps/mobile/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
"react-native": "0.88.0-rc.3",
115115
"react-native-gesture-handler": "~3.2.1",
116116
"react-native-image-viewing": "^0.2.2",
117-
"react-native-keyboard-controller": "1.22.4",
117+
"react-native-keyboard-controller": "1.22.6",
118118
"react-native-nitro-markdown": "^0.5.0",
119119
"react-native-nitro-modules": "0.35.9",
120120
"react-native-reanimated": "4.7.0",

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

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ import {
4545
ThreadListV2SettledShelfHeader,
4646
ThreadListV2ShowMoreRow,
4747
ThreadListV2SnoozedShelfHeader,
48+
ThreadListV2WorkingShelfHeader,
4849
} from "../threads/thread-list-v2-items";
4950
import { useThreadRowProviderInstanceResolver } from "../threads/thread-provider-instance";
5051
import {
5152
buildThreadListV2Items,
5253
getThreadListV2OrderedSection,
5354
buildThreadListV2ListItems,
5455
threadListV2ListItemsAreEqual,
56+
threadListInboxReturns,
5557
THREAD_LIST_V2_SETTLED_INITIAL_COUNT,
5658
THREAD_LIST_V2_SETTLED_PAGE_COUNT,
5759
type ThreadListV2ListItem,
@@ -469,8 +471,11 @@ export function HomeScreen(props: HomeScreenProps) {
469471
loaded: shelfPreferencesLoaded,
470472
settledShelfExpanded,
471473
snoozedShelfExpanded,
474+
workingShelfEnabled,
475+
workingShelfExpanded,
472476
toggleSettledShelf,
473477
toggleSnoozedShelf,
478+
toggleWorkingShelf,
474479
} = useThreadListV2ShelfPreferences();
475480
// The queued-start and snooze helpers need a clock while the list stays open.
476481
const [nowMinute, setNowMinute] = useState(() => new Date().toISOString().slice(0, 16));
@@ -529,9 +534,14 @@ export function HomeScreen(props: HomeScreenProps) {
529534
queuedThreadKeys,
530535
}),
531536
});
532-
return new Map([...sectionAvailability("pinned"), ...sectionAvailability("active")]);
537+
// The Working beta orders the inbox by time, so only pins can move.
538+
return new Map([
539+
...sectionAvailability("pinned"),
540+
...(workingShelfEnabled ? [] : sectionAvailability("active")),
541+
]);
533542
}, [
534543
activeThreadSortOrder,
544+
workingShelfEnabled,
535545
pinReorderEnvironmentIds,
536546
activeReorderEnvironmentIds,
537547
props.threads,
@@ -543,6 +553,7 @@ export function HomeScreen(props: HomeScreenProps) {
543553
snoozeWakeTick,
544554
]);
545555
const threadListV2Layout = useMemo(() => {
556+
threadListInboxReturns.observe(workingShelfEnabled ? props.threads : null);
546557
// Settled threads are live shells; archived threads keep their original
547558
// "hidden from lists" meaning.
548559
return buildThreadListV2Items({
@@ -558,12 +569,17 @@ export function HomeScreen(props: HomeScreenProps) {
558569
queuedThreadKeys,
559570
settledLimit: settledVisibleCount,
560571
now: new Date().toISOString(),
572+
workingShelfEnabled,
573+
workingShelfExpanded,
574+
inboxReturnAt: threadListInboxReturns.returnedAt,
561575
snoozedShelfExpanded,
562576
settledShelfExpanded,
563577
selectedThreadKey: null,
564578
});
565579
}, [
566580
activeThreadSortOrder,
581+
workingShelfEnabled,
582+
workingShelfExpanded,
567583
pendingOrder,
568584
queuedThreadKeys,
569585
nowMinute,
@@ -618,6 +634,9 @@ export function HomeScreen(props: HomeScreenProps) {
618634
buildThreadListV2ListItems({
619635
items: threadListV2Layout.items,
620636
pendingTasks: v2PendingTasks,
637+
workingCount: threadListV2Layout.workingCount,
638+
workingShelfExpanded,
639+
workingShelfHeaderIndex: threadListV2Layout.workingShelfHeaderIndex,
621640
snoozedCount: threadListV2Layout.snoozedCount,
622641
snoozedShelfExpanded,
623642
snoozedShelfHeaderIndex: threadListV2Layout.snoozedShelfHeaderIndex,
@@ -640,6 +659,7 @@ export function HomeScreen(props: HomeScreenProps) {
640659
snoozeEnvironmentIds,
641660
threadListV2Layout,
642661
v2PendingTasks,
662+
workingShelfExpanded,
643663
],
644664
);
645665

@@ -674,6 +694,16 @@ export function HomeScreen(props: HomeScreenProps) {
674694
/>
675695
);
676696
}
697+
if (item.type === "v2-working-shelf") {
698+
return (
699+
<ThreadListV2WorkingShelfHeader
700+
count={item.count}
701+
disabled={item.disabled}
702+
expanded={item.expanded}
703+
onToggle={toggleWorkingShelf}
704+
/>
705+
);
706+
}
677707
if (item.type === "v2-snoozed-shelf") {
678708
return (
679709
<ThreadListV2SnoozedShelfHeader
@@ -742,7 +772,7 @@ export function HomeScreen(props: HomeScreenProps) {
742772
reorderSupported={
743773
item.item.pinned
744774
? pinReorderEnvironmentIds.has(thread.environmentId)
745-
: activeReorderEnvironmentIds.has(thread.environmentId)
775+
: !workingShelfEnabled && activeReorderEnvironmentIds.has(thread.environmentId)
746776
}
747777
canMoveUp={item.canMoveUp}
748778
canMoveDown={item.canMoveDown}
@@ -794,8 +824,10 @@ export function HomeScreen(props: HomeScreenProps) {
794824
titleRegenerationEnvironmentIds,
795825
toggleSettledShelf,
796826
toggleSnoozedShelf,
827+
toggleWorkingShelf,
797828
v2ProjectTitleByProjectKey,
798829
props.searchQuery,
830+
workingShelfEnabled,
799831
],
800832
);
801833
const v2KeyExtractor = useCallback((item: ThreadListV2ListItem) => item.key, []);
@@ -812,6 +844,8 @@ export function HomeScreen(props: HomeScreenProps) {
812844
savedConnectionsById: props.savedConnectionsById,
813845
searchQuery: props.searchQuery,
814846
threadSearchMatchByKey,
847+
// Rows read it for their reorder menu items.
848+
workingShelfEnabled,
815849
}),
816850
[
817851
projectByKey,
@@ -820,6 +854,7 @@ export function HomeScreen(props: HomeScreenProps) {
820854
listEnvironments,
821855
threadSearchMatchByKey,
822856
v2ProjectTitleByProjectKey,
857+
workingShelfEnabled,
823858
],
824859
);
825860

‎apps/mobile/src/features/settings/SettingsThreadsRouteScreen.tsx‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export function SettingsThreadsRouteScreen() {
4545
contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
4646
>
4747
<AutoSettleSettingsRows />
48+
<BetaSettingsSection />
4849
<LegacySettingsSection />
4950
</ScrollView>
5051
</SettingsScreen>
@@ -239,6 +240,35 @@ function AutoSettleSettingsRows() {
239240
);
240241
}
241242

243+
/**
244+
* Device-local beta toggles, the counterpart of web's Working section (beta)
245+
* in Settings → General.
246+
*/
247+
function BetaSettingsSection() {
248+
const savePreferences = useAtomSet(updateMobilePreferencesAtom);
249+
const preferences = useAtomValue(mobilePreferencesAtom);
250+
const workingShelfEnabled =
251+
AsyncResult.isSuccess(preferences) && preferences.value.workingShelfEnabled === true;
252+
253+
return (
254+
<View className="gap-3">
255+
<SettingsSection title="Beta">
256+
<SettingsSwitchRow
257+
icon="bolt.circle"
258+
label="Working section"
259+
value={workingShelfEnabled}
260+
onValueChange={(value) => savePreferences({ workingShelfEnabled: value })}
261+
/>
262+
</SettingsSection>
263+
<Text className="px-2 text-sm text-foreground-muted">
264+
Fold working and monitoring threads into a Working section. They return to the top of the
265+
list when they need you. While this is on, active threads are ordered by time and cannot be
266+
moved.
267+
</Text>
268+
</View>
269+
);
270+
}
271+
242272
/**
243273
* Device-local legacy toggles. Mobile has no client-settings sync, so this is
244274
* the counterpart of web's Settings → General → Legacy features backed by

0 commit comments

Comments
 (0)