-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: AI prompt management dashboard and enhanced span inspectors #3244
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
Merged
Merged
Changes from 11 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
d7efcb8
feat: prompt management with service layer, dashboard UI, and AI span…
ericallam 3c696b7
feat: operations/providers filters, prompt version model display, ove…
ericallam 86beeb9
feat: generations/metrics across all versions by default, add version…
ericallam db26f63
feat: prompts list redesign with separate columns, bar sparklines, ve…
ericallam 8d5b28f
feat: full-width override banner, cleaner header for prompt detail page
ericallam 1a81db4
feat: add timestamp and duration to AI span inspector header
ericallam 37e3367
feat: custom span inspectors for top-level AI SDK spans (generateText…
ericallam 3935f7e
fix: a11y label on expand button, try-catch request.json, add missing…
ericallam 7a681c2
fix: TypeScript strict mode errors across AI prompts feature
ericallam 2228c9e
coderabbit fixes
ericallam 96e1426
fix: transaction safety, parsePeriodToMs consistency, SQL injection p…
ericallam a2adc21
fix: parameterize prompt slug in SQL queries, add ownership check to …
ericallam f78675f
fix: replace SQL string interpolation with parameterized promptVersio…
ericallam 6586bc6
fix: move distinct operations/providers queries to PromptPresenter, p…
ericallam f267bba
fix: increase generations polling interval from 5s to 10s
ericallam dc7f1ad
fix: remove unused private methods from PromptService
ericallam 543bf2c
refactor: extract shared AI span helpers, SpanMetricRow, parsePeriodT…
ericallam 251e46f
fix: wrap prompt version label removal + creation in transaction to p…
ericallam dcdad1e
fixed 2 validateDOMNesting console errors
ericallam ceb6391
fix: pre-fill override dialog model from current override instead of …
ericallam 3e63357
fix: use $transaction helper instead of prisma.$transaction for Prism…
ericallam 224af6f
chore: add changeset and server-changes for AI prompt management
ericallam 5ba393a
fix: include prompt entity type in isAiInspector to avoid nested scro…
ericallam 8cd61cf
fix: override edit dialog uses override version content instead of se…
ericallam 7533941
fix: add createMultiMethodApiRoute helper, rewrite override API with …
ericallam 4f396c7
feat: add prompt management SDK methods (list, versions, resolve, ove…
ericallam e583e5b
fix: promptHandle.resolve() always uses API when client is available,…
ericallam 7a5d9d9
feat: add tracing spans to all prompt management SDK methods
ericallam ad226d4
fix: remove codepath accessory from prompts.list() span
ericallam 5865db8
feat: typesafe prompts.resolve<typeof myPrompt>() with PromptIdentifi…
ericallam 410e397
fix: use != null check in resolveVersion to handle version 0 correctly
ericallam c5f88fe
fix: use UTC arithmetic for sparkline bucket keys to avoid timezone m…
ericallam 4cf009a
refactor: migrate MCP prompt tools from raw fetchClient to typed API …
ericallam 9084f98
fix: use z.coerce.number() for MCP prompt version inputs to handle st…
ericallam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| import type { ViewUpdate } from "@codemirror/view"; | ||
| import { EditorView, lineNumbers } from "@codemirror/view"; | ||
| import { CheckIcon, ClipboardIcon } from "@heroicons/react/20/solid"; | ||
| import type { ReactCodeMirrorProps, UseCodeMirror } from "@uiw/react-codemirror"; | ||
| import { useCodeMirror } from "@uiw/react-codemirror"; | ||
| import { useCallback, useEffect, useRef, useState } from "react"; | ||
| import { cn } from "~/utils/cn"; | ||
| import { Button } from "../primitives/Buttons"; | ||
| import { getEditorSetup } from "./codeMirrorSetup"; | ||
| import { darkTheme } from "./codeMirrorTheme"; | ||
|
|
||
| export interface TextEditorProps extends Omit<ReactCodeMirrorProps, "onBlur"> { | ||
| defaultValue?: string; | ||
| readOnly?: boolean; | ||
| onChange?: (value: string) => void; | ||
| onUpdate?: (update: ViewUpdate) => void; | ||
| showCopyButton?: boolean; | ||
| additionalActions?: React.ReactNode; | ||
| } | ||
|
|
||
| export function TextEditor(opts: TextEditorProps) { | ||
| const { | ||
| defaultValue = "", | ||
| readOnly = false, | ||
| onChange, | ||
| onUpdate, | ||
| autoFocus, | ||
| showCopyButton = true, | ||
| additionalActions, | ||
| } = opts; | ||
|
|
||
| // Don't use default line numbers from setup — add our own with proper sizing | ||
| const extensions = getEditorSetup(false); | ||
| extensions.push(EditorView.lineWrapping); | ||
| extensions.push( | ||
| lineNumbers({ | ||
| formatNumber: (n) => String(n), | ||
| }) | ||
| ); | ||
| extensions.push( | ||
| EditorView.theme({ | ||
| ".cm-lineNumbers": { | ||
| minWidth: "40px", | ||
| }, | ||
| }) | ||
| ); | ||
|
|
||
| const editor = useRef<HTMLDivElement>(null); | ||
| const settings: Omit<UseCodeMirror, "onBlur"> = { | ||
| ...opts, | ||
| container: editor.current, | ||
| extensions, | ||
| editable: !readOnly, | ||
| contentEditable: !readOnly, | ||
| value: defaultValue, | ||
| autoFocus, | ||
| theme: darkTheme(), | ||
| indentWithTab: false, | ||
| basicSetup: false, | ||
| onChange, | ||
| onUpdate, | ||
| }; | ||
| const { setContainer, view } = useCodeMirror(settings); | ||
| const [copied, setCopied] = useState(false); | ||
|
|
||
| useEffect(() => { | ||
| if (editor.current) { | ||
| setContainer(editor.current); | ||
| } | ||
| }, [setContainer]); | ||
|
|
||
| useEffect(() => { | ||
| if (view !== undefined) { | ||
| if (view.state.doc.toString() === defaultValue) return; | ||
| view.dispatch({ | ||
| changes: { from: 0, to: view.state.doc.length, insert: defaultValue }, | ||
| }); | ||
| } | ||
| }, [defaultValue, view]); | ||
|
|
||
| const copy = useCallback(() => { | ||
| if (view === undefined) return; | ||
| navigator.clipboard.writeText(view.state.doc.toString()); | ||
| setCopied(true); | ||
| setTimeout(() => setCopied(false), 1500); | ||
| }, [view]); | ||
|
|
||
| const showToolbar = showCopyButton || additionalActions; | ||
|
|
||
| return ( | ||
| <div | ||
| className={cn( | ||
| "grid", | ||
| showToolbar ? "grid-rows-[2.5rem_1fr]" : "grid-rows-[1fr]", | ||
| opts.className | ||
| )} | ||
| > | ||
| {showToolbar && ( | ||
| <div className="mx-3 flex items-center justify-between gap-2 border-b border-grid-dimmed"> | ||
| <div className="flex items-center">{additionalActions}</div> | ||
| <div className="flex items-center gap-2"> | ||
| {showCopyButton && ( | ||
| <Button | ||
| type="button" | ||
| variant="minimal/small" | ||
| TrailingIcon={copied ? CheckIcon : ClipboardIcon} | ||
| trailingIconClassName={ | ||
| copied ? "text-green-500 group-hover:text-green-500" : undefined | ||
| } | ||
| onClick={(event) => { | ||
| event.preventDefault(); | ||
| event.stopPropagation(); | ||
| copy(); | ||
| }} | ||
| > | ||
| Copy | ||
| </Button> | ||
| )} | ||
| </div> | ||
| </div> | ||
| )} | ||
| <div className="min-h-0 min-w-0 overflow-auto" ref={editor} /> | ||
| </div> | ||
| ); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.