Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Merge pull request #6790 from laijsg1/fix/6740-outside-workspace-preview
milind-sonie8fff4c96cf0
diff --cc src/components/AttachmentPreview.tsxindex 259911248f,626098b07d..a47336a2c1--- a/src/components/AttachmentPreview.tsx+++ b/src/components/AttachmentPreview.tsx@@@ -417,7 -416,13 +417,7 @@@ export function MessageFolderFiles({ fo);}- export function OutsideWorkspaceFile({ filePath }: { filePath: string }) {-export const REVEALABLE_PATH = /^(?:\/(?!\/)|[a-zA-Z]:[\\/])/;-export function revealBridge(): NonNullable<Window["ogb"]>["revealInFolder"] {- const ogb = typeof window === "undefined" ? undefined : window.ogb;- return ogb?.remoteClient?.active ? undefined : ogb?.revealInFolder;-}-+ export function OutsideWorkspaceFile({ filePath, standalone = false }: { filePath: string; standalone?: boolean }) {const [problem, setProblem] = useState("");const reveal = revealBridge();if (!reveal || !REVEALABLE_PATH.test(filePath)) {@@@ -882,15 -891,15 +882,15 @@@ export function MarkdownImagePreview();}-export function AttachedFileChip({ file, message, linked = false, compact = false, className }: {+export function AttachedFileChip({ file, message, linked = false, compact = false, className, note }: {- file: TranscriptFileAttachment;+ file: TranscriptFileAttachment & { shownPath?: string };message?: MessageAttachmentContext;linked?: boolean;compact?: boolean;- className?: string;+ className?: string; note?: string; // note: a quiet word after the name, such as the conversation it came from}) {const save = useLocalFileSave(file.path, file.name, message);- const preview = useHtmlPreview(file.path, file.name, message);+ const preview = useHtmlPreview(file.path, file.name, message, file.shownPath);const failed = save.state === "failed";if (compact) return <CompactFileChip file={file} message={message} linked={linked} save={save} preview={preview} className={className} />;if (!message || (!file.private && !linked)) {diff --cc src/components/ChatMarkdown.tsxindex 660a098407,4f1162e93e..441e9190b5--- a/src/components/ChatMarkdown.tsx+++ b/src/components/ChatMarkdown.tsx@@@ -363,12 -361,8 +363,12 @@@ export function MermaidDiagram({ code }// source: the original a delivered copy came from, offered on right-click (Show in Finder) like in the gallery.function LocalFileLink({ filePath, shownPath, shownName, name, source, children, message }: { filePath: string; shownPath: string; shownName: string; name?: string; source?: string; children?: ReactNode; message?: MessageAttachmentContext }) {const save = useLocalFileSave(filePath, name, message);- const preview = useHtmlPreview(filePath, shownName, message);+ const preview = useHtmlPreview(filePath, shownName, message, shownPath);const revealMenu = useRevealOriginalMenu();+ const fileOutsideWorkspace = useMessageFileOutsideWorkspace(filePath, message);+ const revealHere = typeof window !== "undefined" && Boolean(window.ogb?.revealInFolder) && !window.ogb?.remoteClient?.active;+ const revealOnClick = fileOutsideWorkspace === true && canRevealHostPath(shownPath) && revealHere;+ const [revealProblem, setRevealProblem] = useState("");if (!message) {return <span title={t("chat.file.legacy")} className="break-words text-ink-secondary">{children}</span>;}@@@ -402,12 -379,12 +402,12 @@@{revealMenu.menu}{preview.opens? <SaveIconButton name={shownName} save={save} retryable={save.retryable} />- : <FilePreviewButton path={filePath} name={shownName} message={message} />}+ : <FilePreviewButton path={filePath} shownPath={shownPath} name={shownName} message={message} />}<buttontype="button"- onClick={preview.opens ? preview.show : () => void save.save()}- disabled={!preview.opens && save.state === "saving"}- title={preview.opens ? preview.label : t("chat.file.saveCopy")}+ onClick={(event) => void pathAction(event)}+ disabled={!preview.opens && (save.state === "saving" || probing)}+ title={pathTitle}className="inline-flex items-center gap-1 break-words text-start text-accent underline decoration-accent/40 hover:decoration-accent disabled:cursor-wait">{children}diff --cc src/components/OutsideWorkspacePreview.tsxindex 0000000000,30c1e77c9a..786b19c72fmode 000000,100644..100644--- a/src/components/OutsideWorkspacePreview.tsx+++ b/src/components/OutsideWorkspacePreview.tsx@@@ -1,0 -1,21 +1,22 @@@-import { OutsideWorkspaceFile, REVEALABLE_PATH, revealBridge } from "./AttachmentPreview";++import { OutsideWorkspaceFile } from "./AttachmentPreview";++import { REVEALABLE_PATH, revealBridge } from "@/lib/reveal-host-path";+ import { t } from "@/lib/i18n";++ export const refusedAsOutsideWorkspace = (error: unknown): boolean => (error as { code?: unknown } | null)?.code === "outside_workspace";++ export function OutsideWorkspacePreview({ filePath }: { filePath: string }) {+ const absolute = REVEALABLE_PATH.test(filePath) || /^(?:\\\\|\/\/)/.test(filePath);+ const revealable = Boolean(revealBridge()) && REVEALABLE_PATH.test(filePath);+ return (+ <div className="p-8 text-center text-sm">+ <p role="alert" className="mb-3 text-ink-secondary">{t("attach.previewOutsideWorkspace")}</p>+ {absolute && <>+ {!revealable && <p className="mb-1 text-[12px] text-ink-secondary">{t("attach.outsideWorkspacePath")}</p>}+ <div className="flex flex-col items-center gap-1 text-[12px]">+ <OutsideWorkspaceFile filePath={filePath} standalone />+ {revealable && <code className="select-all whitespace-pre-wrap break-all text-ink-secondary">{filePath}</code>}+ </div>+ </>}+ </div>+ );+ }