mirror of
https://github.com/wavetermdev/waveterm
synced 2026-05-23 16:58:30 +00:00
track number of terminal commands run (#2519)
This commit is contained in:
parent
5edb6f34ca
commit
d82672c919
10 changed files with 35 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -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 || ""));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import { fireAndForget, sleep } from "../frontend/util/util";
|
|||
import { AuthKey, configureAuthKeyRequestInjection } from "./authkey";
|
||||
import {
|
||||
getActivityState,
|
||||
getAndClearTermCommandsRun,
|
||||
getForceQuit,
|
||||
getGlobalIsRelaunching,
|
||||
setForceQuit,
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"),
|
||||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
1
frontend/types/custom.d.ts
vendored
1
frontend/types/custom.d.ts
vendored
|
|
@ -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 = {
|
||||
|
|
|
|||
2
frontend/types/gotypes.d.ts
vendored
2
frontend/types/gotypes.d.ts
vendored
|
|
@ -37,6 +37,7 @@ declare global {
|
|||
numsshconn?: number;
|
||||
numwslconn?: number;
|
||||
nummagnify?: number;
|
||||
termcommandsrun?: number;
|
||||
numpanics?: number;
|
||||
numaireqs?: number;
|
||||
startup?: number;
|
||||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"`
|
||||
|
|
|
|||
|
|
@ -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"`
|
||||
|
|
|
|||
Loading…
Reference in a new issue