Skip to content

Commit 7503563

Browse files
committed
Merge remote-tracking branch 'github/main' into fix/failed-git-action-refreshes-status
2 parents fd6fdc1 + d756fed commit 7503563

92 files changed

Lines changed: 2202 additions & 250 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.

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,9 @@ import { readEnvironmentScope, usePreparedConnection } from "../../state/session
236236
import { projectEnvironment } from "../../state/projects";
237237
import {
238238
needsWorkspaceBasenameLookup,
239-
pickWorkspaceBasenameMatch,
239+
pickWorkspaceLinkMatch,
240240
WORKSPACE_BASENAME_LOOKUP_LIMIT,
241+
workspaceLinkLookupQuery,
241242
} from "@t3tools/client-runtime/workspace-basename-lookup";
242243
import {
243244
resolveThreadLink,
@@ -1913,7 +1914,10 @@ function renderFeedEntry(
19131914
const bubbleBodyVisible = foldRowId === null || foldExpanded;
19141915
const intentBadge = props.userMessageGrouping.continuesSteer
19151916
? null
1916-
: resolveUserMessageIntentBadge(message.inputIntent);
1917+
: resolveUserMessageIntentBadge(
1918+
message.inputIntent,
1919+
message.projectedItem?.item.status === "pending",
1920+
);
19171921
const referenceIds = new Set(
19181922
collectComposerContextReferences(message.text).map((reference) => reference.contextId),
19191923
);
@@ -2894,17 +2898,18 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
28942898
props.workspaceRoot &&
28952899
relativePath &&
28962900
!/[\\/]$/.test(presentation.path) &&
2897-
needsWorkspaceBasenameLookup(relativePath) &&
2901+
workspaceLinkLookupQuery(presentation.path, props.workspaceRoot) !== null &&
28982902
readEnvironmentScope(props.environmentId, AuthFilesystemReadScope)
28992903
) {
2904+
const workspaceRoot = props.workspaceRoot;
29002905
const originalPath = resolveWorkspaceFilePath(props.workspaceRoot, relativePath);
29012906
void executeAtomQuery(
29022907
appAtomRegistry,
29032908
projectEnvironment.searchEntries({
29042909
environmentId: props.environmentId,
29052910
input: {
2906-
cwd: props.workspaceRoot,
2907-
query: relativePath,
2911+
cwd: workspaceRoot,
2912+
query: workspaceLinkLookupQuery(relativePath, workspaceRoot) ?? relativePath,
29082913
kind: "file",
29092914
limit: WORKSPACE_BASENAME_LOOKUP_LIMIT,
29102915
},
@@ -2914,7 +2919,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
29142919
(result) => {
29152920
const match =
29162921
result._tag === "Success"
2917-
? pickWorkspaceBasenameMatch(relativePath, result.value.entries)
2922+
? pickWorkspaceLinkMatch(relativePath, workspaceRoot, result.value.entries)
29182923
: null;
29192924
if (!match || match === relativePath) {
29202925
openAt(relativePath);
@@ -2931,7 +2936,10 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
29312936
).then(
29322937
(metadata) =>
29332938
openAt(
2934-
metadata._tag === "Success" && metadata.value?.kind !== "directory"
2939+
metadata._tag === "Success" &&
2940+
(needsWorkspaceBasenameLookup(relativePath)
2941+
? metadata.value?.kind !== "directory"
2942+
: metadata.value === null)
29352943
? match
29362944
: relativePath,
29372945
),

‎apps/mobile/src/features/threads/subagent-card-presentation.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe("subagent card", () => {
2222
expect(subagentCardElapsed([unfinished], DateTime.toEpochMillis(later))).toBeNull();
2323
expect(
2424
subagentCardElapsed([{ ...unfinished, status: "running" }], DateTime.toEpochMillis(later)),
25-
).toBe("2m");
25+
).toBe("2m 0s");
2626
expect(
2727
subagentCardElapsed([{ ...unfinished, status: "idle" }], DateTime.toEpochMillis(later)),
2828
).toBeNull();

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ 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}
5956
<ScrollView
6057
ref={scrollRef}
6158
nestedScrollEnabled
@@ -73,6 +70,9 @@ export function ThreadCommandOutput(props: {
7370
if (followRef.current) scrollRef.current?.scrollToEnd({ animated: false });
7471
}}
7572
>
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/features/threads/userMessageIntentBadge.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ export interface UserMessageIntentBadgePresentation {
77

88
export function resolveUserMessageIntentBadge(
99
intent: OrchestrationV2UserMessageInputIntent | undefined,
10+
unread = false,
1011
): UserMessageIntentBadgePresentation | null {
12+
if (unread && (intent === "steer" || intent === "promoted_queued_to_steer")) {
13+
return {
14+
label: "Steer · waiting to be read",
15+
accessibilityLabel:
16+
"Steer waiting for the agent to read it after the running command finishes",
17+
};
18+
}
1119
switch (intent) {
1220
case "steer":
1321
return {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@ 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",
2325
]) {
2426
expect(ENRICHED_INLINE_FILE_LINK_REGEX.test(path), path).toBe(true);
2527
}
2628
for (const text of [
2729
"npm run dev",
2830
"port:3000",
31+
"port:3000-3010",
2932
"TODO:12",
3033
"example.com",
3134
"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+){0,2}|[A-Za-z0-9._-]+\.[A-Za-z0-9_-]+:\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+(?::\d+|-\d+)?)?|[A-Za-z0-9._-]+\.[A-Za-z0-9_-]+:\d+(?::\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-
ToolActivityNativeAppReference,
18+
NativeAppIconReference,
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: ToolActivityNativeAppReference,
155+
app: NativeAppIconReference,
156156
expiresAt: Schema.Number,
157157
}),
158158
Schema.Struct({
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
2+
import * as NodeServices from "@effect/platform-node/NodeServices";
3+
import { expect, it } from "@effect/vitest";
4+
import * as Effect from "effect/Effect";
5+
import * as FileSystem from "effect/FileSystem";
6+
import * as Layer from "effect/Layer";
7+
import * as Path from "effect/Path";
8+
import { ChildProcessSpawner } from "effect/process";
9+
import * as HostProcess from "@t3tools/shared/HostProcess";
10+
11+
import * as ServerConfig from "../config.ts";
12+
import * as NativeAppIconResolver from "./NativeAppIconResolver.ts";
13+
14+
it.effect("resolves the exact bundle path without Spotlight and caches the converted icon", () =>
15+
Effect.gen(function* () {
16+
const fs = yield* FileSystem.FileSystem;
17+
const path = yield* Path.Path;
18+
const root = yield* fs.makeTempDirectoryScoped({ prefix: "t3-bundle-icon-" });
19+
const bundle = path.join(root, "Build Output", "My App.app");
20+
const resources = path.join(bundle, "Contents", "Resources");
21+
yield* fs.makeDirectory(resources, { recursive: true });
22+
yield* fs.writeFileString(path.join(resources, "AppIcon.icns"), "icon");
23+
const commands: string[] = [];
24+
const spawner = Layer.mock(ChildProcessSpawner.ChildProcessSpawner)({
25+
string: (command) =>
26+
Effect.gen(function* () {
27+
if (command._tag !== "StandardCommand") return "";
28+
commands.push(command.command);
29+
if (command.command === "/usr/bin/plutil") return "AppIcon";
30+
if (command.command === "/usr/bin/sips") {
31+
yield* fs.writeFileString(String(command.args.at(-1)), "converted icon");
32+
}
33+
return "";
34+
}),
35+
});
36+
yield* Effect.gen(function* () {
37+
const resolver = yield* NativeAppIconResolver.make;
38+
const reference = { _tag: "app-path" as const, path: bundle };
39+
const icon = yield* resolver.resolve(reference);
40+
expect(icon).not.toBeNull();
41+
if (icon === null) return;
42+
expect(yield* fs.readFileString(icon)).toBe("converted icon");
43+
expect(yield* resolver.resolve(reference)).toBe(icon);
44+
expect(yield* resolver.resolve({ _tag: "app-path", path: "~/Build Output/My App.app" })).toBe(
45+
icon,
46+
);
47+
expect(commands.filter((command) => command === "/usr/bin/sips")).toHaveLength(1);
48+
expect(commands).not.toContain("/usr/bin/mdfind");
49+
expect(yield* resolver.resolve({ _tag: "app-path", path: "relative.app" })).toBeNull();
50+
expect(yield* resolver.resolve({ _tag: "app-path", path: root })).toBeNull();
51+
}).pipe(
52+
Effect.provide(
53+
Layer.mergeAll(
54+
spawner,
55+
ServerConfig.ServerConfig.layerTest(root, { prefix: "t3-native-icon-config-" }),
56+
),
57+
),
58+
Effect.provideService(HostProcess.Platform, "darwin"),
59+
Effect.provideService(HostProcess.HomeDirectory, root),
60+
);
61+
}).pipe(Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))),
62+
);

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

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

35-
function appCacheKey(app: ToolActivityNativeAppReference): string {
36+
function appCacheKey(app: NativeAppIconReference): string {
3637
return JSON.stringify(app);
3738
}
3839

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

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

9394
const resolveApplicationPath = Effect.fn("NativeAppIconResolver.resolveApplicationPath")(function* (
94-
app: ToolActivityNativeAppReference,
95+
app: NativeAppIconReference,
9596
) {
9697
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+
}
97102
const query =
98103
app._tag === "app-id"
99104
? `kMDItemCFBundleIdentifier == '${app.appId}'`
@@ -131,7 +136,7 @@ const resolveApplicationPath = Effect.fn("NativeAppIconResolver.resolveApplicati
131136
});
132137

133138
const resolveNativeAppIconUncached = Effect.fn("NativeAppIconResolver.resolveUncached")(function* (
134-
app: ToolActivityNativeAppReference,
139+
app: NativeAppIconReference,
135140
) {
136141
const fileSystem = yield* FileSystem.FileSystem;
137142
const path = yield* Path.Path;
@@ -242,7 +247,7 @@ export const make = Effect.gen(function* () {
242247
);
243248

244249
const resolveAttempt = Effect.fn("NativeAppIconResolver.resolve")(function* (
245-
app: ToolActivityNativeAppReference,
250+
app: NativeAppIconReference,
246251
) {
247252
if (
248253
hostPlatform !== "darwin" ||

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,10 +412,14 @@ 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+
});
415418
for (const resource of [
416419
{ _tag: "workspace-file", threadId: ThreadId.make("thread"), path: "file.txt" },
417420
{ _tag: "media-file", threadId: ThreadId.make("thread"), path: "/repo/image.png" },
418421
{ _tag: "draft-workspace-file", cwd: "/repo", path: "file.txt" },
422+
{ _tag: "native-app-icon", app: { _tag: "app-path", path: "/private/Secret.app" } },
419423
] as const) {
420424
expect(
421425
yield* client[WS_METHODS.assetsCreateUrl]({ resource }).pipe(Effect.flip),
@@ -424,7 +428,7 @@ it.effect("separates host file URLs from readable attachment URLs", () =>
424428
requiredPermission: AuthFilesystemReadScope,
425429
});
426430
}
427-
expect(handled).toBe(1);
431+
expect(handled).toBe(2);
428432
}).pipe(Effect.scoped),
429433
);
430434

0 commit comments

Comments
 (0)