mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-11 03:13:12 +00:00
refactor(ui): centralize default ports and add parity test
- add ui default port constants for cliproxy and cursor - wire preset utils to shared ui default port constants - add backend/ui sync test to prevent port drift
This commit is contained in:
1 parent
688f3e3889
commit
63f422179e
3 files changed
+36
-2
No files matched your search
@@ -0,0 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Default Port Sync Test
|
||||||
|
*
|
||||||
|
* Keeps backend and UI default ports in sync while allowing independent modules.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { describe, expect, test } from 'bun:test';
|
||||||
|
import { CLIPROXY_DEFAULT_PORT as BACKEND_CLIPROXY_DEFAULT_PORT } from '../../../src/cliproxy/config/port-manager';
|
||||||
|
import { DEFAULT_CURSOR_PORT as BACKEND_CURSOR_DEFAULT_PORT } from '../../../src/cursor/cursor-models';
|
||||||
|
import {
|
||||||
|
CLIPROXY_DEFAULT_PORT as UI_CLIPROXY_DEFAULT_PORT,
|
||||||
|
DEFAULT_CURSOR_PORT as UI_CURSOR_DEFAULT_PORT,
|
||||||
|
} from '../../../ui/src/lib/default-ports';
|
||||||
|
|
||||||
|
describe('Default Port Sync', () => {
|
||||||
|
test('CLIProxy default port is synced between backend and UI', () => {
|
||||||
|
expect(UI_CLIPROXY_DEFAULT_PORT).toBe(BACKEND_CLIPROXY_DEFAULT_PORT);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Cursor default port is synced between backend and UI', () => {
|
||||||
|
expect(UI_CURSOR_DEFAULT_PORT).toBe(BACKEND_CURSOR_DEFAULT_PORT);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
/**
|
||||||
|
* UI-side default ports.
|
||||||
|
*
|
||||||
|
* Keep UI defaults explicit to preserve frontend decoupling from backend build internals.
|
||||||
|
* Sync is enforced by backend/UI parity tests in `tests/unit/cliproxy`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const CLIPROXY_DEFAULT_PORT = 8317;
|
||||||
|
export const DEFAULT_CURSOR_PORT = 20129;
|
||||||
@@ -4,9 +4,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { MODEL_CATALOGS } from './model-catalogs';
|
import { MODEL_CATALOGS } from './model-catalogs';
|
||||||
|
import { CLIPROXY_DEFAULT_PORT } from './default-ports';
|
||||||
|
export { CLIPROXY_DEFAULT_PORT } from './default-ports';
|
||||||
|
|
||||||
/** CLIProxy port - should match the backend configuration */
|
/** CLIProxy port - should match the backend configuration */
|
||||||
export const CLIPROXY_PORT = 8317;
|
export const CLIPROXY_PORT = CLIPROXY_DEFAULT_PORT;
|
||||||
|
|
||||||
/** Default fallback API key if fetch fails */
|
/** Default fallback API key if fetch fails */
|
||||||
const DEFAULT_API_KEY = 'ccs-internal-managed';
|
const DEFAULT_API_KEY = 'ccs-internal-managed';
|
||||||
@@ -53,7 +55,7 @@ export async function applyDefaultPreset(
|
|||||||
// Fetch effective API key (respects user customization)
|
// Fetch effective API key (respects user customization)
|
||||||
const effectiveApiKey = await fetchEffectiveApiKey();
|
const effectiveApiKey = await fetchEffectiveApiKey();
|
||||||
|
|
||||||
const effectivePort = port ?? CLIPROXY_PORT;
|
const effectivePort = port ?? CLIPROXY_DEFAULT_PORT;
|
||||||
const settings = {
|
const settings = {
|
||||||
env: {
|
env: {
|
||||||
ANTHROPIC_BASE_URL: `http://127.0.0.1:${effectivePort}/api/provider/${provider}`,
|
ANTHROPIC_BASE_URL: `http://127.0.0.1:${effectivePort}/api/provider/${provider}`,
|
||||||
|
|||||||
Reference in new issue
Block a user