Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions emain/emain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ electron.ipcMain.on("quicklook", (event, filePath: string) => {

electron.ipcMain.on("open-native-path", (event, filePath: string) => {
console.log("open-native-path", filePath);
filePath = filePath.replace("~", electronApp.getPath("home"));
fireAndForget(() =>
callWithOriginalXdgCurrentDesktopAsync(() =>
electron.shell.openPath(filePath).then((excuse) => {
Expand Down
5 changes: 3 additions & 2 deletions frontend/app/app-bg.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// Copyright 2025, Command Line Inc.
// SPDX-License-Identifier: Apache-2.0

import { PLATFORM, PlatformMacOS } from "@/util/platformutil";
import { computeBgStyleFromMeta } from "@/util/waveutil";
import useResizeObserver from "@react-hook/resize-observer";
import { useAtomValue } from "jotai";
import { CSSProperties, useCallback, useLayoutEffect, useRef } from "react";
import { debounce } from "throttle-debounce";
import { atoms, getApi, PLATFORM, WOS } from "./store/global";
import { atoms, getApi, WOS } from "./store/global";
import { useWaveObjectValue } from "./store/wos";

export function AppBackground() {
Expand All @@ -18,7 +19,7 @@ export function AppBackground() {
debounce(30, () => {
if (
bgRef.current &&
PLATFORM !== "darwin" &&
PLATFORM !== PlatformMacOS &&
bgRef.current &&
"windowControlsOverlay" in window.navigator
) {
Expand Down
13 changes: 3 additions & 10 deletions frontend/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@

import { Workspace } from "@/app/workspace/workspace";
import { ContextMenuModel } from "@/store/contextmenu";
import {
atoms,
createBlock,
getSettingsPrefixAtom,
globalStore,
isDev,
PLATFORM,
removeFlashError,
} from "@/store/global";
import { atoms, createBlock, getSettingsPrefixAtom, globalStore, isDev, removeFlashError } from "@/store/global";
import { appHandleKeyDown, keyboardMouseDownHandler } from "@/store/keymodel";
import { getElemAsStr } from "@/util/focusutil";
import * as keyutil from "@/util/keyutil";
import { PLATFORM } from "@/util/platformutil";
import * as util from "@/util/util";
import clsx from "clsx";
import debug from "debug";
Expand All @@ -29,7 +22,7 @@ import { NotificationBubbles } from "./notification/notificationbubbles";

import "./app.scss";

// this should come after app.scss (don't remove the newline above otherwise prettier will reorder these imports)
// tailwindsetup.css should come *after* app.scss (don't remove the newline above otherwise prettier will reorder these imports)
import "../tailwindsetup.css";

const dlog = debug("wave:app");
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/element/quicktips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// SPDX-License-Identifier: Apache-2.0

import { MagnifyIcon } from "@/app/element/magnify";
import { PLATFORM } from "@/app/store/global";
import { PLATFORM, PlatformMacOS } from "@/util/platformutil";
import "./quicktips.scss";

const KeyBinding = ({ keyDecl }: { keyDecl: string }) => {
const parts = keyDecl.split(":");
const elems: React.ReactNode[] = [];
for (let part of parts) {
if (part === "Cmd") {
if (PLATFORM === "darwin") {
if (PLATFORM === PlatformMacOS) {
elems.push(
<div key="cmd" className="keybinding">
⌘ Cmd
Expand Down
7 changes: 1 addition & 6 deletions frontend/app/store/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from "@/layout/lib/types";
import { getWebServerEndpoint } from "@/util/endpoints";
import { fetch } from "@/util/fetchutil";
import { setPlatform } from "@/util/platformutil";
import { deepCompareReturnPrev, getPrefixedSettings, isBlank } from "@/util/util";
import { atom, Atom, PrimitiveAtom, useAtomValue } from "jotai";
import { globalStore } from "./jotaiStore";
Expand All @@ -25,7 +26,6 @@ import { ClientService, ObjectService } from "./services";
import * as WOS from "./wos";
import { getFileSubject, waveEventSubscribe } from "./wps";

let PLATFORM: NodeJS.Platform = "darwin";
let atoms: GlobalAtomsType;
let globalEnvironment: "electron" | "renderer";
const blockComponentModelMap = new Map<string, BlockComponentModel>();
Expand All @@ -46,10 +46,6 @@ function initGlobal(initOpts: GlobalInitOptions) {
initGlobalAtoms(initOpts);
}

function setPlatform(platform: NodeJS.Platform) {
PLATFORM = platform;
}

function initGlobalAtoms(initOpts: GlobalInitOptions) {
const windowIdAtom = atom(initOpts.windowId) as PrimitiveAtom<string>;
const clientIdAtom = atom(initOpts.clientId) as PrimitiveAtom<string>;
Expand Down Expand Up @@ -790,7 +786,6 @@ export {
isDev,
loadConnStatus,
openLink,
PLATFORM,
pushFlashError,
pushNotification,
recordTEvent,
Expand Down
5 changes: 3 additions & 2 deletions frontend/app/tab/tabbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { Button } from "@/app/element/button";
import { modalsModel } from "@/app/store/modalmodel";
import { WindowDrag } from "@/element/windowdrag";
import { deleteLayoutModelForTab } from "@/layout/index";
import { atoms, createTab, getApi, globalStore, isDev, PLATFORM, setActiveTab } from "@/store/global";
import { atoms, createTab, getApi, globalStore, isDev, setActiveTab } from "@/store/global";
import { PLATFORM, PlatformMacOS } from "@/util/platformutil";
import { fireAndForget } from "@/util/util";
import { useAtomValue } from "jotai";
import { OverlayScrollbars } from "overlayscrollbars";
Expand Down Expand Up @@ -641,7 +642,7 @@ const TabBar = memo(({ workspace }: TabBarProps) => {
</div>
) : undefined;
const appMenuButton =
PLATFORM !== "darwin" && !settings["window:showmenubar"] ? (
PLATFORM !== PlatformMacOS && !settings["window:showmenubar"] ? (
<div ref={appMenuButtonRef} className="app-menu-button" onClick={onEllipsisClick}>
<i className="fa fa-ellipsis" />
</div>
Expand Down
177 changes: 55 additions & 122 deletions frontend/app/view/preview/directorypreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import { CopyButton } from "@/app/element/copybutton";
import { Input } from "@/app/element/input";
import { useDimensionsWithCallbackRef } from "@/app/hook/useDimensions";
import { ContextMenuModel } from "@/app/store/contextmenu";
import { PLATFORM, atoms, createBlock, getApi, globalStore } from "@/app/store/global";
import { atoms, getApi, globalStore } from "@/app/store/global";
import { RpcApi } from "@/app/store/wshclientapi";
import { TabRpcClient } from "@/app/store/wshrpcutil";
import { type PreviewModel } from "@/app/view/preview/preview";
import { checkKeyPressed, isCharacterKeyEvent } from "@/util/keyutil";
import { fireAndForget, isBlank, makeNativeLabel } from "@/util/util";
import { PLATFORM, PlatformMacOS } from "@/util/platformutil";
import { addOpenMenuItems } from "@/util/previewutil";
import { fireAndForget, isBlank } from "@/util/util";
import { formatRemoteUri } from "@/util/waveutil";
import { offset, useDismiss, useFloating, useInteractions } from "@floating-ui/react";
import {
Expand Down Expand Up @@ -301,13 +303,21 @@ function DirectoryTable({
newPath = path.substring(0, lastInstance) + newName;
console.log(`replacing ${fileName} with ${newName}: ${path}`);
fireAndForget(async () => {
await RpcApi.FileMoveCommand(TabRpcClient, {
srcuri: await model.formatRemoteUri(path, globalStore.get),
desturi: await model.formatRemoteUri(newPath, globalStore.get),
opts: {
recursive: true,
},
});
try {
await RpcApi.FileMoveCommand(TabRpcClient, {
srcuri: await model.formatRemoteUri(path, globalStore.get),
desturi: await model.formatRemoteUri(newPath, globalStore.get),
opts: {
recursive: true,
},
});
} catch (e) {
const errorStatus: ErrorMsg = {
status: "Rename Failed",
text: `${e}`,
};
globalStore.set(model.errorMsgAtom, errorStatus);
}
model.refreshCallback();
});
}
Expand Down Expand Up @@ -521,17 +531,6 @@ function TableBody({
}
const normPath = finfo.path;
const fileName = finfo.path.split("/").pop();
let parentFileInfo: FileInfo;
try {
parentFileInfo = await RpcApi.FileInfoCommand(TabRpcClient, {
info: {
path: await model.formatRemoteUri(finfo.dir, globalStore.get),
},
});
} catch (e) {
console.log("could not get parent file info. using child file info as fallback");
parentFileInfo = finfo;
}
const menu: ContextMenuItem[] = [
{
label: "New File",
Expand Down Expand Up @@ -570,71 +569,8 @@ function TableBody({
label: "Copy Full File Name (Shell Quoted)",
click: () => fireAndForget(() => navigator.clipboard.writeText(shellQuote([finfo.path]))),
},
{
type: "separator",
},
{
label: "Download File",
click: () => {
const remoteUri = formatRemoteUri(finfo.path, conn);
getApi().downloadFile(remoteUri);
},
},
{
type: "separator",
},
{
label: "Open Preview in New Block",
click: () =>
fireAndForget(async () => {
const blockDef: BlockDef = {
meta: {
view: "preview",
file: finfo.path,
connection: conn,
},
};
await createBlock(blockDef);
}),
},
];
if (!conn) {
menu.push(
{
type: "separator",
},
// TODO: resolve correct host path if connection is WSL
{
label: makeNativeLabel(PLATFORM, finfo.isdir, false),
click: () => {
getApi().openNativePath(normPath);
},
},
{
label: makeNativeLabel(PLATFORM, true, true),
click: () => {
getApi().openNativePath(parentFileInfo.path);
},
}
);
}
if (finfo.mimetype == "directory") {
menu.push({
label: "Open Terminal in New Block",
click: () =>
fireAndForget(async () => {
const termBlockDef: BlockDef = {
meta: {
controller: "shell",
view: "term",
"cmd:cwd": await model.formatRemoteUri(finfo.path, globalStore.get),
connection: conn,
},
};
await createBlock(termBlockDef);
}),
});
}
addOpenMenuItems(menu, conn, finfo);
menu.push(
{
type: "separator",
Expand All @@ -643,10 +579,18 @@ function TableBody({
label: "Delete",
click: () => {
fireAndForget(async () => {
await RpcApi.FileDeleteCommand(TabRpcClient, {
path: await model.formatRemoteUri(finfo.path, globalStore.get),
recursive: false,
}).catch((e) => console.log(e));
try {
await RpcApi.FileDeleteCommand(TabRpcClient, {
path: await model.formatRemoteUri(finfo.path, globalStore.get),
recursive: false,
});
} catch (e) {
const errorStatus: ErrorMsg = {
status: "Delete Failed",
text: `${e}`,
};
globalStore.set(model.errorMsgAtom, errorStatus);
}
setRefreshVersion((current) => current + 1);
});
},
Expand Down Expand Up @@ -782,7 +726,8 @@ function DirectoryPreview({ model }: DirectoryPreviewProps) {
const [refreshVersion, setRefreshVersion] = useAtom(model.refreshVersion);
const conn = useAtomValue(model.connection);
const blockData = useAtomValue(model.blockAtom);
const dirPath = useAtomValue(model.normFilePath);
const finfo = useAtomValue(model.statFile);
const dirPath = finfo?.path;
const [copyStatus, setCopyStatus] = useState<FileCopyStatus>(null);

useEffect(() => {
Expand All @@ -796,16 +741,26 @@ function DirectoryPreview({ model }: DirectoryPreviewProps) {

useEffect(() => {
const getContent = async () => {
const file = await RpcApi.FileReadCommand(
TabRpcClient,
{
info: {
path: await model.formatRemoteUri(dirPath, globalStore.get),
let entries: FileInfo[];
try {
const file = await RpcApi.FileReadCommand(
TabRpcClient,
{
info: {
path: await model.formatRemoteUri(dirPath, globalStore.get),
},
},
},
null
);
setUnfilteredData(file.entries);
null
);
entries = file.entries ?? [];
} catch (e) {
const errorStatus: ErrorMsg = {
status: "Cannot Read Directory",
text: `${e}`,
};
globalStore.set(model.errorMsgAtom, errorStatus);
}
setUnfilteredData(entries);
};
getContent();
}, [conn, dirPath, refreshVersion]);
Expand Down Expand Up @@ -864,7 +819,7 @@ function DirectoryPreview({ model }: DirectoryPreviewProps) {
if (
checkKeyPressed(waveEvent, "Space") &&
searchText == "" &&
PLATFORM == "darwin" &&
PLATFORM == PlatformMacOS &&
!blockData?.meta?.connection
) {
getApi().onQuicklook(selectedPath);
Expand Down Expand Up @@ -1023,29 +978,7 @@ function DirectoryPreview({ model }: DirectoryPreviewProps) {
type: "separator",
},
];
if (!conn) {
// TODO: resolve correct host path if connection is WSL
menu.push({
label: makeNativeLabel(PLATFORM, true, true),
click: () => {
getApi().openNativePath(dirPath);
},
});
}
menu.push({
label: "Open Terminal in New Block",
click: async () => {
const termBlockDef: BlockDef = {
meta: {
controller: "shell",
view: "term",
"cmd:cwd": dirPath,
connection: conn,
},
};
await createBlock(termBlockDef);
},
});
addOpenMenuItems(menu, conn, finfo);

ContextMenuModel.showContextMenu(menu, e);
},
Expand Down
Loading
Loading