Skip to content

Commit 5c2b8e6

Browse files
committed
chore: merge upstream main
Move the insight callout onto the extracted assistant timeline row.
2 parents 51043e1 + b7b905d commit 5c2b8e6

103 files changed

Lines changed: 12011 additions & 8364 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/ci.yml‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ jobs:
8383
- name: Setup Vite+
8484
uses: ./.github/actions/setup-ci-deps
8585

86+
# electron's install.js (run by ensure:electron) reads this cache before it
87+
# downloads from GitHub. The key changes only with the Electron version.
88+
- name: Cache Electron download
89+
uses: actions/cache@v6
90+
with:
91+
path: ~/.cache/electron
92+
key: electron-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('node_modules/.pnpm/electron@*/node_modules/electron/package.json') }}
93+
8694
- name: Ensure Electron runtime is installed
8795
run: vp run --filter @t3tools/desktop ensure:electron
8896

@@ -132,6 +140,14 @@ jobs:
132140
- name: Setup Vite+
133141
uses: ./.github/actions/setup-ci-deps
134142

143+
# electron's install.js (run by ensure:electron) reads this cache before it
144+
# downloads from GitHub. The key changes only with the Electron version.
145+
- name: Cache Electron download
146+
uses: actions/cache@v6
147+
with:
148+
path: ~/.cache/electron
149+
key: electron-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('node_modules/.pnpm/electron@*/node_modules/electron/package.json') }}
150+
135151
- name: Ensure Electron runtime is installed
136152
id: electron
137153
run: vp run --filter @t3tools/desktop ensure:electron
@@ -222,6 +238,14 @@ jobs:
222238
- name: Setup Vite+
223239
uses: ./.github/actions/setup-ci-deps
224240

241+
# electron's install.js (run by ensure:electron) reads this cache before it
242+
# downloads from GitHub. The key changes only with the Electron version.
243+
- name: Cache Electron download
244+
uses: actions/cache@v6
245+
with:
246+
path: ~/.cache/electron
247+
key: electron-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('node_modules/.pnpm/electron@*/node_modules/electron/package.json') }}
248+
225249
- name: Ensure Electron runtime is installed
226250
run: vp run --filter @t3tools/desktop ensure:electron
227251

‎.pnpmfile.cjs‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Windows WSL dev mode runs the server under Linux from the same node_modules
2+
// as the Windows client, so Windows installs also need Linux x64 glibc native
3+
// modules. Other platforms install only their own binaries; setting this
4+
// everywhere added ~2.2 GB of foreign binaries to every macOS install.
5+
// Release scripts stage their own installs with explicit architectures.
6+
module.exports = {
7+
hooks: {
8+
updateConfig(config) {
9+
// oxlint-disable-next-line t3code/no-global-process-runtime -- pnpm loads this file before any Effect runtime exists.
10+
if (process.platform !== "win32") return config;
11+
return {
12+
...config,
13+
supportedArchitectures: {
14+
os: ["current", "linux"],
15+
cpu: ["current", "x64"],
16+
libc: ["current", "glibc"],
17+
},
18+
};
19+
},
20+
},
21+
};

‎AGENTS.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,13 @@ The most common defect in this repo is a change that works on the path you teste
7878
## Dev servers
7979

8080
- `vp i` installs. Worktrees get this from the t3.json setup script; if module resolution looks broken, it probably did not run.
81+
- Setup runs in the background. While `.t3/setup-running` names a live PID, wait for it and do not run `vp i`. It ends with `.t3/setup-done` or `.t3/setup-failed` (with the error tail). With no marker at all, setup never ran here, so run `vp i` yourself.
8182
- `vp run dev` starts server and web. In a worktree, state defaults to that worktree's gitignored `.t3`, which deliberately outranks an ambient `T3CODE_HOME` so you cannot land on shared state by accident. An explicit `--home-dir` still wins.
8283
- Ports derive from the worktree path and are stable across restarts, but read the real ones from the `[dev-runner]` line since occupied ports shift.
8384
- Sharing over the tailnet is three steps: run `vp run dev --share` in the background, wait for the `pairingUrl:` line in its output, then give that full URL to an unpaired browser. Do not wire up `tailscale serve` by hand, open the URL yourself, or consume the user's pairing link. A browser with the reusable dev cookie can use the bare origin. If a normal one-time token was consumed, mint a fresh one with `node apps/server/src/bin.ts pair`. It carries standard scopes, while the startup URL carries admin scopes needed for Connections settings.
8485
- To reuse web dev auth across worktrees, configure one fixed `T3CODE_DEV_AUTH_TOKEN` in the main checkout's gitignored `.env`. The `t3.json` setup links that file into worktrees. Never commit or publish the token or a startup URL. See [Reusable dev credential](docs/operations/development.md#reusable-dev-credential).
8586
- Stop what you started, by the PID you tracked. See rule 1.
87+
- Need a second checkout? `git worktree add` it next to this worktree, not in `/tmp`. Remove it when done.
8688

