Skip to content

feat: save channel proxy configs, close #1078#1080

Merged
looplj merged 1 commit intorelease/v0.9.xfrom
dev-tmp
Mar 16, 2026
Merged

feat: save channel proxy configs, close #1078#1080
looplj merged 1 commit intorelease/v0.9.xfrom
dev-tmp

Conversation

@looplj
Copy link
Copy Markdown
Owner

@looplj looplj commented Mar 16, 2026

No description provided.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 enhances the channel configuration experience by introducing a robust proxy preset management system. Users can now save frequently used proxy settings, which are automatically stored when applied to a channel. These saved presets can then be easily selected from a dropdown when configuring new or existing channels, significantly reducing manual input and potential errors. A new dedicated section in the system settings allows for viewing and managing these saved proxy configurations.

Highlights

  • Proxy Preset Management: Introduced the ability to save and manage proxy server configurations as reusable presets.
  • Automated Saving: Proxy configurations are now automatically saved as presets when a channel is configured or updated with a custom URL proxy.
  • UI Integration: Integrated proxy preset selection into both the channel creation/edit dialog and the dedicated channel proxy configuration dialog.
  • System Settings Tab: Added a new 'Proxy Presets' tab under system settings for centralized management (viewing and deleting) of saved proxy configurations.
  • Backend Support: Implemented backend GraphQL queries and mutations to support fetching, saving, and deleting proxy presets.
Changelog
  • frontend/src/features/channels/components/channels-action-dialog.tsx
    • Integrated proxy preset management and auto-saving into the channel creation/edit dialog.
    • Added an OAuth hint message for proxy configurations.
  • frontend/src/features/channels/components/channels-proxy-dialog.tsx
    • Incorporated proxy preset selection and auto-saving into the channel proxy configuration dialog.
  • frontend/src/features/system/components/proxy-presets-settings.tsx
    • Added a new component to display, list, and manage proxy presets within system settings.
  • frontend/src/features/system/components/tabs.tsx
    • Updated system settings tabs to include a new 'Proxy' tab for managing proxy presets.
  • frontend/src/features/system/data/system.ts
    • Implemented new GraphQL hooks and types for fetching, saving, and deleting proxy presets.
  • frontend/src/locales/en/channels.json
    • Added new English translation keys for proxy preset UI elements and an OAuth hint.
  • frontend/src/locales/en/system.json
    • Added new English translation keys for the system proxy settings tab and management UI.
  • frontend/src/locales/zh-CN/channels.json
    • Added new Chinese translation keys for proxy preset UI elements and an OAuth hint.
  • frontend/src/locales/zh-CN/system.json
    • Added new Chinese translation keys for the system proxy settings tab and management UI.
  • internal/server/biz/system_proxy.go
    • Implemented business logic for managing proxy presets, including retrieving, saving, and deleting them.
  • internal/server/gql/gqlgen.yml
    • Mapped new GraphQL types ProxyPreset and SaveProxyPresetInput to their Go business logic counterparts.
  • internal/server/gql/system.graphql
    • Defined new GraphQL types and mutations/queries for proxy preset management.
  • internal/server/gql/system.resolvers.go
    • Implemented GraphQL resolvers for proxy preset queries and mutations.
Activity
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.

Copy link
Copy Markdown
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 pull request introduces a feature to save and manage proxy configurations as presets. The implementation is comprehensive, covering backend logic for storage and frontend UI for management and usage. I've identified a minor inconsistency in the frontend data handling and a potential race condition on the backend that could be addressed to improve robustness.

toast.success(t('channels.messages.updateSuccess'));
// Auto-save to proxy presets
if (values.type === ProxyType.URL && values.url) {
saveProxyPreset.mutate({ url: values.url, username: values.username, password: values.password });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

For consistency with channels-action-dialog.tsx and to avoid sending empty strings for optional fields, it's better to convert empty strings to undefined. This ensures that empty optional fields are not included in the GraphQL mutation payload.

Suggested change
saveProxyPreset.mutate({ url: values.url, username: values.username, password: values.password });
saveProxyPreset.mutate({ url: values.url, username: values.username || undefined, password: values.password || undefined });

Comment on lines +44 to +70
func (s *SystemService) SaveProxyPreset(ctx context.Context, preset ProxyPreset) error {
presets, err := s.ProxyPresets(ctx)
if err != nil {
return err
}

found := false
for i, p := range presets {
if p.URL == preset.URL {
presets[i] = preset
found = true

break
}
}

if !found {
presets = append(presets, preset)
}

jsonBytes, err := json.Marshal(presets)
if err != nil {
return fmt.Errorf("failed to marshal proxy presets: %w", err)
}

return s.setSystemValue(ctx, SystemKeyProxyPresets, string(jsonBytes))
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The current implementation of SaveProxyPreset uses a read-modify-write pattern that can lead to a race condition. If two requests try to modify presets concurrently (e.g., one saving, one deleting), one of the updates could be lost. The same issue exists in DeleteProxyPreset.

To ensure data consistency, these operations should be performed within a database transaction with row-level locking.

Example of how this could be implemented with ent:

func (s *SystemService) SaveProxyPreset(ctx context.Context, preset ProxyPreset) error {
	return s.db.WithTx(ctx, func(tx *ent.Tx) error {
		txCtx := ent.NewContext(ctx, tx)
		
		// Lock the row for update
		sys, err := tx.System.Query().
			Where(system.KeyEQ(SystemKeyProxyPresets)).
			ForUpdate().
			Only(txCtx)

		var presets []ProxyPreset
		if err != nil {
			if !ent.IsNotFound(err) {
				return fmt.Errorf("failed to get proxy presets: %w", err)
			}
			// If not found, presets is an empty slice
		} else {
			if err := json.Unmarshal([]byte(sys.Value), &presets); err != nil {
				return fmt.Errorf("failed to unmarshal proxy presets: %w", err)
			}
		}

		// ... (rest of the modification logic for saving)

		jsonBytes, err := json.Marshal(presets)
		if err != nil {
			return fmt.Errorf("failed to marshal proxy presets: %w", err)
		}

		// This would require setSystemValue to be adapted to use the transaction client
		return setSystemValue(txCtx, SystemKeyProxyPresets, string(jsonBytes))
	})
}

@looplj looplj merged commit 7e83542 into release/v0.9.x Mar 16, 2026
2 checks passed
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.

1 participant