Skip to content

Commit bb35b94

Browse files
committed
merge: sync reduced upstream agent context budget
2 parents 8be315b + 5211acf commit bb35b94

133 files changed

Lines changed: 4242 additions & 2015 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.

‎.github/actions/setup-ci-deps/action.yml‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ runs:
7070
INSTALL_ARGS: ${{ inputs.install-args }}
7171
run: |
7272
echo "path=$(vp pm cache dir)" >> "$GITHUB_OUTPUT"
73+
metadata_dir="${pnpm_config_cache_dir:-$RUNNER_TEMP/pnpm-metadata}"
74+
echo "pnpm_config_cache_dir=$metadata_dir" >> "$GITHUB_ENV"
75+
echo "verified=$metadata_dir/lockfile-verified.jsonl" >> "$GITHUB_OUTPUT"
7376
if [[ -z "$INSTALL_ARGS" ]]; then
7477
echo "namespace=full" >> "$GITHUB_OUTPUT"
7578
else
@@ -94,6 +97,16 @@ runs:
9497
pnpm-${{ steps.pnpm_store.outputs.namespace }}-v1-${{ runner.os }}-${{ runner.arch }}-
9598
pnpm-full-v1-${{ runner.os }}-${{ runner.arch }}-
9699
100+
# pnpm accepts an earlier pass for the same lockfile and policy at any age, so
101+
# a cached record skips fetching registry metadata for every package.
102+
- name: Restore lockfile verification
103+
id: pnpm_verified
104+
if: inputs.install == 'true'
105+
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
106+
with:
107+
path: ${{ steps.pnpm_store.outputs.verified }}
108+
key: pnpm-verified-v1-${{ hashFiles('pnpm-lock.yaml', 'pnpm-workspace.yaml', 'package.json') }}
109+
97110
- name: Install dependencies
98111
if: inputs.install == 'true'
99112
shell: bash
@@ -102,6 +115,13 @@ runs:
102115
# Unquoted so each filter is its own argument.
103116
run: vp install $INSTALL_ARGS
104117

118+
- name: Save lockfile verification
119+
if: inputs.install == 'true' && steps.pnpm_verified.outputs.cache-hit != 'true'
120+
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
121+
with:
122+
path: ${{ steps.pnpm_store.outputs.verified }}
123+
key: ${{ steps.pnpm_verified.outputs.cache-primary-key }}
124+
105125
# A filtered install that started from the current full store adds nothing
106126
# worth a second copy of it.
107127
- name: Save pnpm store

‎.github/workflows/release-desktop.yml‎

Lines changed: 93 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,29 @@ jobs:
163163
env:
164164
pnpm_config_cache_dir: ${{ runner.temp }}/pnpm-metadata
165165

