Skip to content

Commit b6f33dc

Browse files
committed
Merge remote-tracking branch 'origin/main' into t3/sync-pr-draft-sidebar-status
2 parents 1e4d9ce + 96f09c6 commit b6f33dc

156 files changed

Lines changed: 25110 additions & 20207 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/scripts/ci-changes.cjs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// node ci-changes.cjs --paths <file> --full run every Linux job, gate only the macOS lint
66
// node ci-changes.cjs changed paths unknown: run everything
77
//
8+
// scripts/check-changed.ts requires the same decisions so local runs match CI.
9+
//
810
// Every changed path maps to workspace packages, which then pull in their
911
// dependents from package.json. A path this file does not recognize runs
1012
// everything, so a new root file or directory can only cost minutes.
@@ -201,4 +203,6 @@ function main() {
201203
for (const [key, value] of Object.entries(outputs)) console.log(`${key}=${value}`);
202204
}
203205

204-
main();
206+
module.exports = { readWorkspace, decide };
207+
208+
if (require.main === module) main();

‎.github/scripts/ci-changes.d.cts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
interface WorkspacePackage {
2+
readonly name: string;
3+
readonly dir: string;
4+
readonly hasTest: boolean;
5+
readonly deps: ReadonlyArray<string>;
6+
}
7+
8+
export function readWorkspace(): Array<WorkspacePackage>;
9+
10+
export function decide(
11+
files: ReadonlyArray<string> | null,
12+
packages: ReadonlyArray<WorkspacePackage>,
13+
full: boolean,
14+
): {
15+
affected: Array<string>;
16+
outputs: {
17+
typecheck: boolean;
18+
build: boolean;
19+
test: boolean;
20+
test_packages: string;
21+
test_web: boolean;
22+
test_server: boolean;
23+
rust: boolean;
24+
release_smoke: boolean;
25+
mobile_native: boolean;
26+
};
27+
};
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
const assert = require("node:assert/strict");
2+
const { spawnSync } = require("node:child_process");
3+
const { mkdtempSync, readFileSync, rmSync, existsSync } = require("node:fs");
4+
const { tmpdir } = require("node:os");
5+
const { join } = require("node:path");
6+
const { test } = require("node:test");
7+
8+
const release = readFileSync(join(__dirname, "../workflows/release.yml"), "utf8");
9+
const preview = readFileSync(join(__dirname, "../workflows/web-preview.yml"), "utf8");
10+
const stepPattern =
11+
/ name: (?:Build staged deployment|Deploy preview)\n shell: bash\n run: \|\n((?: .*\n|\n)+)/g;
12+
const steps = [
13+
...Array.from(release.matchAll(stepPattern), (match, index) => [
14+
index === 0 ? "hosted web" : "marketing",
15+
match[1],
16+
]),
17+
...Array.from(preview.matchAll(stepPattern), (match) => ["web preview", match[1]]),
18+
];
19+
assert.equal(steps.length, 3, "Expected both release steps and the preview step");
20+
21+
const url = "https://t3code-fixture-pinglabs.vercel.app";
22+
const warning = 'Error while parsing config file: "/runner/t3code/pnpm-lock.yaml"';
23+
24+
function runStep(script, stdout, exitCode = 0) {
25+
const directory = mkdtempSync(join(tmpdir(), "t3-vercel-output-"));
26+
const outputFile = join(directory, "output");
27+
try {
28+
const result = spawnSync(
29+
"bash",
30+
[
31+
"-c",
32+
'vp() { printf "%s\\n" "$FIXTURE_STDOUT"; return "$FIXTURE_EXIT"; }\n' +
33+
'curl() { printf \'{"id":"fixture-project"}\\n\'; }\n' +
34+
script.replace(/^ /gm, "").replace(/\$\{\{.*?\}\}/g, "fixture"),
35+
],
36+
{
37+
encoding: "utf8",
38+
env: {
39+
PATH: process.env.PATH,
40+
VERCEL_TOKEN: "fixture-token",
41+
VERCEL_ORG_ID: "fixture-org",
42+
VERCEL_PROJECT_ID: "fixture-project",
43+
GITHUB_OUTPUT: outputFile,
44+
FIXTURE_STDOUT: stdout,
45+
FIXTURE_EXIT: String(exitCode),
46+
},
47+
},
48+
);
49+
assert.ifError(result.error);
50+
return {
51+
...result,
52+
output: existsSync(outputFile) ? readFileSync(outputFile, "utf8") : "",
53+
};
54+
} finally {
55+
rmSync(directory, { recursive: true, force: true });
56+
}
57+
}
58+
59+
for (const [name, script] of steps) {
60+
for (const [label, stdout] of [
61+
["plain URL", url],
62+
["lockfile warning", `${warning}\n${url}`],
63+
["trailing diagnostic", `${url}\nDone`],
64+
]) {
65+
test(`${name}: saves one deployment URL after ${label}`, () => {
66+
const result = runStep(script, stdout);
67+
assert.equal(result.status, 0, result.stderr);
68+
assert.deepEqual(
69+
result.output.split("\n").filter((line) => !line.startsWith("project_id=")),
70+
[`deployment_url=${url}`, ""],
71+
);
72+
});
73+
}
74+
75+
for (const [label, stdout, exitCode] of [
76+
["missing URL", warning, 0],
77+
["invalid URL", "https://example.invalid/deployment", 0],
78+
["multiple URLs", `${url}\nhttps://other.vercel.app`, 0],
79+
["failed deployment", url, 1],
80+
]) {
81+
test(`${name}: rejects ${label} without saving output`, () => {
82+
const result = runStep(script, stdout, exitCode);
83+
assert.notEqual(result.status, 0);
84+
assert.equal(result.output, "");
85+
});
86+
}
87+
}

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ jobs:
253253
run: python3 -B .github/scripts/stage-preview-bundle.test.py
254254

