Skip to content

Commit ca5d78d

Browse files
committed
fix some bugs with single node layouts
1 parent dbd60a3 commit ca5d78d

4 files changed

Lines changed: 40 additions & 16 deletions

File tree

frontend/app/store/keymodel.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,19 @@ function switchBlockByBlockNum(index: number) {
146146
function switchBlockInDirection(tabId: string, direction: NavigateDirection) {
147147
const layoutModel = getLayoutModelForTabById(tabId);
148148
const inWaveAI = globalStore.get(atoms.waveAIFocusedAtom);
149+
150+
if (direction === NavigateDirection.Left) {
151+
const numBlocks = globalStore.get(layoutModel.numLeafs);
152+
if (inWaveAI) {
153+
return;
154+
}
155+
if (numBlocks === 1) {
156+
// special case: layout model doesn't set "rect" when there's only one block
157+
WaveAIModel.getInstance().focusInput();
158+
return;
159+
}
160+
}
161+
149162
const navResult = layoutModel.switchNodeFocusInDirection(direction, inWaveAI);
150163
if (navResult.atLeft) {
151164
WaveAIModel.getInstance().focusInput();

frontend/app/store/tabrpcclient.ts

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,34 @@ export class TabClient extends WshClient {
2727
throw new Error(`Block not found: ${blockId}`);
2828
}
2929

30-
const additionalProps = layoutModel.getNodeAdditionalProperties(node);
31-
if (!additionalProps?.rect) {
32-
throw new Error(`Block rect not found for: ${blockId}`);
33-
}
34-
3530
const displayContainer = layoutModel.displayContainerRef.current;
3631
if (!displayContainer) {
3732
throw new Error("Display container not found");
3833
}
3934

4035
const containerRect = displayContainer.getBoundingClientRect();
41-
const blockRect = additionalProps.rect;
42-
43-
const electronRect: Electron.Rectangle = {
44-
x: Math.round(containerRect.x + blockRect.left),
45-
y: Math.round(containerRect.y + blockRect.top),
46-
width: Math.round(blockRect.width),
47-
height: Math.round(blockRect.height),
48-
};
36+
const additionalProps = layoutModel.getNodeAdditionalProperties(node);
37+
38+
let electronRect: Electron.Rectangle;
39+
40+
if (!additionalProps?.rect) {
41+
// Bug: rect is not set when there is only one block in the layout
42+
// In this case, use the full container rect
43+
electronRect = {
44+
x: Math.round(containerRect.x),
45+
y: Math.round(containerRect.y),
46+
width: Math.round(containerRect.width),
47+
height: Math.round(containerRect.height),
48+
};
49+
} else {
50+
const blockRect = additionalProps.rect;
51+
electronRect = {
52+
x: Math.round(containerRect.x + blockRect.left),
53+
y: Math.round(containerRect.y + blockRect.top),
54+
width: Math.round(blockRect.width),
55+
height: Math.round(blockRect.height),
56+
};
57+
}
4958

5059
return await getApi().captureScreenshot(electronRect);
5160
}

pkg/aiusechat/openai/openai-backend.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,9 @@ func handleOpenAIEvent(
627627
}
628628
return nil, nil
629629

630+
case "response.output_text.done":
631+
return nil, nil
632+
630633
case "response.content_part.done":
631634
var ev openaiResponseContentPartDoneEvent
632635
if err := json.Unmarshal([]byte(data), &ev); err != nil {

pkg/aiusechat/openai/openai-convertmessage.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,15 @@ func debugPrintReq(req *OpenAIRequest, endpoint string) {
100100
for _, tool := range req.Tools {
101101
toolNames = append(toolNames, tool.Name)
102102
}
103+
log.Printf("model %s\n", req.Model)
103104
if len(toolNames) > 0 {
104105
log.Printf("tools: %s\n", strings.Join(toolNames, ","))
105106
}
106-
107+
107108
log.Printf("inputs (%d):", len(req.Input))
108109
for idx, input := range req.Input {
109110
debugPrintInput(idx, input)
110111
}
111-
112-
log.Printf("baseurl: %s\n", endpoint)
113112
}
114113

115114
// buildOpenAIHTTPRequest creates a complete HTTP request for the OpenAI API

0 commit comments

Comments
 (0)