Skip to content

feat: GenAI Shortcuts for PromptInput#4107

Open
ernst-dev wants to merge 48 commits intomainfrom
dev-v3-ernstka-shortcuts
Open

feat: GenAI Shortcuts for PromptInput#4107
ernst-dev wants to merge 48 commits intomainfrom
dev-v3-ernstka-shortcuts

Conversation

@ernst-dev
Copy link
Copy Markdown
Member

@ernst-dev ernst-dev commented Dec 12, 2025

Description

Adds shortcuts features to PromptInput:

  • Underlying input becomes a div with contenteditable enabled to allow rendering custom elements
  • Adds menu system to attach to triggers with filters @ or /
  • Complex rendering logic to ensure cross-browser consistency
  • Reference representation through inline Token elements

Related links, issue #, if available: n/a

How has this been tested?

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@ernst-dev ernst-dev force-pushed the dev-v3-ernstka-shortcuts branch from cb759ce to 5e2c3a3 Compare February 18, 2026 17:30
@mxschll mxschll self-requested a review February 20, 2026 17:43
@ernst-dev ernst-dev force-pushed the dev-v3-ernstka-shortcuts branch from b3fa438 to 3f4d535 Compare February 26, 2026 15:14
@ernst-dev ernst-dev marked this pull request as ready for review February 26, 2026 15:32
@ernst-dev ernst-dev requested a review from a team as a code owner February 26, 2026 15:32
@ernst-dev ernst-dev force-pushed the dev-v3-ernstka-shortcuts branch from 3f4d535 to 9f0faad Compare February 26, 2026 15:35
@gethinwebster gethinwebster removed the request for review from a team February 27, 2026 09:13
@ernst-dev ernst-dev force-pushed the dev-v3-ernstka-shortcuts branch from 69b458f to d2ebfd6 Compare March 6, 2026 09:01
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 6, 2026

Codecov Report

❌ Patch coverage is 88.67925% with 288 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.66%. Comparing base (7d3ac02) to head (50756f1).

Files with missing lines Patch % Lines
src/prompt-input/tokens/use-token-mode.ts 76.19% 149 Missing ⚠️
src/prompt-input/core/caret-controller.ts 88.55% 42 Missing ⚠️
src/prompt-input/core/event-handlers.ts 89.92% 41 Missing ⚠️
src/test-utils/dom/prompt-input/index.ts 55.76% 23 Missing ⚠️
src/prompt-input/internal.tsx 93.84% 8 Missing ⚠️
src/prompt-input/core/caret-spot-utils.ts 88.67% 6 Missing ⚠️
src/prompt-input/components/token-mode.tsx 84.37% 5 Missing ⚠️
src/prompt-input/components/menu-dropdown.tsx 77.77% 4 Missing ⚠️
src/prompt-input/core/token-operations.ts 98.00% 4 Missing ⚠️
src/prompt-input/core/token-utils.ts 97.82% 3 Missing ⚠️
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4107      +/-   ##
==========================================
- Coverage   97.44%   96.66%   -0.78%     
==========================================
  Files         903      919      +16     
  Lines       26510    29007    +2497     
  Branches     9569    10491     +922     
==========================================
+ Hits        25832    28041    +2209     
- Misses        672      960     +288     
  Partials        6        6              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ernst-dev ernst-dev force-pushed the dev-v3-ernstka-shortcuts branch from d7e193a to 7c9cae2 Compare March 12, 2026 17:11
@ernst-dev ernst-dev force-pushed the dev-v3-ernstka-shortcuts branch from 3d5686c to 992d693 Compare March 25, 2026 18:27
const finalCursorPosition = caretEnd ?? insertPosition + text.length;
textarea.setSelectionRange(finalCursorPosition, finalCursorPosition);

textarea.dispatchEvent(new Event('input', { bubbles: true }));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is the purpose of this dispatch event?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we even necessarily support handleInsertText for textarea mode?

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.

The event is to trigger the change of events that typically happen when a user types text into the input. I'm inclined to support it for textarea as well even if it doesn't really get used as the function is on the ref for both textarea and token-mode. It doesn't hurt to have it work for both in my opinion

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But how does it help consumers? Is it captured by our code to make some change or do we expect it to be caught by the consumer code? If so - we should rather expose our non-cancelable on-input event via a dedicated handler.

"i18nStrings.datePlaceholder": "GG/MM/AAAA",
"i18nStrings.isoDatePlaceholder": "AAAA-MM-GG",
"i18nStrings.slashedDatePlaceholder": "AAAA/MM/GG",
"i18nStrings.isoDatePlaceholder": "GG-MM-AAAA",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These two strings should not change. Instead, i18nStrings.datePlaceholder should be changed to AAAA/MM/GG

"i18nStrings.datePlaceholder": "JJ/MM/AAAA",
"i18nStrings.isoDatePlaceholder": "AAAA-MM-JJ",
"i18nStrings.slashedDatePlaceholder": "AAAA/MM/JJ",
"i18nStrings.isoDatePlaceholder": "JJ-MM-AAAA",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same as in Italian, these two strings should not have been change, it is the previous one that was wrong.

We can address existing issues separately but let's not introduce regressions.

"i18nStrings.datePlaceholder": "DD/MM/YYYY",
"i18nStrings.isoDatePlaceholder": "YYYY-MM-DD",
"i18nStrings.slashedDatePlaceholder": "YYYY/MM/DD",
"i18nStrings.isoDatePlaceholder": "DD-MM-YYYY",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Similar feedback here as with French and Italian below

const menuOpen = props.getMenuOpen();

handleKey(
event as unknown as {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this double cast necessary?

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.

Good catch, it's not needed at all, will remove in the next commit

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants