diff --git a/apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx b/apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx
index 36ec394368fbb..9c3d5abc811e4 100644
--- a/apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx
+++ b/apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx
@@ -25,6 +25,7 @@ import * as Schema from "effect/Schema";
import { videoMimeType } from "@t3tools/shared/video";
import {
filePreviewKind,
+ hostPreviewMimeTypeFromExtension,
isWorkspaceBrowserPreviewPath,
isWorkspaceImagePreviewPath,
mediaMimeTypeFromExtension,
@@ -123,11 +124,16 @@ function FileHeader(props: {
readonly fileInspectorSupported: boolean;
readonly onBack: () => void;
readonly onReturnToThread: () => void;
+ readonly onDownload?: (() => void) | undefined;
+ readonly downloadLabel?: string;
+ readonly downloading?: boolean;
+ readonly downloadDisabled?: boolean;
readonly actions: ReadonlyArray<{
readonly id: string;
readonly title: string;
readonly icon: string;
readonly inline: boolean;
+ readonly disabled?: boolean;
readonly onPress: () => unknown;
}>;
}) {
@@ -150,20 +156,33 @@ function FileHeader(props: {
}
: undefined
}
- actions={
- props.fileInspectorSupported
+ actions={[
+ ...(props.onDownload
+ ? [
+ {
+ accessibilityLabel: props.downloading
+ ? gt("Opening share sheet…")
+ : (props.downloadLabel ?? gt("Save or share")),
+ icon: "tray.and.arrow.down" as const,
+ onPress: props.onDownload,
+ disabled: props.downloading || props.downloadDisabled,
+ loading: props.downloading,
+ },
+ ]
+ : []),
+ ...(props.fileInspectorSupported
? [
{
accessibilityLabel: panes.auxiliaryPaneVisible
? gt("Hide file navigator")
: gt("Show file navigator"),
- icon: "sidebar.right",
+ icon: "sidebar.right" as const,
selected: panes.auxiliaryPaneVisible,
onPress: toggleAuxiliaryPane,
},
]
- : undefined
- }
+ : []),
+ ]}
menus={[
{
title: gt("File actions"),
@@ -178,11 +197,14 @@ function FileHeader(props: {
items: modes.map((action) => ({
...action,
selected: action.id === props.activeMode,
+ disabled: action.disabled,
})),
},
]
: []),
- ...props.actions.filter(({ inline }) => !inline),
+ ...props.actions
+ .filter(({ inline }) => !inline)
+ .map((action) => ({ ...action, disabled: action.disabled })),
],
},
]}
@@ -215,6 +237,15 @@ function normalizeRouteLine(value: string | null): number | null {
return Number.isInteger(parsed) && parsed > 0 ? parsed : null;
}
+function hostDownloadMimeType(path: string): string {
+ const name = basename(path);
+ const dot = name.lastIndexOf(".");
+ return (
+ (dot > 0 ? hostPreviewMimeTypeFromExtension(name.slice(dot)) : null) ??
+ "application/octet-stream"
+ );
+}
+
function defaultViewMode(path: string | null): FileViewMode {
return path !== null &&
(isWorkspaceBrowserPreviewPath(path) ||
@@ -829,7 +860,41 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
resource: assetPreview.resource,
}
: undefined;
- const mediaActions = useMediaActions(mediaSource);
+ // Preview URLs refuse spreadsheets, source, and other non-media files. A download asks for the
+ // file as an attachment, which the server will serve for any type.
+ const downloadSource: MediaActionsSource | undefined =
+ mediaSource !== undefined ||
+ environmentId === null ||
+ relativePath === null ||
+ directoryPath !== null
+ ? undefined
+ : threadId !== null && targetPath !== null
+ ? {
+ name: basename(relativePath),
+ mimeType: hostDownloadMimeType(relativePath),
+ environmentId,
+ threadId,
+ resource: {
+ _tag: "media-file",
+ threadId,
+ path: targetPath,
+ disposition: "attachment",
+ },
+ }
+ : cwd !== null
+ ? {
+ name: basename(relativePath),
+ mimeType: hostDownloadMimeType(relativePath),
+ environmentId,
+ resource: {
+ _tag: "draft-workspace-file",
+ cwd,
+ path: relativePath,
+ disposition: "attachment",
+ },
+ }
+ : undefined;
+ const mediaActions = useMediaActions(mediaSource ?? downloadSource);
const videoSource: MediaVideoPreviewSource | null =
environmentId !== null &&
relativePath !== null &&
@@ -966,11 +1031,22 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
id: action.id,
title: action.title,
icon:
- action.id === "save" ? ("square.and.arrow.up" as const) : ("doc.on.doc" as const),
+ action.id === "save" ? ("tray.and.arrow.down" as const) : ("doc.on.doc" as const),
inline: false,
+ disabled: action.disabled,
onPress: action.run,
}))
: [
+ ...mediaActions.actions
+ .filter(({ id }) => id === "save")
+ .map((action) => ({
+ id: action.id,
+ title: action.title,
+ icon: "tray.and.arrow.down" as const,
+ inline: false as const,
+ disabled: action.disabled,
+ onPress: action.run,
+ })),
{
id: "copy-path",
title: gt("Copy path"),
@@ -1138,6 +1214,7 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
}
const headerSubtitle = fileHeaderSubtitle(projectName, relativePath);
+ const saveFile = mediaActions.actions.find((action) => action.id === "save");
return withInspector(
@@ -1148,6 +1225,14 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
fileInspectorSupported={fileInspector.supported}
onBack={handleBack}
onReturnToThread={handleReturnToThread}
+ {...(saveFile
+ ? {
+ onDownload: saveFile.run,
+ downloadLabel: saveFile.title,
+ downloading: mediaActions.sharing,
+ downloadDisabled: saveFile.disabled === true && !mediaActions.sharing,
+ }
+ : {})}
actions={fileMenuActions}
/>
diff --git a/apps/mobile/src/features/threads/ThreadFeed.tsx b/apps/mobile/src/features/threads/ThreadFeed.tsx
index b1b196bec37f2..74e822d813312 100644
--- a/apps/mobile/src/features/threads/ThreadFeed.tsx
+++ b/apps/mobile/src/features/threads/ThreadFeed.tsx
@@ -706,7 +706,6 @@ function MessageAttachmentFile(props: {
readonly attachment: ChatFileAttachment;
readonly onPressPreview: (source: FilePreviewSource) => void;
readonly onPlaybackStart: () => void;
- readonly standaloneFile?: boolean;
readonly available?: boolean;
}) {
const gt = useGT();
@@ -837,6 +836,7 @@ function MessageAttachmentFile(props: {
sizeBytes={attachment.sizeBytes}
onOpen={openAttachment}
onPlaybackStart={props.onPlaybackStart}
+ onDownload={() => shareFile(sourceIdentifier)}
onLongPress={() => shareFile(sourceIdentifier)}
/>
@@ -894,18 +894,16 @@ function MessageAttachmentFile(props: {
type="monochrome"
/>
- {props.standaloneFile ? (
- shareFile(sourceIdentifier)}
- >
-
-
- ) : null}
+ shareFile(sourceIdentifier)}
+ >
+
+
);
@@ -2449,7 +2447,6 @@ function renderFeedEntry(
}
onPressPreview={props.onPressPreview}
onPlaybackStart={props.onPlaybackStart}
- standaloneFile
/>
);
})}
diff --git a/apps/mobile/src/features/threads/ThreadInlineFilePreview.tsx b/apps/mobile/src/features/threads/ThreadInlineFilePreview.tsx
index f9a7969bbe178..c596197f80de3 100644
--- a/apps/mobile/src/features/threads/ThreadInlineFilePreview.tsx
+++ b/apps/mobile/src/features/threads/ThreadInlineFilePreview.tsx
@@ -27,34 +27,47 @@ type PreviewProps = {
readonly onOpen: () => void;
readonly onPlaybackStart?: () => void;
readonly onLongPress?: () => void;
+ readonly onDownload?: () => void;
};
function FileCardHeader(props: PreviewProps) {
const gt = useGT();
const messages = useMessages();
return (
-
-
-
-
-
-
- {props.source.name}
-
-
- {props.sizeBytes !== undefined
- ? gt("Audio · {size}", { size: formatAttachmentSize(props.sizeBytes, messages) })
- : gt("Audio")}
-
-
-
-
+
+
+
+
+
+
+
+ {props.source.name}
+
+
+ {props.sizeBytes !== undefined
+ ? gt("Audio · {size}", { size: formatAttachmentSize(props.sizeBytes, messages) })
+ : gt("Audio")}
+
+
+
+
+ {props.onDownload ? (
+
+
+
+ ) : null}
+
);
}
diff --git a/apps/mobile/src/features/threads/fileChipMenu.test.ts b/apps/mobile/src/features/threads/fileChipMenu.test.ts
index 5c992b58f379a..123b7b0c05911 100644
--- a/apps/mobile/src/features/threads/fileChipMenu.test.ts
+++ b/apps/mobile/src/features/threads/fileChipMenu.test.ts
@@ -76,15 +76,25 @@ describe("file chip downloads", () => {
expect(fileChipShareSource(target, threadId)).toEqual({
name: path.split("/").at(-1),
mimeType,
- resource: { _tag: "media-file", threadId, path },
+ resource: { _tag: "media-file", threadId, path, disposition: "attachment" },
});
});
- it("does not offer downloads the host asset endpoint cannot serve", () => {
- for (const href of ["src/app.ts", "/tmp/archive.7z", "/tmp/clip.mp4.txt"]) {
- const target = resolveFileChipTarget(href, "/repo")!;
- expect(fileChipShareSource(target, threadId)).toBeNull();
- expect(fileChipMenu(target).actions.some(({ id }) => id === "save")).toBe(false);
- }
+ it.each([
+ ["src/app.ts", "/repo/src/app.ts", "app.ts"],
+ ["/tmp/archive.7z", "/tmp/archive.7z", "archive.7z"],
+ ["/tmp/clip.mp4.txt", "/tmp/clip.mp4.txt", "clip.mp4.txt"],
+ ["exports/close-list.csv", "/repo/exports/close-list.csv", "close-list.csv"],
+ ])("offers a download for %s, which the preview endpoint will not inline", (href, path, name) => {
+ const target = resolveFileChipTarget(href, "/repo")!;
+ expect(fileChipMenu(target).actions).toContainEqual({
+ id: "save",
+ title: "Save or share",
+ });
+ expect(fileChipShareSource(target, threadId)).toEqual({
+ name,
+ mimeType: "application/octet-stream",
+ resource: { _tag: "media-file", threadId, path, disposition: "attachment" },
+ });
});
});
diff --git a/apps/mobile/src/features/threads/fileChipMenu.ts b/apps/mobile/src/features/threads/fileChipMenu.ts
index cc46062a471c7..ab2be411916b5 100644
--- a/apps/mobile/src/features/threads/fileChipMenu.ts
+++ b/apps/mobile/src/features/threads/fileChipMenu.ts
@@ -49,23 +49,31 @@ export function resolveFileChipTarget(
};
}
-function fileChipMetadata(target: FileChipTarget) {
+function fileChipFile(target: FileChipTarget) {
const path = target.fullPath ?? target.relativePath;
if (!path) return null;
const name = fileBasename(path);
const dot = name.lastIndexOf(".");
- const mimeType = dot < 0 ? null : hostPreviewMimeTypeFromExtension(name.slice(dot));
- return mimeType ? { path, name, mimeType } : null;
+ // An attachment disposition serves every file. Preview types keep their own media type.
+ const mimeType =
+ (dot < 0 ? null : hostPreviewMimeTypeFromExtension(name.slice(dot))) ??
+ "application/octet-stream";
+ return { path, name, mimeType };
}
/** Use literal resolved paths so encoded filename characters are not decoded twice. */
export function fileChipShareSource(target: FileChipTarget, threadId: ThreadId) {
- const metadata = fileChipMetadata(target);
- return metadata
+ const file = fileChipFile(target);
+ return file
? {
- name: metadata.name,
- mimeType: metadata.mimeType,
- resource: { _tag: "media-file" as const, threadId, path: metadata.path },
+ name: file.name,
+ mimeType: file.mimeType,
+ resource: {
+ _tag: "media-file" as const,
+ threadId,
+ path: file.path,
+ disposition: "attachment" as const,
+ },
}
: null;
}
@@ -82,14 +90,7 @@ export function fileChipMenu(
? [{ id: "copy-relative-path", title: resolve(msg("Copy relative path")) }]
: []),
{ id: "open-file", title: resolve(msg("Open in file viewer")) },
- ...(fileChipMetadata(target)
- ? [
- {
- id: "save",
- title: resolve(msg("Save or share")),
- },
- ]
- : []),
+ { id: "save", title: resolve(msg("Save or share")) },
],
};
}
diff --git a/apps/server/src/provider/acp/AcpSessionRuntime.processTree.test.ts b/apps/server/src/provider/acp/AcpSessionRuntime.processTree.test.ts
index 6b9afa7f30c50..4ffd67bbadf32 100644
--- a/apps/server/src/provider/acp/AcpSessionRuntime.processTree.test.ts
+++ b/apps/server/src/provider/acp/AcpSessionRuntime.processTree.test.ts
@@ -161,10 +161,15 @@ describe("terminatePosixOwnedProcessTree", () => {
expect(AcpSessionRuntime.resolveLinuxCgroupTargetCommand("grok", scratch, { PATH: "" })).toBe(
bareGrok,
);
- // Undefined PATH searches /usr/bin:/bin; the bareGrok fixture lives only in cwd.
+ // Undefined PATH searches /usr/bin:/bin. An installed grok is that binary, not the cwd fixture.
+ const defaultPathGrok = AcpSessionRuntime.resolveLinuxCgroupTargetCommand("grok", scratch, {
+ PATH: undefined,
+ });
expect(
- AcpSessionRuntime.resolveLinuxCgroupTargetCommand("grok", scratch, { PATH: undefined }),
- ).toBeUndefined();
+ defaultPathGrok === undefined ||
+ defaultPathGrok === "/usr/bin/grok" ||
+ defaultPathGrok === "/bin/grok",
+ ).toBe(true);
expect(
AcpSessionRuntime.resolveLinuxCgroupTargetCommand("sh", scratch, { PATH: undefined }),
).toBeDefined();
diff --git a/fork-seams.txt b/fork-seams.txt
index 2d1f2159fc678..9160e7d7b51ef 100644
--- a/fork-seams.txt
+++ b/fork-seams.txt
@@ -17,11 +17,15 @@ apps/desktop/src/window/DesktopWindow.ts # webauthn: preview guests disable the
apps/mobile/app.config.ts # tooling: wraps the default export in applyForkMobileConfig (app.config.fork.ts)
apps/mobile/package.json # tooling: eas-build-pre-install script for the trimmed EAS archive (.easignore); i18n: i18n:generate runs scripts/fork-i18n.ts
apps/mobile/src/App.tsx # identity: mounts IdentityClaimGate
+apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx # mobile-download: header and File actions save any workspace file, not only images and video
apps/mobile/src/features/home/HomeRouteScreen.tsx # identity: ownership-filters the home thread list and adds ownership to its filter menu (features/identity/OwnershipFilter.tsx)
apps/mobile/src/features/home/ThreadListFilters.tsx # identity: Mine/Theirs chip beside the environment and project chips
apps/mobile/src/features/threads/ThreadDetailScreen.tsx # identity: passes renderMessageSender (features/identity/MessageSenderCaption.tsx) to ThreadFeed
-apps/mobile/src/features/threads/ThreadFeed.tsx # identity: optional renderMessageSender prop rendered above user messages; ThreadFeed imports no identity code
+apps/mobile/src/features/threads/ThreadFeed.tsx # identity: optional renderMessageSender prop rendered above user messages; ThreadFeed imports no identity code; mobile-download: file attachments show a download button
+apps/mobile/src/features/threads/ThreadInlineFilePreview.tsx # mobile-download: audio cards take a download button
apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx # identity: ownership-filters the sidebar thread list and adds ownership to its filter menu
+apps/mobile/src/features/threads/fileChipMenu.test.ts # mobile-download: file-chip save covers files the preview endpoint will not inline
+apps/mobile/src/features/threads/fileChipMenu.ts # mobile-download: every file chip offers Save or share through an attachment asset URL
apps/mobile/src/features/threads/thread-list-v2-items.tsx # identity: thread rows show the creator/participant mark (features/identity/ParticipantStack.tsx)
apps/mobile/src/i18n/I18nProvider.tsx # i18n: wraps the catalog loader with withForkTranslations (fork-translations/)
apps/mobile/src/persistence/mobile-preferences.ts # identity: persists the Mine/Theirs ownership choice (features/identity/ownershipFilterOptions.ts)
@@ -46,6 +50,7 @@ apps/server/src/preview/ServerBrowserContexts.ts # webauthn: optional prepareCo
apps/server/src/processRunner.ts # direnv: optional extendEnv so direnv runs with exactly the provider environment
apps/server/src/provider/AntigravityProvider.ts # antigravity-usage-limits: optional probeUsage/clearUsage/watchUsageEnabled hooks delegated to antigravityUsageLimitsFork.ts
apps/server/src/provider/Drivers/AntigravityDriver.ts # antigravity-usage-limits: registers makeAntigravityUsageLimitsProbe (antigravityUsageLimitsFork.ts) on the Antigravity provider
+apps/server/src/provider/acp/AcpSessionRuntime.processTree.test.ts # cgroup-lookup: undefined PATH may resolve an installed grok and must not resolve the cwd fixture
apps/server/src/server.ts # identity: provides the persisted IdentityService layer; pr-quota: BackgroundPolicy comes from background/settledWorktreeFreeze.ts (settled worktrees skip background PR polling); direnv: DirenvEnvironment.layerLive in the runtime core layer merge; jira: adds the /api/jira/webhook route layer (jira/JiraServerLayers.ts); github: adds the /api/github/webhook route layer (github/GitHubServerLayers.ts); discord: the command-readiness middleware lets the bot's token exchange and discovery through (discord/commandReadinessExemption.ts); bot-browser: provides preview/forkPreviewAutomationHost.ts layer in place of PreviewAutomationBroker.layer (same broker plus external hosts and thread claims)
apps/server/src/ws.ts # identity: spreads identity.* handlers and wraps dispatch/launch so operate commands carry the session's source (identity/identityWsHandlers.ts); bot-browser: spreads the previewAutomation.* external host handlers (preview/forkPreviewAutomationHost.ts)
apps/web/package.json # i18n: i18n:generate runs scripts/fork-i18n.ts, which keeps fork strings out of upstream catalogs