Skip to content

feat(apollo-wind): add PromptEditor component [MST-10659]#784

Merged
fikewa-olatunji merged 16 commits into
mainfrom
feat/apollo-wind-prompt-editor
Jun 24, 2026
Merged

feat(apollo-wind): add PromptEditor component [MST-10659]#784
fikewa-olatunji merged 16 commits into
mainfrom
feat/apollo-wind-prompt-editor

Conversation

@fikewa-olatunji

@fikewa-olatunji fikewa-olatunji commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Jira: MST-10659

Summary

Ports the Lexical-based PromptEditor from flow-workbench into @uipath/apollo-wind as a reusable, fully prop-driven component. It renders inline variable token pills (input / output / state / resource), a formatting toolbar, a markdown preview mode, and a $-triggered variable autocomplete.

The port deliberately decouples the editor from flow-workbench-specific systems that don't exist in a design system:

  • Autocomplete & token tooltip rebuilt on apollo-wind primitives (Command / Popover / Tooltip), driven by the autoCompleteOptions prop — no flow VariablePicker or schema services.
  • i18n stripped to plain English literals (no react-i18next).
  • Theme detection dropped; token colors map to apollo-wind design tokens (theme-adaptive via CSS).
  • React-Flow keyboard shielding dropped.
  • Variable drag-and-drop is supported via a decoupled native HTML5 VariableDropPlugin + mapVarDropToToken prop (the consumer owns the drag source and sets the path on dataTransfer under the exported VARIABLE_DRAG_MIME) — no dnd-kit dependency, unlike flow-workbench's version.

Public API

PromptEditor + types (PromptEditorProps, PromptEditorRef, PromptEditorToken, PromptEditorTokenType, PromptEditorAutoCompleteOption, PromptEditorMode) exported from the package root. Controlled (value/onChange) and uncontrolled (initialValue) usage, multiline, minRows/maxRows, placeholder, disabled, showToolbar, mode/onModeChange, borderless, fillHeight, and an imperative editorRef.

Dependencies

apollo-wind: lexical, @lexical/react, @lexical/utils, @lexical/clipboard (0.42.0), marked, dompurify.