255255
- name: Test release checks
256-
run: node --test .github/scripts/check-nightly-release.test.cjs
256+
run: node --test .github/scripts/check-nightly-release.test.cjs .github/scripts/vercel-deployment-output.test.cjs
257257

258258
- name: Finish installing browser secret helper build libraries
259259
timeout-minutes: 5

‎.github/workflows/release.yml‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ jobs:
10721072
fi
10731073
10741074
echo "Building hosted web app for $channel_name channel."
1075-
deployment_url="$(
1075+
deployment_output="$(
10761076
vp dlx [email protected] deploy \
10771077
--archive=tgz \
10781078
--prod \
@@ -1091,6 +1091,13 @@ jobs:
10911091
--build-env "VITE_HOSTED_APP_URL=$router_url" \
10921092
--build-env "VITE_HOSTED_APP_CHANNEL=$channel_name"
10931093
)"
1094+
printf '%s\n' "$deployment_output"
1095+
# Vercel can print lockfile warnings to stdout before the deployment URL.
1096+
deployment_url="$(printf '%s\n' "$deployment_output" | grep -E '^https://[[:alnum:].-]+\.vercel\.app$')"
1097+
if [[ "$deployment_url" == *$'\n'* ]]; then
1098+
echo "Vercel returned multiple deployment URLs." >&2
1099+
exit 1
1100+
fi
10941101
echo "Staged $deployment_url."
10951102
echo "deployment_url=$deployment_url" >> "$GITHUB_OUTPUT"
10961103
@@ -1219,7 +1226,7 @@ jobs:
12191226
)"
12201227
export VERCEL_PROJECT_ID
12211228
1222-
deployment_url="$(
1229+
deployment_output="$(
12231230
vp dlx [email protected] deploy \
12241231
--archive=tgz \
12251232
--prod \
@@ -1228,6 +1235,13 @@ jobs:
12281235
--token "$VERCEL_TOKEN" \
12291236
--scope "${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}"
12301237
)"
1238+
printf '%s\n' "$deployment_output"
1239+
# Vercel can print lockfile warnings to stdout before the deployment URL.
1240+
deployment_url="$(printf '%s\n' "$deployment_output" | grep -E '^https://[[:alnum:].-]+\.vercel\.app$')"
1241+
if [[ "$deployment_url" == *$'\n'* ]]; then
1242+
echo "Vercel returned multiple deployment URLs." >&2
1243+
exit 1
1244+
fi
12311245
echo "Staged $deployment_url."
12321246
echo "deployment_url=$deployment_url" >> "$GITHUB_OUTPUT"
12331247
echo "project_id=$VERCEL_PROJECT_ID" >> "$GITHUB_OUTPUT"