8789
## Test data
8890

@@ -95,7 +97,9 @@ An empty database is a bad test. Seed your worktree's `.t3` with a copy of real
9597

9698
## Verifying
9799

98-
- Smallest proof that the change works. `vp test run <files>` for the tests you touched, targeted lint and typecheck for the scope you changed.
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.
102+
- Run `node -e` snippets from `apps/server` or the owning package. `effect` does not resolve from the repo root.
99103
- 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.
100104
- **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.
101105
- Backend behavior changes ship with focused tests for that behavior.
@@ -137,7 +141,7 @@ For authorized mobile verification, a missing or outdated native client is a bui
137141
- UI changes need before/after images. Motion or timing needs a short video.
138142
- Upload PR evidence to GitHub. Never commit PR-only screenshots or assets such as `.github/pr-assets/`.
139143
- One request is one PR. Split it only when the maintainer asks. Outside contributions follow the stricter [one problem per PR](CONTRIBUTING.md#one-problem) rule.
140-
- When babysitting: poll checks and comments newer than the last push, verify each bot finding against the source, fix real ones, dismiss false positives with a written reason. Stay quiet when nothing is new. Stop when the bots are green on the latest commit.
144+
- When babysitting: call `watch_pull_request` and end your turn. T3 Code wakes you on checks, comments, or conflicts. Do not poll or sleep. Verify each bot finding against the source, fix real ones, dismiss false positives with a written reason. Stay quiet when nothing is new. Stop when the bots are green on the latest commit.
141145

142146
## Documentation
143147

‎apps/desktop/package.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"scripts": {
88
"ensure:electron": "node scripts/ensure-electron-runtime.mjs",
99
"start": "node scripts/start-electron.mjs",
10-
"typecheck": "tsc-rs --noEmit",
1110
"test": "vp test run --passWithNoTests",
1211
"smoke-test": "node scripts/smoke-test.mjs"
1312
},

‎apps/desktop/scripts/ensure-electron-runtime.mjs‎

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,26 @@ function runChecked(command, args) {
116116
);
117117
}
118118

