diff --git a/packages/ui/src/components/instance/shell/right-panel/tabs/FilesTab.tsx b/packages/ui/src/components/instance/shell/right-panel/tabs/FilesTab.tsx index dc462474..f9f949ce 100644 --- a/packages/ui/src/components/instance/shell/right-panel/tabs/FilesTab.tsx +++ b/packages/ui/src/components/instance/shell/right-panel/tabs/FilesTab.tsx @@ -1,12 +1,14 @@ -import { For, Show, type Accessor, type Component, type JSX } from "solid-js" +import { For, Show, Suspense, lazy, type Accessor, type Component, type JSX } from "solid-js" import type { FileNode } from "@opencode-ai/sdk/v2/client" import { RefreshCw } from "lucide-solid" -import { MonacoFileViewer } from "../../../../file-viewer/monaco-file-viewer" - import SplitFilePanel from "../components/SplitFilePanel" +const LazyMonacoFileViewer = lazy(() => + import("../../../../file-viewer/monaco-file-viewer").then((module) => ({ default: module.MonacoFileViewer })), +) + interface FilesTabProps { t: (key: string, vars?: Record) => string @@ -51,8 +53,8 @@ const FilesTab: Component = (props) => { const headerDisplayedPath = () => props.browserSelectedPath() || props.browserPath() const emptyViewerMessage = () => { - if (props.browserLoading() && entriesValue === null) return "Loading files..." - return "Select a file to preview" + if (props.browserLoading() && entriesValue === null) return props.t("instanceInfo.loading") + return props.t("instanceShell.filesShell.viewerEmpty") } const renderViewer = () => ( @@ -77,7 +79,9 @@ const FilesTab: Component = (props) => { } > {(payload) => ( - + {props.t("instanceInfo.loading")}}> + + )} } @@ -91,7 +95,7 @@ const FilesTab: Component = (props) => { } >
- Loading… + {props.t("instanceInfo.loading")}
@@ -113,7 +117,7 @@ const FilesTab: Component = (props) => { -
Loading files...
+
{props.t("instanceInfo.loading")}
@@ -154,7 +158,7 @@ const FilesTab: Component = (props) => { - Loading… + {props.t("instanceInfo.loading")} {(err) => {err()}} @@ -180,7 +184,7 @@ const FilesTab: Component = (props) => { onResizeMouseDown={props.onResizeMouseDown} onResizeTouchStart={props.onResizeTouchStart} isPhoneLayout={props.isPhoneLayout()} - overlayAriaLabel="Files" + overlayAriaLabel={props.t("instanceShell.rightPanel.tabs.files")} /> ) } diff --git a/packages/ui/src/components/instance/shell/right-panel/tabs/GitChangesTab.tsx b/packages/ui/src/components/instance/shell/right-panel/tabs/GitChangesTab.tsx index b2ab7ff4..c22a5231 100644 --- a/packages/ui/src/components/instance/shell/right-panel/tabs/GitChangesTab.tsx +++ b/packages/ui/src/components/instance/shell/right-panel/tabs/GitChangesTab.tsx @@ -1,14 +1,16 @@ -import { For, Show, createMemo, type Accessor, type Component, type JSX } from "solid-js" +import { For, Show, Suspense, createMemo, lazy, type Accessor, type Component, type JSX } from "solid-js" import type { File as GitFileStatus } from "@opencode-ai/sdk/v2/client" import { RefreshCw } from "lucide-solid" -import { MonacoDiffViewer } from "../../../../file-viewer/monaco-diff-viewer" - import DiffToolbar from "../components/DiffToolbar" import SplitFilePanel from "../components/SplitFilePanel" import type { DiffContextMode, DiffViewMode, DiffWordWrapMode } from "../types" +const LazyMonacoDiffViewer = lazy(() => + import("../../../../file-viewer/monaco-diff-viewer").then((module) => ({ default: module.MonacoDiffViewer })), +) + interface GitChangesTabProps { t: (key: string, vars?: Record) => string @@ -80,11 +82,11 @@ const GitChangesTab: Component = (props) => { }) const emptyViewerMessage = createMemo(() => { - if (!hasSession()) return "Select a session to view changes." + if (!hasSession()) return props.t("instanceShell.sessionChanges.noSessionSelected") const currentEntries = entries() - if (currentEntries === null) return "Loading git changes…" - if (nonDeleted().length === 0) return "No git changes yet." - return "No file selected." + if (currentEntries === null) return props.t("instanceShell.sessionChanges.loading") + if (nonDeleted().length === 0) return props.t("instanceShell.sessionChanges.empty") + return props.t("instanceShell.filesShell.viewerEmpty") }) const renderContent = (): JSX.Element => { @@ -122,7 +124,8 @@ const GitChangesTab: Component = (props) => { } > {(file) => ( - {props.t("instanceShell.sessionChanges.loading")}}> + = (props) => { contextMode={props.diffContextMode()} wordWrap={props.diffWordWrapMode()} /> - )} + + )} } > @@ -144,7 +148,7 @@ const GitChangesTab: Component = (props) => { } >
- Loading… + {props.t("instanceInfo.loading")}
@@ -220,8 +224,8 @@ const GitChangesTab: Component = (props) => { - - {selected?.path || "Git Changes"} + + {selected?.path || props.t("instanceShell.rightPanel.tabs.gitChanges")}
diff --git a/packages/ui/src/lib/git-diff-lowlight.ts b/packages/ui/src/lib/git-diff-lowlight.ts index e998e3a9..20b0c418 100644 --- a/packages/ui/src/lib/git-diff-lowlight.ts +++ b/packages/ui/src/lib/git-diff-lowlight.ts @@ -171,7 +171,7 @@ export const highlighter = { ignoreSyntaxHighlightList.push(...values) }, getAST(raw: string, fileName?: string, lang?: string) { - const language = String(lang || "plaintext") + const language = typeof lang === "string" ? lang.trim() : "" if ( fileName && ignoreSyntaxHighlightList.some((item) => (item instanceof RegExp ? item.test(fileName) : fileName === item)) @@ -179,7 +179,7 @@ export const highlighter = { return undefined } - if (lowlight.registered(language)) { + if (language && lowlight.registered(language)) { return lowlight.highlight(language, raw) }