1
+import { clientHostEnvironmentAtom } from "../state/clientHostEnvironment";
2
import { buildFileLinkParentSuffixByPath, fileLinkLabel } from "@t3tools/shared/fileLinks";
3
import {
4
isWindowsDrivePathHref,
411
function markdownServerConfigFields(config: ServerConfig | null) {
412
return {
413
pullRequestsEnabled: config !== null,
414
+ isMacOS: config?.environment.platform.os === "darwin",
415
availableEditors: config?.availableEditors ?? NO_MARKDOWN_EDITORS,
416
revealInFileManagerLabel:
417
config?.shellRevealInFileManager === true && config.availableEditors.includes("file-manager")
428
): boolean {
429
return (
430
previous.pullRequestsEnabled === next.pullRequestsEnabled &&
431
+ previous.isMacOS === next.isMacOS &&
432
previous.revealInFileManagerLabel === next.revealInFileManagerLabel &&
433
previous.availableEditors.length === next.availableEditors.length &&
434
previous.availableEditors.every((editor, index) => editor === next.availableEditors[index])
554
const environmentId = threadRef?.environmentId ?? explicitEnvironmentId ?? null;
555
const canOperateHost = useEnvironmentScope(environmentId, AuthOrchestrationOperateScope);
556
const canOperatePreview = useEnvironmentScope(environmentId, AuthPreviewOperateScope);
557
+ const isClientHost = useAtomValue(clientHostEnvironmentAtom(environmentId));
558
const remoteOpen = useRemoteOpenResolution(environmentId);
559
const canUseShellActions =
560
canOperateHost &&
624
},
625
);
626
};
623
- const { pullRequestsEnabled, availableEditors, revealInFileManagerLabel } = useAtomValue(
627
+ const { pullRequestsEnabled, availableEditors, revealInFileManagerLabel, isMacOS } = useAtomValue(
628
markdownServerConfigFieldsAtom(environmentId),
629
);
630
const projects = useProjects();
815
cwd,
816
findWorkspaceMatch: () => findWorkspaceFileMatch(fileLinkMeta),
817
});
818
+ const isAppBundle = isMacOS && fileLinkMeta.filePath.endsWith(".app");
819
+ const canOpenApp =
820
+ environmentId !== null &&
821
+ isAppBundle &&
822
+ isClientHost &&
823
+ canOperateHost &&
824
+ availableEditors.includes("file-manager");
825
const mediaPath = mediaSource ?? fileLinkMeta.filePath;
826
const canPreviewMedia =
827
mediaMimeTypeFromExtension(
836
environmentId={environmentId}
837
href={fileLinkMeta.targetPath}
838
targetPath={fileLinkMeta.targetPath}
828
- iconPath={fileLinkMeta.filePath}
839
+ iconPath={
840
+ isAppBundle && cwd
841
+ ? resolveWorkspaceFilePath(fileLinkMeta.filePath, cwd)
842
+ : fileLinkMeta.filePath
843
+ }
844
+ isAppBundle={isAppBundle}
845
workspaceRelativePath={fileLinkMeta.workspaceRelativePath}
830
- panelPath={panelPath}
846
+ panelPath={isAppBundle ? null : panelPath}
847
line={fileLinkMeta.line}
848
label={fileLinkLabel(
849
{
857
theme={resolvedTheme}
858
threadRef={threadRef}
859
onOpen={
844
- canUseShellActions
860
+ canOpenApp
861
? async () =>
846
- openInPreferredEditor(
847
- markdownFileEditorTarget(fileLinkMeta, await resolveHostPath()),
848
- )
849
- : undefined
862
+ openInEditor({
863
+ environmentId,
864
+ input: { cwd: (await resolveHostPath()).absolutePath, editor: "file-manager" },
865
+ })
866
+ : canUseShellActions
867
+ ? async () =>
868
+ openInPreferredEditor(
869
+ markdownFileEditorTarget(fileLinkMeta, await resolveHostPath()),
870
+ )
871
+ : undefined
872
}
873
resolveCopyPaths={async () =>
874
markdownFileCopyPaths(fileLinkMeta, await resolveHostPath(), cwd)
879
? () => openMarkdownMedia(mediaPath, fileLinkMeta.filePath)
880
: undefined
881
}
860
- openInEditorMenuLabel={preferredEditorMenuLabel}
882
+ openInEditorMenuLabel={canOpenApp ? "Open app" : preferredEditorMenuLabel}
883
onReveal={
884
canUseShellActions && revealInFileManagerLabel !== undefined
885
? async () => revealFileInFileManager((await resolveHostPath()).absolutePath)