Skip to content

Commit e26b1e9

Browse files
feat(scripts): scenarios prove a fix in the real app with e2e
A scenario is an e2e test (scripts/scenarios/*.e2e.ts) that runs against the real dev stack with the replay agent as the model. e2e starts the app, drives the browser and records the run; one fixture seeds T3 state through the app's CLI. `scenarios:prove` runs a scenario on a base and a head commit and reports failsOnBase and passesOnHead with captures side by side. Co-Authored-By: Claude Fable 5.2 <[email protected]>
1 parent 5be6bc9 commit e26b1e9

88 files changed

Lines changed: 1488 additions & 1833 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.

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ apps/mobile/.android-cache/
3838
artifacts/app-store/screenshots/
3939
artifacts/mobile-e2e/
4040
artifacts/mobile-behavior/
41+
scripts/.e2e/
4142
.github/pr-assets/
4243
native/**/target/
4344
node_modules/

‎AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ An empty database is a bad test. Seed your worktree's `.t3` with a copy of real
108108
- [Testing](docs/internals/testing.md) carries these same test rules, plus review guidance, for review bots. Change both together.
109109
- **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.
110110
- Backend behavior changes ship with focused tests for that behavior.
111-
- Proof for a bug fix depends on the bug. Logic, data, state, and protocol bugs get a failing test first (the fewest that fail on `main` for that reason, in an existing case of the module's test file where one fits), then the fix. Purely visual bugs (spacing, colour, alignment, a layout shift) get before/after captures as their proof and no test: do not add UI tests for nitpicks, and do not ask for one in review when a capture already shows it. A server-only fix with no visible surface ships the test plus a short runtime transcript.
111+
- Proof for a bug fix depends on the bug. Logic, data, state, and protocol bugs get a failing test first (the fewest that fail on `main` for that reason, in an existing case of the module's test file where one fits), then the fix. Purely visual bugs (spacing, colour, alignment, a layout shift) get before/after captures as their proof and no test: do not add UI tests for nitpicks, and do not ask for one in review when a capture already shows it. A server-only fix with no visible surface ships the test plus a short runtime transcript. For a bug a user can reproduce in the web client, `vp run scenarios:prove` shows it failing on base and passing on the fix in the real app; see [Scenarios](docs/operations/scenarios.md).
112112
- The server is event-sourced, and side effects run after the command commits. In tests, drain the effect worker (`OrchestrationEffectWorkerV2.drain`) or await the specific persisted event or `Deferred` that marks the milestone. Never wait on sleeps or polling. A test that needs a timeout to pass is wrong. Concretely:
113113
- `it.effect` runs on a `TestClock`; `Effect.sleep` only advances through `TestClock.adjust`. `it.live` is wall-clock and only for subprocess or network fixtures.
114114
- No `yieldNow` or `sleep` polling loops. Await the `Deferred`, take from the `Queue`, or drain the worker.

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,8 @@ import { readEnvironmentScope, usePreparedConnection } from "../../state/session
236236
import { projectEnvironment } from "../../state/projects";
237237
import {
238238
needsWorkspaceBasenameLookup,
239-
pickWorkspaceLinkMatch,
239+
pickWorkspaceBasenameMatch,
240240
WORKSPACE_BASENAME_LOOKUP_LIMIT,
241-
workspaceLinkLookupQuery,
242241
} from "@t3tools/client-runtime/workspace-basename-lookup";
243242
import {
244243
resolveThreadLink,
@@ -2895,18 +2894,17 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
28952894
props.workspaceRoot &&
28962895
relativePath &&
28972896
!/[\\/]$/.test(presentation.path) &&
2898-
workspaceLinkLookupQuery(presentation.path, props.workspaceRoot) !== null &&
2897+
needsWorkspaceBasenameLookup(relativePath) &&
28992898
readEnvironmentScope(props.environmentId, AuthFilesystemReadScope)
29002899
) {
2901-
const workspaceRoot = props.workspaceRoot;
29022900
const originalPath = resolveWorkspaceFilePath(props.workspaceRoot, relativePath);
29032901
void executeAtomQuery(
29042902
appAtomRegistry,
29052903
projectEnvironment.searchEntries({
29062904
environmentId: props.environmentId,
29072905
input: {
2908-
cwd: workspaceRoot,
2909-
query: workspaceLinkLookupQuery(relativePath, workspaceRoot) ?? relativePath,
2906+
cwd: props.workspaceRoot,
2907+
query: relativePath,
29102908
kind: "file",
29112909
limit: WORKSPACE_BASENAME_LOOKUP_LIMIT,
29122910
},
@@ -2916,7 +2914,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
29162914
(result) => {
29172915
const match =
29182916
result._tag === "Success"
2919-
? pickWorkspaceLinkMatch(relativePath, workspaceRoot, result.value.entries)
2917+
? pickWorkspaceBasenameMatch(relativePath, result.value.entries)
29202918
: null;
29212919
if (!match || match === relativePath) {
29222920
openAt(relativePath);
@@ -2933,10 +2931,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
29332931
).then(
29342932
(metadata) =>
29352933
openAt(
2936-
metadata._tag === "Success" &&
2937-
(needsWorkspaceBasenameLookup(relativePath)
2938-
? metadata.value?.kind !== "directory"
2939-
: metadata.value === null)
2934+
metadata._tag === "Success" && metadata.value?.kind !== "directory"
29402935
? match
29412936
: relativePath,
29422937
),

‎apps/mobile/src/features/threads/thread-command-output.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ export function ThreadCommandOutput(props: {
5353
}
5454
return (
5555
<View className="pt-1.5">
56+
{data?.output.truncated ? (
57+
<Text className="pb-0.5 text-3xs text-foreground-subtle">Earlier output not shown</Text>
58+
) : null}
5659
<ScrollView
5760
ref={scrollRef}
5861
nestedScrollEnabled
@@ -70,9 +73,6 @@ export function ThreadCommandOutput(props: {
7073
if (followRef.current) scrollRef.current?.scrollToEnd({ animated: false });
7174
}}
7275
>
73-
{data?.output.truncated ? (
74-
<Text className="pb-0.5 text-3xs text-foreground-subtle">Earlier output not shown</Text>
75-
) : null}
7676
<Text selectable className="font-mono text-2xs leading-normal text-foreground-muted">
7777
{spans.map((span, index) =>
7878
span.style === null ? (

‎apps/mobile/src/lib/enrichedLinkPresentation.test.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,12 @@ describe("Enriched link presentation", () => {
2020
"/tmp/report.md",
2121
"C:\\repo\\app.tsx",
2222
"app.tsx:12:3",
23-
"src/http.ts:42-64",
24-
"http.ts:42-64",
2523
]) {
2624
expect(ENRICHED_INLINE_FILE_LINK_REGEX.test(path), path).toBe(true);
2725
}
2826
for (const text of [
2927
"npm run dev",
3028
"port:3000",
31-
"port:3000-3010",
3229
"TODO:12",
3330
"example.com",
3431
"https://example.com/app.tsx",

‎apps/mobile/src/lib/enrichedLinkPresentation.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export function enrichedLinkVariantPattern(url: string) {
9292
}
9393

9494
export const ENRICHED_INLINE_FILE_LINK_REGEX =
95-
/^(?!\S*:\/\/)(?:(?:\.{1,2}[\\/]|~[\\/]|\/(?:Users|home|tmp|var|etc|opt|mnt|Volumes|private|root|usr|bin|sbin|lib|lib64|srv|dev|proc|sys|run|boot|media|workspace|workspaces)\/|[A-Za-z]:[\\/])[^\s`]+|(?:[A-Za-z0-9._-]+[\\/])+[A-Za-z0-9._-]+\.[A-Za-z0-9_-]+(?::\d+(?::\d+|-\d+)?)?|[A-Za-z0-9._-]+\.[A-Za-z0-9_-]+:\d+(?::\d+|-\d+)?)$/;
95+
/^(?!\S*:\/\/)(?:(?:\.{1,2}[\\/]|~[\\/]|\/(?:Users|home|tmp|var|etc|opt|mnt|Volumes|private|root|usr|bin|sbin|lib|lib64|srv|dev|proc|sys|run|boot|media|workspace|workspaces)\/|[A-Za-z]:[\\/])[^\s`]+|(?:[A-Za-z0-9._-]+[\\/])+[A-Za-z0-9._-]+\.[A-Za-z0-9_-]+(?::\d+){0,2}|[A-Za-z0-9._-]+\.[A-Za-z0-9_-]+:\d+(?::\d+)?)$/;
9696

9797
export function enrichedSkillLinkRegex(skills?: ReadonlyArray<SelectableMarkdownSkill>) {
9898
const names = [...new Set(skills?.map((skill) => skill.name) ?? [])].filter(Boolean);

‎apps/server/src/assets/AssetAccess.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
AssetWorkspaceRootNormalizationError,
1616
SOURCE_CONTROL_MEDIA_ASSET,
1717
ThreadId,
18-
NativeAppIconReference,
18+
ToolActivityNativeAppReference,
1919
TurnItemId,
2020
} from "@t3tools/contracts";
2121
import {
@@ -152,7 +152,7 @@ const AssetClaimsSchema = Schema.Union([
152152
Schema.Struct({
153153
version: Schema.Literal(1),
154154
kind: Schema.Literal("native-app-icon"),
155-
app: NativeAppIconReference,
155+
app: ToolActivityNativeAppReference,
156156
expiresAt: Schema.Number,
157157
}),
158158
Schema.Struct({

‎apps/server/src/assets/NativeAppIconResolver.test.ts‎

Lines changed: 0 additions & 62 deletions
This file was deleted.

‎apps/server/src/assets/NativeAppIconResolver.ts‎

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { expandHomePath } from "@t3tools/provider-core/server/pathExpansion";
2-
import type { NativeAppIconReference } from "@t3tools/contracts";
1+
import type { ToolActivityNativeAppReference } from "@t3tools/contracts";
32
import * as Cache from "effect/Cache";
43
import * as Cause from "effect/Cause";
54
import * as Digest from "effect/crypto/Digest";
@@ -29,16 +28,16 @@ const RESOLUTION_CACHE_MAX_ENTRIES = 256;
2928
export class NativeAppIconResolver extends Context.Service<
3029
NativeAppIconResolver,
3130
{
32-
readonly resolve: (app: NativeAppIconReference) => Effect.Effect<string | null>;
31+
readonly resolve: (app: ToolActivityNativeAppReference) => Effect.Effect<string | null>;
3332
}
3433
>()("t3/assets/NativeAppIconResolver") {}
3534

36-
function appCacheKey(app: NativeAppIconReference): string {
35+
function appCacheKey(app: ToolActivityNativeAppReference): string {
3736
return JSON.stringify(app);
3837
}
3938

40-
function appFromCacheKey(key: string): NativeAppIconReference {
41-
return JSON.parse(key) as NativeAppIconReference;
39+
function appFromCacheKey(key: string): ToolActivityNativeAppReference {
40+
return JSON.parse(key) as ToolActivityNativeAppReference;
4241
}
4342

4443
const existingFile = Effect.fn("NativeAppIconResolver.existingFile")(function* (filePath: string) {
@@ -92,13 +91,9 @@ function containsControlCharacter(value: string): boolean {
9291
}
9392

9493
const resolveApplicationPath = Effect.fn("NativeAppIconResolver.resolveApplicationPath")(function* (
95-
app: NativeAppIconReference,
94+
app: ToolActivityNativeAppReference,
9695
) {
9796
const path = yield* Path.Path;
98-
if (app._tag === "app-path") {
99-
const appPath = expandHomePath(app.path, yield* HostProcess.HomeDirectory);
100-
return path.isAbsolute(appPath) && appPath.endsWith(".app") ? appPath : null;
101-
}
10297
const query =
10398
app._tag === "app-id"
10499
? `kMDItemCFBundleIdentifier == '${app.appId}'`
@@ -136,7 +131,7 @@ const resolveApplicationPath = Effect.fn("NativeAppIconResolver.resolveApplicati
136131
});
137132

138133
const resolveNativeAppIconUncached = Effect.fn("NativeAppIconResolver.resolveUncached")(function* (
139-
app: NativeAppIconReference,
134+
app: ToolActivityNativeAppReference,
140135
) {
141136
const fileSystem = yield* FileSystem.FileSystem;
142137
const path = yield* Path.Path;
@@ -247,7 +242,7 @@ export const make = Effect.gen(function* () {
247242
);
248243

249244
const resolveAttempt = Effect.fn("NativeAppIconResolver.resolve")(function* (
250-
app: NativeAppIconReference,
245+
app: ToolActivityNativeAppReference,
251246
) {
252247
if (
253248
hostPlatform !== "darwin" ||

‎apps/server/src/auth/RpcAuthorization.test.ts‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -412,14 +412,10 @@ it.effect("separates host file URLs from readable attachment URLs", () =>
412412
yield* client[WS_METHODS.assetsCreateUrl]({
413413
resource: { _tag: "attachment", attachmentId: "image" },
414414
});
415-
yield* client[WS_METHODS.assetsCreateUrl]({
416-
resource: { _tag: "native-app-icon", app: { _tag: "app-id", appId: "com.apple.calculator" } },
417-
});
418415
for (const resource of [
419416
{ _tag: "workspace-file", threadId: ThreadId.make("thread"), path: "file.txt" },
420417
{ _tag: "media-file", threadId: ThreadId.make("thread"), path: "/repo/image.png" },
421418
{ _tag: "draft-workspace-file", cwd: "/repo", path: "file.txt" },
422-
{ _tag: "native-app-icon", app: { _tag: "app-path", path: "/private/Secret.app" } },
423419
] as const) {
424420
expect(
425421
yield* client[WS_METHODS.assetsCreateUrl]({ resource }).pipe(Effect.flip),
@@ -428,7 +424,7 @@ it.effect("separates host file URLs from readable attachment URLs", () =>
428424
requiredPermission: AuthFilesystemReadScope,
429425
});
430426
}
431-
expect(handled).toBe(2);
427+
expect(handled).toBe(1);
432428
}).pipe(Effect.scoped),
433429
);
434430

0 commit comments

Comments
 (0)