Skip to content

Commit facefdd

Browse files
authored
job events, terminal command types, connect error codes (#2855)
1 parent 9ea1d24 commit facefdd

File tree

22 files changed

+678
-378
lines changed

22 files changed

+678
-378
lines changed

cmd/server/main-server.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ func updateTelemetryCounts(lastCounts telemetrydata.TEventProps) telemetrydata.T
238238
props.CountWorkspaces, _, _ = wstore.DBGetWSCounts(ctx)
239239
props.CountSSHConn = conncontroller.GetNumSSHHasConnected()
240240
props.CountWSLConn = wslconn.GetNumWSLHasConnected()
241+
props.CountJobs = jobcontroller.GetNumJobsRunning()
242+
props.CountJobsConnected = jobcontroller.GetNumJobsConnected()
241243
props.CountViews, _ = wstore.DBGetBlockViewCounts(ctx)
242244

243245
fullConfig := wconfig.GetWatcher().GetFullConfig()

cmd/wsh/cmd/wshcmd-jobdebug.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ func jobDebugStartRun(cmd *cobra.Command, args []string) error {
386386

387387
data := wshrpc.CommandJobControllerStartJobData{
388388
ConnName: jobConnFlag,
389+
JobKind: "task",
389390
Cmd: cmdToRun,
390391
Args: cmdArgs,
391392
Env: make(map[string]string),

emain/emain-activity.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ let globalIsRelaunching = false;
1010
let forceQuit = false;
1111
let userConfirmedQuit = false;
1212
let termCommandsRun = 0;
13+
let termCommandsRemote = 0;
14+
let termCommandsWsl = 0;
15+
let termCommandsDurable = 0;
1316

1417
export function setWasActive(val: boolean) {
1518
wasActive = val;
@@ -72,3 +75,33 @@ export function getAndClearTermCommandsRun(): number {
7275
termCommandsRun = 0;
7376
return count;
7477
}
78+
79+
export function incrementTermCommandsRemote() {
80+
termCommandsRemote++;
81+
}
82+
83+
export function getAndClearTermCommandsRemote(): number {
84+
const count = termCommandsRemote;
85+
termCommandsRemote = 0;
86+
return count;
87+
}
88+
89+
export function incrementTermCommandsWsl() {
90+
termCommandsWsl++;
91+
}
92+
93+
export function getAndClearTermCommandsWsl(): number {
94+
const count = termCommandsWsl;
95+
termCommandsWsl = 0;
96+
return count;
97+
}
98+
99+
export function incrementTermCommandsDurable() {
100+
termCommandsDurable++;
101+
}
102+
103+
export function getAndClearTermCommandsDurable(): number {
104+
const count = termCommandsDurable;
105+
termCommandsDurable = 0;
106+
return count;
107+
}

emain/emain-ipc.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ import { RpcApi } from "../frontend/app/store/wshclientapi";
1212
import { getWebServerEndpoint } from "../frontend/util/endpoints";
1313
import * as keyutil from "../frontend/util/keyutil";
1414
import { fireAndForget, parseDataUrl } from "../frontend/util/util";
15-
import { incrementTermCommandsRun } from "./emain-activity";
15+
import {
16+
incrementTermCommandsDurable,
17+
incrementTermCommandsRemote,
18+
incrementTermCommandsRun,
19+
incrementTermCommandsWsl,
20+
} from "./emain-activity";
1621
import { createBuilderWindow, getAllBuilderWindows, getBuilderWindowByWebContentsId } from "./emain-builder";
1722
import { callWithOriginalXdgCurrentDesktopAsync, unamePlatform } from "./emain-platform";
1823
import { getWaveTabViewByWebContentsId } from "./emain-tabview";
@@ -407,9 +412,21 @@ export function initIpcHandlers() {
407412
console.log("fe-log", logStr);
408413
});
409414

410-
electron.ipcMain.on("increment-term-commands", () => {
411-
incrementTermCommandsRun();
412-
});
415+
electron.ipcMain.on(
416+
"increment-term-commands",
417+
(event, opts?: { isRemote?: boolean; isWsl?: boolean; isDurable?: boolean }) => {
418+
incrementTermCommandsRun();
419+
if (opts?.isRemote) {
420+
incrementTermCommandsRemote();
421+
}
422+
if (opts?.isWsl) {
423+
incrementTermCommandsWsl();
424+
}
425+
if (opts?.isDurable) {
426+
incrementTermCommandsDurable();
427+
}
428+
}
429+
);
413430

414431
electron.ipcMain.on("native-paste", (event) => {
415432
event.sender.paste();

emain/emain.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import { fireAndForget, sleep } from "../frontend/util/util";
1212
import { AuthKey, configureAuthKeyRequestInjection } from "./authkey";
1313
import {
1414
getActivityState,
15+
getAndClearTermCommandsDurable,
16+
getAndClearTermCommandsRemote,
1517
getAndClearTermCommandsRun,
18+
getAndClearTermCommandsWsl,
1619
getForceQuit,
1720
getGlobalIsRelaunching,
1821
getUserConfirmedQuit,
@@ -182,6 +185,9 @@ function logActiveState() {
182185
if (termCmdCount > 0) {
183186
activity.termcommandsrun = termCmdCount;
184187
}
188+
const termCmdRemoteCount = getAndClearTermCommandsRemote();
189+
const termCmdWslCount = getAndClearTermCommandsWsl();
190+
const termCmdDurableCount = getAndClearTermCommandsDurable();
185191

186192
const props: TEventProps = {
187193
"activity:activeminutes": activity.activeminutes,
@@ -191,6 +197,15 @@ function logActiveState() {
191197
if (termCmdCount > 0) {
192198
props["activity:termcommandsrun"] = termCmdCount;
193199
}
200+
if (termCmdRemoteCount > 0) {
201+
props["activity:termcommands:remote"] = termCmdRemoteCount;
202+
}
203+
if (termCmdWslCount > 0) {
204+
props["activity:termcommands:wsl"] = termCmdWslCount;
205+
}
206+
if (termCmdDurableCount > 0) {
207+
props["activity:termcommands:durable"] = termCmdDurableCount;
208+
}
194209
if (astate.wasActive && isWaveAIOpen) {
195210
props["activity:waveaiactiveminutes"] = 1;
196211
}

emain/preload.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ contextBridge.exposeInMainWorld("api", {
6363
clearWebviewStorage: (webContentsId: number) => ipcRenderer.invoke("clear-webview-storage", webContentsId),
6464
setWaveAIOpen: (isOpen: boolean) => ipcRenderer.send("set-waveai-open", isOpen),
6565
closeBuilderWindow: () => ipcRenderer.send("close-builder-window"),
66-
incrementTermCommands: () => ipcRenderer.send("increment-term-commands"),
66+
incrementTermCommands: (opts?: { isRemote?: boolean; isWsl?: boolean; isDurable?: boolean }) =>
67+
ipcRenderer.send("increment-term-commands", opts),
6768
nativePaste: () => ipcRenderer.send("native-paste"),
6869
openBuilder: (appId?: string) => ipcRenderer.send("open-builder", appId),
6970
setBuilderWindowAppId: (appId: string) => ipcRenderer.send("set-builder-window-appid", appId),

0 commit comments

Comments
 (0)