feat(composer): fold large pastes into text attachments (#11442)

This commit is contained in:
Chris Deeming authored and GitHub committed 2026-09-12 17:28:28 -07:00
1 parent 36caf200c2
commit 68c2277f50
77 files changed
+3278 -465

No files matched your search

@@ -583,6 +583,7 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
useAdaptiveWorkspacePaneRole("inspector");
const navigation = useNavigation();
const { fileInspector, panes, toggleAuxiliaryPane } = useAdaptiveWorkspaceLayout();
const { appearance, setCodeWordBreak } = useAppearancePreferences();
const iconColor = useUniwindTheme()["--color-icon"];
const isAndroid = Platform.OS === "android";
const params = props.route.params;
@@ -763,6 +764,16 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
onPress: () => setModeOverride({ path: relativePath, mode: "source" }),
} as const)
: null,
// Only the source body wraps; a rendered preview lays itself out.
resolvedActiveMode === "source"
? ({
id: "word-wrap",
title: appearance.codeWordBreak ? "Disable word wrap" : "Enable word wrap",
icon: "text.alignleft",
inline: false,
onPress: () => setCodeWordBreak(!appearance.codeWordBreak),
} as const)
: null,
...(mediaSource
? mediaActions.actions
.filter(({ id }) => id !== "open-file")
@@ -783,6 +794,17 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
onPress: () => copyTextWithHaptic(relativePath),
} as const,
]),
// Selecting a long file by hand is painful on a phone, so copying the whole thing is
// the action most readers actually want. The attachment screen already offers it.
fileData?.contents != null
? ({
id: "copy-contents",
title: fileData.truncated ? "Copy preview" : "Copy contents",
icon: "doc.on.doc",
inline: false,
onPress: () => copyTextWithHaptic(fileData.contents),
} as const)
: null,
isPdfFile({ name: relativePath }) && previewUri !== null
? ({
id: "open-pdf",
@@ -821,6 +843,8 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
: null,
].filter((action) => action !== null);
}, [
appearance.codeWordBreak,
setCodeWordBreak,
assetPreviewUri,
assetPreview.refresh,
previewUri,
@@ -833,6 +857,8 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
resolvedActiveMode,
mediaSource,
mediaActions.actions,
fileData?.contents,
fileData?.truncated,
]);
const androidFileMenuActions = useMemo<MenuAction[]>(