Skip to content

fix: unify gateway recovery overlay and polish OpenClaw copy#45

Merged
lsave merged 6 commits intomainfrom
codex/gateway-recovery-overlay
Mar 27, 2026
Merged

fix: unify gateway recovery overlay and polish OpenClaw copy#45
lsave merged 6 commits intomainfrom
codex/gateway-recovery-overlay

Conversation

@lsave
Copy link
Copy Markdown
Contributor

@lsave lsave commented Mar 27, 2026

Summary:

  • add an app-level gateway recovery overlay with a small state reducer so runtime restarts use one consistent recovering and failed experience
  • cover the recovery flow with focused tests and wire in the new setup locale strings for the overlay
  • polish Chinese OpenClaw-related copy across key surfaces and fix host-event unsubscribe handling to use the preload cleanup hook when available

Validation:

  • pnpm exec vitest run tests/unit/gateway-recovery-state.test.ts tests/unit/gateway-recovery-overlay.test.tsx
  • pnpm exec tsc --noEmit --pretty false

Copy link
Copy Markdown

@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 GatewayRecoveryOverlay component to manage and display the UI during gateway recovery or failure. It includes state logic, updated translations—standardizing terminology to 'OpenClaw'—and comprehensive unit tests. A critical bug was identified in src/lib/host-events.ts where an event listener is registered twice, potentially causing duplicate event execution.

Comment on lines 51 to 64
ipc.on(ipcChannel, listener);
// preload's `on()` wraps the callback in an internal subscription function
// and returns a cleanup function that removes that exact wrapper. We MUST
// use the returned cleanup rather than calling `off(channel, listener)`,
// because `listener` !== the internal wrapper and removeListener would be
// a no-op, leaking the subscription.
const unsubscribe = ipc.on(ipcChannel, listener);
if (typeof unsubscribe === 'function') {
return unsubscribe;
}
// Fallback for environments where on() doesn't return cleanup
return () => {
ipc.off(ipcChannel, listener);
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

The ipc.on(ipcChannel, listener) call is made twice, once on line 51 and again on line 57. This will cause the event handler to be registered twice, and consequently, it will be executed twice for every event, which can lead to unexpected behavior and bugs.

The first call on line 51 appears to be a leftover from the previous implementation and should be removed. The correct implementation should only register the listener once.

    // preload's `on()` wraps the callback in an internal subscription function
    // and returns a cleanup function that removes that exact wrapper.  We MUST
    // use the returned cleanup rather than calling `off(channel, listener)`,
    // because `listener` !== the internal wrapper and removeListener would be
    // a no-op, leaking the subscription.
    const unsubscribe = ipc.on(ipcChannel, listener);
    if (typeof unsubscribe === 'function') {
      return unsubscribe;
    }
    // Fallback for environments where on() doesn't return cleanup
    return () => {
      ipc.off(ipcChannel, listener);
    };

@lsave
Copy link
Copy Markdown
Contributor Author

lsave commented Mar 27, 2026

/gemini review

Copy link
Copy Markdown

@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 new GatewayRecoveryOverlay component and associated state management logic to handle UI feedback when the OpenClaw gateway is restarting or fails to recover. It includes comprehensive unit tests for the recovery flow, updates to Chinese translations for consistency (renaming "Gateway" to "OpenClaw Service"), and a refactor of the host event subscription logic to better handle cleanup. The review feedback identifies unrelated layout changes in the update dialog that should be reverted to maintain scope.


{status === 'downloading' && progress && (
<div className="mt-4 rounded-2xl border border-black/6 bg-background/70 px-4 py-3 text-sm text-muted-foreground dark:border-white/10">
<div className="mt-4 rounded-2xl border border-black/6 bg-background/70 px-4 py-3 mr-5 text-sm text-muted-foreground dark:border-white/10">
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The mr-5 class was added here, but it seems unrelated to the main goals of this pull request, which are focused on the gateway recovery overlay and i18n copy. This might be an unintentional change that could affect the layout. If this margin is not required, it would be best to remove it to avoid unintended side effects.

Suggested change
<div className="mt-4 rounded-2xl border border-black/6 bg-background/70 px-4 py-3 mr-5 text-sm text-muted-foreground dark:border-white/10">
<div className="mt-4 rounded-2xl border border-black/6 bg-background/70 px-4 py-3 text-sm text-muted-foreground dark:border-white/10">


{status === 'downloaded' && autoInstallCountdown != null && autoInstallCountdown >= 0 && (
<div className="mt-4 rounded-2xl border border-black/6 bg-background/70 px-4 py-3 text-sm text-muted-foreground dark:border-white/10">
<div className="mt-4 rounded-2xl border border-black/6 bg-background/70 px-4 py-3 mr-5 text-sm text-muted-foreground dark:border-white/10">
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Similar to the change above, the mr-5 class was added here. This seems unrelated to the main goals of this pull request. If this margin is not required, it would be best to remove it to avoid unintended layout side effects.

Suggested change
<div className="mt-4 rounded-2xl border border-black/6 bg-background/70 px-4 py-3 mr-5 text-sm text-muted-foreground dark:border-white/10">
<div className="mt-4 rounded-2xl border border-black/6 bg-background/70 px-4 py-3 text-sm text-muted-foreground dark:border-white/10">

@lsave lsave merged commit 1380523 into main Mar 27, 2026
2 checks passed
@lsave lsave deleted the codex/gateway-recovery-overlay branch March 27, 2026 15:15
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