166+
# The CLI archive and the staged app install without a lockfile, so they
167+
# ask the registry about every package and fetch platform packages the
168+
# workspace store lacks. They share this registry metadata and store. A
169+
# new week starts cold, which bounds how stale cached ranges can get.
170+
- name: Resolve staged install cache
171+
id: stage_pnpm
172+
shell: bash
173+
run: |
174+
echo "dir=$RUNNER_TEMP/desktop-stage-pnpm" >> "$GITHUB_OUTPUT"
175+
echo "prefix=desktop-stage-pnpm-v2-${{ inputs.platform }}-${{ inputs.arch }}-$(date -u +%G-%V)-" >> "$GITHUB_OUTPUT"
176+
177+
- name: Restore staged install cache
178+
id: stage_pnpm_cache
179+
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
180+
with:
181+
path: ${{ steps.stage_pnpm.outputs.dir }}
182+
key: ${{ steps.stage_pnpm.outputs.prefix }}${{ github.run_id }}-${{ github.run_attempt }}
183+
restore-keys: ${{ steps.stage_pnpm.outputs.prefix }}
184+
185+
- name: Mark staged install cache
186+
shell: bash
187+
run: mkdir -p "${{ steps.stage_pnpm.outputs.dir }}" && touch "$RUNNER_TEMP/desktop-stage-pnpm.marker"
188+
166189
- name: Cache resource monitor
167190
id: resource_monitor_cache
168191
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
@@ -254,21 +277,60 @@ jobs:
254277
if [[ "${{ inputs.version }}" =~ -nightly\.[0-9]{8}\.[0-9]+$ ]]; then brand=nightly; fi
255278
node scripts/apply-web-brand-assets.ts "$brand" apps/server/dist/client
256279
280+
- name: Resolve target Node.js for the CLI executable
281+
id: target_node
282+
if: inputs.cli_archive && inputs.platform == 'win'
283+
shell: bash
284+
run: echo "version=$(node -p 'require("./package.json").engines.node')" >> "$GITHUB_OUTPUT"
285+
286+
# The download only changes with engines.node, so a cached copy keeps
287+
# releases off nodejs.org, which stalls on the runners some days.
288+
- name: Restore target Node.js for the CLI executable
289+
id: target_node_cache
290+
if: inputs.cli_archive && inputs.platform == 'win'
291+
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
292+
with:
293+
path: ${{ runner.temp }}/node-download
294+
key: node-download-v${{ steps.target_node.outputs.version }}-win-${{ inputs.arch }}
295+
257296
# tsdown downloads the target Node with one fetch and no retry, and
258297
# nodejs.org drops that download often enough to fail releases. Seed
259-
# tsdown's cache with a retried, checksum-verified copy instead.
298+
# tsdown's cache with a retried, checksum-verified copy instead. A transfer
299+
# under 100 KB/s for 30s counts as failed, so a stall retries.
260300
- name: Download target Node.js for the CLI executable
301+
if: inputs.cli_archive && inputs.platform == 'win' && steps.target_node_cache.outputs.cache-hit != 'true'
302+
shell: bash
303+
env:
304+
VERSION: ${{ steps.target_node.outputs.version }}
305+
run: |
306+
set -euo pipefail
307+
name="node-v$VERSION-win-${{ inputs.arch }}"
308+
dir="$RUNNER_TEMP/node-download"
309+
mkdir -p "$dir"
310+
fetch=(curl -fsSL --retry 5 --retry-all-errors --connect-timeout 10 --speed-limit 102400 --speed-time 30)
311+
"${fetch[@]}" -o "$dir/$name.zip" "https://nodejs.org/dist/v$VERSION/$name.zip"
312+
"${fetch[@]}" -o "$dir/SHASUMS256.txt" "https://nodejs.org/dist/v$VERSION/SHASUMS256.txt"
313+
(cd "$dir" && grep " $name.zip\$" SHASUMS256.txt | sha256sum -c -)
314+
315+
# Saved right away so a later failure in this job still keeps the download.
316+
- name: Save target Node.js for the CLI executable
317+
if: inputs.cli_archive && inputs.platform == 'win' && steps.target_node_cache.outputs.cache-hit != 'true'
318+
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
319+
with:
320+
path: ${{ runner.temp }}/node-download
321+
key: ${{ steps.target_node_cache.outputs.cache-primary-key }}
322+
323+
- name: Install target Node.js for the CLI executable
261324
if: inputs.cli_archive && inputs.platform == 'win'
262325
shell: bash
326+
env:
327+
VERSION: ${{ steps.target_node.outputs.version }}
263328
run: |
264329
set -euo pipefail
265-
version="$(node -p 'require("./package.json").engines.node')"
266-
name="node-v$version-win-${{ inputs.arch }}"
267-
dest="${XDG_CACHE_HOME:-$HOME/.cache}/tsdown/node/v$version/win-${{ inputs.arch }}"
330+
name="node-v$VERSION-win-${{ inputs.arch }}"
268331
dir="$RUNNER_TEMP/node-download"
269-
mkdir -p "$dir" "$dest"
270-
curl -fsSL --retry 5 --retry-all-errors -o "$dir/$name.zip" "https://nodejs.org/dist/v$version/$name.zip"
271-
curl -fsSL --retry 5 --retry-all-errors -o "$dir/SHASUMS256.txt" "https://nodejs.org/dist/v$version/SHASUMS256.txt"
332+
dest="${XDG_CACHE_HOME:-$HOME/.cache}/tsdown/node/v$VERSION/win-${{ inputs.arch }}"
333+
mkdir -p "$dest"
272334
(cd "$dir" && grep " $name.zip\$" SHASUMS256.txt | sha256sum -c -)
273335
unzip -p "$dir/$name.zip" "$name/node.exe" > "$dest/node.exe"
274336
@@ -332,6 +394,9 @@ jobs:
332394
if: inputs.cli_archive
333395
shell: bash
334396
env:
397+
pnpm_config_cache_dir: ${{ steps.stage_pnpm.outputs.dir }}/cache
398+
pnpm_config_store_dir: ${{ steps.stage_pnpm.outputs.dir }}/store
399+
pnpm_config_prefer_offline: "true"
335400
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
336401
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
337402
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
@@ -451,7 +516,10 @@ jobs:
451516
- name: Build desktop artifact
452517
shell: bash
453518
env:
454-
pnpm_config_cache_dir: ${{ runner.temp }}/pnpm-metadata
519+
# pnpm only goes to the registry for packages or versions the cache lacks.
520+
pnpm_config_cache_dir: ${{ steps.stage_pnpm.outputs.dir }}/cache
521+
pnpm_config_store_dir: ${{ steps.stage_pnpm.outputs.dir }}/store
522+
pnpm_config_prefer_offline: "true"
455523
T3CODE_DESKTOP_REUSE_RESOURCE_MONITOR: true
456524
T3CODE_DESKTOP_REUSE_LINUX_CAPTURE_HELPERS: ${{ steps.capture_helper_cache.outputs.cache-hit == 'true' }}
457525
CSC_LINK: ${{ secrets.CSC_LINK }}
@@ -536,6 +604,23 @@ jobs:
536604
537605
vp run dist:desktop:artifact "${args[@]}"
538606
607+
# Warm installs only touch the store index, so new content means a fetch.
608+
- name: Check staged install cache for new content
609+
id: stage_pnpm_changed
610+
shell: bash
611+
run: |
612+
dir="${{ steps.stage_pnpm.outputs.dir }}"
613+
new=$(find "$dir/cache/v12" "$dir/store/v11/files" -type f -newer "$RUNNER_TEMP/desktop-stage-pnpm.marker" 2>/dev/null | wc -l | tr -d ' ')
614+
echo "Staged installs added $new cached files."
615+
echo "changed=$([[ "$new" -gt 0 ]] && echo true || echo false)" >> "$GITHUB_OUTPUT"
616+
617+
- name: Save staged install cache
618+
if: steps.stage_pnpm_changed.outputs.changed == 'true'
619+
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
620+
with:
621+
path: ${{ steps.stage_pnpm.outputs.dir }}
622+
key: ${{ steps.stage_pnpm_cache.outputs.cache-primary-key }}
623+
539624
# A build can package fine and still not open (a missing module in the
540625
# backend or the bundle). This launches the app from the shipped
541626
# AppImage or DMG.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ const clientSettings: ClientSettings = {
3434
confirmThreadDelete: false,
3535
confirmThreadUnpin: false,
3636
contextWindowMeterEnabled: false,
37-
composerCollapseOnScroll: true,
3837
diffFilesCollapsed: true,
3938
diffIgnoreWhitespace: true,
4039
diffLayout: "stacked",
@@ -64,6 +63,7 @@ const clientSettings: ClientSettings = {
6463
sidebarProjectSortOrder: "manual",
6564
sidebarThreadSortOrder: "created_at",
6665
boringSidebarEnabled: false,
66+
boringSidebarMultilineRows: false,
6767
legacySidebarEnabled: false,
6868
sidebarWorkingShelfEnabled: false,
6969
loadBalancingEnabled: false,

‎apps/mobile/app.config.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ const config: ExpoConfig = {
226226
slug: "t3-code",
227227
platforms: ["ios", "android"],
228228
scheme: variant.scheme,
229-
version: repoEnv.T3CODE_MOBILE_VERSION ?? "2.1.0",
229+
version: repoEnv.T3CODE_MOBILE_VERSION ?? "2.2.0",
230230
runtimeVersion: {
231231
// Skip costly fingerprinting on dev launches; preview and production OTAs require matching native projects.
232232
policy: runtimeVersionPolicy,

‎apps/mobile/metro.config.js‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ async function generateMobileThirdPartyLicenses() {
5656
const manifest = await generateThirdPartyLicenseManifest({
5757
configFile: path.join(workspaceRoot, "third-party-licenses.config.json"),
5858
packageManifests: [{ bundle: "mobile", path: path.join(__dirname, "package.json") }],
59-
allowMissingGeneratedNotices:
60-
process.env.NODE_ENV !== "production" &&
61-
process.env.EAS_BUILD !== "true" &&
62-
process.env.T3CODE_LICENSES_STRICT !== "1",
6359
});
6460

6561
await Promise.all([

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
3030
import { SymbolView, type AppSymbolName } from "../../components/ui/AppSymbol";
3131
import { AppText as Text, AppTextInput as TextInput } from "../../components/ui/AppText";
3232
import { EnvironmentMachineSymbol } from "../../components/EnvironmentMachineSymbol";
33-
import { useLinkableMachines } from "../../state/peerLinks";
33+
import { peerLinkEnvironment, useLinkableMachines } from "../../state/peerLinks";
3434
import { mintPairingCodeOn } from "../../state/peerPairingCode";
35-
import { serverEnvironment } from "../../state/server";
3635
import { useEnvironmentScope, usePreparedConnection } from "../../state/session";
3736
import { useAtomCommand } from "../../state/use-atom-command";
3837
import { ListChoiceRow as SettingsChoiceRow } from "../../components/ui/ListChoiceRow";
@@ -107,13 +106,13 @@ function PendingLinkRequest(props: {
107106
const [open, setOpen] = useState(false);
108107
const [declining, setDeclining] = useState(false);
109108
const [error, setError] = useState<string | null>(null);
110-
const answer = useAtomCommand(serverEnvironment.answerLinkRequest, {
109+
const answer = useAtomCommand(peerLinkEnvironment.answerRequest, {
111110
label: "decline link request",
112111
reportFailure: false,
113112
reportDefect: false,
114113
});
115114
const canAnswer = useAtomValue(
116-
serverEnvironment.answerLinkRequest.permissionAtom(props.environmentId),
115+
peerLinkEnvironment.answerRequest.permissionAtom(props.environmentId),
117116
);
118117
const target = linkRequestTargetName(item);
119118

@@ -244,7 +243,7 @@ function LinkRequestSheet(props: {
244243
const [mintFailed, setMintFailed] = useState<ReadonlySet<EnvironmentId>>(new Set());
245244
// Submit then a tap can both run before a re-render; this guard is synchronous.
246245
const inFlight = useRef(false);
247-
const answer = useAtomCommand(serverEnvironment.answerLinkRequest, {
246+
const answer = useAtomCommand(peerLinkEnvironment.answerRequest, {
248247
label: "answer link request",
249248
// The failure cause holds the request, and with it the code; keep it out of the console.
250249
reportFailure: false,

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

Lines changed: 95 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,92 @@ function compactionLabel(label: string, title: string | undefined) {
12081208
: label;
12091209
}
12101210

1211+
function RunFoldButton({
1212+
entry,
1213+
environmentId,
1214+
threadId,
1215+
onToggle,
1216+
rowSizing,
1217+
iconColor,
1218+
}: {
1219+
entry: Extract<ThreadFeedEntry, { type: "run-fold" }>;
1220+
environmentId: EnvironmentId;
1221+
threadId: ThreadId;
1222+
onToggle: (runId: RunId) => void;
1223+
rowSizing: ReturnType<typeof deriveThreadWorkLogSizing>;
1224+
iconColor: ColorValue;
1225+
}) {
1226+
const loadWork = useAtomCommand(threadEnvironment.loadEarlierHistory, { reportFailure: false });
1227+
const anchorsKey = entry.deferredWorkItemIds?.join("\n") ?? "";
1228+
const [failed, setFailed] = useState(false);
1229+
const load = () => {
1230+
if (!anchorsKey) return;
1231+
void Promise.all(
1232+
anchorsKey
1233+
.split("\n")
1234+
.map((workAnchorId) => loadWork({ environmentId, input: { threadId, workAnchorId } })),
1235+
).then((results) =>
1236+
setFailed(
1237+
results.some((result) => result._tag === "Failure" || result.value._tag === "error"),
1238+
),
1239+
);
1240+
};
1241+
const loadOnExpand = useEffectEvent(load);
1242+
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- Restored expanded folds load their deferred server history on mount.
1243+
useEffect(() => {
1244+
if (entry.expanded && anchorsKey && environmentId && threadId) loadOnExpand();
1245+
}, [entry.expanded, anchorsKey, environmentId, threadId]);
1246+
const error = anchorsKey && failed ? "Couldn't load work. Tap to retry." : null;
1247+
const loading = entry.expanded && anchorsKey !== "" && !failed;
1248+
const toggle = () => {
1249+
setFailed(false);
1250+
if (error && entry.expanded) load();
1251+
else onToggle(entry.runId);
1252+
};
1253+
1254+
return (
1255+
<View className="min-w-0 flex-1">
1256+
<Pressable
1257+
accessibilityRole="button"
1258+
accessibilityState={{ expanded: entry.expanded, busy: loading }}
1259+
onPress={toggle}
1260+
hitSlop={4}
1261+
className="min-h-11 min-w-0 flex-1 flex-row items-center gap-2"
1262+
style={{ minHeight: Math.max(TURN_FOLD_HEIGHT - 3.5, rowSizing.estimatedRowHeight) }}
1263+
>
1264+
<Text
1265+
key={rowSizing.textSizeKey}
1266+
numberOfLines={1}
1267+
className="shrink font-t3-medium text-sm tabular-nums text-foreground-muted"
1268+
>
1269+
{entry.label}
1270+
{error ? ` · ${error}` : ""}
1271+
</Text>
1272+
<ThreadDisclosureChevron
1273+
expanded={entry.expanded}
1274+
collapsedDirection="right"
1275+
size={15}
1276+
tintColor={iconColor}
1277+
/>
1278+
</Pressable>
1279+
{loading ? (
1280+
<View
1281+
accessible={false}
1282+
importantForAccessibility="no-hide-descendants"
1283+
className="gap-2 px-1 pb-2"
1284+
>
1285+
{(["40%", "60%", "33%"] as const).map((width) => (
1286+
<View key={width} className="flex-row items-center gap-2">
1287+
<View className="size-3 rounded bg-subtle-strong" />
1288+
<View className="h-2.5 rounded-full bg-subtle-strong" style={{ width }} />
1289+
</View>
1290+
))}
1291+
</View>
1292+
) : null}
1293+
</View>
1294+
);
1295+
}
1296+
12111297
function renderFeedEntry(
12121298
info: { item: ThreadFeedRow; index: number },
12131299
props: Pick<
@@ -1279,30 +1365,15 @@ function renderFeedEntry(
12791365
if (entry.type === "run-fold") {
12801366
return (
12811367
<View className="mb-1 flex-row items-center border-b border-border-subtle px-2">
1282-
<Pressable
1283-
accessibilityRole="button"
1284-
accessibilityState={{ expanded: entry.expanded }}
1285-
onPress={() => props.onToggleTurnFold(entry.runId)}
1286-
hitSlop={4}
1287-
className="min-h-11 min-w-0 flex-1 flex-row items-center gap-2"
1288-
style={{
1289-
minHeight: Math.max(TURN_FOLD_HEIGHT - 3.5, props.workRowSizing.estimatedRowHeight),
1290-
}}
1291-
>
1292-
<Text
1293-
key={props.workRowSizing.textSizeKey}
1294-
numberOfLines={1}
1295-
className="shrink font-t3-medium text-sm tabular-nums text-foreground-muted"
1296-
>
1297-
{entry.label}
1298-
</Text>
1299-
<ThreadDisclosureChevron
1300-
expanded={entry.expanded}
1301-
collapsedDirection="right"
1302-
size={15}
1303-
tintColor={iconSubtleColor}
1304-
/>
1305-
</Pressable>
1368+
<RunFoldButton
1369+
key={entry.id}
1370+
entry={entry}
1371+
environmentId={props.environmentId}
1372+
threadId={props.threadId}
1373+
onToggle={props.onToggleTurnFold}
1374+
rowSizing={props.workRowSizing}
1375+
iconColor={iconSubtleColor}
1376+
/>
13061377
{entry.checkpointSummary ? (
13071378
<TurnDiffStat
13081379
checkpoint={entry.checkpointSummary}

0 commit comments

Comments
 (0)