Skip to content

feat(apollo-wind): honor \{{ escape and host clipboard hooks in prompt editor - #1217

Open
akraminakib wants to merge 1 commit into
mainfrom
feat/MST-12952-escape-variable-chips
Open

akraminakib wants to merge 1 commit into
mainfrom
feat/MST-12952-escape-variable-chips

Conversation

@akraminakib

@akraminakib akraminakib commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Summary

Part of MST-12952: Flow users need to keep a {{ $vars.x }} reference as literal text in an inline-agent prompt, for example to pass one agent's prompt to another agent. Flow stores this as \{{ … }}, the same escape its expression fields already use. On load and save Flow converts between its string format and the editor's tokens, but plain-text copy/paste happens inside the prompt editor. There, any {{ … }} became a chip: the escape was ignored, and {{name}} pasted as an invalid chip.

This PR lets a host supply its own clipboard string format, and makes the default paste/copy handle the \{{ escape. The Flow side will follow in a flow-workbench PR once this is released.

Changes

  • New optional PromptEditor props parseClipboardText / serializeClipboardTokens, passed to CopyPastePlugin. They replace the plain-text parse on paste and the plain text written on copy/cut. Lexical-JSON pastes between editors are unaffected. The plugin reads them through a ref, so inline callbacks don't re-register the commands.
  • Default clipboardStringToTokens: the number of backslashes right before a {{ decides what it is. An odd number means an escaped literal {{; an even number means literal backslashes followed by a chip. The count is halved either way. A plain \{{ … }} is therefore literal text with the backslash dropped.
  • Default tokensToClipboardString: a literal {{ in text is written as \{{. Backslashes right before a {{, or right before a chip, are doubled. This way any text survives a copy → paste, including text that ends in a backslash just before a chip.
  • Two new stories: Clipboard escaping (default behaviour) and With host clipboard format (a host parser that only turns {{ vars.* }} into chips).

Flow

flowchart TD
    P[Paste plain text] --> H{parseClipboardText provided?}
    H -- yes --> HP[Host parser]
    H -- no --> D[clipboardStringToTokens]
    D --> E{"\{{ escaped?"}
    E -- yes --> T[Literal text]
    E -- no --> C[Chip]
    HP --> I[Insert tokens]
    T --> I
    C --> I
Loading

Testing

  • pnpm lint passes (plus lint:css, lint:deps, check:dependencies)
  • pnpm typecheck passes
  • pnpm test passes including the new CopyPastePlugin.test.tsx (paste, plus copy/cut with a host serializer) and serialization round-trip cases
  • pnpm test:visual: not applicable (no test:visual tasks defined)
  • Manual testing / Storybook checked: both new stories render. This was a render smoke test only; I didn't click through them in the Storybook UI.
  • Type-safe (no as any / type suppressions added)

Copilot AI lite review requested due to automatic review settings September 24, 2026 16:56
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Apollo Coded App preview deployments are ready.

Project Status Preview Updated (PT)
apollo-design Ready Preview · Logs Sep 24, 2026, 10:14:12 AM
apollo-docs Ready Preview · Logs Sep 24, 2026, 10:14:12 AM
apollo-landing Ready Preview · Logs Sep 24, 2026, 10:14:12 AM
apollo-vertex Ready Preview · Logs Sep 24, 2026, 10:14:12 AM

@github-actions github-actions Bot added the size:L 100-499 changed lines. label Sep 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Dependency License Review

  • ✅ 1937 package(s) scanned
  • ✅ No license issues found
  • ⚠️ 2 package(s) excluded (see details below)
License distribution
License Packages
MIT 1708
ISC 88
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.3.3 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 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.

Copilot review overview

🟡 Changes recommended

One or more issues must be addressed before approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

Adds escaped \{{ clipboard handling and host-configurable clipboard codecs to the Apollo Wind prompt editor.

Changes:

  • Escapes literal {{ sequences during clipboard serialization.
  • Adds host parser/serializer props and plugin wiring.
  • Adds stories and serialization/paste tests.
File Description
packages/​apollo-wind/​src/​components/​ui/​prompt-editor/​utils/​serialization.ts Updated as part of this pull request.
packages/​apollo-wind/​src/​components/​ui/​prompt-editor/​utils/​serialization.test.ts Updated as part of this pull request.
packages/​apollo-wind/​src/​components/​ui/​prompt-editor/​prompt-editor.tsx Updated as part of this pull request.
packages/​apollo-wind/​src/​components/​ui/​prompt-editor/​prompt-editor.stories.tsx Updated as part of this pull request.
packages/​apollo-wind/​src/​components/​ui/​prompt-editor/​plugins/​CopyPastePlugin.tsx Updated as part of this pull request.
packages/​apollo-wind/​src/​components/​ui/​prompt-editor/​plugins/​CopyPastePlugin.test.tsx Updated as part of this pull request.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/apollo-wind/src/components/ui/prompt-editor/utils/serialization.ts Outdated
Comment on lines +159 to +164
handled = copySelectionToClipboard(
editor,
event.clipboardData!,
selection,
codecRef.current.serialize
);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added in 7e5ef0e. Two new tests dispatch COPY_COMMAND and CUT_COMMAND with a host serializeClipboardTokens and assert the text/plain payload; the cut test also checks the editor is empty afterwards.

Copilot AI review requested due to automatic review settings September 24, 2026 17:03
@akraminakib
akraminakib force-pushed the feat/MST-12952-escape-variable-chips branch from 9a3922e to 7e5ef0e Compare September 24, 2026 17:03
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

📊 Coverage + size by package

Per-package coverage and bundle size on this PR. New-line coverage = of the source lines this PR adds or changes, the % hit by tests.

Package Coverage New-line coverage Packed (gzip) Unpacked vs main
@uipath/apollo-core — — 42.01 MB 50.16 MB ±0
@uipath/apollo-react 46.1% — 7.74 MB 30.05 MB ±0
@uipath/apollo-ui-icons — — 2.86 MB 6.96 MB ±0
@uipath/apollo-wind 69.3% 100.0% (24/24) 471.4 KB 2.98 MB +1.1 KB
@uipath/ap-chat 85.8% — 43.90 MB 56.64 MB ±0

"Coverage" is each package's own coverage.include scope (e.g. apollo-core instruments only scripts/). "Packed"/"Unpacked" come from npm pack --dry-run and only cover built packages — "—" means not measured this run (package not affected / not built). "vs main" is the packed (gzipped) delta against the last successful main build (the package-sizes artifact from the Release workflow); "—" there means no main baseline was available this run. The baseline is main's latest build, not this PR's exact merge-base, so it includes any drift since the branch diverged. Packages with no vitest config are omitted.

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.

Copilot review overview

🟢 Approval recommended

No unresolved issues were identified that would block approval.

Review effort: Lite
Findings: 1 Low severity

Open (1)
Resolved since last review (1)

@github-actions

Copy link
Copy Markdown
Contributor

Storybook visual diff

⚠️ Visual changes detected: 5 changed, 4 added (of 62 compared, 53 unchanged). View report

Baseline is the deployed main Storybook, so changes merged to main after this branch was last updated can also appear here. Logs

Updated (PT): Sep 24, 2026, 10:18:30 AM

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg:apollo-wind size:L 100-499 changed lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants