Skip to content

Support case-insensitive model filter patterns#1725

Merged
looplj merged 1 commit into
looplj:unstablefrom
zhaozhaozz:fix/channel-model-filter-ignore-case-1724
May 29, 2026
Merged

Support case-insensitive model filter patterns#1725
looplj merged 1 commit into
looplj:unstablefrom
zhaozhaozz:fix/channel-model-filter-ignore-case-1724

Conversation

@zhaozhaozz

Copy link
Copy Markdown
Contributor

Summary

  • Support leading (?i) in channel model filter preview and validation.
  • Document the case-insensitive model filter syntax in the channel dialog.
  • Add backend xregexp coverage for case-insensitive match and filter behavior.

Tests

  • go test ./internal/pkg/xregexp
  • pnpm exec tsc --noEmit --pretty false
  • git diff --check

Closes #1724

@zhaozhaozz

Copy link
Copy Markdown
Contributor Author

CI note: the initial checks failed before repository commands ran. The lint and test jobs failed while downloading actions/setup-go@v5; the backend and frontend build jobs failed during checkout with HTTP 403 from GitHub. Local verification completed with:

  • go test ./internal/pkg/xregexp
  • pnpm exec tsc --noEmit --pretty false
  • git diff --check

@zhaozhaozz zhaozhaozz force-pushed the fix/channel-model-filter-ignore-case-1724 branch from 5afaae6 to c53391a Compare May 26, 2026 12:44
@greptile-apps

greptile-apps Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds (?i) case-insensitive prefix support to the channel model filter UI — fixing a bug where (?i)^gpt-4 was incorrectly flagged as invalid because the old validation used bare new RegExp(val) (which throws on (?i) in JavaScript). The backend already handled this via regexp2 inline modifiers; this PR closes the gap on the frontend.

  • pattern.ts: ensureAnchored (returning a string) is replaced by compilePattern (returning a compiled RegExp). splitInlineModifier now extracts the modifier as JS RegExp flags so (?i)^gpt-4 becomes /^(?:gpt-4)$/i. A new exported isValidModelPattern provides clean separation between validation and matching, scoped deliberately to (?i) only.
  • channels-action-dialog.tsx: Validation now delegates to isValidModelPattern, which correctly accepts (?i) patterns.
  • Locale files & backend tests: Placeholder, description copy, and Go test coverage updated to match the new behaviour.

Confidence Score: 5/5

Safe to merge — the change is a focused, well-scoped fix with no regressions on existing patterns.

The refactor correctly replaces bare new RegExp(val) validation with isValidModelPattern, which translates the modifier into a proper JS i flag before compiling. All existing matching semantics for non-modifier patterns are preserved and the implementation is consistent across validation, matching, locale strings, and backend tests.

No files require special attention.

Important Files Changed

Filename Overview
frontend/src/features/channels/utils/pattern.ts Core logic refactored: ensureAnchored replaced by compilePattern returning RegExp; splitInlineModifier now emits JS flags; new isValidModelPattern export added.
frontend/src/features/channels/components/channels-action-dialog.tsx Validation updated to use isValidModelPattern instead of raw new RegExp(val), correctly accepting (?i) patterns.
internal/pkg/xregexp/match_test.go Adds two focused test cases for (?i) in TestMatchString and TestFilter.
frontend/src/locales/en/channels.json Placeholder and description updated to document (?i) syntax.
frontend/src/locales/zh-CN/channels.json Chinese locale updated in parallel with the English locale.

Reviews (3): Last reviewed commit: "Support case-insensitive model filter pa..." | Re-trigger Greptile

Comment thread frontend/src/features/channels/utils/pattern.ts
@zhaozhaozz zhaozhaozz force-pushed the fix/channel-model-filter-ignore-case-1724 branch from c53391a to f59cd71 Compare May 27, 2026 02:26
@looplj

looplj commented May 28, 2026

Copy link
Copy Markdown
Owner

有点冲突了

@zhaozhaozz zhaozhaozz force-pushed the fix/channel-model-filter-ignore-case-1724 branch from f59cd71 to 5b30302 Compare May 29, 2026 08:42
@looplj looplj merged commit 1451e7f into looplj:unstable May 29, 2026
4 checks passed
junjiangao pushed a commit to junjiangao/axonhub that referenced this pull request May 30, 2026
Co-authored-by: userZ <spare.nets-0y@icloud.com>
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.

Support case-insensitive channel model filter preview

2 participants