Skip to content

feat(web): detect workbench session expiration and support reopening - #917

Merged
kyasbal merged 2 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-swulrskwnoqu
Aug 27, 2026
Merged

kyasbal merged 2 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-swulrskwnoqu

Conversation

@kyasbal

@kyasbal kyasbal commented Aug 27, 2026

Copy link
Copy Markdown
Member

Summary

This PR detects backend in-memory Workbench session expiration (e.g. after a 15-minute inactivity sweep) and guides the user to reconnect without losing their frontend inspection state.

Key Changes

  • Session Expiration Detection:
    • Periodically sends heartbeat pings to backend (every 5 minutes).
    • Pauses heartbeats when the document is hidden/backgrounded, and sends an immediate health check upon tab focus/visibility.
    • Detects expired sessions proactively via heartbeat response and reactively on RPC errors (Code.NotFound).
  • Session Timed Out Dialog (khi-session-timed-out):
    • Displays a modal dialog when the backend session expires, preventing broken UI states.
    • Offers two clear actions:
      • Reconnect / Retry: Invokes reopenWorkbench() with live progress reporting via ProgressDialogStatusUpdator.
      • Return to Startup: Closes the invalid session and navigates back to the startup screen.
  • Orchestration Service:
    • Introduced SessionTimeoutDialogService to monitor isWorkbenchExpired signal and manage dialog lifecycle.
  • Unit Tests & Storybook:
    • Comprehensive unit tests for SessionTimedOutLayoutComponent, SessionTimedOutSmartComponent, SessionTimeoutDialogService, and WorkbenchClientService.
    • Added Storybook stories for layout visual states (Default, Reconnecting, ErrorState).
Detect backend Workbench in-memory session expiration and guide user to reconnect.

- Periodically ping backend via heartbeat RPC (5-minute interval).
- Pause heartbeats when the tab is hidden and resume on visibility/focus.
- Proactively and reactively detect expired sessions (Code.NotFound / inactive heartbeat).
- Display a modal dialog (SessionTimedOut) allowing the user to reconnect and reload the dataset without losing frontend state, or return to startup.
- Track progress during reopening using ProgressDialog.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 session timeout handling mechanism, including a new timeout dialog layout and smart component, a dialog service to monitor session expiration, and updates to the workbench client service to support heartbeats and session reopening. The review feedback highlights several critical race conditions and logic improvements, such as preventing heartbeat restarts on expired sessions, adding defensive checks to handle session closure during in-flight reconnections, fixing a dialog reference race condition on close, and disabling navigation buttons during active reconnection attempts.

@kyasbal
kyasbal marked this pull request as ready for review August 27, 2026 05:22
@kyasbal
kyasbal merged commit ba9cb9f into GoogleCloudPlatform:main Aug 27, 2026
16 checks passed
@kyasbal
kyasbal deleted the push-swulrskwnoqu branch August 27, 2026 05:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant