Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions electron/gateway/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import path from 'path';
import { EventEmitter } from 'events';
import WebSocket from 'ws';
import { PORTS } from '../utils/config';
import { getSetting } from '../utils/store';
import { JsonRpcNotification, isNotification, isResponse } from './protocol';
import { logger } from '../utils/logger';
import {
Expand Down Expand Up @@ -176,6 +177,13 @@ export class GatewayManager extends EventEmitter {
return;
}

// Read port from user settings
const configuredPort = await getSetting('gatewayPort');
if (configuredPort && configuredPort !== this.status.port) {
logger.info(`Using configured gateway port: ${configuredPort}`);
this.status.port = configuredPort;
}

this.startLock = true;
const startEpoch = this.lifecycleController.bump('start');
logger.info(`Gateway start requested (port=${this.status.port})`);
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/locales/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@
"openFolder": "Open Folder",
"autoStart": "Auto-start Gateway",
"autoStartDesc": "Start Gateway when ClawX launches",
"portConfig": "Gateway Port",
"portConfigDesc": "Port for OpenClaw Gateway (default: 18789). Restart Gateway to apply changes.",
"proxyTitle": "Proxy",
"proxyDesc": "Route Electron and Gateway traffic through your local proxy client.",
"proxyServer": "Proxy Server",
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/locales/ja/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@
"openFolder": "フォルダーを開く",
"autoStart": "ゲートウェイ自動起動",
"autoStartDesc": "ClawX 起動時にゲートウェイを自動起動",
"portConfig": "Gateway ポート",
"portConfigDesc": "OpenClaw Gateway のポート(デフォルト:18789)。変更には Gateway の再起動が必要です。",
"proxyTitle": "プロキシ",
"proxyDesc": "Electron と Gateway の通信をローカルプロキシ経由にします。",
"proxyServer": "プロキシサーバー",
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/locales/zh/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@
"openFolder": "打开文件夹",
"autoStart": "自动启动网关",
"autoStartDesc": "ClawX 启动时自动启动网关",
"portConfig": "Gateway 端口",
"portConfigDesc": "OpenClaw Gateway 端口(默认:18789)。修改后需要重启 Gateway。",
"proxyTitle": "代理",
"proxyDesc": "让 Electron 和 Gateway 的网络请求都走本地代理客户端。",
"proxyServer": "代理服务器",
Expand Down
22 changes: 22 additions & 0 deletions src/pages/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export function Settings() {
setLanguage,
gatewayAutoStart,
setGatewayAutoStart,
gatewayPort,
setGatewayPort,
proxyEnabled,
proxyServer,
proxyHttpServer,
Expand Down Expand Up @@ -508,6 +510,26 @@ export function Settings() {
/>
</div>

<div className="space-y-2">
<Label htmlFor="gateway-port" className="text-[15px] font-medium text-foreground/80">{t('gateway.portConfig')}</Label>
<Input
id="gateway-port"
type="number"
min={1024}
max={65535}
value={gatewayPort}
onChange={(e) => {
const port = parseInt(e.target.value);
if (port >= 1024 && port <= 65535) {
setGatewayPort(port);
}
}}
className="h-10 rounded-xl bg-black/5 dark:bg-white/5 border-transparent font-mono text-[13px]"
/>
<p className="text-[11px] text-muted-foreground">
{t('gateway.portConfigDesc')}
</p>
</div>

<div className="flex items-center justify-between">
<div>
Expand Down