fix rpc no-route errors, fix fileopen in preview (#313)

This commit is contained in:
Mike Sawka
2024-09-03 21:08:51 -07:00
committed by GitHub
parent 558fda1253
commit a7746bc5cc
7 changed files with 63 additions and 9 deletions
+8
View File
@@ -103,6 +103,14 @@ function handleIncomingRpcMessage(msg: RpcMessage, eventHandlerFn: (event: WaveE
}
return;
}
if (msg.command == "message") {
if (msg.data?.oref != null) {
console.log("rpc:message", msg.data?.oref, msg.data?.message);
} else {
console.log("rpc:message", msg.data?.message);
}
return;
}
console.log("rpc command not supported", msg);
return;
+5
View File
@@ -107,6 +107,11 @@ class WshServerType {
return WOS.wshServerRpcHelper_call("remotefileinfo", data, opts);
}
// command "remotefilejoin" [call]
RemoteFileJoinCommand(data: string[], opts?: RpcOpts): Promise<FileInfo> {
return WOS.wshServerRpcHelper_call("remotefilejoin", data, opts);
}
// command "remotestreamcpudata" [responsestream]
RemoteStreamCpuDataCommand(opts?: RpcOpts): AsyncGenerator<TimeSeriesData, void, boolean> {
return WOS.wshServerRpcHelper_responsestream("remotestreamcpudata", null, opts);
+20 -7
View File
@@ -4,6 +4,7 @@
import { TypeAheadModal } from "@/app/modals/typeaheadmodal";
import { ContextMenuModel } from "@/app/store/contextmenu";
import { tryReinjectKey } from "@/app/store/keymodel";
import { WshServer } from "@/app/store/wshserver";
import { Markdown } from "@/element/markdown";
import { NodeModel } from "@/layout/index";
import { createBlock, globalStore, refocusNode } from "@/store/global";
@@ -42,6 +43,13 @@ const SpecializedViewMap: { [view: string]: ({ model }: SpecializedViewProps) =>
directory: DirectoryPreview,
};
function makeConnRoute(conn: string): string {
if (util.isBlank(conn)) {
return "conn:local";
}
return "conn:" + conn;
}
function isTextFile(mimeType: string): boolean {
if (mimeType == null) {
return false;
@@ -484,13 +492,18 @@ export class PreviewModel implements ViewModel {
this.updateOpenFileModalAndError(false);
return true;
}
const newPath = fileInfo.dir + "/" + filePath;
const conn = globalStore.get(this.connection) ?? "";
const newFileInfo = await services.FileService.StatFile(conn, newPath);
this.updateOpenFileModalAndError(false);
this.goHistory(newFileInfo.path);
refocusNode(this.blockId);
return true;
const conn = globalStore.get(this.connection);
try {
const newFileInfo = await WshServer.RemoteFileJoinCommand([fileInfo.dir, filePath], {
route: makeConnRoute(conn),
});
this.updateOpenFileModalAndError(false);
this.goHistory(newFileInfo.path);
refocusNode(this.blockId);
} catch (e) {
globalStore.set(this.openFileError, e.message);
console.error("Error opening file", fileInfo.dir, filePath, e);
}
}
isSpecializedView(sv: string): boolean {