119-
function installElectronRuntime(electronDir, version) {
119+
// electron's own installer goes through @electron/get, which reuses its
120+
// download cache (~/.cache/electron, ~/Library/Caches/electron) and verifies
121+
// the bundled checksums. pnpm 11 never runs it because electron has no
122+
// install script, so a new worktree would otherwise download 130 MB again.
123+
function installFromElectronCache(electronDir) {
124+
const result = NodeChildProcess.spawnSync(
125+
process.execPath,
126+
[NodePath.join(electronDir, "install.js")],
127+
{ stdio: ["ignore", "inherit", "inherit"] },
128+
);
129+
if (result.status === 0) {
130+
return true;
131+
}
132+
process.stderr.write(
133+
`electron install.js failed with exit code ${result.status ?? "unknown"}, downloading with curl instead\n`,
134+
);
135+
return false;
136+
}
137+
138+
function downloadElectronRuntime(electronDir, version) {
120139
const tempDir = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-electron-"));
121140
const zipPath = NodePath.join(tempDir, `electron-v${version}-${hostPlatform}-${hostArch}.zip`);
122141

@@ -149,21 +168,27 @@ function installElectronRuntime(electronDir, version) {
149168
}
150169
}
151170

171+
function resetRuntime(electronDir) {
172+
NodeFS.rmSync(NodePath.join(electronDir, "dist"), { recursive: true, force: true });
173+
NodeFS.rmSync(NodePath.join(electronDir, "path.txt"), { force: true });
174+
}
175+
152176
export function ensureElectronRuntime() {
153177
const electronPackageJsonPath = require.resolve("electron/package.json");
154178
const electronPackageJson = JSON.parse(NodeFS.readFileSync(electronPackageJsonPath, "utf8"));
155179
const electronDir = NodePath.dirname(electronPackageJsonPath);
156180
const platformPath = getPlatformPath();
157181
const electronPath = NodePath.join(electronDir, "dist", platformPath);
158-
const missingBeforeInstall = missingRuntimePaths(electronDir, platformPath);
159-
const invalidBeforeInstall = invalidRuntimePaths(electronDir, platformPath);
160-
161-
if (missingBeforeInstall.length > 0 || invalidBeforeInstall.length > 0) {
162-
if (NodeFS.existsSync(NodePath.join(electronDir, "dist"))) {
163-
NodeFS.rmSync(NodePath.join(electronDir, "dist"), { recursive: true, force: true });
182+
const needsInstall = () =>
183+
missingRuntimePaths(electronDir, platformPath).length > 0 ||
184+
invalidRuntimePaths(electronDir, platformPath).length > 0;
185+
186+
if (needsInstall()) {
187+
resetRuntime(electronDir);
188+
if (!installFromElectronCache(electronDir) || needsInstall()) {
189+
resetRuntime(electronDir);
190+
downloadElectronRuntime(electronDir, electronPackageJson.version);
164191
}
165-
NodeFS.rmSync(NodePath.join(electronDir, "path.txt"), { force: true });
166-
installElectronRuntime(electronDir, electronPackageJson.version);
167192
}
168193

169194
const missingAfterInstall = missingRuntimePaths(electronDir, platformPath);

‎apps/desktop/vite.config.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ export default defineConfig({
4343
dependsOn: ["t3#build"],
4444
cache: false,
4545
},
46+
// tsc-rs rewrites the tsbuildinfo it reads, which keeps a task out of the cache.
47+
typecheck: {
48+
command: "tsc-rs --noEmit",
49+
cache: { input: [{ auto: true }, "!*.tsbuildinfo"] },
50+
},
4651
},
4752
},
4853
pack: [
@@ -145,6 +150,9 @@ export default defineConfig({
145150
// The Windows lane runs workspace suites concurrently; filesystem-heavy
146151
// desktop integration tests can exceed Vitest's 5 second default there.
147152
testTimeout: 15_000,
148-
setupFiles: ["../../packages/shared/src/testing/longTempDir.ts"],
153+
setupFiles: [
154+
"../../packages/shared/src/testing/longTempDir.ts",
155+
"../../packages/shared/src/testing/providerEnv.ts",
156+
],
149157
},
150158
});

‎apps/marketing/astro.config.mjs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { defineConfig } from "astro/config";
22

3+
// Astro loads env with an empty prefix, and under `vp run` Vite+'s loadEnv then reports every
4+
// variable to the task cache. Any env difference (TERM, VP_RAW_SUBCOMMAND, an agent's session
5+
// vars) would rerun `astro check`. Without the runner client, loadEnv reads process.env directly;
6+
// file tracking does not use this client.
7+
delete process.env.VP_RUN_NODE_CLIENT_PATH;
8+
39
export default defineConfig({
410
site: "https://t3.codes",
511
server: {

‎apps/marketing/package.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
"stage:install-scripts": "node scripts/stage-install-scripts.mjs",
88
"dev": "node scripts/stage-install-scripts.mjs && astro dev",
99
"build": "node scripts/stage-install-scripts.mjs && astro build",
10-
"preview": "astro preview",
11-
"typecheck": "astro check"
10+
"preview": "astro preview"
1211
},
1312
"dependencies": {
1413
"@t3tools/shared": "workspace:*",

‎apps/marketing/vite.config.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { defineConfig } from "vite-plus";
2+
3+
// Astro reads astro.config.mjs. This file only configures `vp run` tasks.
4+
export default defineConfig({
5+
run: {
6+
tasks: {
7+
// `astro check` regenerates .astro/*.d.ts and then reads them, which
8+
// keeps a task out of the cache. Its real inputs are tracked as usual.
9+
typecheck: {
10+
command: "astro check",
11+
cache: { input: [{ auto: true }, "!.astro/**"] },
12+
},
13+
},
14+
},
15+
});

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

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,11 @@ export interface ThreadComposerProps {
178178
readonly onStopThread: () => void;
179179
/** Present while the thread's queue is held. */
180180
readonly onResumeQueue: (() => Promise<void>) | null;
181-
readonly onSendMessage: (followUp?: ActiveTurnComposerAction) => Promise<MessageId | null>;
181+
/** `stillSendable` reports whether the draft is unchanged after any wait before sending. */
182+
readonly onSendMessage: (
183+
followUp?: ActiveTurnComposerAction,
184+
stillSendable?: () => boolean,
185+
) => Promise<MessageId | null>;
182186
readonly onShowUsageLimits: (report: UsageLimitsReport | null) => void;
183187
readonly canSwitchProvider: boolean;
184188
readonly onUpdateModelSelection: (modelSelection: ModelSelection) => void;
@@ -356,6 +360,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
356360
const inputRef = props.editorRef ?? fallbackInputRef;
357361
const [isFocused, setIsFocused] = useState(false);
358362
const pendingPastedTextAttachmentCountRef = useRef(0);
363+
const pendingNativeImagePasteCountRef = useRef(0);
359364
const [pendingPastedTextAttachmentCount, setPendingPastedTextAttachmentCount] = useState(0);
360365
const settingsSheetPresentation = useThreadSettingsSheetPresentation({
361366
editorRef: inputRef,
@@ -599,15 +604,33 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
599604
setComposerEditing(false);
600605
};
601606
const handleSend = async (followUp?: ActiveTurnComposerAction) => {
602-
if (isSubmissionLocked || pendingPastedTextAttachmentCountRef.current > 0) return;
607+
if (
608+
isSubmissionLocked ||
609+
pendingPastedTextAttachmentCountRef.current > 0 ||
610+
pendingNativeImagePasteCountRef.current > 0
611+
)
612+
return;
603613
if (usageLimitsOffered && isUsageLimitsCommand(draftMessage) && draftAttachments.length === 0) {
604614
if (openUsageLimits()) onChangeDraftMessage("");
605615
return;
606616
}
607617
const threadKey = scopedThreadKey(props.environmentId, props.selectedThread.id);
608618
if (inFlightThreadIdsRef.current.has(threadKey)) return;
609619
inFlightThreadIdsRef.current.add(threadKey);
610-
const sent = await settlePromise(() => onSendMessage(followUp));
620+
const draftAtSend = getComposerDraftSnapshot(composerDraftKey);
621+
const stillSendable = () => {
622+
const draft = getComposerDraftSnapshot(composerDraftKey);
623+
return (
624+
pendingPastedTextAttachmentCountRef.current === 0 &&
625+
pendingNativeImagePasteCountRef.current === 0 &&
626+
draft.text === draftAtSend.text &&
627+
draft.attachments.length === draftAtSend.attachments.length &&
628+
draft.attachments.every(
629+
(attachment, index) => attachment.id === draftAtSend.attachments[index]?.id,
630+
)
631+
);
632+
};
633+
const sent = await settlePromise(() => onSendMessage(followUp, stillSendable));
611634
inFlightThreadIdsRef.current.delete(threadKey);
612635
if (AsyncResult.isFailure(sent)) {
613636
// The composer state already surfaces send errors; only the lock needed releasing.
@@ -915,7 +938,11 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
915938
}}
916939
onSelectionChange={composerMenu.onSelectionChange}
917940
onPasteImages={(uris) => {
918-
if (!isSubmissionLocked) void props.onNativePasteImages(uris);
941+
if (isSubmissionLocked) return;
942+
pendingNativeImagePasteCountRef.current += 1;
943+
void props.onNativePasteImages(uris).finally(() => {
944+
pendingNativeImagePasteCountRef.current -= 1;
945+
});
919946
}}
920947
onPasteText={(paste) => {
921948
if (isSubmissionLocked) return;

0 commit comments

Comments
 (0)