Skip to content

Commit b2e5156

Browse files
Merge remote-tracking branch 'origin/main' into fix/word-preview-engine-limits
2 parents d8cadaa + 950c342 commit b2e5156

199 files changed

Lines changed: 6734 additions & 1017 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/app/DesktopApp.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as Layer from "effect/Layer";
77
import * as FileSystem from "effect/FileSystem";
88
import * as Path from "effect/Path";
99
import * as HttpClient from "effect/http/HttpClient";
10+
import { ChildProcessSpawner } from "effect/process";
1011
import * as NetService from "@t3tools/shared/Net";
1112
import * as Fiber from "effect/Fiber";
1213
import * as Option from "effect/Option";
@@ -213,6 +214,7 @@ it.effect.each([false, true])(
213214
Effect.provide(
214215
Layer.mergeAll(
215216
Layer.mock(BrowserImport.BrowserImport, {}),
217+
Layer.mock(ChildProcessSpawner.ChildProcessSpawner, {}),
216218
Layer.mock(DesktopBackendConfiguration.DesktopBackendConfiguration, {}),
217219
Layer.mock(DesktopCliCommand.DesktopCliCommand, {}),
218220
Layer.mock(DesktopClientSettings.DesktopClientSettings, {}),

‎apps/desktop/src/electron/ElectronMenu.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ function normalizeContextMenuItems(source: readonly ContextMenuItem[]): ContextM
7575

7676
const normalizedItem: ContextMenuItem = {
7777
id: sourceItem.id,
78-
label: sourceItem.label,
78+
label:
79+
typeof sourceItem.detail === "string" && sourceItem.detail.length > 0
80+
? `${sourceItem.label} (${sourceItem.detail})`
81+
: sourceItem.label,
7982
destructive: sourceItem.destructive === true,
8083
disabled: sourceItem.disabled === true,
8184
...(sourceItem.separatorBefore === true ? { separatorBefore: true } : {}),

‎apps/desktop/src/updates/DesktopUpdates.test.ts‎

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import * as NodeModule from "node:module";
2+
13
import { assert, describe, it } from "@effect/vitest";
24
import { DESKTOP_UPDATE_RESTART_MARKER_FILE } from "@t3tools/contracts";
5+
import { computeReleaseNotes } from "electron-updater/out/providers/GitHubProvider.js";
36
import * as Cause from "effect/Cause";
47
import * as Deferred from "effect/Deferred";
58
import * as Duration from "effect/Duration";
@@ -22,6 +25,57 @@ import * as DesktopUpdatePolicy from "./DesktopUpdatePolicy.ts";
2225
import * as DesktopUpdates from "./DesktopUpdates.ts";
2326
import { flushCallbacks, makeHarness } from "./updatesTestHarness.ts";
2427

28+
type ReleaseFeed = Parameters<typeof computeReleaseNotes>[2];
29+
type RunningVersion = Parameters<typeof computeReleaseNotes>[0];
30+
31+
// electron-updater's own dependencies, which apps/desktop does not declare.
32+
const requireFromUpdater = NodeModule.createRequire(
33+
NodeModule.createRequire(import.meta.url).resolve("electron-updater"),
34+
);
35+
const { parseXml } = requireFromUpdater("builder-util-runtime") as {
36+
parseXml: (xml: string) => ReleaseFeed;
37+
};
38+
const semver = requireFromUpdater("semver") as { parse: (version: string) => RunningVersion };
39+
40+
const releaseTitle = (version: string) =>
41+
version.includes("-nightly.")
42+
? `T3 Code Nightly ${version} (0123456789ab)`
43+
: `T3 Code v${version}`;
44+
45+
const releaseFeed = (...versions: ReadonlyArray<string>) =>
46+
parseXml(
47+
`<feed xmlns="http://www.w3.org/2005/Atom">${versions
48+
.map(
49+
(version) =>
50+
`<entry><link rel="alternate" type="text/html" href="https://github.com/pingdotgg/t3code/releases/tag/v${version}"/><title>${releaseTitle(version)}</title><content type="html">&lt;ul&gt;&lt;li&gt;${version} change&lt;/li&gt;&lt;/ul&gt;</content></entry>`,
51+
)
52+
.join("")}</feed>`,
53+
);
54+
55+
/** The update info electron-updater's GitHub provider reports when /releases/latest names `version`. */
56+
const stableUpdateInfo = (
57+
feed: ReleaseFeed,
58+
version: string,
59+
runningVersion: string,
60+
fullChangelog: boolean,
61+
) => {
62+
const latestRelease =
63+
feed
64+
.getElements("entry")
65+
.find((entry) => entry.element("link").attribute("href").endsWith(`/tag/v${version}`)) ??
66+
feed.element("entry");
67+
return {
68+
version,
69+
releaseName: latestRelease.elementValueOrEmpty("title"),
70+
releaseNotes: computeReleaseNotes(
71+
semver.parse(runningVersion),
72+
fullChangelog,
73+
feed,
74+
latestRelease,
75+
),
76+
};
77+
};
78+
2579
describe("DesktopUpdates", () => {
2680
it.effect("updates Linux .deb installs and leaves other non-AppImage installs off", () =>
2781
Effect.gen(function* () {
@@ -109,6 +163,51 @@ describe("DesktopUpdates", () => {
109163
).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer)));
110164
});
111165

166+
it.effect.each([
167+
{
168+
name: "shows no notes for a Stable release missing from the releases feed",
169+
runningVersion: "1.2.3",
170+
feedVersions: ["1.2.5-nightly.20261102.1", "1.2.5-nightly.20261101.1"],
171+
expected: [],
172+
},
173+
{
174+
name: "shows a Stable release's own notes from the releases feed",
175+
runningVersion: "1.2.3",
176+
feedVersions: ["1.2.5-nightly.20261102.1", "1.2.4", "1.2.4-nightly.20261030.1"],
177+
expected: [{ version: "1.2.4", items: ["1.2.4 change"], totalItems: 1 }],
178+
},
179+
{
180+
name: "shows a Stable release's notes when switching down from a newer Nightly",
181+
runningVersion: "1.2.5-nightly.20261027.1",
182+
feedVersions: ["1.2.5-nightly.20261102.1", "1.2.4"],
183+
expected: [{ version: "1.2.4", items: ["1.2.4 change"], totalItems: 1 }],
184+
},
185+
])("$name", ({ runningVersion, feedVersions, expected }) => {
186+
const harness = makeHarness();
187+
188+
return Effect.scoped(
189+
Effect.gen(function* () {
190+
const updates = yield* DesktopUpdates.DesktopUpdates;
191+
yield* updates.configure;
192+
193+
harness.emit(
194+
"update-available",
195+
stableUpdateInfo(
196+
releaseFeed(...feedVersions),
197+
"1.2.4",
198+
runningVersion,
199+
harness.fullChangelog(),
200+
),
201+
);
202+
yield* flushCallbacks;
203+
204+
const state = yield* updates.getState;
205+
assert.equal(state.availableVersion, "1.2.4");
206+
assert.deepEqual(state.releaseNotes, expected);
207+
}),
208+
).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer)));
209+
});
210+
112211
it.effect("preserves a queued installer when the feed has no update", () => {
113212
const harness = makeHarness();
114213

‎apps/desktop/src/updates/DesktopUpdates.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ import * as ElectronWindow from "../electron/ElectronWindow.ts";
3636
import * as IpcChannels from "../ipc/channels.ts";
3737
import * as DesktopAppSettings from "../settings/DesktopAppSettings.ts";
3838
import * as DesktopUpdatePolicy from "./DesktopUpdatePolicy.ts";
39-
import { normalizeDesktopUpdateReleaseNotes } from "./releaseNotes.ts";
39+
import {
40+
normalizeDesktopUpdateReleaseNotes,
41+
releaseNotesOfOfferedVersion,
42+
} from "./releaseNotes.ts";
4043
import { desktopUpdateChannelOf } from "@t3tools/shared/cliRelease";
4144
import { compareSemverVersions } from "@t3tools/shared/semver";
4245
import {
@@ -72,6 +75,7 @@ const UpdateInfo = Schema.Struct({
7275
version: Schema.String,
7376
// Malformed notes must not block update-state decoding; normalizeDesktopUpdateReleaseNotes validates separately.
7477
releaseNotes: Schema.optional(Schema.Unknown),
78+
releaseName: Schema.optional(Schema.NullOr(Schema.String)),
7579
releaseDate: Schema.optional(Schema.String),
7680
});
7781

@@ -939,7 +943,7 @@ export const make = Effect.gen(function* () {
939943

940944
const checkedAt = yield* currentIsoTimestamp;
941945
const { releaseNotes, omittedReleaseCount } = normalizeDesktopUpdateReleaseNotes(
942-
info.releaseNotes,
946+
releaseNotesOfOfferedVersion(info),
943947
info.version,
944948
state.channel,
945949
info.releaseDate,

‎apps/desktop/src/updates/releaseNotes.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,22 @@ interface NormalizedDesktopUpdateReleaseNotes {
171171
readonly omittedReleaseCount: number;
172172
}
173173

174+
const escapeRegExp = (value: string) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
175+
176+
/**
177+
* Untagged notes come from the feed entry named by releaseName, which is the newest entry when the
178+
* offered release is not on the feed's first page. Keep them only when that entry is the offered one.
179+
*/
180+
export function releaseNotesOfOfferedVersion(info: {
181+
readonly version: string;
182+
readonly releaseNotes?: unknown;
183+
readonly releaseName?: string | null | undefined;
184+
}): unknown {
185+
if (typeof info.releaseNotes !== "string" || !info.releaseName) return info.releaseNotes;
186+
const namesVersion = new RegExp(`(?:^|[^\\w.-])v?${escapeRegExp(info.version)}(?![\\w.-])`);
187+
return namesVersion.test(info.releaseName) ? info.releaseNotes : undefined;
188+
}
189+
174190
/** fullChangelog includes all greater semvers, so preview cuts sort above nightlies of the same base version. */
175191
export function normalizeDesktopUpdateReleaseNotes(
176192
releaseNotes: unknown,

‎apps/mobile/src/components/ui/AndroidAnchoredMenu.android.tsx‎

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import { Pressable, ScrollView, View } from "react-native";
66
import { useKeyboardState } from "react-native-keyboard-controller";
77

88
import { useHardwareBack } from "../../lib/backHandler";
9-
import { deriveMenuHorizontalPlacement } from "../../lib/menu-placement";
9+
import {
10+
deriveMenuHorizontalPlacement,
11+
deriveMenuVerticalPlacement,
12+
} from "../../lib/menu-placement";
1013
import { WindowHingeContext } from "../../native/window-hinge-context";
1114
import { OverlayPortal } from "./OverlayPortal";
1215
import { useAndroidControlSizing } from "./useAndroidControlSizing";
@@ -41,10 +44,9 @@ export type AndroidAnchoredMenuProps = {
4144
};
4245

4346
export function AndroidAnchoredMenu(props: AndroidAnchoredMenuProps) {
44-
const { scale, menuWidth: desiredMenuWidth } = useAndroidControlSizing();
47+
const { scale, menuWidth: desiredMenuWidth, menuItemHeight } = useAndroidControlSizing();
4548
const [anchor, setAnchor] = useState<AnchorSnapshot | null>(null);
4649
const [path, setPath] = useState<readonly MenuAction[]>([]);
47-
const [rootHeight, setRootHeight] = useState<number | null>(null);
4850
const [overlay, setOverlay] = useState<OverlayFrame | null>(null);
4951
const windowHinge = use(WindowHingeContext);
5052
// State, not a ref: `open` reaches render-prop children, and the compiler
@@ -58,7 +60,6 @@ export function AndroidAnchoredMenu(props: AndroidAnchoredMenuProps) {
5860
setAnchor(null);
5961
setPath([]);
6062
setOverlay(null);
61-
setRootHeight(null);
6263
};
6364

6465
const open = () => {
@@ -70,7 +71,6 @@ export function AndroidAnchoredMenu(props: AndroidAnchoredMenuProps) {
7071
const measureOverlay = () => {
7172
overlayRef.current?.measureInWindow((x, y, width, height) => {
7273
setOverlay({ x, y, width, height });
73-
setRootHeight(height);
7474
});
7575
};
7676

@@ -110,17 +110,19 @@ export function AndroidAnchoredMenu(props: AndroidAnchoredMenuProps) {
110110
margin: SCREEN_MARGIN,
111111
hinge: windowHinge && { x: windowHinge.x - overlay.x, width: windowHinge.width },
112112
});
113-
// This in-window menu preserves keyboard focus; subtract the IME area so its items remain tappable.
114-
const usableBottom =
115-
overlay === null ? 0 : overlay.height - (keyboardVisible ? keyboardHeight : 0);
116-
const spaceBelow =
113+
const verticalPlacement =
117114
local === null || overlay === null
118-
? 0
119-
: usableBottom - (local.y + local.height) - ANCHOR_GAP - SCREEN_MARGIN;
120-
const spaceAbove = local === null ? 0 : local.y - ANCHOR_GAP - SCREEN_MARGIN;
121-
const opensDown = spaceBelow >= 280 || spaceBelow >= spaceAbove;
122-
const maxHeight = Math.min(opensDown ? spaceBelow : spaceAbove, 480);
123-
const placeable = local !== null && rootHeight !== null;
115+
? null
116+
: deriveMenuVerticalPlacement({
117+
anchorY: local.y,
118+
anchorHeight: local.height,
119+
overlayHeight: overlay.height,
120+
// This in-window menu preserves keyboard focus; subtract the IME area so its items remain tappable.
121+
keyboardInset: keyboardVisible ? keyboardHeight : 0,
122+
gap: ANCHOR_GAP,
123+
margin: SCREEN_MARGIN,
124+
minHeight: 2 * menuItemHeight + 14 * scale,
125+
});
124126

125127
const onPressItem = (action: MenuAction) => {
126128
if ((action.subactions?.length ?? 0) > 0) {
@@ -167,7 +169,7 @@ export function AndroidAnchoredMenu(props: AndroidAnchoredMenuProps) {
167169
onLayout={measureOverlay}
168170
>
169171
<Pressable accessible={false} className="absolute inset-0" onPress={close} />
170-
{!placeable || local === null ? null : !anchor.keyboardWasVisible ? (
172+
{local === null ? null : !anchor.keyboardWasVisible ? (
171173
<MenuPopup
172174
// Compose aligns to the trigger's start if it fits; hinge-safe triggers keep menus on their side.
173175
anchor={windowHinge ? { ...local, x: left, width: menuWidth } : local}
@@ -185,12 +187,9 @@ export function AndroidAnchoredMenu(props: AndroidAnchoredMenuProps) {
185187
className="absolute overflow-hidden bg-card-alt shadow-md"
186188
style={{
187189
left,
188-
maxHeight,
189190
width: menuWidth,
190191
borderRadius: 4 * scale,
191-
...(opensDown
192-
? { top: local.y + local.height + ANCHOR_GAP }
193-
: { bottom: (rootHeight ?? 0) - local.y + ANCHOR_GAP }),
192+
...verticalPlacement,
194193
}}
195194
>
196195
{/* Compose DropdownMenu takes focus; in-window editor menus preserve the keyboard. */}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616

1717
import { useProjects } from "../../state/entities";
1818
import { environmentThreadShells } from "../../state/threads";
19-
import { usePendingNewTasks } from "../../state/use-pending-new-tasks";
19+
import { useLaunchingThreads, usePendingNewTasks } from "../../state/use-pending-new-tasks";
2020
import { useWorkspaceState } from "../../state/workspace";
2121
import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
2222
import {
@@ -46,9 +46,8 @@ export function HomeRouteScreen() {
4646
const projects = useProjects();
4747
// Stop rebuilding the streaming thread list while Thread covers Home.
4848
const visible = useHomeRouteVisible();
49-
const threads = useAtomValueWhileVisible(
50-
environmentThreadShells.navigationThreadShellsAtom,
51-
visible,
49+
const threads = useLaunchingThreads(
50+
useAtomValueWhileVisible(environmentThreadShells.navigationThreadShellsAtom, visible),
5251
);
5352
const { environments: workspaceEnvironments, state: catalogState } = useWorkspaceState();
5453
const { savedConnectionsById } = useSavedRemoteConnections();

‎apps/mobile/src/features/projects/AddProjectScreen.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,12 +1424,11 @@ export function AddProjectDestinationScreen(props: {
14241424

14251425
const originRoute = getActiveRoute(navigation);
14261426
setIsSubmitting(true);
1427-
const projectId = ProjectId.make(uuidv4());
14281427
const title = inferProjectTitleFromPath(resolved.path);
14291428
const startResult = await startProjectClone({
14301429
environmentId: environment.environmentId,
14311430
input: {
1432-
projectId,
1431+
projectId: ProjectId.make(uuidv4()),
14331432
title,
14341433
createdAt: new Date().toISOString(),
14351434
remoteUrl,
@@ -1440,6 +1439,7 @@ export function AddProjectDestinationScreen(props: {
14401439
setError(errorMessage(Cause.squash(startResult.cause)));
14411440
} else {
14421441
void suggestAppAccessForRemote(checkAppAccess, environment.environmentId, remoteUrl);
1442+
const { projectId } = startResult.value;
14431443
// Wait for the create event; the client store otherwise falls back to the project picker and loses clone controls.
14441444
const project = await waitForProject(
14451445
{ environmentId: environment.environmentId, projectId },

0 commit comments

Comments
 (0)