fix: Gateway status discrepancy — foreign detection, claim action, banner sync

- Services page: foreign Gateway now shows warning dot (yellow) instead of green
- Add claim_gateway command (Rust + dev-api + frontend API) to adopt foreign Gateway
- Services page: add "Claim Gateway" button for foreign Gateway instances
- Top banner: distinguish foreign Gateway (warning + claim) vs stopped (info + start)
- app-state: expose isGatewayForeign(), pass foreign flag to onGatewayChange listeners
- Services page actions now immediately sync global Gateway state (no 15s poll wait)
- Relax owner matching: cli_path missing on either side no longer triggers foreign
- Add i18n keys: foreignGatewayBanner, claimGateway, claimSuccess, claimFailed, processing
This commit is contained in:
晴天
2026-04-05 23:12:16 +08:00
parent b2ab316353
commit 42aeb8b077
10 changed files with 123 additions and 26 deletions

View File

@@ -2354,10 +2354,10 @@ function matchesCurrentGatewayOwnerSignature(owner) {
if (!owner || owner.startedBy !== 'clawpanel') return false
const current = currentGatewayOwnerSignature()
if (Number(owner.port || 0) !== current.port) return false
if (!current.cliPath) return false
const ownerCliPath = canonicalCliPath(owner.cliPath)
if (!ownerCliPath || ownerCliPath !== current.cliPath) return false
if (!owner.openclawDir || path.resolve(owner.openclawDir) !== current.openclawDir) return false
// 仅当双方都有 cliPath 且不同时才视为不匹配;任一侧缺失时放宽为兼容(向后兼容旧记录/未绑定 CLI
const ownerCliPath = canonicalCliPath(owner.cliPath)
if (ownerCliPath && current.cliPath && ownerCliPath !== current.cliPath) return false
return true
}
@@ -3031,6 +3031,15 @@ const handlers = {
return true
},
async claim_gateway() {
const label = 'ai.openclaw.gateway'
const status = await getLocalGatewayRuntime(label)
if (!status?.running) throw new Error('Gateway 未运行,无需认领')
writeGatewayOwner(status.pid || null)
serverCacheInvalidate('svc_status')
return true
},
async stop_service({ label }) {
const status = await getLocalGatewayRuntime(label)
if (status?.running) {