‎.github/workflows/web-preview.yml‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,20 @@ jobs:
7777
7878
vercel_scope="${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}"
7979
80-
deployment_url="$(
80+
deployment_output="$(
8181
vp dlx [email protected] deploy \
8282
--archive=tgz \
8383
--yes \
8484
--token "$VERCEL_TOKEN" \
8585
--scope "$vercel_scope"
8686
)"
87+
printf '%s\n' "$deployment_output"
88+
# Vercel can print lockfile warnings to stdout before the deployment URL.
89+
deployment_url="$(printf '%s\n' "$deployment_output" | grep -E '^https://[[:alnum:].-]+\.vercel\.app$')"
90+
if [[ "$deployment_url" == *$'\n'* ]]; then
91+
echo "Vercel returned multiple deployment URLs." >&2
92+
exit 1
93+
fi
8794
8895
echo "Deployed $deployment_url"
8996
echo "deployment_url=$deployment_url" >> "$GITHUB_OUTPUT"

‎.vercelignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Vercel's default .pnp* rule also excludes pnpm's hook, whose checksum is in the lockfile.
2+
!/.pnpmfile.cjs

‎AGENTS.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,17 @@ The most common defect in this repo is a change that works on the path you teste
9090

9191
An empty database is a bad test. Seed your worktree's `.t3` with a copy of real data instead of pointing at live state:
9292

93-
- Run `vp run migrate-dev-db` with your dev server stopped. It rebuilds `<worktree>/.t3/userdata/statev2.sqlite` from a read-only snapshot of `~/.t3/userdata/statev2.sqlite`, the developer's real data. It keeps recent projects and their stopped threads, and drops scheduled tasks, pending work, and auth sessions, so your dev server never runs the developer's agents. Raise `--projects` and `--threads-per-project` for more data.
93+
- The first `vp run dev` in a worktree does this for you when its database is missing. `--no-seed` or `T3CODE_DEV_SEED=0` skips it.
94+
- Run `vp run migrate-dev-db` with your dev server stopped to refresh. It rebuilds `<worktree>/.t3/userdata/statev2.sqlite` from a read-only snapshot of `~/.t3/userdata/statev2.sqlite`, the developer's real data. It keeps recent projects and their stopped threads, and drops scheduled tasks, pending work, and auth sessions, so your dev server never runs the developer's agents. Raise `--projects` and `--threads-per-project` for more data.
9495
- Refresh `statev2.sqlite`, not `state.sqlite`. The server copies the V1 `state.sqlite` only when `statev2.sqlite` is missing.
9596
- Bring `secrets` and `settings.json` only if the flow under test needs them.
9697
- Copy in, never symlink. Data flows one way: into your sandbox, never back out.
9798

9899
## Verifying
99100

