From b490113a8744a59280d19c7716caaa4955f71769 Mon Sep 17 00:00:00 2001 From: Mike Sawka Date: Sun, 6 Oct 2024 12:42:25 -0700 Subject: [PATCH] change cursorAccent to cursor to match xtermjs. (#968) also add more feedback for waveai -- tooltips + icon for local/cloud. also use 'ai:name' correctly --- frontend/app/view/waveai/waveai.tsx | 43 +++++++++++++++++++---- frontend/types/gotypes.d.ts | 2 +- pkg/wconfig/defaultconfig/termthemes.json | 8 ++--- pkg/wconfig/settingsconfig.go | 2 +- 4 files changed, 42 insertions(+), 13 deletions(-) diff --git a/frontend/app/view/waveai/waveai.tsx b/frontend/app/view/waveai/waveai.tsx index 5f282f24b..222a075a0 100644 --- a/frontend/app/view/waveai/waveai.tsx +++ b/frontend/app/view/waveai/waveai.tsx @@ -110,18 +110,47 @@ export class WaveAiModel implements ViewModel { set(this.updateLastMessageAtom, "", false); }); this.viewText = atom((get) => { + const viewTextChildren: HeaderElem[] = []; const settings = get(atoms.settingsAtom); const isCloud = isBlank(settings?.["ai:apitoken"]) && isBlank(settings?.["ai:baseurl"]); let modelText = "gpt-4o-mini"; if (!isCloud && !isBlank(settings?.["ai:model"])) { - modelText = settings["ai:model"]; + if (!isBlank(settings?.["ai:name"])) { + modelText = settings["ai:name"]; + } else { + modelText = settings["ai:model"]; + } } - const viewTextChildren: HeaderElem[] = [ - { - elemtype: "text", - text: modelText, - }, - ]; + if (isCloud) { + viewTextChildren.push({ + elemtype: "iconbutton", + icon: "cloud", + title: "Using Wave's AI Proxy (gpt-4o-mini)", + disabled: true, + }); + } else { + const baseUrl = settings["ai:baseurl"] ?? "OpenAI Default Endpoint"; + const modelName = settings["ai:model"]; + if (baseUrl.startsWith("http://localhost") || baseUrl.startsWith("http://127.0.0.1")) { + viewTextChildren.push({ + elemtype: "iconbutton", + icon: "location-dot", + title: "Using Local Model @ " + baseUrl + " (" + modelName + ")", + disabled: true, + }); + } else { + viewTextChildren.push({ + elemtype: "iconbutton", + icon: "globe", + title: "Using Remote Model @ " + baseUrl + " (" + modelName + ")", + disabled: true, + }); + } + } + viewTextChildren.push({ + elemtype: "text", + text: modelText, + }); return viewTextChildren; }); } diff --git a/frontend/types/gotypes.d.ts b/frontend/types/gotypes.d.ts index b05721217..30fbbaf1f 100644 --- a/frontend/types/gotypes.d.ts +++ b/frontend/types/gotypes.d.ts @@ -515,7 +515,7 @@ declare global { foreground: string; selectionBackground: string; background: string; - cursorAccent: string; + cursor: string; }; // wshrpc.TimeSeriesData diff --git a/pkg/wconfig/defaultconfig/termthemes.json b/pkg/wconfig/defaultconfig/termthemes.json index 663564650..460060f30 100644 --- a/pkg/wconfig/defaultconfig/termthemes.json +++ b/pkg/wconfig/defaultconfig/termthemes.json @@ -23,7 +23,7 @@ "foreground": "#c1c1c1", "selectionBackground": "", "background": "#00000077", - "cursorAccent": "" + "cursor": "" }, "dracula": { "display:name": "Dracula", @@ -49,7 +49,7 @@ "foreground": "#F8F8F2", "selectionBackground": "#44475a", "background": "#282a36", - "cursorAccent": "#f8f8f2" + "cursor": "#f8f8f2" }, "monokai": { "display:name": "Monokai", @@ -75,7 +75,7 @@ "foreground": "#F8F8F2", "selectionBackground": "#49483E", "background": "#272822", - "cursorAccent": "#F8F8F2" + "cursor": "#F8F8F2" }, "campbell": { "display:name": "Campbell", @@ -101,6 +101,6 @@ "foreground": "#CCCCCC", "selectionBackground": "#3A96DD", "background": "#0C0C0C", - "cursorAccent": "#CCCCCC" + "cursor": "#CCCCCC" } } diff --git a/pkg/wconfig/settingsconfig.go b/pkg/wconfig/settingsconfig.go index 4d528667e..d93a33f18 100644 --- a/pkg/wconfig/settingsconfig.go +++ b/pkg/wconfig/settingsconfig.go @@ -392,5 +392,5 @@ type TermThemeType struct { Foreground string `json:"foreground"` SelectionBackground string `json:"selectionBackground"` Background string `json:"background"` - CursorAccent string `json:"cursorAccent"` + Cursor string `json:"cursor"` }