Skip to content

feat: proxy port from config + config set/init commands#35

Merged
zx06 merged 3 commits intomainfrom
feat/proxy-port-config-set
Mar 24, 2026
Merged

feat: proxy port from config + config set/init commands#35
zx06 merged 3 commits intomainfrom
feat/proxy-port-config-set

Conversation

@zx06
Copy link
Copy Markdown
Owner

@zx06 zx06 commented Mar 24, 2026

Summary

Feature 1: Proxy Port from Config

  • Add local_port field to Profile config for proxy port persistence
  • When config local_port is set and port is in use:
    • TTY: prompt user to choose random port or quit
    • Non-TTY: return XSQL_PORT_IN_USE error
  • Port priority: --local-port flag > profile.local_port > 0 (auto)

Feature 2: Config Set/Init Commands

  • xsql config init - create template config file
  • xsql config set <key> <value> - quick config modification
    • Supports profile.<name>.<field> and ssh_proxy.<name>.<field>

Changes

  • internal/config/types.go: Add LocalPort to Profile
  • internal/config/write.go: Config write/update capability
  • internal/proxy/proxy.go: Port conflict detection with XSQL_PORT_IN_USE
  • cmd/xsql/proxy.go: Config-based port resolution + TTY conflict prompt
  • cmd/xsql/config.go: New config init/set commands
  • internal/errors/codes.go: New XSQL_PORT_IN_USE error code
  • RFC 0006 + updated docs (cli-spec, config, error-contract)
  • Comprehensive unit tests and E2E tests

Testing

  • All existing tests pass
  • New unit test coverage: config write (89%), proxy (94%), errors (87%)
  • E2E tests for config init, config set, proxy port from config

- Add local_port field to Profile config for proxy port persistence
- When config local_port is set and port is in use:
  - TTY: prompt user to choose random port or quit
  - Non-TTY: return XSQL_PORT_IN_USE error
- Port priority: --local-port flag > profile.local_port > 0 (auto)
- Add 'xsql config init' to create template config file
- Add 'xsql config set <key> <value>' for quick config modification
  - Supports profile.<name>.<field> and ssh_proxy.<name>.<field>
- Add XSQL_PORT_IN_USE error code
- Add RFC 0006 documenting both features
- Update docs: cli-spec.md, config.md, error-contract.md
- Add comprehensive unit tests and E2E tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 79.15058% with 54 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.92%. Comparing base (2a58171) to head (5a983b4).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
cmd/xsql/proxy.go 20.58% 26 Missing and 1 partial ⚠️
internal/config/write.go 86.00% 14 Missing and 7 partials ⚠️
cmd/xsql/config.go 86.95% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #35      +/-   ##
==========================================
- Coverage   82.03%   80.92%   -1.11%     
==========================================
  Files          37       40       +3     
  Lines        2449     2726     +277     
==========================================
+ Hits         2009     2206     +197     
- Misses        331      397      +66     
- Partials      109      123      +14     
Flag Coverage Δ
e2e 44.09% <0.00%> (-0.22%) ⬇️
integration 44.09% <0.00%> (-0.22%) ⬇️
unittests 68.23% <79.15%> (+0.32%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

xuzhuo and others added 2 commits March 24, 2026 11:34
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
21.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@zx06 zx06 merged commit 4048289 into main Mar 24, 2026
13 of 14 checks passed
@zx06 zx06 deleted the feat/proxy-port-config-set branch March 24, 2026 03:43
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