Skip to content

fix: Request Filters improvements & SOCKS proxy fix#501

Merged
ding113 merged 5 commits intoding113:devfrom
miraserver:fix/req-filters-adv
Jan 2, 2026
Merged

fix: Request Filters improvements & SOCKS proxy fix#501
ding113 merged 5 commits intoding113:devfrom
miraserver:fix/req-filters-adv

Conversation

@miraserver
Copy link
Contributor

@miraserver miraserver commented Jan 1, 2026

Summary

This PR contains three fixes/improvements:

1. Fix: Exclude deleted providers from group tags dropdown in Request Filters

  • getDistinctProviderGroupsAction was showing group tags from soft-deleted providers
  • Added deletedAt IS NULL filter to match the behavior of getDistinctProviderGroups in repository

2. Feature: Add circuit breaker filter toggle on Providers page

  • Added a switch toggle to filter providers by circuit breaker state
  • Toggle appears only when there are providers with open circuit breaker
  • When enabled, shows only providers with broken circuits
  • Filter works on top of existing filters (type, status, group, search)
  • Visual feedback: icon and text turn red when filter is active
  • Added i18n translations for all 5 languages

3. Fix: SOCKS proxy not working with undici ("this.dispatch is not a function")

  • SocksProxyAgent from socks-proxy-agent is a Node.js HTTP Agent that doesn't implement undici's Dispatcher interface
  • Replaced with fetch-socks which provides socksDispatcher - a native undici Dispatcher implementation
  • Tested with real SOCKS5 proxy - works correctly

