authorgravatar for 269035359+t3-code[bot]@users.noreply.github.comt3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com> 2026-08-16 10:06:38+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-08-16 10:06:38+02:00
log3583cd27dccda1b35fe80d9411a95a7217cc8176
treec74afae1579278f99e783f3fe9f8f9396cd221ce
parent27732293373fbb081a966b437ae022afe77db16b
signature Signed by PGP key B5690EEEBB952194

test: favor behavior over implementation details (#7157)


9 files changed, 9 insertions(+), 87 deletions(-)

apps/mobile/src/features/terminal/terminalLaunchContext.test.ts+1-9
......@@ -2,7 +2,6 @@ import { describe, expect, it } from "vite-plus/test";
22import { EnvironmentId, ThreadId } from "@t3tools/contracts";
33
44import {
5 peekPendingTerminalLaunch,
65 resolvePreferredThreadWorktreePath,
76 resolveTerminalOpenLocation,
87 stagePendingTerminalLaunch,
......@@ -82,19 +81,13 @@ describe("pending terminal launches", () => {
8281 },
8382 });
8483
85 expect(peekPendingTerminalLaunch(target)).toEqual({
86 cwd: "/repo/worktrees/feature",
87 worktreePath: "/repo/worktrees/feature",
88 env: { FOO: "bar" },
89 initialInput: "pnpm dev\r",
90 });
9184 expect(takePendingTerminalLaunch(target)).toEqual({
9285 cwd: "/repo/worktrees/feature",
9386 worktreePath: "/repo/worktrees/feature",
9487 env: { FOO: "bar" },
9588 initialInput: "pnpm dev\r",
9689 });
97 expect(peekPendingTerminalLaunch(target)).toBeNull();
90 expect(takePendingTerminalLaunch(target)).toBeNull();
9891 });
9992
10093 it("keeps pending launches isolated per terminal target", () => {
......@@ -118,7 +111,6 @@ describe("pending terminal launches", () => {
118111 },
119112 });
120113
121 expect(peekPendingTerminalLaunch(otherTarget)).toBeNull();
122114 expect(takePendingTerminalLaunch(otherTarget)).toBeNull();
123115 expect(takePendingTerminalLaunch(primaryTarget)).toEqual({
124116 cwd: "/repo/root",
apps/mobile/src/features/terminal/terminalLaunchContext.ts-6
......@@ -36,12 +36,6 @@ export function stagePendingTerminalLaunch(input: {
3636 });
3737}
3838
39export function peekPendingTerminalLaunch(
40 target: PendingTerminalLaunchTarget,
41): PendingTerminalLaunch | null {
42 return pendingTerminalLaunches.get(pendingTerminalLaunchKey(target)) ?? null;
43}
44
4539export function takePendingTerminalLaunch(
4640 target: PendingTerminalLaunchTarget,
4741): PendingTerminalLaunch | null {
apps/mobile/src/features/terminal/threadTerminalPanelModel.test.ts deleted-40
......@@ -1,40 +0,0 @@
1import { EnvironmentId, ThreadId } from "@t3tools/contracts";
2import { describe, expect, it } from "vite-plus/test";
3
4import {
5 buildThreadTerminalAttachInput,
6 threadTerminalSubscriptionKey,
7 type ThreadTerminalSubscriptionIdentity,
8} from "./threadTerminalPanelModel";
9
10const identity: ThreadTerminalSubscriptionIdentity = {
11 environmentId: EnvironmentId.make("env-1"),
12 threadId: ThreadId.make("thread-1"),
13 terminalId: "default",
14 cwd: "/repo",
15 worktreePath: "/repo",
16};
17
18describe("threadTerminalSubscriptionKey", () => {
19 it("does not include mutable terminal dimensions", () => {
20 const initialAttach = buildThreadTerminalAttachInput(identity, { cols: 80, rows: 24 });
21 const resizedAttach = buildThreadTerminalAttachInput(identity, { cols: 132, rows: 40 });
22
23 expect(initialAttach).not.toEqual(resizedAttach);
24 expect(threadTerminalSubscriptionKey({ ...identity, ...initialAttach })).toBe(
25 threadTerminalSubscriptionKey({ ...identity, ...resizedAttach }),
26 );
27 });
28
29 it.each([
30 ["environment", { environmentId: EnvironmentId.make("env-2") }],
31 ["thread", { threadId: ThreadId.make("thread-2") }],
32 ["terminal", { terminalId: "term-2" }],
33 ["cwd", { cwd: "/repo/packages/app" }],
34 ["worktree", { worktreePath: "/repo/worktrees/feature" }],
35 ])("changes when the %s identity changes", (_label, update) => {
36 expect(threadTerminalSubscriptionKey({ ...identity, ...update })).not.toBe(
37 threadTerminalSubscriptionKey(identity),
38 );
39 });
40});
apps/mobile/src/features/terminal/threadTerminalPanelModel.ts-12
......@@ -13,18 +13,6 @@ export interface TerminalGridSize {
1313 readonly rows: number;
1414}
1515
16export function threadTerminalSubscriptionKey(
17 identity: ThreadTerminalSubscriptionIdentity,
18): string {
19 return JSON.stringify([
20 identity.environmentId,
21 identity.threadId,
22 identity.terminalId,
23 identity.cwd,
24 identity.worktreePath,
25 ]);
26}
27
2816export function buildThreadTerminalAttachInput(
2917 identity: ThreadTerminalSubscriptionIdentity,
3018 gridSize: TerminalGridSize,
apps/web/src/components/chat/MessagesTimeline.test.tsx+1-7
......@@ -134,7 +134,6 @@ function matchMedia() {
134134}
135135
136136let MessagesTimeline: typeof import("./MessagesTimeline").MessagesTimeline;
137let toolCallExpandedBodyClassName: typeof import("./MessagesTimeline").toolCallExpandedBodyClassName;
138137
139138beforeAll(async () => {
140139 const classList = {
......@@ -168,7 +167,7 @@ beforeAll(async () => {
168167 },
169168 });
170169
171 ({ MessagesTimeline, toolCallExpandedBodyClassName } = await import("./MessagesTimeline"));
170 ({ MessagesTimeline } = await import("./MessagesTimeline"));
172171}, 30_000);
173172
174173const ACTIVE_THREAD_ENVIRONMENT_ID = EnvironmentId.make("environment-local");
......@@ -238,11 +237,6 @@ function buildAssistantTimelineEntry(text: string) {
238237}
239238
240239describe("MessagesTimeline", () => {
241 it("sizes expanded tool details with the configured code font size", () => {
242 expect(toolCallExpandedBodyClassName).toContain("var(--font-size-code");
243 expect(toolCallExpandedBodyClassName).not.toContain("text-[11px]");
244 });
245
246240 it("uses the larger leading inset only when the top fade is enabled", () => {
247241 const timelineEntries = [buildUserTimelineEntry("Hello")];
248242
apps/web/src/components/chat/MessagesTimeline.tsx+1-1
......@@ -2063,7 +2063,7 @@ function buildToolCallExpandedBody(
20632063 return blocks.length > 0 ? blocks.join("\n\n") : null;
20642064}
20652065
2066export const toolCallExpandedBodyClassName =
2066const toolCallExpandedBodyClassName =
20672067 "max-h-64 cursor-text overflow-auto whitespace-pre-wrap break-words font-mono text-secondary-label text-[length:var(--font-size-code,0.6875rem)] leading-relaxed select-text";
20682068
20692069function workEntryIconName(workEntry: TimelineWorkEntry): WorkEntryIconName {
apps/web/src/components/composerFooterLayout.test.ts+5-8
......@@ -3,7 +3,6 @@ import { describe, expect, it } from "vite-plus/test";
33import {
44 COMPOSER_FOOTER_COMPACT_BREAKPOINT_PX,
55 COMPOSER_FOOTER_WIDE_ACTIONS_COMPACT_BREAKPOINT_PX,
6 COMPOSER_PRIMARY_ACTIONS_COMPACT_BREAKPOINT_PX,
76 shouldUseCompactComposerPrimaryActions,
87 shouldUseCompactComposerFooter,
98} from "./composerFooterLayout";
......@@ -38,16 +37,14 @@ describe("shouldUseCompactComposerFooter", () => {
3837
3938describe("shouldUseCompactComposerPrimaryActions", () => {
4039 it("matches the wide footer breakpoint", () => {
41 expect(COMPOSER_PRIMARY_ACTIONS_COMPACT_BREAKPOINT_PX).toBe(
42 COMPOSER_FOOTER_WIDE_ACTIONS_COMPACT_BREAKPOINT_PX,
43 );
4440 expect(
45 shouldUseCompactComposerPrimaryActions(COMPOSER_PRIMARY_ACTIONS_COMPACT_BREAKPOINT_PX - 1, {
46 hasWideActions: true,
47 }),
41 shouldUseCompactComposerPrimaryActions(
42 COMPOSER_FOOTER_WIDE_ACTIONS_COMPACT_BREAKPOINT_PX - 1,
43 { hasWideActions: true },
44 ),
4845 ).toBe(true);
4946 expect(
50 shouldUseCompactComposerPrimaryActions(COMPOSER_PRIMARY_ACTIONS_COMPACT_BREAKPOINT_PX, {
47 shouldUseCompactComposerPrimaryActions(COMPOSER_FOOTER_WIDE_ACTIONS_COMPACT_BREAKPOINT_PX, {
5148 hasWideActions: true,
5249 }),
5350 ).toBe(false);
apps/web/src/components/composerFooterLayout.ts+1-3
......@@ -1,7 +1,5 @@
11export const COMPOSER_FOOTER_COMPACT_BREAKPOINT_PX = 620;
22export const COMPOSER_FOOTER_WIDE_ACTIONS_COMPACT_BREAKPOINT_PX = 780;
3export const COMPOSER_PRIMARY_ACTIONS_COMPACT_BREAKPOINT_PX =
4 COMPOSER_FOOTER_WIDE_ACTIONS_COMPACT_BREAKPOINT_PX;
53
64export function shouldUseCompactComposerFooter(
75 width: number | null,
......@@ -20,5 +18,5 @@ export function shouldUseCompactComposerPrimaryActions(
2018 if (!options?.hasWideActions) {
2119 return false;
2220 }
23 return width !== null && width < COMPOSER_PRIMARY_ACTIONS_COMPACT_BREAKPOINT_PX;
21 return width !== null && width < COMPOSER_FOOTER_WIDE_ACTIONS_COMPACT_BREAKPOINT_PX;
2422}
packages/shared/src/terminalLabels.test.ts-1
......@@ -34,7 +34,6 @@ describe("resolveTerminalSessionLabel", () => {
3434describe("nextTerminalId", () => {
3535 it("allocates term-1 when no terminals are listed yet", () => {
3636 expect(nextTerminalId([])).toBe(DEFAULT_TERMINAL_ID);
37 expect(nextTerminalId([])).toBe("term-1");
3837 });
3938
4039 it("allocates term-2 when only term-1 exists", () => {