-
Notifications
You must be signed in to change notification settings - Fork 57.6k
feat(editor): Add dev-panel for DOM-annotated feedback prompts (no-changelog) #28761
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 all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
ee335ae
feat(editor): Add dev panel for prompting Claude about DOM elements (…
Tuukkaa 28c0f53
feat(editor): Support multi-annotation dev-panel workflow with number…
Tuukkaa 010ff6b
feat(editor): Persist dev-panel annotations across refresh with 7-day…
Tuukkaa 74f07d0
feat(editor): Add drag-to-select for dev-panel element picker (no-cha…
Tuukkaa be39314
refactor(editor): Simplify dev-panel to clipboard-only and hide behin…
Tuukkaa c7b42e7
chore: Regenerate pnpm-lock.yaml after removing dev-panel-channel
Tuukkaa 892704f
chore: Untrack .claude/specs and remove dev-panel spec doc
Tuukkaa 5146095
chore: Revert .gitignore change (no-changelog)
Tuukkaa 9dd0a61
chore: Restore pnpm-lock.yaml to master state (no-changelog)
Tuukkaa 1cff341
fix(editor): Address dev-panel review comments (no-changelog)
Tuukkaa ea7ca51
refactor(editor): Replace hardcoded colors in dev-panel with tokens (…
Tuukkaa 234b738
refactor(editor): Use darker shade for dev-panel FAB and toolbar (no-…
Tuukkaa e08dbe1
refactor(editor): Use blue token for dev-panel badges and hover overl…
Tuukkaa b8a3d88
refactor(editor): Use blue token for dev-panel crosshair active state…
Tuukkaa aaed44d
refactor(editor): Use surface tokens and darker text in dev-panel pop…
Tuukkaa d76db31
feat(editor): Polish dev-panel chrome with design system components a…
Tuukkaa 23ca8ab
chore(editor): Silence css-var-naming for intentional surface token i…
Tuukkaa 1a6e038
fix(editor): Keep dev-panel popover shortcuts working when focus leav…
Tuukkaa fc47feb
fix(editor): Address dev-panel review feedback (no-changelog)
Tuukkaa 633520c
feat(editor): Add feature flag overrides to dev-panel (no-changelog)
Tuukkaa 2fe3d90
refactor(editor): Polish dev-panel flag panel sizing and picker hando…
Tuukkaa b2ff9aa
fix(editor): Seed dev-panel flag list from server-evaluated featureFl…
Tuukkaa cbf0794
refactor(editor): Lean on global window.featureFlags typing in dev-pa…
Tuukkaa bad000c
fix(editor): Tighten dev-panel picker, marker, and popover state hand…
Tuukkaa 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
957 changes: 957 additions & 0 deletions
957
packages/frontend/editor-ui/src/app/dev/dev-panel/DevPanel.vue
Large diffs are not rendered by default.
Oops, something went wrong.
585 changes: 585 additions & 0 deletions
585
packages/frontend/editor-ui/src/app/dev/dev-panel/FlagPanel.vue
Large diffs are not rendered by default.
Oops, something went wrong.
159 changes: 159 additions & 0 deletions
159
packages/frontend/editor-ui/src/app/dev/dev-panel/PromptPopover.vue
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,159 @@ | ||
| <script setup lang="ts"> | ||
| import { N8nButton, N8nInput } from '@n8n/design-system'; | ||
| import { computed, onMounted, onUnmounted, ref, watch } from 'vue'; | ||
|
|
||
| const props = withDefaults( | ||
| defineProps<{ | ||
| anchor: Element; | ||
| initialPrompt?: string; | ||
| isEditing?: boolean; | ||
| }>(), | ||
| { initialPrompt: '', isEditing: false }, | ||
| ); | ||
|
|
||
| const emit = defineEmits<{ | ||
| add: [prompt: string]; | ||
| cancel: []; | ||
| }>(); | ||
|
|
||
| const prompt = ref(props.initialPrompt); | ||
|
|
||
| const anchorRect = ref<DOMRect>(props.anchor.getBoundingClientRect()); | ||
|
|
||
| function updateAnchorRect() { | ||
| anchorRect.value = props.anchor.getBoundingClientRect(); | ||
| } | ||
|
|
||
| const popoverStyle = computed(() => { | ||
| const rect = anchorRect.value; | ||
| const popoverWidth = 360; | ||
| const popoverHeightGuess = 180; | ||
| const margin = 8; | ||
| const viewportWidth = window.innerWidth; | ||
| const viewportHeight = window.innerHeight; | ||
|
|
||
| let top = rect.bottom + margin; | ||
| if (top + popoverHeightGuess > viewportHeight) { | ||
| top = Math.max(margin, rect.top - popoverHeightGuess - margin); | ||
| } | ||
|
|
||
| let left = rect.left; | ||
| if (left + popoverWidth > viewportWidth - margin) { | ||
| left = Math.max(margin, viewportWidth - popoverWidth - margin); | ||
| } | ||
|
|
||
| return { | ||
| top: `${top}px`, | ||
| left: `${left}px`, | ||
| width: `${popoverWidth}px`, | ||
| }; | ||
| }); | ||
|
|
||
| function handleKeyDown(event: KeyboardEvent) { | ||
| if (event.key === 'Escape') { | ||
| event.preventDefault(); | ||
| emit('cancel'); | ||
| return; | ||
| } | ||
| if (event.key === 'Enter' && (event.metaKey || event.ctrlKey)) { | ||
| event.preventDefault(); | ||
| handleAdd(); | ||
| } | ||
| } | ||
|
|
||
| function handleFocus(event: FocusEvent) { | ||
| const target = event.target as HTMLTextAreaElement | null; | ||
| if (!target) return; | ||
| const end = target.value.length; | ||
| target.setSelectionRange(end, end); | ||
| } | ||
|
|
||
| function handleAdd() { | ||
| const text = prompt.value.trim(); | ||
| if (!text) return; | ||
| emit('add', text); | ||
| } | ||
|
|
||
| onMounted(() => { | ||
| window.addEventListener('resize', updateAnchorRect); | ||
| window.addEventListener('scroll', updateAnchorRect, true); | ||
| }); | ||
|
|
||
| onUnmounted(() => { | ||
| window.removeEventListener('resize', updateAnchorRect); | ||
| window.removeEventListener('scroll', updateAnchorRect, true); | ||
| }); | ||
|
|
||
| watch( | ||
| () => props.anchor, | ||
| () => updateAnchorRect(), | ||
| ); | ||
|
|
||
| watch( | ||
| () => props.initialPrompt, | ||
| (value) => { | ||
| prompt.value = value; | ||
| }, | ||
| ); | ||
| </script> | ||
|
|
||
| <template> | ||
| <div | ||
| class="dev-panel-popover" | ||
| :style="popoverStyle" | ||
| role="dialog" | ||
| aria-label="AI prompt" | ||
| @keydown="handleKeyDown" | ||
| > | ||
| <N8nInput | ||
| v-model="prompt" | ||
| type="textarea" | ||
| size="small" | ||
| autofocus | ||
| :rows="4" | ||
| :placeholder=" | ||
| isEditing | ||
| ? 'Edit the annotation. ⌘↵ to save, Esc to cancel.' | ||
| : 'Describe the change. ⌘↵ to add, Esc to cancel.' | ||
| " | ||
| @focus="handleFocus" | ||
| /> | ||
| <div class="dev-panel-actions"> | ||
| <N8nButton variant="outline" size="small" @click="emit('cancel')"> Cancel </N8nButton> | ||
| <N8nButton | ||
| variant="solid" | ||
| size="small" | ||
| :disabled="!prompt.trim()" | ||
| :title="isEditing ? 'Save changes (⌘↵)' : 'Add to annotations list (⌘↵)'" | ||
| @click="handleAdd" | ||
| > | ||
| {{ isEditing ? 'Save' : 'Add' }} | ||
| </N8nButton> | ||
| </div> | ||
| </div> | ||
| </template> | ||
|
|
||
| <style scoped> | ||
| .dev-panel-popover { | ||
| position: fixed; | ||
| z-index: 2147483646; | ||
| /* stylelint-disable-next-line @n8n/css-var-naming */ | ||
| background: var(--background--surface); | ||
| border: var(--border); | ||
| border-radius: var(--radius--lg); | ||
| box-shadow: 0 10px 30px var(--color--black-alpha-300); | ||
| padding: var(--spacing--xs); | ||
| font-family: var(--font-family); | ||
| font-size: var(--font-size--sm); | ||
| color: var(--color--text--shade-1); | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: var(--spacing--2xs); | ||
| } | ||
|
|
||
| .dev-panel-actions { | ||
| display: flex; | ||
| justify-content: flex-end; | ||
| gap: var(--spacing--3xs); | ||
| } | ||
| </style> | ||
80 changes: 80 additions & 0 deletions
80
packages/frontend/editor-ui/src/app/dev/dev-panel/annotationStorage.ts
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,80 @@ | ||
| import type { ElementContext } from './collectElementContext'; | ||
| import type { Annotation } from './formatPrompt'; | ||
|
|
||
| const STORAGE_KEY = 'n8n.devPanel.annotations'; | ||
| const TTL_MS = 7 * 24 * 60 * 60 * 1000; | ||
|
|
||
| type StoredEntry = { updatedAt: number; annotations: Annotation[] }; | ||
| type StoredShape = Record<string, StoredEntry>; | ||
|
|
||
| function read(): StoredShape { | ||
| try { | ||
| const raw = localStorage.getItem(STORAGE_KEY); | ||
| if (!raw) return {}; | ||
| const parsed: unknown = JSON.parse(raw); | ||
| return parsed && typeof parsed === 'object' ? (parsed as StoredShape) : {}; | ||
| } catch { | ||
| return {}; | ||
| } | ||
| } | ||
|
|
||
| function write(data: StoredShape) { | ||
| try { | ||
| localStorage.setItem(STORAGE_KEY, JSON.stringify(data)); | ||
| } catch { | ||
| // storage quota exceeded or disabled — nothing we can do | ||
| } | ||
| } | ||
|
|
||
| function prune(data: StoredShape, now: number): { data: StoredShape; changed: boolean } { | ||
| const pruned: StoredShape = {}; | ||
| let changed = false; | ||
| for (const [key, entry] of Object.entries(data)) { | ||
| if (!entry || typeof entry.updatedAt !== 'number' || now - entry.updatedAt > TTL_MS) { | ||
| changed = true; | ||
| continue; | ||
| } | ||
| pruned[key] = entry; | ||
| } | ||
| return { data: pruned, changed }; | ||
| } | ||
|
|
||
| export function loadAnnotations(path: string): Annotation[] { | ||
| const { data, changed } = prune(read(), Date.now()); | ||
| if (changed) write(data); | ||
| return data[path]?.annotations ?? []; | ||
| } | ||
|
|
||
| export function saveAnnotations(path: string, annotations: Annotation[]) { | ||
| const { data } = prune(read(), Date.now()); | ||
| if (annotations.length === 0) { | ||
| delete data[path]; | ||
| } else { | ||
| data[path] = { updatedAt: Date.now(), annotations }; | ||
| } | ||
| write(data); | ||
| } | ||
|
|
||
| function escapeAttributeValue(value: string): string { | ||
| return value.replace(/\\/g, '\\\\').replace(/"/g, '\\"'); | ||
| } | ||
|
|
||
| export function resolveElementForContext(context: ElementContext): Element | null { | ||
| if (context.selector) { | ||
| try { | ||
| const el = document.querySelector(context.selector); | ||
| if (el) return el; | ||
| } catch { | ||
| // invalid selector — fall through to testid | ||
| } | ||
| } | ||
| if (context.testid) { | ||
| try { | ||
| const el = document.querySelector(`[data-testid="${escapeAttributeValue(context.testid)}"]`); | ||
| if (el) return el; | ||
| } catch { | ||
| // invalid selector — give up | ||
| } | ||
| } | ||
| return null; | ||
| } |
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.