-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Add annotation tool to highlight changed elements in preview #565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ import { Button } from "../ui/button"; | |
| import { useAppStore } from "../../store/app-store"; | ||
| import { useProjectStore } from "../../store/project-store"; | ||
| import { extractHtml } from "./extractHtml"; | ||
| import PreviewComponent from "./PreviewComponent"; | ||
| import PreviewComponent, { Annotation } from "./PreviewComponent"; | ||
| import { downloadCode } from "./download"; | ||
|
|
||
| function openInNewTab(code: string) { | ||
|
|
@@ -69,6 +69,26 @@ function PreviewPane({ settings, onOpenVersions }: Props) { | |
| ? extractHtml(currentCode) | ||
| : currentCode; | ||
|
|
||
| // Extract annotations from the selected variant's completed annotate tool events | ||
| const annotations: Annotation[] = useMemo(() => { | ||
| if (!currentCommit) return []; | ||
| const variant = currentCommit.variants[currentCommit.selectedVariantIndex]; | ||
| const events = variant?.agentEvents || []; | ||
| for (const event of events) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This extraction returns as soon as it sees the first completed Useful? React with 👍 / 👎. |
||
| if ( | ||
| event.type === "tool" && | ||
| event.toolName === "annotate" && | ||
| event.status === "complete" | ||
| ) { | ||
| const output = event.output as { annotations?: Array<{ selector: string; description: string }> } | undefined; | ||
| if (output?.annotations && Array.isArray(output.annotations)) { | ||
| return output.annotations; | ||
| } | ||
| } | ||
| } | ||
| return []; | ||
| }, [currentCommit]); | ||
|
|
||
| return ( | ||
| <div className="flex-1 flex flex-col min-h-0"> | ||
| <Tabs | ||
|
|
@@ -217,13 +237,15 @@ function PreviewPane({ settings, onOpenVersions }: Props) { | |
| device="desktop" | ||
| onScaleChange={setDesktopScale} | ||
| viewMode={desktopViewMode} | ||
| annotations={annotations} | ||
| /> | ||
| </TabsContent> | ||
| <TabsContent value="mobile" className="flex-1 min-h-0 mt-0 data-[state=active]:flex data-[state=active]:flex-col"> | ||
| <PreviewComponent | ||
| code={previewCode} | ||
| device="mobile" | ||
| viewMode="actual" | ||
| annotations={annotations} | ||
| /> | ||
| </TabsContent> | ||
| <TabsContent value="code" className="flex-1 min-h-0 mt-0 overflow-auto"> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new
annotateruntime only validates thatannotationsis a non-empty list, then immediately callsannotation.get(...)on each item. If the model emits malformed JSON likeannotations: ["#hero"]or[null], this throws anAttributeErrorinstead of returning a structured tool error, which can abort the tool-execution turn rather than producing a recoverable failure result.Useful? React with 👍 / 👎.