Changes

  • src/actions/request-filters.ts - Added deletedAt filter
  • src/app/[locale]/settings/providers/_components/provider-manager.tsx - Circuit breaker toggle UI
  • src/lib/proxy-agent.ts - Replace SocksProxyAgent with socksDispatcher
  • next.config.ts - Update outputFileTracingIncludes
  • messages/*/settings.json - i18n for circuit breaker filter

Test plan

  • Request Filters: Verify deleted provider groups don't appear in dropdown
  • Providers page: Toggle appears when circuit breaker is open, filters correctly
  • SOCKS proxy: Tested with SOCKS5 proxy - requests go through proxy correctly

🤖 Generated with Claude Code

Greptile Summary

This PR addresses three distinct improvements:

1. SOCKS Proxy Compatibility Fix: Replaced socks-proxy-agent with fetch-socks to resolve undici compatibility issues. The original SocksProxyAgent is a Node.js HTTP Agent that doesn't implement undici's Dispatcher interface, causing "this.dispatch is not a function" errors. The new socksDispatcher from fetch-socks is a native undici Dispatcher implementation that properly integrates with the undici request pipeline.

2. Request Filters Bug Fix: Fixed getDistinctProviderGroupsAction to exclude soft-deleted providers (deletedAt IS NULL), aligning with the existing getDistinctProviderGroups repository method. This prevents deleted provider group tags from appearing in the dropdown filter.

3. Circuit Breaker Filter Feature: Added a toggle switch on the Providers page to filter providers by circuit breaker state. The toggle only appears when there are providers with open circuit breakers, provides visual feedback (red icon and text when active), and works seamlessly with existing filters (type, status, group, search).

All changes are well-tested, properly documented, and include i18n translations for all supported languages.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • All changes are focused, well-implemented, and properly tested. The SOCKS proxy fix resolves a real compatibility issue with the correct solution. The request filters fix properly aligns behavior between action and repository layers. The circuit breaker feature is a clean, additive enhancement with proper conditional rendering and visual feedback.
  • No files require special attention

Important Files Changed

Filename Overview
src/lib/proxy-agent.ts Replaced socks-proxy-agent with fetch-socks for undici compatibility. SOCKS dispatcher now properly implements undici's Dispatcher interface.
package.json Removed socks-proxy-agent dependency and added fetch-socks v1.3.2
src/actions/request-filters.ts Added deletedAt IS NULL filter to exclude soft-deleted providers from group tags dropdown, matching repository behavior
src/app/[locale]/settings/providers/_components/provider-manager.tsx Added circuit breaker filter toggle with visual feedback (red icon/text when active), only shown when broken providers exist

Sequence Diagram

sequenceDiagram
    participant Client
    participant ProxyAgent
    participant SocksDispatcher
    participant UndiciRequest
    participant TargetAPI

    Note over ProxyAgent: Before: SocksProxyAgent (incompatible)
    Note over ProxyAgent: After: fetch-socks socksDispatcher

    Client->>ProxyAgent: createProxyAgentForProvider(provider, targetUrl)
    
    alt SOCKS5/SOCKS4 Protocol
        ProxyAgent->>SocksDispatcher: socksDispatcher({type, host, port}, {timeout})
        Note right of SocksDispatcher: Native undici Dispatcher
        ProxyAgent-->>Client: {agent: Dispatcher, http2Enabled: false}
    else HTTP/HTTPS Protocol
        ProxyAgent->>ProxyAgent: new ProxyAgent({uri, allowH2, timeouts})
        ProxyAgent-->>Client: {agent: ProxyAgent, http2Enabled: true}
    end

    Client->>UndiciRequest: undiciRequest(url, {dispatcher: agent})
    UndiciRequest->>SocksDispatcher: dispatch(request)
    SocksDispatcher->>TargetAPI: Forward via SOCKS proxy
    TargetAPI-->>SocksDispatcher: Response
    SocksDispatcher-->>UndiciRequest: Response
    UndiciRequest-->>Client: Response
Loading

John Doe and others added 3 commits January 1, 2026 20:01
…lters

The getDistinctProviderGroupsAction was showing group tags from soft-deleted
providers. Added deletedAt IS NULL filter to match the behavior of
getDistinctProviderGroups in repository/provider.ts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add a switch toggle to filter providers by circuit breaker state.
The toggle appears only when there are providers with open circuit breaker.
When enabled, shows only providers with broken circuits.

- Filter works on top of existing filters (type, status, group, search)
- Visual feedback: icon and text turn red when filter is active
- Added i18n translations for all 5 languages

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…patibility

SocksProxyAgent from socks-proxy-agent is a Node.js HTTP Agent that doesn't
implement undici's Dispatcher interface, causing "this.dispatch is not a
function" error when used with undici.request().

Replace with fetch-socks which provides socksDispatcher - a native undici
Dispatcher implementation for SOCKS4/SOCKS5 proxies.

- Replace socks-proxy-agent with fetch-socks dependency
- Update createProxyAgentForProvider to use socksDispatcher
- Update next.config.ts outputFileTracingIncludes
- Update comments in forwarder.ts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @miraserver, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request delivers several key improvements and fixes across the application. It refines the Request Filters by ensuring that only active providers are considered when displaying group tags, preventing stale data from appearing. A new user interface feature has been added to the Providers page, allowing users to easily filter providers based on their circuit breaker status, enhancing monitoring capabilities. Furthermore, a critical fix for SOCKS proxy connections has been implemented, resolving compatibility issues with the undici HTTP client by integrating a more suitable proxy agent.

Highlights

  • Request Filters: Excluded soft-deleted providers from the group tags dropdown in Request Filters to ensure only active providers are displayed.
  • Providers Page UI: Introduced a new toggle on the Providers page to filter providers by their circuit breaker state, appearing only when there are providers with open circuit breakers.
  • SOCKS Proxy: Fixed SOCKS proxy functionality by replacing socks-proxy-agent with fetch-socks, which provides a native undici Dispatcher implementation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions bot added size/S Small PR (< 200 lines) bug Something isn't working area:UI area:i18n area:provider labels Jan 1, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This PR delivers three valuable improvements. The SOCKS proxy fix by switching to fetch-socks is a great move for better compatibility with undici. The new circuit breaker filter on the providers page is a useful feature, and its implementation is clean and efficient. The fix to exclude deleted providers from the request filters dropdown is also a necessary correction. The code is well-written, but I have one suggestion for src/actions/request-filters.ts to improve code consistency.

Comment on lines 289 to 294
.where(
and(
isNull(providers.deletedAt),
sql`${providers.groupTag} IS NOT NULL AND ${providers.groupTag} != ''`
)
);
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

While using sql works, it's more idiomatic and type-safe to use drizzle-orm's built-in operators for this query. This would also make the code more consistent with other queries in the codebase. You can achieve the same logic using isNotNull, ne, and a nested and. You'll also need to add isNotNull and ne to your drizzle-orm import.

Suggested change
.where(
and(
isNull(providers.deletedAt),
sql`${providers.groupTag} IS NOT NULL AND ${providers.groupTag} != ''`
)
);
.where(
and(
isNull(providers.deletedAt),
and(isNotNull(providers.groupTag), ne(providers.groupTag, ""))
)
);

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code Review Summary

No significant issues identified in this PR.

PR Size: S

  • Lines changed: 156 (112 additions, 44 deletions)
  • Files changed: 11

Changes Reviewed

1. Request Filters: Exclude deleted providers from dropdown

  • Added deletedAt IS NULL filter to getDistinctProviderGroupsAction
  • Matches repository pattern in getDistinctProviderGroups
  • Correctly prevents soft-deleted provider groups from appearing in UI

2. Providers Page: Circuit breaker filter toggle

  • Clean implementation of circuit breaker state filter
  • Proper memoization with correct dependencies
  • Good UX with visual feedback and conditional visibility

3. SOCKS Proxy: Replace socks-proxy-agent with fetch-socks

  • Replaced non-undici-compatible SocksProxyAgent with socksDispatcher
  • Fixes "this.dispatch is not a function" error
  • Proper type safety: removed any type, uses Dispatcher interface
  • Error handling and logging preserved
  • Dependency properly added to package.json and next.config.ts

Review Coverage

  • Logic and correctness - Clean
  • Security (OWASP Top 10) - Clean
  • Error handling - Clean
  • Type safety - Improved (removed any type)
  • Documentation accuracy - Clean
  • Test coverage - Adequate
  • Code clarity - Good

Automated review by Claude AI

…filtering

Replace sql template with isNotNull and ne operators for better type-safety
and consistency with drizzle-orm patterns.

Changes in both:
- src/actions/request-filters.ts
- src/repository/provider.ts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@miraserver miraserver force-pushed the fix/req-filters-adv branch from 63d0aa6 to 1b8577f Compare January 1, 2026 17:19
@ding113 ding113 merged commit f017a83 into ding113:dev Jan 2, 2026
@github-project-automation github-project-automation bot moved this from Backlog to Done in Claude Code Hub Roadmap Jan 2, 2026
@github-actions github-actions bot mentioned this pull request Jan 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:i18n area:provider area:UI bug Something isn't working size/S Small PR (< 200 lines)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants

Comments