Skip to content

Commit d4825b0

Browse files
committed
checkpoint
1 parent cba80c6 commit d4825b0

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

frontend/app/aipanel/aipanel.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import { WaveUIMessagePart } from "@/app/aipanel/aitypes";
5+
import { atoms } from "@/app/store/global";
56
import { globalStore } from "@/app/store/jotaiStore";
67
import { getWebServerEndpoint } from "@/util/endpoints";
78
import { checkKeyPressed, keydownWrapper } from "@/util/keyutil";
@@ -40,6 +41,7 @@ const AIPanelComponent = memo(({ className, onClose }: AIPanelProps) => {
4041
msg,
4142
chatid: globalStore.get(model.chatId),
4243
widgetaccess: globalStore.get(model.widgetAccess),
44+
tabid: globalStore.get(atoms.staticTabId),
4345
},
4446
};
4547
},

pkg/aiusechat/tools.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import (
99
"github.com/wavetermdev/waveterm/pkg/aiusechat/uctypes"
1010
)
1111

12+
func MakeToolsForTab(tabId string, widgetAccess bool) []uctypes.ToolDefinition {
13+
return nil
14+
}
15+
1216
func GetAdderToolDefinition() uctypes.ToolDefinition {
1317
return uctypes.ToolDefinition{
1418
Name: "adder",

pkg/aiusechat/usechat.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,10 @@ func WaveAIPostMessageWrap(ctx context.Context, sseHandler *sse.SSEHandlerCh, ai
228228

229229
// PostMessageRequest represents the request body for posting a message
230230
type PostMessageRequest struct {
231-
Msg uctypes.AIMessage `json:"msg"`
232-
ChatID string `json:"chatid"`
231+
TabId string `json:"tabid"`
232+
ChatID string `json:"chatid"`
233+
Msg uctypes.AIMessage `json:"msg"`
234+
WidgetAccess bool `json:"widgetaccess,omitempty"`
233235
}
234236

235237
func WaveAIPostMessageHandler(w http.ResponseWriter, r *http.Request) {
@@ -256,6 +258,16 @@ func WaveAIPostMessageHandler(w http.ResponseWriter, r *http.Request) {
256258
return
257259
}
258260

261+
// Validate tabid is present and is a UUID
262+
if req.TabId == "" {
263+
http.Error(w, "tabid is required in request body", http.StatusBadRequest)
264+
return
265+
}
266+
if _, err := uuid.Parse(req.TabId); err != nil {
267+
http.Error(w, "tabid must be a valid UUID", http.StatusBadRequest)
268+
return
269+
}
270+
259271
// Validate the message
260272
if err := req.Msg.Validate(); err != nil {
261273
http.Error(w, fmt.Sprintf("Message validation failed: %v", err), http.StatusInternalServerError)
@@ -277,6 +289,8 @@ func WaveAIPostMessageHandler(w http.ResponseWriter, r *http.Request) {
277289
tools := []uctypes.ToolDefinition{
278290
GetAdderToolDefinition(),
279291
}
292+
tabTools := MakeToolsForTab(req.TabId, req.WidgetAccess)
293+
tools = append(tools, tabTools...)
280294

281295
// Call the core WaveAIPostMessage function
282296
if err := WaveAIPostMessageWrap(r.Context(), sseHandler, aiOpts, req.ChatID, &req.Msg, tools); err != nil {

0 commit comments

Comments
 (0)