Feat: replace delimiter text input with block-based builder (#15057)#15078
Feat: replace delimiter text input with block-based builder (#15057)#15078Rene0422 wants to merge 4 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughReplaces the free-text delimiter input with a block-based DelimiterBuilder, adds parse/serialize utilities, renders removable chips and preset buttons with keyboard/blur behavior, integrates the builder into the form field, and adds English/Chinese locale keys. ChangesDelimiter Block Builder Implementation
Sequence Diagram(s)sequenceDiagram
participant DelimiterFormField
participant DelimiterBuilder
participant parseDelimiterBlocks
participant serializeDelimiterBlocks
DelimiterFormField->>DelimiterBuilder: render(value, onChange)
DelimiterBuilder->>parseDelimiterBlocks: parse(value)
DelimiterBuilder->>serializeDelimiterBlocks: serialize(blocks)
DelimiterBuilder->>DelimiterFormField: onChange(serialized)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@web/src/components/delimiter-form-field.tsx`:
- Around line 109-113: The remove-button in DelimiterFormField is using a
hardcoded English aria-label ("remove delimiter"); update the <button> in the
DelimiterFormField component to use the app's localization API (e.g., the
existing i18n/translation hook or function used elsewhere like t(...) or
useTranslations(...)) to produce the aria-label dynamically so it follows locale
changes; reference the button element and its onRemove handler and replace the
literal aria-label string with a translated key such as "removeDelimiter"
(ensure the translation key is added to locale files).
- Around line 83-87: serializeDelimiterBlocks currently embeds user-entered
backticks into the wire format unescaped; update serializeDelimiterBlocks to
first escape any backticks in each block (replace "`" with "\`") before wrapping
multi-char blocks in backticks and before joining, and apply the same escaping
to the other delimiter-serialization logic in this file (the second
serialization block around lines 143-150) so that any "`" in user input is
properly escaped and round-trips with the parser.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: fbcae72d-27e9-4cbf-a7a6-d294804b0bf7
📒 Files selected for processing (3)
web/src/components/delimiter-form-field.tsxweb/src/locales/en.tsweb/src/locales/zh.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@web/src/components/delimiter-form-field.tsx`:
- Around line 110-114: The remove button in DelimiterFormField (the <button>
with onClick={onRemove}) removes the native outline but doesn't provide a
replacement focus indicator; update its class list to restore an accessible
visible focus state (e.g. remove or replace focus:outline-none with a
focus-visible or focus ring utility such as focus-visible:ring
focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-state-error
or equivalent CSS) so keyboard users can clearly see which chip's delete control
is focused while preserving the existing hover styles.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 67ea7192-f170-4ce5-9209-63a7d2fbc93c
📒 Files selected for processing (3)
web/src/components/delimiter-form-field.tsxweb/src/locales/en.tsweb/src/locales/zh.ts
✅ Files skipped from review due to trivial changes (1)
- web/src/locales/zh.ts
f487f85 to
3656df0
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@web/src/components/delimiter-form-field.tsx`:
- Around line 190-199: The Enter handling in the onKeyDown handler inside
delimiter-form-field.tsx currently calls handleSubmit() immediately and should
be guarded against IME composition; modify the onKeyDown callback (the branch
that checks e.key === 'Enter') to only call handleSubmit() when composition is
not in progress by checking !e.nativeEvent.isComposing and also handling the
legacy composition keyCode (skip if e.nativeEvent.isComposing === true or
e.keyCode === 229). Leave the Escape branch (which calls setDraft('') and
setAdding(false)) unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a26428c8-ffd7-46aa-a00b-14f634acfc76
📒 Files selected for processing (3)
web/src/components/delimiter-form-field.tsxweb/src/locales/en.tsweb/src/locales/zh.ts
✅ Files skipped from review due to trivial changes (2)
- web/src/locales/en.ts
- web/src/locales/zh.ts
Summary
Fixes #15057.
Replaces the free-text Delimiter for text input with a block-based
builder. The previous input forced users to know escape conventions
(
\nvs\\n) and backtick rules for multi-char delimiters, gave novisual feedback on what was configured, and made managing multiple
delimiters awkward.
What changed
web/src/components/delimiter-form-field.tsxparseDelimiterBlocks/serializeDelimiterBlockshelpers splitthe delimiter string into discrete blocks (single chars + backtick-
wrapped multi-char sequences) and back. Round-trip verified on
representative inputs (
\n,\n。;!?,`###`\n,a`bc`d).DelimiterBuildercomponent:Badgechip;\n/\t/\rdisplay as↵/⇥/↩for clarity.Input; Enter commits, Escapecancels, blur commits. Multi-char entries are auto-wrapped in
backticks at serialize time so users never type them.
##Heading,---HR)one-click append the corresponding delimiter.
DelimiterFormFieldnow rendersDelimiterBuilderinstead of theraw
Input.DelimiterInput(the legacy single-input component) is keptexported so the agent token-chunker form
(
pages/agent/form/token-chunker-form/index.tsx), which already hasits own list UI, continues to work unchanged.
web/src/locales/en.ts,web/src/locales/zh.ts— six new keysunder
knowledgeDetails:delimiterAddPlaceholder,delimiterPresetsLabel,delimiterPresetNewline,delimiterPresetTab,delimiterPresetHeading,delimiterPresetHr. Per the frontendCLAUDE.md, added only to
en.tsandzh.ts.Wire format / backend compatibility
The persisted shape of
parser_config.delimiteris unchanged — stilla single string consumed by
rag.nlp.naive_mergeinrag/nlp/__init__.py, where backtick-wrapped substrings denote multi-char delimiters and everything else is
treated as a single-char delimiter. No backend or schema changes.
Out of scope
children-delimiter-form.tsxalreadyuse
useFieldArray-based list UIs with+ Add/ trash icons — norework needed.
removable and presets cover the common cases; to "change" a chip,
remove + re-add.
Test plan
confirm delimiter renders as chips, defaulting to
↵for theseeded
\n.;, press Enter → new;chip appears.###, press Enter → chip shows###;saved value contains
`###`(backticks auto-added).##,---) → corresponding chipappends; underlying value updates correctly.
added.
"\n`##`;"→renders as
[↵] [##] [;].unchanged (sanity-check by uploading a test doc).
DelimiterInput, not the builder).in Chinese.
Not verified
node_modulesare not present in this worktree, sonpm run lintandtscwere not executed. Round-trip behavior of the parser wasunit-tested via standalone Node. Please run lint + typecheck in CI
before merging.
Type of change