fix(rules): correct mihomo rule name mapping#68
Open
cesaryuan wants to merge 1 commit intoforu17:mainfrom
Open
fix(rules): correct mihomo rule name mapping#68cesaryuan wants to merge 1 commit intoforu17:mainfrom
cesaryuan wants to merge 1 commit intoforu17:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes rule-name normalization in the collector so Mihomo/Clash “proxy group” hops are no longer persisted as rule names, while preserving Surge’s existing rule-name semantics when the resolved rule already matches the last chain hop. This also centralizes rule-name generation to a shared helper and adds regression tests.
Changes:
- Introduce a shared
buildRuleNamehelper and reuse it across SQLite writes, ClickHouse writes, and realtime aggregation. - Correct Mihomo/Clash rule-name derivation to use
rule+rulePayload(instead of the last chain hop). - Add/adjust tests to cover Mihomo mapping + Surge preservation behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| apps/web/components/features/rules/interactive-rule-stats.tsx | Clarifies (in comment) that Gateway-rule proxy-group names match Surge’s stored rule naming behavior. |
| apps/collector/src/shared/utils/rule-name.ts | Adds centralized helper for consistent rule-name construction across collectors/writers. |
| apps/collector/src/modules/stats/stats.service.test.ts | Updates chain-flow regression fixture to reflect corrected rule/rulePayload semantics. |
| apps/collector/src/modules/realtime/realtime.store.ts | Uses shared helper so realtime rule aggregation matches persisted rule naming. |
| apps/collector/src/modules/collector/batch-buffer.ts | Uses shared helper for rule-count logging (aligning with persisted rule naming). |
| apps/collector/src/modules/clickhouse/clickhouse.writer.ts | Uses shared helper so ClickHouse writes match SQLite/realtime rule naming. |
| apps/collector/src/database/repositories/traffic-writer.test.ts | Adds regression coverage for Mihomo mapping + Surge-preservation behavior. |
| apps/collector/src/database/repositories/traffic-writer.repository.ts | Replaces duplicated rule-name logic with shared helper and fixes rule→proxy mapping to use the resolved rule name. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
close #67
Testing