100-
- Smallest proof that the change works. `vp test run <files>` for the tests you touched (`-t "<name>"` in big files), `vp lint <files>`, and `vp run typecheck` in the package you changed. Not `npx tsc`; it is 3x slower than tsc-rs.
101-
- Run `vp run knip:check` (about 35 s) when you add, remove, or rename exports, files, or dependencies.
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.
102+
- While you iterate, run `vp test run <files>`. For big files, add `-t "<name>"`.
103+
- Do not use `npx tsc`. Use `vp run typecheck`; it uses tsc-rs, which is 3x faster.
102104
- Run `node -e` snippets from `apps/server` or the owning package. `effect` does not resolve from the repo root.
103105
- Test meaningful logic or observable behavior. Do not render components to static markup to assert props or attributes, or add tests that merely assert callback wiring or mirror the implementation.
104106
- **Do not run repo-wide checks.** No `vp check`, no `vp run -r test`, no `vp run -r typecheck` unless I ask. CI owns the full suite.
@@ -174,7 +176,7 @@ Architecture and its constraints: `docs/internals/overview.md`. Glossary: `docs/
174176
- `packages/contracts` - Effect/Schema contracts plus small derived helpers. No heavy runtime logic.
175177
- `packages/shared` - shared runtime utils, subpath exports, no barrel.
176178
- `packages/client-runtime` - client code shared by web and mobile.
177-
- `.repos/` - vendored read-only references. Prefer their patterns over invented ones. Never edit or import from them. Sync with `vpr sync:repos` when bumping the matching dependency.
179+
- `.repos/` - vendored read-only references. Prefer their patterns over invented ones. Never edit or import from them. Sync with `vpr sync:repos` when bumping the matching dependency. If it is missing (sparse checkout), read a file with `git show origin/main:.repos/<path>`.
178180

179181
## Taste
180182

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
149149
void Haptics.selectionAsync();
150150
if (action === "remove") {
151151
await cancel(buildCancelQueuedRunCommand({ ...target, runId }));
152+
} else if (workflow?.canSendNow) {
153+
await resume({ ...target, input: { threadId: target.threadId, runId } });
152154
} else if (workflow?.activeRun && workflow.canPromoteToSteer) {
153155
await promote({
154156
...target,
@@ -221,6 +223,7 @@ export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
221223
const controls = resolveThreadQueueRowControls({
222224
busy: busyRunId !== null || draggedRunId !== null,
223225
canPromoteToSteer: workflow?.canPromoteToSteer ?? false,
226+
canSendNow: workflow?.canSendNow ?? false,
224227
canReorder: workflow?.canReorder ?? false,
225228
index,
226229
isEditing: editing?.runId === run.id,
@@ -326,12 +329,12 @@ export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
326329
accessibilityLabel={`Actions for queued message ${index + 1}`}
327330
shouldOpenOnLongPress
328331
actions={[
329-
...(workflow?.canPromoteToSteer
332+
...(workflow?.canPromoteToSteer || workflow?.canSendNow
330333
? [
331334
{
332335
id: "steer",
333-
title: "Steer now",
334-
attributes: { disabled: !controls.canSteer },
336+
title: workflow?.canSendNow ? "Send now" : "Steer now",
337+
attributes: { disabled: !controls.canSend },
335338
image: Platform.OS === "ios" ? "arrow.turn.left.up" : "arrow_upward",
336339
},
337340
]
@@ -385,16 +388,20 @@ export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
385388
Editing
386389
</Text>
387390
) : null}
388-
{workflow?.canPromoteToSteer ? (
391+
{workflow?.canPromoteToSteer || workflow?.canSendNow ? (
389392
<Pressable
390393
accessibilityRole="button"
391-
accessibilityLabel={`Steer with message ${index + 1} now`}
392-
disabled={!controls.canSteer}
394+
accessibilityLabel={
395+
workflow?.canSendNow
396+
? `Send message ${index + 1} now`
397+
: `Steer with message ${index + 1} now`
398+
}
399+
disabled={!controls.canSend}
393400
onPress={() => void act(run.id, "steer")}
394401
className="h-8 shrink-0 justify-center rounded-full bg-primary px-3 active:opacity-70 disabled:opacity-40"
395402
>
396403
<Text className="font-t3-medium text-xs text-primary-foreground">
397-
Steer
404+
{workflow?.canSendNow ? "Send now" : "Steer"}
398405
</Text>
399406
</Pressable>
400407
) : null}

‎apps/mobile/src/features/threads/threadQueueControlPresentation.test.ts‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,28 @@ import {
77
} from "./threadQueueControlPresentation";
88

99
describe("threadQueueControlPresentation", () => {
10+
it.each([
11+
{ busy: false, isEditing: false, expected: true },
12+
{ busy: true, isEditing: false, expected: false },
13+
{ busy: false, isEditing: true, expected: false },
14+
])(
15+
"gates sending a stopped thread's queued message with $busy busy and $isEditing editing",
16+
({ busy, isEditing, expected }) => {
17+
const controls = resolveThreadQueueRowControls({
18+
busy,
19+
isEditing,
20+
canPromoteToSteer: false,
21+
canSendNow: true,
22+
canReorder: false,
23+
index: 0,
24+
queuedCount: 1,
25+
text: "Queued message",
26+
});
27+
28+
expect(controls.canSend).toBe(expected);
29+
},
30+
);
31+
1032
it("shows an assistant quote as its quoted text", () => {
1133
const href = formatAssistantCitationHref({
1234
version: 1,
@@ -22,6 +44,7 @@ describe("threadQueueControlPresentation", () => {
2244
const controls = resolveThreadQueueRowControls({
2345
busy: false,
2446
canPromoteToSteer: true,
47+
canSendNow: false,
2548
canReorder: true,
2649
index: 0,
2750
queuedCount: 1,
@@ -37,6 +60,7 @@ describe("threadQueueControlPresentation", () => {
3760
const editing = resolveThreadQueueRowControls({
3861
busy: false,
3962
canPromoteToSteer: true,
63+
canSendNow: false,
4064
canReorder: true,
4165
index: 1,
4266
isEditing: true,
@@ -46,7 +70,7 @@ describe("threadQueueControlPresentation", () => {
4670

4771
expect(editing.isEditing).toBe(true);
4872
expect(editing.canEdit).toBe(false);
49-
expect(editing.canSteer).toBe(false);
73+
expect(editing.canSend).toBe(false);
5074
expect(editing.canMoveUp).toBe(true);
5175
expect(editing.canDismiss).toBe(true);
5276
});

0 commit comments

Comments
 (0)