Skip to content

Commit a63819c

Browse files
authored
Merge branch 'main' into fix/android-pr-link-back-stack
2 parents d26280c + dd14848 commit a63819c

410 files changed

Lines changed: 15542 additions & 2622 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/workflows/agent-context-budget.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@ jobs:
5151
echo "Accepted by the agent-context-increase label."
5252
exit 0
5353
fi
54-
echo "::error file=$BUDGET::Agent context grew compared to main. Cut the added text, or ask a maintainer to add the agent-context-increase label."
54+
echo "::error file=$BUDGET::Agent context grew compared to main. Cut the added text and rerun the evals that cover it (evals/README.md), or ask a maintainer to add the agent-context-increase label."
5555
exit 1

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,15 @@ jobs:
390390
mkdir -p "$target_dir"
391391
cp "native/resource-monitor/target/${{ inputs.rust_target }}/release/${binary_name}" "$target_dir/$binary_name"
392392
393+
- uses: ./.github/actions/setup-apt-mirrors
394+
if: inputs.platform == 'linux'
395+
396+
# The Linux archive ships libatomic.so.1 and points t3's RUNPATH at it.
397+
- name: Install patchelf
398+
if: inputs.cli_archive && inputs.platform == 'linux'
399+
shell: bash
400+
run: command -v patchelf || { sudo apt-get update && sudo apt-get install -y patchelf; }
401+
393402
- name: Build CLI archive
394403
if: inputs.cli_archive
395404
shell: bash
@@ -433,9 +442,6 @@ jobs:
433442
path: release-cli/*
434443
if-no-files-found: error
435444

436-
- uses: ./.github/actions/setup-apt-mirrors
437-
if: inputs.platform == 'linux'
438-
439445
- name: Install Linux desktop build libraries
440446
if: inputs.platform == 'linux'
441447
shell: bash

‎.github/workflows/release.yml‎

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,11 +762,16 @@ jobs:
762762
timeout-minutes: 30
763763
permissions:
764764
contents: write
765+
# Release notes read PR bodies and authors.
766+
pull-requests: read
765767
steps:
766768
- name: Checkout
767769
uses: actions/checkout@v6
768770
with:
769771
ref: ${{ needs.preflight.outputs.ref }}
772+
# Release notes need history back to the previous tag, not file contents.
773+
fetch-depth: 0
774+
filter: blob:none
770775
sparse-checkout: |
771776
/*
772777
!/.repos/
@@ -892,6 +897,27 @@ jobs:
892897
echo 'EOF'
893898
} >> "$GITHUB_OUTPUT"
894899
900+
# A short model summary over GitHub's full list. Without a notes file, the
901+
# release falls back to GitHub's generated notes.
902+
- name: Write release notes
903+
if: needs.preflight.outputs.release_channel != 'preview' && needs.preflight.outputs.previous_tag != ''
904+
continue-on-error: true
905+
timeout-minutes: 5
906+
env:
907+
GH_TOKEN: ${{ github.token }}
908+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
909+
run: |
910+
node scripts/generate-release-notes.ts \
911+
--repository "${{ github.repository }}" \
912+
--tag "${{ needs.preflight.outputs.tag }}" \
913+
--ref "${{ needs.preflight.outputs.ref }}" \
914+
--previous-tag "${{ needs.preflight.outputs.previous_tag }}" \
915+
--version "${{ needs.preflight.outputs.version }}" \
916+
--output release-notes.md
917+
if [[ -f release-notes.md ]]; then
918+
cat release-notes.md >> "$GITHUB_STEP_SUMMARY"
919+
fi
920+
895921
# A preview release gets a warning instead of generated notes. Generated
896922
# notes would list every commit since the previous preview, which is
897923
# unmerged branch history no one should read as a changelog, and would
@@ -917,10 +943,11 @@ jobs:
917943
tag_name: ${{ needs.preflight.outputs.tag }}
918944
target_commitish: ${{ needs.preflight.outputs.ref }}
919945
name: ${{ needs.preflight.outputs.release_name }}
920-
generate_release_notes: ${{ needs.preflight.outputs.release_channel != 'preview' }}
921-
body_path: ${{ needs.preflight.outputs.release_channel == 'preview' && 'release-notes.md' || '' }}
946+
generate_release_notes: ${{ hashFiles('release-notes.md') == '' }}
947+
body_path: ${{ hashFiles('release-notes.md') != '' && 'release-notes.md' || '' }}
922948
previous_tag: ${{ needs.preflight.outputs.previous_tag }}
923949
prerelease: ${{ needs.preflight.outputs.is_prerelease }}
950+
draft: ${{ needs.preflight.outputs.is_prerelease }}
924951
make_latest: ${{ needs.preflight.outputs.make_latest }}
925952
files: ${{ steps.release_files.outputs.files }}
926953
fail_on_unmatched_files: true
@@ -936,11 +963,23 @@ jobs:
936963
generate_release_notes: ${{ needs.preflight.outputs.release_channel != 'preview' }}
937964
body_path: ${{ needs.preflight.outputs.release_channel == 'preview' && 'release-notes.md' || '' }}
938965
prerelease: ${{ needs.preflight.outputs.is_prerelease }}
966+
draft: ${{ needs.preflight.outputs.is_prerelease }}
939967
make_latest: ${{ needs.preflight.outputs.make_latest }}
940968
files: ${{ steps.release_files.outputs.files }}
941969
fail_on_unmatched_files: true
942970
token: ${{ github.token }}
943971

972+
# The action keeps a stable release a draft until its assets finish uploading, but publishes a
973+
# prerelease first. Desktop clients update connected servers from the CLI archives as soon as
974+
# they see the release, so a prerelease also goes public only once every asset is attached.
975+
- name: Publish prerelease
976+
if: needs.preflight.outputs.is_prerelease == 'true'
977+
env:
978+
GH_TOKEN: ${{ github.token }}
979+
GH_REPO: ${{ github.repository }}
980+
RELEASE_TAG: ${{ needs.preflight.outputs.tag }}
981+
run: gh release edit "$RELEASE_TAG" --draft=false
982+
944983
# The `t3` npm package is a launcher that downloads this version's CLI
945984
# archive from the GitHub Release, so it publishes only once that release
946985
# exists. Preview publishes too, under the `preview` dist-tag, which

‎AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ An empty database is a bad test. Seed your worktree's `.t3` with a copy of real
9898

9999
## Verifying
100100

101-
- Before you push, run `vp run check:changed`. It runs CI's fast checks for changed files: format, lint, knip, typecheck of affected packages and dependents, and tests beside changes. CI still runs the full test suites.
101+
- Before you push, run `vp run check:changed`. It runs CI's fast checks for changed files: format, lint, knip, typecheck of affected packages and dependents, tests beside changes, and the cross-file checks those miss. CI still runs the full test suites.
102102
- While you iterate, run `vp test run <files>`. For big files, add `-t "<name>"`.
103103
- Use `vp run typecheck`, not `npx tsc`; it caches per package. Both run tsc-rs (`typescript` is the `@tsc-rs/typescript` drop-in).
104104
- Run `node -e` snippets from `apps/server` or the owning package. `effect` does not resolve from the repo root.

‎apps/desktop/package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@t3tools/desktop",
3-
"version": "0.1.3",
3+
"version": "0.1.5",
44
"private": true,
55
"type": "module",
66
"main": "dist-electron/boot.cjs",
@@ -22,7 +22,7 @@
2222
"@t3tools/tailscale": "workspace:*",
2323
"dbus-next": "0.10.2",
2424
"effect": "catalog:",
25-
"electron": "44.9.3",
25+
"electron": "44.10.0",
2626
"electron-store": "^8.2.0",
2727
"electron-updater": "^6.8.9",
2828
"electron-webauthn": "catalog:",

‎apps/desktop/src/app/DesktopCliCommand.test.ts‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as NodeServices from "@effect/platform-node/NodeServices";
22
import { afterEach, beforeEach, expect, it } from "@effect/vitest";
3+
import * as HostProcess from "@t3tools/shared/HostProcess";
34
import * as Effect from "effect/Effect";
45
import * as FileSystem from "effect/FileSystem";
56
import * as Option from "effect/Option";
@@ -135,6 +136,14 @@ it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
135136
yield* command.uninstall;
136137
expect(yield* fs.readFileString(theirs)).toBe("npm's t3\n");
137138
expect(yield* fs.readLink(path.join(home, "bin", "t3"))).toBe(path.join(home, "gone"));
139+
140+
const launcher = path.join(home, ".t3", "bin", "t3");
141+
yield* fs.writeFileString(launcher, "npm's t3\n");
142+
process.env.PATH = path.dirname(launcher);
143+
expect(yield* command.state).toMatchObject({ onPath: false, shadowedBy: launcher });
144+
expect((yield* Effect.flip(command.install)).message).toContain("Could not set up");
145+
yield* command.uninstall;
146+
expect(yield* fs.readFileString(launcher)).toBe("npm's t3\n");
138147
}).pipe(Effect.scoped),
139148
);
140149

@@ -183,6 +192,67 @@ it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
183192
}).pipe(Effect.scoped),
184193
);
185194

195+
it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")(
196+
"skips a t3 directory or a file this user cannot execute",
197+
() =>
198+
Effect.gen(function* () {
199+
const fs = yield* FileSystem.FileSystem;
200+
const path = yield* Path.Path;
201+
const home = yield* fs.makeTempDirectoryScoped();
202+
const folder = path.join(home, "folder");
203+
const plain = path.join(home, "plain");
204+
const shadow = path.join(home, "shadow");
205+
yield* fs.makeDirectory(path.join(folder, "t3"), { recursive: true });
206+
yield* fs.makeDirectory(plain);
207+
yield* fs.writeFileString(path.join(plain, "t3"), "notes\n");
208+
// Root can execute mode 0o601; other users must honor the owner permissions.
209+
yield* fs.chmod(path.join(plain, "t3"), process.getuid?.() === 0 ? 0o600 : 0o601);
210+
yield* fs.makeDirectory(shadow);
211+
yield* fs.writeFileString(path.join(shadow, "t3"), "#!/bin/sh\n", { mode: 0o755 });
212+
process.env.PATH = [folder, plain, shadow, path.join(home, ".local", "bin")].join(":");
213+
214+
const command = yield* commandIn({ home });
215+
expect((yield* command.state).shadowedBy).toBe(path.join(shadow, "t3"));
216+
217+
const error = yield* Effect.flip(command.install);
218+
expect(error.message).toContain(path.join(shadow, "t3"));
219+
220+
yield* fs.remove(shadow, { recursive: true });
221+
expect(yield* command.install).toMatchObject({
222+
onPath: true,
223+
installedPath: path.join(home, ".local", "bin", "t3"),
224+
});
225+
}).pipe(Effect.scoped),
226+
);
227+
228+
it.effect("does not treat its own launcher as another t3 when its folder is first on PATH", () =>
229+
Effect.gen(function* () {
230+
const fs = yield* FileSystem.FileSystem;
231+
const path = yield* Path.Path;
232+
const home = yield* fs.makeTempDirectoryScoped();
233+
const launcher = path.join(home, ".t3", "bin", "t3");
234+
process.env.PATH = [path.dirname(launcher), path.join(home, ".local", "bin")].join(":");
235+
236+
const command = yield* commandIn({ home });
237+
const installed = yield* command.install;
238+
239+
expect(yield* fs.exists(launcher)).toBe(true);
240+
expect(installed).toMatchObject({
241+
onPath: true,
242+
installedPath: path.join(home, ".local", "bin", "t3"),
243+
});
244+
expect(installed.shadowedBy).toBeUndefined();
245+
expect(yield* command.state).toEqual(installed);
246+
247+
const removed = yield* command.uninstall;
248+
expect(removed.installedPath).toBeNull();
249+
expect(removed.onPath).toBe(true);
250+
expect(yield* command.state).toEqual(removed);
251+
expect(yield* fs.exists(installed.installedPath!)).toBe(false);
252+
expect(yield* fs.exists(launcher)).toBe(true);
253+
}).pipe(Effect.scoped),
254+
);
255+
186256
it.effect("leaves the Windows PATH alone when it cannot be read", () =>
187257
Effect.gen(function* () {
188258
const fs = yield* FileSystem.FileSystem;

‎apps/desktop/src/app/DesktopCliCommand.ts‎

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// @effect-diagnostics-next-line nodeBuiltinImport:off -- FileSystem.access has no execute check.
2+
import * as NodeFSP from "node:fs/promises";
3+
14
import type { DesktopCliCommandState } from "@t3tools/contracts";
25
import * as Context from "effect/Context";
36
import * as Effect from "effect/Effect";
@@ -89,6 +92,19 @@ export const make = Effect.gen(function* () {
8992
Effect.orElseSucceed(() => false),
9093
);
9194

95+
// PATH can reach the regular launcher directly; removal still requires isOurLink.
96+
const runsOurLauncher = Effect.fn("DesktopCliCommand.runsOurLauncher")(
97+
function* (candidate: string) {
98+
if (yield* isOurLink(candidate)) return true;
99+
const [resolved, ours] = yield* Effect.all([fs.realPath(candidate), fs.realPath(launcher)]);
100+
if (resolved !== ours) return false;
101+
const info = yield* fs.stat(candidate);
102+
if (info.type !== "File" || Number(info.size) > 16_384) return false;
103+
return (yield* fs.readFileString(candidate)).includes(DesktopCliShim.MARKER);
104+
},
105+
Effect.orElseSucceed(() => false),
106+
);
107+
92108
const powershell = (env: Record<string, string>) =>
93109
Effect.scoped(
94110
Effect.gen(function* () {
@@ -118,18 +134,27 @@ export const make = Effect.gen(function* () {
118134
Effect.mapError(() => fail("Could not update your PATH.")),
119135
);
120136

137+
const isExecutableFile = Effect.fn("DesktopCliCommand.isExecutableFile")(
138+
function* (target: string) {
139+
if ((yield* fs.stat(target)).type !== "File") return false;
140+
yield* Effect.tryPromise(() => NodeFSP.access(target, NodeFSP.constants.X_OK));
141+
return true;
142+
},
143+
Effect.orElseSucceed(() => false),
144+
);
145+
121146
const firstOnPath = Effect.gen(function* () {
122147
for (const directory of pathEntries(process.env.PATH, ":")) {
123148
const candidate = path.join(directory, "t3");
124-
if (yield* exists(candidate)) return Option.some(candidate);
149+
if (yield* isExecutableFile(candidate)) return Option.some(candidate);
125150
}
126151
return Option.none<string>();
127152
});
128153

129154
const foreignFirstOnPath = Effect.gen(function* () {
130155
if (windows) return Option.none<string>();
131156
const first = yield* firstOnPath;
132-
if (Option.isNone(first) || (yield* isOurLink(first.value))) return Option.none<string>();
157+
if (Option.isNone(first) || (yield* runsOurLauncher(first.value))) return Option.none<string>();
133158
return first;
134159
});
135160

@@ -156,12 +181,17 @@ export const make = Effect.gen(function* () {
156181
const installed = yield* installedAt;
157182
const shadowedBy = yield* foreignFirstOnPath;
158183
const shadow = Option.isSome(shadowedBy) ? { shadowedBy: shadowedBy.value } : {};
159-
if (Option.isNone(installed)) {
160-
return { supported: true, installedPath: null, onPath: false, launcherPath, ...shadow };
161-
}
162184
const first = yield* firstOnPath;
163-
const onPath = windows || (Option.isSome(first) && (yield* isOurLink(first.value)));
164-
return { supported: true, installedPath: installed.value, onPath, launcherPath, ...shadow };
185+
const onPath = windows
186+
? Option.isSome(installed)
187+
: Option.isSome(first) && (yield* runsOurLauncher(first.value));
188+
return {
189+
supported: true,
190+
installedPath: Option.getOrNull(installed),
191+
onPath,
192+
launcherPath,
193+
...shadow,
194+
};
165195
}).pipe(
166196
Effect.orElseSucceed(() => ({
167197
supported: false,

0 commit comments

Comments
 (0)