mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-21 16:38:23 +01:00
activity update + dont allow empty workspace names (#1393)
This commit is contained in:
parent
942eeaa8e9
commit
7386fc19f7
@ -143,6 +143,7 @@ func beforeSendActivityUpdate(ctx context.Context) {
|
||||
activity.NumWindows, _ = wstore.DBGetCount[*waveobj.Window](ctx)
|
||||
activity.NumSSHConn = conncontroller.GetNumSSHHasConnected()
|
||||
activity.NumWSLConn = wsl.GetNumWSLHasConnected()
|
||||
activity.NumWSNamed, activity.NumWS, _ = wstore.DBGetWSCounts(ctx)
|
||||
err := telemetry.UpdateActivity(ctx, activity)
|
||||
if err != nil {
|
||||
log.Printf("error updating before activity: %v\n", err)
|
||||
|
@ -51,12 +51,15 @@ When telemetry is active, we collect the following data. It is stored in the `te
|
||||
| NumTabs | The number of existing tabs open on a given day. |
|
||||
| NewTab | The number of new tabs created on a given day |
|
||||
| NumWindows | The number of existing windows open on a given day. |
|
||||
| NumWS | The number of existing workspaces on a given day. |
|
||||
| NumWSNamed | The number of named workspaces on a give day. |
|
||||
| NewTab | The number of new tabs opened on a given day. |
|
||||
| NumStartup | The number of times waveterm has been started on a given day. |
|
||||
| NumShutdown | The number of times waveterm has been shut down on a given day. |
|
||||
| SetTabTheme | The number of times the tab theme is changed from the context menu |
|
||||
| NumMagnify | The number of times any block is magnified |
|
||||
| NumPanics | The number of backend (golang) panics caught in the current day |
|
||||
| NumAIReqs | The number of AI requests made in the current day |
|
||||
| NumSSHConn | The number of distinct SSH connections that have been made to distinct hosts |
|
||||
| NumWSLConns | The number of distinct WSL connections that have been made to distinct distros |
|
||||
| Renderers | The number of new block views of each type are open on a given day. |
|
||||
|
@ -410,7 +410,6 @@ electron.ipcMain.on("set-window-init-status", (event, status: "ready" | "wave-re
|
||||
return;
|
||||
}
|
||||
if (status === "ready") {
|
||||
console.log("initResolve");
|
||||
tabView.initResolve();
|
||||
if (tabView.savedInitOpts) {
|
||||
console.log("savedInitOpts");
|
||||
@ -419,7 +418,6 @@ electron.ipcMain.on("set-window-init-status", (event, status: "ready" | "wave-re
|
||||
console.log("no-savedInitOpts");
|
||||
}
|
||||
} else if (status === "wave-ready") {
|
||||
console.log("waveReadyResolve");
|
||||
tabView.waveReadyResolve();
|
||||
}
|
||||
});
|
||||
|
@ -110,7 +110,13 @@ const ColorAndIconSelector = memo(
|
||||
|
||||
return (
|
||||
<div className="color-icon-selector">
|
||||
<Input ref={inputRef} className="vertical-padding-3" onChange={onTitleChange} value={title} autoFocus />
|
||||
<Input
|
||||
ref={inputRef}
|
||||
className={clsx("vertical-padding-3", { error: title === "" })}
|
||||
onChange={onTitleChange}
|
||||
value={title}
|
||||
autoFocus
|
||||
/>
|
||||
<ColorSelector
|
||||
selectedColor={color}
|
||||
colors={["#e91e63", "#8bc34a", "#ff9800", "#ffc107", "#03a9f4", "#3f51b5", "#f44336"]}
|
||||
@ -262,7 +268,9 @@ const WorkspaceSwitcherItem = ({
|
||||
|
||||
const setWorkspace = useCallback((newWorkspace: Workspace) => {
|
||||
fireAndForget(async () => {
|
||||
setObjectValue({ ...newWorkspace, otype: "workspace" }, undefined, true);
|
||||
if (newWorkspace.name != "") {
|
||||
setObjectValue({ ...newWorkspace, otype: "workspace" }, undefined, true);
|
||||
}
|
||||
setWorkspaceEntry({ ...workspaceEntry, workspace: newWorkspace });
|
||||
});
|
||||
}, []);
|
||||
|
9
frontend/types/gotypes.d.ts
vendored
9
frontend/types/gotypes.d.ts
vendored
@ -22,10 +22,13 @@ declare global {
|
||||
newtab?: number;
|
||||
numblocks?: number;
|
||||
numwindows?: number;
|
||||
numws?: number;
|
||||
numwsnamed?: number;
|
||||
numsshconn?: number;
|
||||
numwslconn?: number;
|
||||
nummagnify?: number;
|
||||
numpanics?: number;
|
||||
numaireqs?: number;
|
||||
startup?: number;
|
||||
shutdown?: number;
|
||||
settabtheme?: number;
|
||||
@ -1127,9 +1130,9 @@ declare global {
|
||||
|
||||
// waveobj.Workspace
|
||||
type Workspace = WaveObj & {
|
||||
name: string;
|
||||
icon: string;
|
||||
color: string;
|
||||
name?: string;
|
||||
icon?: string;
|
||||
color?: string;
|
||||
tabids: string[];
|
||||
pinnedtabids: string[];
|
||||
activetabid: string;
|
||||
|
@ -39,6 +39,8 @@ type TelemetryData struct {
|
||||
NumTabs int `json:"numtabs"`
|
||||
NumBlocks int `json:"numblocks,omitempty"`
|
||||
NumWindows int `json:"numwindows,omitempty"`
|
||||
NumWS int `json:"numws,omitempty"`
|
||||
NumWSNamed int `json:"numwsnamed,omitempty"`
|
||||
NumSSHConn int `json:"numsshconn,omitempty"`
|
||||
NumWSLConn int `json:"numwslconn,omitempty"`
|
||||
NumMagnify int `json:"nummagnify,omitempty"`
|
||||
@ -46,6 +48,7 @@ type TelemetryData struct {
|
||||
NumStartup int `json:"numstartup,omitempty"`
|
||||
NumShutdown int `json:"numshutdown,omitempty"`
|
||||
NumPanics int `json:"numpanics,omitempty"`
|
||||
NumAIReqs int `json:"numaireqs,omitempty"`
|
||||
SetTabTheme int `json:"settabtheme,omitempty"`
|
||||
Displays []wshrpc.ActivityDisplayType `json:"displays,omitempty"`
|
||||
Renderers map[string]int `json:"renderers,omitempty"`
|
||||
@ -116,6 +119,7 @@ func UpdateActivity(ctx context.Context, update wshrpc.ActivityUpdate) error {
|
||||
tdata.SetTabTheme += update.SetTabTheme
|
||||
tdata.NumMagnify += update.NumMagnify
|
||||
tdata.NumPanics += update.NumPanics
|
||||
tdata.NumAIReqs += update.NumAIReqs
|
||||
if update.NumTabs > 0 {
|
||||
tdata.NumTabs = update.NumTabs
|
||||
}
|
||||
@ -125,6 +129,12 @@ func UpdateActivity(ctx context.Context, update wshrpc.ActivityUpdate) error {
|
||||
if update.NumWindows > 0 {
|
||||
tdata.NumWindows = update.NumWindows
|
||||
}
|
||||
if update.NumWS > 0 {
|
||||
tdata.NumWS = update.NumWS
|
||||
}
|
||||
if update.NumWSNamed > 0 {
|
||||
tdata.NumWSNamed = update.NumWSNamed
|
||||
}
|
||||
if update.NumSSHConn > 0 && update.NumSSHConn > tdata.NumSSHConn {
|
||||
tdata.NumSSHConn = update.NumSSHConn
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/wavetermdev/waveterm/pkg/telemetry"
|
||||
"github.com/wavetermdev/waveterm/pkg/wshrpc"
|
||||
)
|
||||
|
||||
@ -63,6 +64,7 @@ func makeAIError(err error) wshrpc.RespOrErrorUnion[wshrpc.OpenAIPacketType] {
|
||||
}
|
||||
|
||||
func RunAICommand(ctx context.Context, request wshrpc.OpenAiStreamRequest) chan wshrpc.RespOrErrorUnion[wshrpc.OpenAIPacketType] {
|
||||
telemetry.GoUpdateActivityWrap(wshrpc.ActivityUpdate{NumAIReqs: 1}, "RunAICommand")
|
||||
if request.Opts.APIType == ApiType_Anthropic {
|
||||
endpoint := request.Opts.BaseURL
|
||||
if endpoint == "" {
|
||||
|
@ -167,9 +167,9 @@ type ActiveTabUpdate struct {
|
||||
type Workspace struct {
|
||||
OID string `json:"oid"`
|
||||
Version int `json:"version"`
|
||||
Name string `json:"name"`
|
||||
Icon string `json:"icon"`
|
||||
Color string `json:"color"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Icon string `json:"icon,omitempty"`
|
||||
Color string `json:"color,omitempty"`
|
||||
TabIds []string `json:"tabids"`
|
||||
PinnedTabIds []string `json:"pinnedtabids"`
|
||||
ActiveTabId string `json:"activetabid"`
|
||||
|
@ -608,10 +608,13 @@ type ActivityUpdate struct {
|
||||
NewTab int `json:"newtab,omitempty"`
|
||||
NumBlocks int `json:"numblocks,omitempty"`
|
||||
NumWindows int `json:"numwindows,omitempty"`
|
||||
NumWS int `json:"numws,omitempty"`
|
||||
NumWSNamed int `json:"numwsnamed,omitempty"`
|
||||
NumSSHConn int `json:"numsshconn,omitempty"`
|
||||
NumWSLConn int `json:"numwslconn,omitempty"`
|
||||
NumMagnify int `json:"nummagnify,omitempty"`
|
||||
NumPanics int `json:"numpanics,omitempty"`
|
||||
NumAIReqs int `json:"numaireqs,omitempty"`
|
||||
Startup int `json:"startup,omitempty"`
|
||||
Shutdown int `json:"shutdown,omitempty"`
|
||||
SetTabTheme int `json:"settabtheme,omitempty"`
|
||||
|
@ -45,6 +45,22 @@ func DBGetCount[T waveobj.WaveObj](ctx context.Context) (int, error) {
|
||||
})
|
||||
}
|
||||
|
||||
// returns (num named workespaces, num total workspaces, error)
|
||||
func DBGetWSCounts(ctx context.Context) (int, int, error) {
|
||||
var named, total int
|
||||
err := WithTx(ctx, func(tx *TxWrap) error {
|
||||
query := `SELECT count(*) FROM db_workspace WHERE COALESCE(json_extract(data, '$.name'), '') <> ''`
|
||||
named = tx.GetInt(query)
|
||||
query = `SELECT count(*) FROM db_workspace`
|
||||
total = tx.GetInt(query)
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
return named, total, nil
|
||||
}
|
||||
|
||||
var viewRe = regexp.MustCompile(`^[a-z0-9]{1,20}$`)
|
||||
|
||||
func DBGetBlockViewCounts(ctx context.Context) (map[string]int, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user