Skip to content

Commit ab8c4e0

Browse files
authored
fix: get refreshed code block context (#2612)
1 parent 7c0bb39 commit ab8c4e0

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

apps/web/client/public/onlook-preload-script.js

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/web/client/src/components/store/editor/chat/context.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ export class ChatContext {
5252
return c;
5353
}
5454
return { ...c, content: fileContent.content } satisfies FileMessageContext;
55-
} else if (c.type === MessageContextType.HIGHLIGHT) {
56-
const codeBlock = await this.editorEngine.sandbox.getCodeBlock(c.path);
55+
} else if (c.type === MessageContextType.HIGHLIGHT && c.oid) {
56+
const codeBlock = await this.editorEngine.sandbox.getCodeBlock(c.oid);
5757
if (codeBlock === null) {
5858
console.error('No code block found for node', c.path);
5959
return c;
@@ -119,6 +119,7 @@ export class ChatContext {
119119
content: codeBlock,
120120
start: templateNode.startTag.start.line,
121121
end: templateNode.endTag?.end.line || templateNode.startTag.start.line,
122+
oid,
122123
});
123124
fileNames.add(templateNode.path);
124125
}

packages/models/src/chat/message/context.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export type HighlightMessageContext = BaseMessageContext & {
2222
path: string;
2323
start: number;
2424
end: number;
25+
oid?: string;
2526
};
2627

2728
export type ImageMessageContext = BaseMessageContext & {

0 commit comments

Comments
 (0)