Skip to content

Commit 12344e3

Browse files
committed
rename usechat-types.go (for AI). change display fields to have more consistent names
1 parent c6f2f72 commit 12344e3

File tree

5 files changed

+28
-15
lines changed

5 files changed

+28
-15
lines changed

frontend/app/aipanel/aitypes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
import { ChatRequestOptions, FileUIPart, UIMessage, UIMessagePart } from "ai";
55

66
type WaveUIDataTypes = {
7-
// pkg/aiusechat/uctypes/usechat-types.go UIMessageDataUserFile
7+
// pkg/aiusechat/uctypes/uctypes.go UIMessageDataUserFile
88
userfile: {
99
filename: string;
1010
size: number;
1111
mimetype: string;
1212
previewurl?: string;
1313
};
14-
// pkg/aiusechat/uctypes/usechat-types.go UIMessageDataToolUse
14+
// pkg/aiusechat/uctypes/uctypes.go UIMessageDataToolUse
1515
tooluse: {
1616
toolcallid: string;
1717
toolname: string;

frontend/app/aipanel/thinkingmode.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ export const ThinkingLevelDropdown = memo(() => {
6060
"group flex items-center gap-1.5 px-2 py-1 text-xs text-gray-300 hover:text-white rounded transition-colors cursor-pointer border border-gray-600/50",
6161
isOpen ? "bg-gray-700" : "bg-gray-800/50 hover:bg-gray-700"
6262
)}
63-
title={`Thinking: ${displayConfig.displayname}`}
63+
title={`Thinking: ${displayConfig["display:name"]}`}
6464
>
65-
<i className={cn(makeIconClass(displayConfig.icon, false), "text-[10px]")}></i>
65+
<i className={cn(makeIconClass(displayConfig["display:icon"], false), "text-[10px]")}></i>
6666
<span className={`text-[11px] ${isOpen ? "inline" : "hidden group-hover:inline @w450:inline"}`}>
67-
{displayConfig.displayname}
67+
{displayConfig["display:name"]}
6868
</span>
6969
<i className="fa fa-chevron-down text-[8px]"></i>
7070
</button>
@@ -74,6 +74,7 @@ export const ThinkingLevelDropdown = memo(() => {
7474
<div className="fixed inset-0 z-40" onClick={() => setIsOpen(false)} />
7575
<div className="absolute top-full left-0 mt-1 bg-gray-800 border border-gray-600 rounded shadow-lg z-50 min-w-[280px]">
7676
{thinkingModeConfigs
77+
.sort((a, b) => (a["display:order"] || 0) - (b["display:order"] || 0) || (a["display:name"] || "").localeCompare(b["display:name"] || ""))
7778
.filter((config) => !(hideQuick && config.mode === "quick"))
7879
.map((config, index, filteredConfigs) => {
7980
const isFirst = index === 0;
@@ -94,9 +95,9 @@ export const ThinkingLevelDropdown = memo(() => {
9495
} transition-colors text-left`}
9596
>
9697
<div className="flex items-center gap-2 w-full">
97-
<i className={makeIconClass(config.icon, false)}></i>
98+
<i className={makeIconClass(config["display:icon"], false)}></i>
9899
<span className={`text-sm ${isSelected ? "font-bold" : ""}`}>
99-
{config.displayname}
100+
{config["display:name"]}
100101
{isDisabled && " (premium)"}
101102
</span>
102103
{isSelected && <i className="fa fa-check ml-auto"></i>}

frontend/types/gotypes.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,20 @@ declare global {
1616
// uctypes.AIThinkingModeConfig
1717
type AIThinkingModeConfig = {
1818
mode: string;
19-
displayname: string;
19+
"display:name": string;
20+
"display:order"?: number;
21+
"display:icon": string;
2022
apitype: string;
2123
model: string;
2224
thinkinglevel: string;
2325
baseurl?: string;
26+
waveaicloud?: boolean;
2427
apiversion?: string;
2528
apitoken?: string;
29+
apitokensecretname?: string;
2630
premium: boolean;
27-
icon: string;
2831
description: string;
32+
capabilities?: string[];
2933
};
3034

3135
// wshrpc.ActivityDisplayType
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ const (
152152

153153
type AIThinkingModeConfig struct {
154154
Mode string `json:"mode"`
155-
DisplayName string `json:"displayname"`
155+
DisplayName string `json:"display:name"`
156+
DisplayOrder float64 `json:"display:order,omitempty"`
157+
DisplayIcon string `json:"display:icon"`
156158
APIType string `json:"apitype"`
157159
Model string `json:"model"`
158160
ThinkingLevel string `json:"thinkinglevel"`
@@ -162,7 +164,6 @@ type AIThinkingModeConfig struct {
162164
APIToken string `json:"apitoken,omitempty"`
163165
APITokenSecretName string `json:"apitokensecretname,omitempty"`
164166
Premium bool `json:"premium"`
165-
Icon string `json:"icon"`
166167
Description string `json:"description"`
167168
Capabilities []string `json:"capabilities,omitempty"`
168169
}

pkg/aiusechat/usechat-thinkingmode.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package aiusechat
55

66
import (
77
"fmt"
8+
"sort"
89

910
"github.com/wavetermdev/waveterm/pkg/aiusechat/uctypes"
1011
)
@@ -13,36 +14,39 @@ var thinkingModeConfigs = map[string]uctypes.AIThinkingModeConfig{
1314
uctypes.ThinkingModeQuick: {
1415
Mode: uctypes.ThinkingModeQuick,
1516
DisplayName: "Quick",
17+
DisplayOrder: -3,
1618
APIType: APIType_OpenAI,
1719
Model: uctypes.DefaultOpenAIModel,
1820
ThinkingLevel: uctypes.ThinkingLevelLow,
1921
WaveAICloud: true,
2022
Premium: false,
21-
Icon: "bolt",
23+
DisplayIcon: "bolt",
2224
Description: "Fastest responses (gpt-5-mini)",
2325
Capabilities: []string{uctypes.AICapabilityTools, uctypes.AICapabilityImages, uctypes.AICapabilityPdfs},
2426
},
2527
uctypes.ThinkingModeBalanced: {
2628
Mode: uctypes.ThinkingModeBalanced,
2729
DisplayName: "Balanced",
30+
DisplayOrder: -2,
2831
APIType: APIType_OpenAI,
2932
Model: uctypes.PremiumOpenAIModel,
3033
ThinkingLevel: uctypes.ThinkingLevelLow,
3134
WaveAICloud: true,
3235
Premium: true,
33-
Icon: "sparkles",
36+
DisplayIcon: "sparkles",
3437
Description: "Good mix of speed and accuracy\n(gpt-5.1 with minimal thinking)",
3538
Capabilities: []string{uctypes.AICapabilityTools, uctypes.AICapabilityImages, uctypes.AICapabilityPdfs},
3639
},
3740
uctypes.ThinkingModeDeep: {
3841
Mode: uctypes.ThinkingModeDeep,
3942
DisplayName: "Deep",
43+
DisplayOrder: -1,
4044
APIType: APIType_OpenAI,
4145
Model: uctypes.PremiumOpenAIModel,
4246
ThinkingLevel: uctypes.ThinkingLevelMedium,
4347
WaveAICloud: true,
4448
Premium: true,
45-
Icon: "lightbulb",
49+
DisplayIcon: "lightbulb",
4650
Description: "Slower but most capable\n(gpt-5.1 with full reasoning)",
4751
Capabilities: []string{uctypes.AICapabilityTools, uctypes.AICapabilityImages, uctypes.AICapabilityPdfs},
4852
},
@@ -55,7 +59,7 @@ var thinkingModeConfigs = map[string]uctypes.AIThinkingModeConfig{
5559
ThinkingLevel: uctypes.ThinkingLevelLow,
5660
APITokenSecretName: "OPENROUTER_KEY",
5761
Premium: false,
58-
Icon: "bolt",
62+
DisplayIcon: "bolt",
5963
Description: "Fast and capable via OpenRouter\n(Mistral Small 3.2)",
6064
Capabilities: []string{uctypes.AICapabilityTools},
6165
},
@@ -76,5 +80,8 @@ func WaveAIGetModes() ([]uctypes.AIThinkingModeConfig, error) {
7680
for _, config := range thinkingModeConfigs {
7781
modes = append(modes, config)
7882
}
83+
sort.Slice(modes, func(i, j int) bool {
84+
return modes[i].DisplayOrder < modes[j].DisplayOrder
85+
})
7986
return modes, nil
8087
}

0 commit comments

Comments
 (0)