apollo-react: its existing lexical + @lexical/* packages are bumped 0.16.0 → 0.42.0 to align with apollo-wind so the repo-wide dependency-version-consistency check passes without an exemption (the only resulting code change is the LexicalErrorBoundary named-import fix). No new audit findings.

Robustness

Token/option props are normalized to arrays so malformed input (e.g. a Storybook "Set object" {}) can't crash the editor or preview. maxRows caps the visible height and scrolls (clamped so it isn't overridden when maxRows ≤ minRows).

Testing

  • vitest: 19 unit tests for PromptEditor (rendering, toolbar, preview, mode toggle, autocomplete mount, malformed-input tolerance) — full apollo-wind suite passes (928 tests).
  • Storybook stories: Default, SingleLine, WithTokens, WithToolbar, WithAutocomplete, Preview, Disabled, Borderless, Controlled.
  • Verified locally: biome format/lint clean, test:coverage passes, full pnpm build (all 8 packages) succeeds, frozen lockfile in sync.
  • Interactive flows (typing, $-autocomplete, chip insertion, light/dark, height capping) verified end-to-end in a headless browser.

Copilot AI review requested due to automatic review settings June 5, 2026 22:47
@fikewa-olatunji fikewa-olatunji changed the title feat(apollo-wind): add PromptEditor component feat(apollo-wind): add PromptEditor component (MST-10659) Jun 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Ports a Lexical-based PromptEditor into @uipath/apollo-wind as a reusable component, including token-pill rendering, $-triggered variable autocomplete, formatting toolbar, and a sanitized markdown preview mode.

Changes:

  • Added PromptEditor public exports (+ supporting types) and integrated Lexical-based editor with token nodes + plugins.
  • Implemented toolbar actions, token copy/paste serialization, $-autocomplete menu, validation, and rename-on-options-change behavior.
  • Added markdown preview rendering via marked + dompurify, plus Storybook + unit tests; updated dependencies/lockfile.

Reviewed changes

Copilot reviewed 35 out of 36 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pnpm-lock.yaml Locks new Lexical + markdown preview dependencies and transitive graph.
packages/apollo-wind/package.json Adds Lexical + marked + dompurify runtime deps for the new component.
packages/apollo-wind/src/index.ts Exports PromptEditor + types from the package root.
packages/apollo-wind/src/components/ui/prompt-editor/index.ts Local barrel export for PromptEditor and its public types.
packages/apollo-wind/src/components/ui/prompt-editor/types.ts Defines token/types API and token color/label helpers.
packages/apollo-wind/src/components/ui/prompt-editor/prompt-editor.tsx Main component wiring Lexical composer, plugins, toolbar, preview, and imperative ref API.
packages/apollo-wind/src/components/ui/prompt-editor/prompt-editor.test.tsx Unit tests for rendering, toolbar/preview toggling, and malformed-prop tolerance.
packages/apollo-wind/src/components/ui/prompt-editor/prompt-editor.stories.tsx Storybook coverage for common modes (toolbar, autocomplete, preview, controlled, etc.).
packages/apollo-wind/src/components/ui/prompt-editor/utils/index.ts Barrel export for prompt-editor utilities.
packages/apollo-wind/src/components/ui/prompt-editor/utils/serialization.ts Token ↔ Lexical state conversion + clipboard string serialization/parsing + selection token extraction.
packages/apollo-wind/src/components/ui/prompt-editor/utils/insert-token.ts Inserts token nodes at cursor / selection.
packages/apollo-wind/src/components/ui/prompt-editor/utils/comparison.ts Token-array deep equality helper.
packages/apollo-wind/src/components/ui/prompt-editor/utils/autocomplete-segments.ts $ trigger helpers (type inference, regex, dismissed-trigger sentinel).
packages/apollo-wind/src/components/ui/prompt-editor/plugins/ValueSyncPlugin.tsx Controlled-value sync into Lexical state with focus-aware selection preservation.
packages/apollo-wind/src/components/ui/prompt-editor/plugins/ValidateTokensPlugin.tsx Marks token pills invalid if not present in autocomplete option set.
packages/apollo-wind/src/components/ui/prompt-editor/plugins/RenameTokensPlugin.tsx Renames token values when option-path trees indicate a rename.
packages/apollo-wind/src/components/ui/prompt-editor/plugins/AutocompletePlugin.tsx Drives $ trigger detection and commits selected/free-form variables as token pills.
packages/apollo-wind/src/components/ui/prompt-editor/plugins/CopyPastePlugin.tsx Custom copy/cut/paste integrating token clipboard format and Lexical mime payload.
packages/apollo-wind/src/components/ui/prompt-editor/plugins/EditorRefPlugin.tsx Exposes Lexical editor instance to parent wiring.
packages/apollo-wind/src/components/ui/prompt-editor/plugins/MultilinePlugin.tsx Enforces single-line vs multiline behavior (enter suppression, newline stripping).
packages/apollo-wind/src/components/ui/prompt-editor/plugins/NodeSelectionFixPlugin.tsx Keyboard/cursor management for inline DecoratorNode “pill” selection.
packages/apollo-wind/src/components/ui/prompt-editor/plugins/ToolbarActionsPlugin.tsx Implements formatting actions by inserting markdown markers/prefixes.
packages/apollo-wind/src/components/ui/prompt-editor/plugins/shared/token-nodes.ts Shared traversal helpers for finding token nodes in editor state.
packages/apollo-wind/src/components/ui/prompt-editor/nodes/index.ts Barrel export for the custom Lexical token nodes.
packages/apollo-wind/src/components/ui/prompt-editor/nodes/InputTokenNode.tsx Input token DecoratorNode implementation.
packages/apollo-wind/src/components/ui/prompt-editor/nodes/OutputTokenNode.tsx Output token DecoratorNode implementation.
packages/apollo-wind/src/components/ui/prompt-editor/nodes/StateTokenNode.tsx State token DecoratorNode implementation.
packages/apollo-wind/src/components/ui/prompt-editor/nodes/ResourceTokenNode.tsx Resource token DecoratorNode implementation.
packages/apollo-wind/src/components/ui/prompt-editor/components/EditorToolbar.tsx Toolbar UI (edit/preview toggle + formatting buttons).
packages/apollo-wind/src/components/ui/prompt-editor/components/PromptEditorAutocompleteMenu.tsx Caret-anchored command menu for variable selection.
packages/apollo-wind/src/components/ui/prompt-editor/components/MarkdownPreview.tsx Markdown preview rendering + sanitization + token-pill HTML injection.
packages/apollo-wind/src/components/ui/prompt-editor/components/markdown-preview.css Styles for preview output and token pills in sanitized HTML.
packages/apollo-wind/src/components/ui/prompt-editor/components/TokenPill.tsx Visual pill rendering (icons, remove button, selected outline).
packages/apollo-wind/src/components/ui/prompt-editor/components/TokenPillWithTooltip.tsx Adds tooltips + NodeSelection mouse handling to token pills.
packages/apollo-wind/src/components/ui/prompt-editor/components/token-icon-markup.ts Inline lucide SVG markup builder for preview-mode token icons.
packages/apollo-wind/src/components/ui/prompt-editor/components/token-icon-markup.test.ts Tests for SVG markup builder output.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

@fikewa-olatunji fikewa-olatunji force-pushed the feat/apollo-wind-prompt-editor branch from b5f8a7a to 9168e44 Compare June 5, 2026 23:29
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (PT)
apollo-design 🟢 Ready Preview, Logs Jun 23, 2026, 03:46:06 PM
apollo-docs 🟢 Ready Preview, Logs Jun 23, 2026, 03:46:06 PM
apollo-landing 🟢 Ready Preview, Logs Jun 23, 2026, 03:46:06 PM
apollo-vertex 🟢 Ready Preview, Logs Jun 23, 2026, 03:46:06 PM

@github-actions github-actions Bot added pkg:apollo-wind size:XXL 1,000+ changed lines. labels Jun 5, 2026
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Dependency License Review

  • 1945 package(s) scanned
  • ✅ No license issues found
  • ⚠️ 2 package(s) excluded (see details below)
License distribution
License Packages
MIT 1715
ISC 89
Apache-2.0 55
BSD-3-Clause 27
BSD-2-Clause 23
BlueOak-1.0.0 8
MPL-2.0 4
MIT-0 3
CC0-1.0 3
MIT OR Apache-2.0 2
(MIT OR Apache-2.0) 2
Unlicense 2
LGPL-3.0-or-later 1
Python-2.0 1
CC-BY-4.0 1
(MPL-2.0 OR Apache-2.0) 1
Unknown 1
Artistic-2.0 1
(WTFPL OR MIT) 1
(BSD-2-Clause OR MIT OR Apache-2.0) 1
CC-BY-3.0 1
0BSD 1
(MIT OR CC0-1.0) 1
MIT AND ISC 1
Excluded packages
Package Version License Reason
@img/sharp-libvips-linux-x64 1.2.4 LGPL-3.0-or-later LGPL pre-built binary, not linked
khroma 2.1.0 Unknown MIT per GitHub repo, missing license field in package.json

Copilot AI review requested due to automatic review settings June 5, 2026 23:40
@fikewa-olatunji fikewa-olatunji force-pushed the feat/apollo-wind-prompt-editor branch from 9168e44 to 7fc6691 Compare June 5, 2026 23:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 34 out of 35 changed files in this pull request and generated 5 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread packages/apollo-wind/src/components/ui/prompt-editor/prompt-editor.test.tsx Outdated
@fikewa-olatunji fikewa-olatunji force-pushed the feat/apollo-wind-prompt-editor branch from 7fc6691 to 10b1152 Compare June 5, 2026 23:47
Copilot AI review requested due to automatic review settings June 5, 2026 23:54
@fikewa-olatunji fikewa-olatunji force-pushed the feat/apollo-wind-prompt-editor branch from 10b1152 to 645a2fb Compare June 5, 2026 23:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 34 out of 35 changed files in this pull request and generated 5 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

@fikewa-olatunji fikewa-olatunji force-pushed the feat/apollo-wind-prompt-editor branch from 645a2fb to 676ed08 Compare June 6, 2026 00:16
Copilot AI review requested due to automatic review settings June 6, 2026 00:29
@fikewa-olatunji fikewa-olatunji force-pushed the feat/apollo-wind-prompt-editor branch from 676ed08 to d64f988 Compare June 6, 2026 00:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 34 out of 35 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

@fikewa-olatunji fikewa-olatunji force-pushed the feat/apollo-wind-prompt-editor branch from d64f988 to b30a8cb Compare June 6, 2026 22:01
Copilot AI review requested due to automatic review settings June 7, 2026 18:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 36 out of 37 changed files in this pull request and generated 12 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread pnpm-workspace.yaml Outdated
Comment thread pnpm-workspace.yaml Outdated
@fikewa-olatunji fikewa-olatunji force-pushed the feat/apollo-wind-prompt-editor branch from e1dd32d to b47504a Compare June 7, 2026 18:30
Copilot AI review requested due to automatic review settings June 23, 2026 18:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 44 out of 46 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

Comment thread packages/apollo-wind/src/styles/tailwind.consumer.css Outdated
Comment thread packages/apollo-wind/package.json
Port the Lexical-based PromptEditor from flow-workbench into apollo-wind as a
reusable, prop-driven component (value / onChange / autoCompleteOptions). It
renders inline token pills (input/output/state/resource), a formatting toolbar,
a markdown preview mode, and a $-triggered variable autocomplete rebuilt on
apollo-wind Command/Popover/Tooltip — decoupled from flow-workbench's variables,
schema, i18n, and theme systems.

Adds lexical, @lexical/react, @lexical/utils, @lexical/clipboard, marked and
dompurify. Token/option props are normalized to arrays so malformed input can't
crash the editor, and token colors map to apollo-wind design tokens. Exports
PromptEditor and its public types from the package root, with unit tests and
Storybook stories.

Refs: MST-10659
- Honor `borderless` in preview mode: drop the editor's own border/background
  there too, so borderless behaves consistently between edit and preview.
- Remove dead `data-invalid` style rule + allowed attribute in MarkdownPreview
  (preview no longer emits it).
- Fix stale lucide version reference (0.555.0 -> 0.577.0) in token-icon-markup.
apollo-react pins lexical 0.16.0 (its ApRichTextEditor); apollo-wind's
PromptEditor requires lexical 0.42.0 (React 19 support + 0.42-only APIs).
The two design-system packages intentionally track different lexical
majors, so ignore the lexical/@lexical/* family in the consistency check
rather than force-aligning and breaking one of the editors.
…focus, preview styles, exports)

- PromptEditorAutocompleteMenu: preventDefault on container pointerdown so focus
  can't leave the editor before commit (review M1)
- Move markdown-preview styles from an inline <style> into the shared package
  stylesheet (tailwind.utilities.css) consumers already import
- Remove unused PromptEditorHighlightLocator/Item types (review M2)
- Export prompt-editor from the components/ui barrel
- Document the no-$ token value convention and that preview is visual-only re: validity
…lity + scope dep exemption

- Narrow the dependency-consistency exemption from the repo-wide lexical family
  to just @uipath/apollo-wind, so lexical drift elsewhere is still caught (review)
- Add unit tests for clipboard token serialization round-trip, free-form path
  type inference + VARIABLE_PATH_REGEX, dismissed-trigger suppression, and token
  equality (the extraction-risky logic; Lexical interaction paths stay limited under jsdom)
Deployed apollo-design Storybook already themes the autodocs story background,
so the borderless PromptEditor preview is readable without this override.
Reverts preview-head.html to match main (review).
…mption

Bumps apollo-react's lexical + @lexical/* from 0.16.0 to 0.42.0 to match
apollo-wind, so the dependency-version-consistency check passes without any
ignore workaround (review). Fixes the one resulting breakage: LexicalErrorBoundary
is a named export in 0.42, not default. apollo-react editor typechecks clean and
its 18 tests pass on 0.42.
Adds a native HTML5 drag-drop VariableDropPlugin + `mapVarDropToToken` prop:
a consumer's drag source sets the variable path on dataTransfer (VARIABLE_DRAG_MIME,
now exported), and the editor inserts a token at the drop point (falling back to the
end of the content when the drop caret can't be resolved). Only the custom MIME is
handled, so ordinary text drops aren't hijacked. Wired through PromptEditor →
EditorInner, with a WithVariableDragDrop story and tests.
- Free-form $path commit now happens in the picker (an 'Insert <path>' item) so
  Enter commits it, instead of an editor handler the focused menu never received.
- VARIABLE_PATH_REGEX accepts state/resource namespaces; inferTokenTypeFromPath
  falls back to the leading namespace (state.*→state, resource.*→resource) so
  free-form chips get the correct node type.
- wrapSelectionWithMarkers normalizes selection.isBackward() so right-to-left
  selections wrap correctly.
- RenameTokensPlugin groups renames by type once (O(1) per-node lookup).
…tylesheet

Splits the .prompt-editor-preview rules out of the shared tailwind.utilities.css into a
dedicated styles/prompt-editor.css, @imported from tailwind.consumer.css and shipped via
rslib's copy step (kept in styles/ for the same-dir import to survive the flat dist copy;
a per-component JS .css import doesn't resolve in the bundless build). Review feedback.
…ns the security floor

The hardcoded >=3.4.9 pin drifted behind main's override (now >=3.4.11), breaking
frozen-lockfile on the PR merge. Let the pnpm-workspace dompurify override own the
security floor and regenerate the lockfile (importer specifier >=3.4.11).
@fikewa-olatunji fikewa-olatunji force-pushed the feat/apollo-wind-prompt-editor branch from d6145e3 to 0735f4e Compare June 23, 2026 19:05
Copilot AI review requested due to automatic review settings June 23, 2026 19:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 44 out of 46 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

…ete text-diff

- setTokens() no longer calls onChange directly when the editor is mounted;
  OnChangePlugin emits once from the resulting state, avoiding a duplicate
  onChange / feedback loops in controlled usage.
- AutocompletePlugin's update listener tracks last text in a closure, reading
  the document once per update instead of traversing both prev and current
  states on every keystroke.
Comment thread packages/apollo-wind/src/styles/tailwind.consumer.css Outdated
Per review: a global stylesheet @import loads the preview CSS for every consumer
even when they don't use the PromptEditor. Move the rules back to an inline
<style> so they load only when the preview renders. Drops styles/prompt-editor.css,
the consumer.css @import, and the rslib copy entry.
Copilot AI review requested due to automatic review settings June 23, 2026 22:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 41 out of 43 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

Comment thread packages/apollo-wind/src/components/ui/prompt-editor/utils/serialization.ts Outdated
Comment thread packages/apollo-react/package.json
…iew)

- ValidateTokensPlugin: move the constant node-type→token-type map to module
  scope instead of rebuilding it per node on every validation pass.
- serialization: declare WORD_JOINER as an explicit \u2060 escape rather than an
  invisible literal char.
@fikewa-olatunji fikewa-olatunji merged commit 73bbfcf into main Jun 24, 2026
47 checks passed
@fikewa-olatunji fikewa-olatunji deleted the feat/apollo-wind-prompt-editor branch June 24, 2026 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dev-packages Adds dev package publishing on pushes to this PR pkg:apollo-react pkg:apollo-wind size:XXL 1,000+ changed lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants