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
11 changes: 11 additions & 0 deletions emain/emain-activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ let globalIsQuitting = false;
let globalIsStarting = true;
let globalIsRelaunching = false;
let forceQuit = false;
let termCommandsRun = 0;

export function setWasActive(val: boolean) {
wasActive = val;
Expand Down Expand Up @@ -52,3 +53,13 @@ export function setForceQuit(val: boolean) {
export function getForceQuit(): boolean {
return forceQuit;
}

export function incrementTermCommandsRun() {
termCommandsRun++;
}

export function getAndClearTermCommandsRun(): number {
const count = termCommandsRun;
termCommandsRun = 0;
return count;
}
5 changes: 5 additions & 0 deletions emain/emain-ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { getWaveTabViewByWebContentsId } from "./emain-tabview";
import { handleCtrlShiftState } from "./emain-util";
import { getWaveVersion } from "./emain-wavesrv";
import { createNewWaveWindow, focusedWaveWindow, getWaveWindowByWebContentsId } from "./emain-window";
import { incrementTermCommandsRun } from "./emain-activity";
import { ElectronWshClient } from "./emain-wsh";

const electronApp = electron.app;
Expand Down Expand Up @@ -395,6 +396,10 @@ export function initIpcHandlers() {
console.log("fe-log", logStr);
});

electron.ipcMain.on("increment-term-commands", () => {
incrementTermCommandsRun();
});

electron.ipcMain.on("open-builder", (event, appId?: string) => {
fireAndForget(() => createBuilderWindow(appId || ""));
});
Expand Down
10 changes: 9 additions & 1 deletion emain/emain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { fireAndForget, sleep } from "../frontend/util/util";
import { AuthKey, configureAuthKeyRequestInjection } from "./authkey";
import {
getActivityState,
getAndClearTermCommandsRun,
getForceQuit,
getGlobalIsRelaunching,
setForceQuit,
Expand Down Expand Up @@ -173,12 +174,19 @@ function logActiveState() {
}
activity.displays = getActivityDisplays();

const termCmdCount = getAndClearTermCommandsRun();
if (termCmdCount > 0) {
activity.termcommandsrun = termCmdCount;
}

const props: TEventProps = {
"activity:activeminutes": activity.activeminutes,
"activity:fgminutes": activity.fgminutes,
"activity:openminutes": activity.openminutes,
};

if (termCmdCount > 0) {
props["activity:termcommandsrun"] = termCmdCount;
}
if (astate.wasActive && isWaveAIOpen) {
props["activity:waveaiactiveminutes"] = 1;
}
Expand Down
2 changes: 2 additions & 0 deletions emain/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import { contextBridge, ipcRenderer, Rectangle, WebviewTag } from "electron";

// update type in custom.d.ts (ElectronApi type)
contextBridge.exposeInMainWorld("api", {
getAuthKey: () => ipcRenderer.sendSync("get-auth-key"),
getIsDev: () => ipcRenderer.sendSync("get-is-dev"),
Expand Down Expand Up @@ -60,6 +61,7 @@ contextBridge.exposeInMainWorld("api", {
clearWebviewStorage: (webContentsId: number) => ipcRenderer.invoke("clear-webview-storage", webContentsId),
setWaveAIOpen: (isOpen: boolean) => ipcRenderer.send("set-waveai-open", isOpen),
closeBuilderWindow: () => ipcRenderer.send("close-builder-window"),
incrementTermCommands: () => ipcRenderer.send("increment-term-commands"),
});

// Custom event for "new-window"
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/view/term/termwrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getFileSubject } from "@/app/store/wps";
import { sendWSCommand } from "@/app/store/ws";
import { RpcApi } from "@/app/store/wshclientapi";
import { TabRpcClient } from "@/app/store/wshrpcutil";
import { WOS, atoms, fetchWaveFile, getSettingsKeyAtom, globalStore, openLink } from "@/store/global";
import { WOS, atoms, fetchWaveFile, getApi, getSettingsKeyAtom, globalStore, openLink } from "@/store/global";
import * as services from "@/store/services";
import { PLATFORM, PlatformMacOS } from "@/util/platformutil";
import { base64ToArray, base64ToString, fireAndForget } from "@/util/util";
Expand Down Expand Up @@ -252,6 +252,7 @@ function handleOsc16162Command(data: string, blockId: string, loaded: boolean, t
case "C":
rtInfo["shell:state"] = "running-command";
globalStore.set(termWrap.shellIntegrationStatusAtom, "running-command");
getApi().incrementTermCommands();
if (cmd.data.cmd64) {
const decodedLen = Math.ceil(cmd.data.cmd64.length * 0.75);
if (decodedLen > 8192) {
Expand Down
1 change: 1 addition & 0 deletions frontend/types/custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ declare global {
clearWebviewStorage: (webContentsId: number) => Promise<void>; // clear-webview-storage
setWaveAIOpen: (isOpen: boolean) => void; // set-waveai-open
closeBuilderWindow: () => void; // close-builder-window
incrementTermCommands: () => void; // increment-term-commands
};

type ElectronContextMenuItem = {
Expand Down
2 changes: 2 additions & 0 deletions frontend/types/gotypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ declare global {
numsshconn?: number;
numwslconn?: number;
nummagnify?: number;
termcommandsrun?: number;
numpanics?: number;
numaireqs?: number;
startup?: number;
Expand Down Expand Up @@ -1061,6 +1062,7 @@ declare global {
"activity:openminutes"?: number;
"activity:waveaiactiveminutes"?: number;
"activity:waveaifgminutes"?: number;
"activity:termcommandsrun"?: number;
"app:firstday"?: boolean;
"app:firstlaunch"?: boolean;
"action:initiator"?: "keyboard" | "mouse";
Expand Down
1 change: 1 addition & 0 deletions pkg/telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func mergeActivity(curActivity *telemetrydata.TEventProps, newActivity telemetry
curActivity.OpenMinutes += newActivity.OpenMinutes
curActivity.WaveAIActiveMinutes += newActivity.WaveAIActiveMinutes
curActivity.WaveAIFgMinutes += newActivity.WaveAIFgMinutes
curActivity.TermCommandsRun += newActivity.TermCommandsRun
if newActivity.AppFirstDay {
curActivity.AppFirstDay = true
}
Expand Down
1 change: 1 addition & 0 deletions pkg/telemetry/telemetrydata/telemetrydata.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ type TEventProps struct {
OpenMinutes int `json:"activity:openminutes,omitempty"`
WaveAIActiveMinutes int `json:"activity:waveaiactiveminutes,omitempty"`
WaveAIFgMinutes int `json:"activity:waveaifgminutes,omitempty"`
TermCommandsRun int `json:"activity:termcommandsrun,omitempty"`

AppFirstDay bool `json:"app:firstday,omitempty"`
AppFirstLaunch bool `json:"app:firstlaunch,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions pkg/wshrpc/wshrpctypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,7 @@ type ActivityUpdate struct {
NumSSHConn int `json:"numsshconn,omitempty"`
NumWSLConn int `json:"numwslconn,omitempty"`
NumMagnify int `json:"nummagnify,omitempty"`
TermCommandsRun int `json:"termcommandsrun,omitempty"`
NumPanics int `json:"numpanics,omitempty"`
NumAIReqs int `json:"numaireqs,omitempty"`
Startup int `json:"startup,omitempty"`
Expand Down
Loading