Skip to content
Open
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
445 changes: 434 additions & 11 deletions client/package-lock.json

Large diffs are not rendered by default.

27 changes: 21 additions & 6 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,35 @@
"target": [
{
"target": "dmg",
"arch": ["x64"]
"arch": [
"x64"
]
},
{
"target": "zip",
"arch": ["x64"]
"arch": [
"x64"
]
}
]
},
"win": {
"target": [
{
"target": "nsis",
"arch": ["x64"]
"arch": [
"x64"
]
}
]
},
"linux": {
"target": [
{
"target": "AppImage",
"arch": ["x64"]
"arch": [
"x64"
]
}
]
},
Expand All @@ -54,7 +62,9 @@
},
"protocols": {
"name": "serenade-protocol",
"schemes": ["serenade"]
"schemes": [
"serenade"
]
},
"publish": {
"provider": "generic",
Expand All @@ -80,7 +90,9 @@
"start:electron": "electron ."
},
"electronWebpack": {
"whiteListedModules": ["react-redux"]
"whiteListedModules": [
"react-redux"
]
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.32",
Expand All @@ -89,6 +101,7 @@
"@fortawesome/react-fontawesome": "^0.1.12",
"@headlessui/react": "^1.4.2",
"@heroicons/react": "^1.0.5",
"@types/winston": "^2.4.4",
"chokidar": "^3.4.3",
"classnames": "^2.3.1",
"codemirror-minified": "^5.63.3",
Expand All @@ -110,6 +123,8 @@
"serenade-driver": "1.1.13",
"speech-recorder": "2.1.0",
"uuid": "^8.3.1",
"winston": "^3.14.2",
"winston-format": "^1.0.1",
"ws": "^8.2.2"
},
"devDependencies": {
Expand Down
7 changes: 5 additions & 2 deletions client/src/main/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ import SettingsWindow from "./windows/settings";
import { Endpoint } from "../shared/endpoint";

export default class API {
private log: Log;

constructor(
private active: Active,
private bridge: RendererBridge,
private log: Log,
private mainWindow: MainWindow,
private metadata: Metadata,
private settings: Settings,
private settingsWindow: () => Promise<SettingsWindow> | undefined
) {
this.log = new Log(settings, "API");
setInterval(() => {
this.ping(this.settings.getStreamingEndpoint());
}, 60000);
Expand Down Expand Up @@ -54,7 +56,8 @@ export default class API {
const buffer = await response.buffer();
return responseClass.toObject(responseClass.decode(buffer), { defaults: true });
} catch (e) {
this.log.logError(e);
let message = "Exception while trying to POST to " + url;
this.log.error(message, e);
}
}

Expand Down
15 changes: 8 additions & 7 deletions client/src/main/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ export default class App {
const settings = (instance.settings = new Settings());
const bridge = (instance.bridge = new RendererBridge(settings));
const system = new System(settings);
const log = (instance.log = new Log(settings));
const log = (instance.log = new Log(settings, "Main"));

log.info("App created! Starting initialization...");
instance.updateDarkModeForAllWindows();

const custom = (instance.custom = await Custom.create(settings));
Expand Down Expand Up @@ -147,9 +149,9 @@ export default class App {
);

const nativeCommands = new NativeCommands(active, insertHistory, revisionBoxWindow, system);
const api = new API(active, bridge, log, mainWindow, metadata, settings, () => settingsWindow);
const stream = (instance.stream = new Stream(active, api, log, settings));
const local = (instance.local = new Local(bridge, log, mainWindow, metadata, settings));
const api = new API(active, bridge, mainWindow, metadata, settings, () => settingsWindow);
const stream = (instance.stream = new Stream(active, api, settings));
const local = (instance.local = new Local(bridge, mainWindow, metadata, settings));
const nux = new NUX(
active,
instance,
Expand All @@ -168,7 +170,7 @@ export default class App {
miniModeWindow,
pluginManager,
stream,
log
settings
);

await custom.start();
Expand All @@ -177,7 +179,6 @@ export default class App {
api,
bridge,
insertHistory,
log,
mainWindow,
miniModeWindow,
nativeCommands,
Expand All @@ -198,7 +199,6 @@ export default class App {
chunkQueue,
custom,
executor,
log,
mainWindow,
microphone,
miniModeWindow,
Expand Down Expand Up @@ -407,6 +407,7 @@ export default class App {
useMiniModeFewerAlternatives: settings.getUseMiniModeFewerAlternatives(),
useMiniModeHideTimeout: settings.getUseMiniModeHideTimeout(),
useVerboseLogging: settings.getUseVerboseLogging(),
loggingLevel: settings.getLoggingLevel(),
},
windows ? windows : [this.mainWindow, this.miniModeWindow, this.settingsWindow]
);
Expand Down
7 changes: 4 additions & 3 deletions client/src/main/execute/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ export default class Executor {
private miniModeHideTimeout?: NodeJS.Timeout;
private pending?: core.ICommandsResponse;
private resolveChainFinished = () => {};
private log: Log;

constructor(
private active: Active,
private api: API,
private bridge: RendererBridge,
private insertHistory: InsertHistory,
private log: Log,
private mainWindow: MainWindow,
private miniModeWindow: MiniModeWindow,
private nativeCommands: NativeCommands,
Expand All @@ -41,6 +41,7 @@ export default class Executor {
private commandHandler: () => any
) {
this.newChainFinishedPromise();
this.log = new Log(this.settings, "Executor");
}

private addToHistory(response: core.ICommandsResponse) {
Expand Down Expand Up @@ -514,7 +515,7 @@ export default class Executor {
}

async executeChain(text: string) {
this.log.logVerbose(`Executing chain: ${text}`);
this.log.debug(`Executing chain: ${text}`);
await this.stream.sendInitializeRequest();
this.stream.sendCallbackRequest({
type: core.CallbackType.CALLBACK_TYPE_CHAIN,
Expand Down Expand Up @@ -561,7 +562,7 @@ export default class Executor {
}

if (response.alternatives && response.alternatives.length > 0) {
this.log.logVerbose(
this.log.debug(
`Showing alternatives [${response.alternatives.map((e: any) => e.transcript).join(", ")}]`
);

Expand Down
8 changes: 6 additions & 2 deletions client/src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import * as os from "os";
import * as path from "path";
import App from "./app";
import Metadata from "../shared/metadata";
import Log from "./log";
import Settings from "./settings";

let instance: App | null = null;
const lock = app.requestSingleInstanceLock();
Expand All @@ -20,9 +22,11 @@ process.env["NODE_" + "ENV"] = "production";

process.on("uncaughtException", (e) => {
if (instance && instance.log) {
instance.log.logError(e);
instance.log.error("uncaughtException", e);
} else {
console.error(e);
let settings = new Settings();
let log = new Log(settings, "Main");
log.error("uncaughtException", e);
}
});

Expand Down
2 changes: 1 addition & 1 deletion client/src/main/ipc/custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ For more information, check out the Serenade API documentation: https://serenade
return new Promise((resolve) => {
this.resolveStart = resolve;
this.stop();
const stream = fs.createWriteStream(path.join(this.settings.path(), "serenade.log"));
const stream = fs.createWriteStream(path.join(this.settings.path(), "custom-command-server.log"));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the name of this file to be something different from the default since this is logging for another process, and the messages would be mixed.

this.process = child_process.fork("serenade-custom-commands-server.min.js", [], {
cwd: path.join(this.settings.path(), "ipc"),
stdio: "pipe",
Expand Down
14 changes: 8 additions & 6 deletions client/src/main/ipc/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ export default class Local {
private logStreams: { [key in RunnableService]?: fs.WriteStream } = {};
private pollingInterval?: NodeJS.Timeout;
private started: boolean = false;
private log: Log;

constructor(
private bridge: RendererBridge,
private log: Log,
private mainWindow: MainWindow,
private metadata: Metadata,
private settings: Settings
) {}
) {
this.log = new Log(settings, "Local");
}

private captureOutput(service: RunnableService, child: child_process.ChildProcess) {
if (this.logStreams[service]) {
Expand Down Expand Up @@ -129,10 +131,10 @@ export default class Local {
this.pollUntilRunning();

let speechEngineModels = path.join(__dirname, "..", "static", "local", "speech-engine-models");
this.log.logVerbose("Initial speech engine model path: " + speechEngineModels);
this.log.info("Initial speech engine model path: " + speechEngineModels);

let codeEngineModels = path.join(__dirname, "..", "static", "local", "code-engine-models");
this.log.logVerbose("Initial code engine model path: " + codeEngineModels);
this.log.info("Initial code engine model path: " + codeEngineModels);

if (os.platform() == "win32") {
speechEngineModels =
Expand All @@ -145,7 +147,7 @@ export default class Local {
])
.stdout.toString()
.trim();
this.log.logVerbose("WSL speech engine path: " + speechEngineModels);
this.log.info("WSL speech engine path: " + speechEngineModels);

codeEngineModels =
"/" +
Expand All @@ -157,7 +159,7 @@ export default class Local {
])
.stdout.toString()
.trim();
this.log.logVerbose("WSL code engine path: " + codeEngineModels);
this.log.info("WSL code engine path: " + codeEngineModels);
}

// here and below: WSL doesn't deal well with paths, so set the cwd to be the same as the binary
Expand Down
9 changes: 6 additions & 3 deletions client/src/main/ipc/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import RendererBridge from "../bridge";
import Stream from "../stream/stream";
import { core } from "../../gen/core";
import Log from "../log";
import Settings from "../settings";

const maximumIconLength = 20000;

export default class IPCServer {
private server: WebSocket.Server;
private log: Log;

constructor(
private active: Active,
Expand All @@ -22,8 +24,9 @@ export default class IPCServer {
private miniModeWindow: MiniModeWindow,
private pluginManager: PluginManager,
private stream: Stream,
private log: Log
private settings: Settings
) {
this.log = new Log(this.settings, "IPCServer");
this.server = new WebSocket.Server({ host: "localhost", port: 17373 });
this.server.on("connection", (websocket) => {
websocket.on("message", (message) => {
Expand All @@ -40,7 +43,7 @@ export default class IPCServer {
icon.length <= maximumIconLength);

if (!iconValid) {
this.log.logVerbose("Plugin provided an app icon that does not adhere to requirements");
this.log.warn("Plugin provided an app icon that does not adhere to requirements");
icon = undefined;
}

Expand All @@ -60,7 +63,7 @@ export default class IPCServer {
}
// custom commands messages from custom commands servers
if (request.message == "customCommands") {
this.log.logVerbose(
this.log.debug(
"Received " +
request.data.commands.length +
" commands, " +
Expand Down
Loading