Skip to content

Commit 4e5b4f1

Browse files
committed
Merge remote-tracking branch 'origin/main' into t3/tool-call-diffs-non-git
2 parents dff7955 + 28da8c8 commit 4e5b4f1

21 files changed

Lines changed: 491 additions & 322 deletions

File tree

‎apps/mobile/src/features/workspace/WorkspaceRootScreen.tsx‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area
1111

1212
import { CompactBrandTitle } from "../../components/CompactBrandTitle";
1313
import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
14+
import { HeaderItemsWidthContext } from "../../native/header-items-width";
1415
import { NativeStackScreenOptions } from "../../native/StackHeader";
1516
import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
1617
import { isDuoDevice } from "../../lib/device-type";
@@ -49,21 +50,22 @@ import { useSelectWorkspaceTab } from "./useSelectWorkspaceTab";
4950
const TAB_TITLES = WORKSPACE_TAB_LABELS;
5051

5152
function WorkspaceRootTitle(props: {
52-
readonly maxWidth: number;
53+
readonly columnWidth: number;
5354
readonly onOpenEnvironments: () => void;
5455
}) {
5556
const { state, settingsOpen } = useWorkspaceTabs()!;
57+
const maxWidth = Math.max(0, props.columnWidth - (use(HeaderItemsWidthContext) ?? 160));
5658
const enabled = useEnabledNavigationTabs();
5759
const tabTitle = settingsOpen
5860
? "Settings"
5961
: enabled.length
6062
? TAB_TITLES[state.selectedTab]
6163
: "Navigation";
6264
return (
63-
<View style={{ width: props.maxWidth, minHeight: 32, justifyContent: "center" }}>
65+
<View style={{ width: maxWidth, minHeight: 32, justifyContent: "center" }}>
6466
<WorkspaceConnectionTitle
6567
brand={<CompactBrandTitle accessibilityLabel={`T3 Code, ${tabTitle}`} fit />}
66-
maxWidth={props.maxWidth}
68+
maxWidth={maxWidth}
6769
onPress={props.onOpenEnvironments}
6870
/>
6971
</View>
@@ -99,8 +101,7 @@ function WorkspaceRootContent() {
99101
const settingsOpen = workspace.settingsOpen;
100102
const renderHeaderTitle = () => (
101103
<WorkspaceRootTitle
102-
// Settings adds its scope filter beside search.
103-
maxWidth={Math.max(0, width - 160 - (settingsOpen ? 44 : 0))}
104+
columnWidth={width}
104105
onOpenEnvironments={() => openSettings(navigation, "SettingsEnvironments")}
105106
/>
106107
);

‎apps/mobile/src/lib/threadActivity.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ it("binds a persisted resume answer only to the next compaction in its run", ()
280280
expect(compactRows).toHaveLength(2);
281281
expect(labels.get(compactRows[0]!.id)).toEqual({
282282
title: "Context compacted after 2h 10m idle",
283-
compacting: "Compacting after 2h 10m idle…",
283+
compacting: "Compacting…",
284284
});
285285
expect(labels.get(compactRows[1]!.id)).toBeUndefined();
286286
}

‎apps/mobile/src/lib/threadActivity.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ export function threadFeedCompactionLabels(feed: ReadonlyArray<ThreadFeedEntry>)
359359
? undefined
360360
: {
361361
title: `Context compacted after ${age} idle`,
362-
compacting: `Compacting after ${age} idle…`,
362+
compacting: "Compacting…",
363363
});
364364
if (labels) labelsByEntryId.set(entry.id, labels);
365365
pendingResumeAgeByRunId.delete(entry.runId);

‎apps/mobile/src/native/V5StackHeader.ios.tsx‎

Lines changed: 76 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { KeyboardController, useKeyboardState } from "react-native-keyboard-cont
99
import { isDuoDevice } from "../lib/device-type";
1010
import { useMobileNavigationTheme } from "../lib/useMobileNavigationTheme";
1111
import { useDeviceType, useNativeLayoutMetrics } from "../native/native-layout-metrics";
12+
import { HeaderItemsWidthContext } from "./header-items-width";
1213
import {
1314
SearchBar,
1415
Stack,
@@ -22,6 +23,10 @@ import {
2223
type HeaderBarButtonSearchBarPlacementItem,
2324
} from "react-native-screens";
2425

26+
// UIKit's bar margins, and the width of a glass bar button.
27+
const BAR_MARGINS = 32;
28+
const BAR_BUTTON_WIDTH = 44;
29+
2530
type HeaderItem = NonNullable<NonNullable<StackHeaderConfigProps["ios"]>["leadingItems"]>[number];
2631
type ToolbarItem =
2732
| NativeStackHeaderItem
@@ -276,6 +281,24 @@ export function V5StackHeader(props: {
276281
const frame = requestAnimationFrame(() => autofocusRef.current?.focus());
277282
return () => cancelAnimationFrame(frame);
278283
}, [searchOptions?.autoFocus, autofocusRef]);
284+
const searchButton = !bottomSearch && searchOptions?.placement === "integratedButton";
285+
const itemsWidth =
286+
BAR_MARGINS +
287+
(props.canGoBack && options.headerBackVisible !== false ? BAR_BUTTON_WIDTH : 0) +
288+
(searchButton ? BAR_BUTTON_WIDTH : 0) +
289+
[...leading, ...trailing].reduce(
290+
(width, item) =>
291+
width +
292+
(item.type === "spacer"
293+
? item.sizing === "fixed"
294+
? item.width
295+
: 0
296+
: // The keyboard dismiss rides the vertical bar, not beside the title.
297+
item.id === "dismiss-keyboard"
298+
? 0
299+
: BAR_BUTTON_WIDTH),
300+
0,
301+
);
279302
const titleStyle = StyleSheet.flatten(options.headerTitleStyle);
280303
const headerStyle = StyleSheet.flatten(options.headerStyle);
281304
const appearance = {
@@ -292,56 +315,58 @@ export function V5StackHeader(props: {
292315
subtitleFontColor: options.headerSubtitleStyle?.color,
293316
};
294317
return (
295-
<Stack.HeaderConfig
296-
hidden={options.headerShown === false}
297-
transparent={options.headerTransparent}
298-
title={title}
299-
subtitle={options.unstable_headerSubtitle ?? options.headerSubtitle}
300-
backButtonHidden={options.headerBackVisible === false}
301-
ios={{
302-
navigationItemStyle: options.unstable_navigationItemStyle,
303-
// Opt-ins apply only where the Duo is short: folded, or held landscape. The Duo
304-
// resolves `automatic` to minimize on scroll, so the tall unfolded display opts out.
305-
minimizationBehavior: !isDuoDevice(deviceType)
306-
? undefined
307-
: deviceType === "duo-unfolded" &&
308-
nativeMetrics &&
309-
nativeMetrics.height > nativeMetrics.width
310-
? "never"
311-
: options.unstable_headerMinimizationBehavior,
312-
tintColor: options.headerTintColor,
313-
searchBar:
314-
mailSearch || searchOptions ? (
315-
<SearchBar
316-
{...searchOptions}
317-
ref={searchOptions?.ref ?? searchRef}
318-
hideNavigationBar={false}
319-
hideWhenScrolling={false}
320-
allowToolbarIntegration={searchOptions?.allowToolbarIntegration ?? true}
321-
placement={bottomSearch ? "integrated" : (searchOptions?.placement ?? "automatic")}
322-
placeholder={mailSearch?.placeholder ?? searchOptions?.placeholder ?? "Search"}
323-
onFocus={(event) => {
324-
searchOptions?.onFocus?.(event);
325-
}}
326-
onChangeText={(event) => {
327-
mailSearch?.onSearchTextChange?.(event.nativeEvent.text);
328-
searchOptions?.onChangeText?.(event);
329-
}}
330-
/>
331-
) : undefined,
332-
toolbarItems: bottom,
333-
leadingItems: leading,
334-
trailingItems: trailing,
335-
titleItem: isValidElement(titleElement)
336-
? { id: "title", render: () => titleElement }
337-
: undefined,
338-
largeTitleEnabled: options.headerLargeTitle,
339-
backButtonDisplayMode: options.headerBackButtonDisplayMode ?? "minimal",
340-
backButtonMenuEnabled: options.headerBackButtonMenuEnabled ?? true,
341-
backButtonTitle: options.headerBackTitle,
342-
standardAppearance: appearance,
343-
scrollEdgeAppearance: appearance,
344-
}}
345-
/>
318+
<HeaderItemsWidthContext value={itemsWidth}>
319+
<Stack.HeaderConfig
320+
hidden={options.headerShown === false}
321+
transparent={options.headerTransparent}
322+
title={title}
323+
subtitle={options.unstable_headerSubtitle ?? options.headerSubtitle}
324+
backButtonHidden={options.headerBackVisible === false}
325+
ios={{
326+
navigationItemStyle: options.unstable_navigationItemStyle,
327+
// Opt-ins apply only where the Duo is short: folded, or held landscape. The Duo
328+
// resolves `automatic` to minimize on scroll, so the tall unfolded display opts out.
329+
minimizationBehavior: !isDuoDevice(deviceType)
330+
? undefined
331+
: deviceType === "duo-unfolded" &&
332+
nativeMetrics &&
333+
nativeMetrics.height > nativeMetrics.width
334+
? "never"
335+
: options.unstable_headerMinimizationBehavior,
336+
tintColor: options.headerTintColor,
337+
searchBar:
338+
mailSearch || searchOptions ? (
339+
<SearchBar
340+
{...searchOptions}
341+
ref={searchOptions?.ref ?? searchRef}
342+
hideNavigationBar={false}
343+
hideWhenScrolling={false}
344+
allowToolbarIntegration={searchOptions?.allowToolbarIntegration ?? true}
345+
placement={bottomSearch ? "integrated" : (searchOptions?.placement ?? "automatic")}
346+
placeholder={mailSearch?.placeholder ?? searchOptions?.placeholder ?? "Search"}
347+
onFocus={(event) => {
348+
searchOptions?.onFocus?.(event);
349+
}}
350+
onChangeText={(event) => {
351+
mailSearch?.onSearchTextChange?.(event.nativeEvent.text);
352+
searchOptions?.onChangeText?.(event);
353+
}}
354+
/>
355+
) : undefined,
356+
toolbarItems: bottom,
357+
leadingItems: leading,
358+
trailingItems: trailing,
359+
titleItem: isValidElement(titleElement)
360+
? { id: "title", render: () => titleElement }
361+
: undefined,
362+
largeTitleEnabled: options.headerLargeTitle,
363+
backButtonDisplayMode: options.headerBackButtonDisplayMode ?? "minimal",
364+
backButtonMenuEnabled: options.headerBackButtonMenuEnabled ?? true,
365+
backButtonTitle: options.headerBackTitle,
366+
standardAppearance: appearance,
367+
scrollEdgeAppearance: appearance,
368+
}}
369+
/>
370+
</HeaderItemsWidthContext>
346371
);
347372
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { createContext } from "react";
2+
3+
/** Width a header's own buttons and margins take beside a custom title, which RN sizes itself. */
4+
export const HeaderItemsWidthContext = createContext<number | null>(null);

‎apps/server/src/provider/Drivers/CodexHomeLayout.test.ts‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ it.layer(NodeServices.layer)("CodexHomeLayout", (it) => {
121121
'{"models":["shared"]}\n',
122122
);
123123
yield* writeTextFile(path.join(sharedHome, "auth.json"), '{"shared":true}\n');
124+
yield* writeTextFile(path.join(sharedHome, "auth.lock"), "");
124125
yield* fileSystem.makeDirectory(shadowHome, { recursive: true });
125126
yield* writeTextFile(path.join(shadowHome, "auth.json"), '{"shadow":true}\n');
127+
yield* writeTextFile(path.join(shadowHome, "auth.lock"), "");
126128
yield* fileSystem.symlink(
127129
path.join(sharedHome, "models_cache.json"),
128130
path.join(shadowHome, "models_cache.json"),
@@ -149,13 +151,17 @@ it.layer(NodeServices.layer)("CodexHomeLayout", (it) => {
149151
.readLink(path.join(shadowHome, "auth.json"))
150152
.pipe(Effect.result);
151153
const authContents = yield* fileSystem.readFileString(path.join(shadowHome, "auth.json"));
154+
const authLockLinkResult = yield* fileSystem
155+
.readLink(path.join(shadowHome, "auth.lock"))
156+
.pipe(Effect.result);
152157

153158
expect(sessionsTarget).toBe(path.join(sharedHome, "sessions"));
154159
expect(configTarget).toBe(path.join(sharedHome, "config.toml"));
155160
expect(mcpOauthLocksTarget).toBe(path.join(sharedHome, "mcp-oauth-locks"));
156161
expect(modelsCacheExists).toBe(false);
157162
expect(authLinkResult._tag).toBe("Failure");
158163
expect(authContents).toContain("shadow");
164+
expect(authLockLinkResult._tag).toBe("Failure");
159165
}),
160166
);
161167

@@ -221,6 +227,40 @@ it.layer(NodeServices.layer)("CodexHomeLayout", (it) => {
221227
}),
222228
);
223229

230+
it.effect.skipIf(!symlinksSupported)(
231+
"shares local thread writer locks once no writer still holds one",
232+
() =>
233+
Effect.gen(function* () {
234+
const fileSystem = yield* FileSystem.FileSystem;
235+
const path = yield* Path.Path;
236+
const sharedHome = yield* makeTempDir("t3code-codex-shared-");
237+
const shadowRoot = yield* makeTempDir("t3code-codex-shadow-root-");
238+
const shadowHome = path.join(shadowRoot, "shadow");
239+
const shadowLocks = path.join(shadowHome, "thread-writer-locks");
240+
const threadLock = path.join(shadowLocks, "019a0000-0000-7000-8000-000000000000.lock");
241+
242+
yield* writeTextFile(path.join(shadowLocks, ".coordination.lock"), "");
243+
yield* writeTextFile(path.join(shadowLocks, ".DS_Store"), "");
244+
yield* writeTextFile(threadLock, "");
245+
246+
const layout = yield* resolveCodexHomeLayout(
247+
decodeCodexSettings({
248+
homePath: sharedHome,
249+
shadowHomePath: shadowHome,
250+
}),
251+
);
252+
253+
yield* materializeCodexShadowHome(layout);
254+
expect(yield* fileSystem.exists(threadLock)).toBe(true);
255+
256+
yield* fileSystem.remove(threadLock);
257+
yield* materializeCodexShadowHome(layout);
258+
expect(yield* fileSystem.readLink(shadowLocks)).toBe(
259+
path.join(sharedHome, "thread-writer-locks"),
260+
);
261+
}),
262+
);
263+
224264
it.effect.skipIf(!symlinksSupported)(
225265
"accepts Codex-created shadow-local runtime directories",
226266
() =>

‎apps/server/src/provider/Drivers/CodexHomeLayout.ts‎

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,19 @@ const KNOWN_SHARED_DIRECTORIES = [
2626
"cache",
2727
"logs",
2828
"mcp-oauth-locks",
29+
"thread-writer-locks",
2930
] as const;
3031

31-
const PRIVATE_ENTRY_NAMES = new Set(["auth.json", "models_cache.json"]);
32+
// auth.lock guards the shadow home's private auth.json.
33+
const PRIVATE_ENTRY_NAMES = new Set(["auth.json", "auth.lock", "models_cache.json"]);
3234
// Finder maintains metadata separately for each directory, including shadow homes.
3335
const SHADOW_LOCAL_ENTRY_NAMES = new Set(["log", "memories", "tmp", ".DS_Store"]);
3436
// Shadow homes may create local runtime locks first; replace them with shared links because they guard shared state.
35-
const REPLACEABLE_SHARED_RUNTIME_ENTRIES = new Set(["mcp-oauth-locks", ".sqlite-maintenance.lock"]);
37+
const REPLACEABLE_SHARED_RUNTIME_ENTRIES = new Set([
38+
"mcp-oauth-locks",
39+
"thread-writer-locks",
40+
".sqlite-maintenance.lock",
41+
]);
3642

3743
function resolveHomePath(path: Path.Path, home: string, value: string | undefined): string {
3844
const expanded =
@@ -253,6 +259,30 @@ const ensureSymlink = Effect.fn("CodexHomeLayout.ensureSymlink")(function* (inpu
253259
});
254260
}
255261

262+
if (input.entryName === "thread-writer-locks") {
263+
const lockNames = yield* input.fileSystem.readDirectory(link).pipe(
264+
Effect.catchTags({
265+
PlatformError: (cause) =>
266+
new CodexShadowHomeFileSystemError({
267+
sharedHomePath: input.sharedHomePath,
268+
effectiveHomePath: input.effectiveHomePath,
269+
operation: "readDirectory",
270+
path: link,
271+
entryName: input.entryName,
272+
cause,
273+
}),
274+
}),
275+
);
276+
// Codex deletes a thread lock on release, so one that is left may still guard a live
277+
// writer. Keep the local directory until a later setup finds none.
278+
if (lockNames.some((name) => name.endsWith(".lock") && name !== ".coordination.lock")) {
279+
return yield* Effect.logWarning(
280+
"Codex shadow home still has thread writer locks; it will share them on a later setup.",
281+
{ path: link },
282+
);
283+
}
284+
}
285+
256286
yield* input.fileSystem.remove(link, { recursive: true }).pipe(
257287
Effect.catchTags({
258288
PlatformError: (cause) =>

0 commit comments

Comments
 (0)