Skip to content

CONSOLE-5183: Add persistent pod terminal sessions to Cloud Shell drawer#16269

Open
BabbarPB08 wants to merge 1 commit intoopenshift:mainfrom
BabbarPB08:feat/persistent-terminal-sessions
Open

CONSOLE-5183: Add persistent pod terminal sessions to Cloud Shell drawer#16269
BabbarPB08 wants to merge 1 commit intoopenshift:mainfrom
BabbarPB08:feat/persistent-terminal-sessions

Conversation

@BabbarPB08
Copy link
Copy Markdown

@BabbarPB08 BabbarPB08 commented Apr 10, 2026

CONSOLE Features and Fixes

Jira: https://issues.redhat.com/browse/RFE-6966

Solution description

Adds the ability to "detach" a pod or node debug terminal session into the Cloud Shell drawer so it persists across page navigation. This addresses a long-standing RFE where users lose their terminal session when navigating away from a pod's terminal tab.

Changes:

  • Redux layer (cloud-shell-actions.ts, cloud-shell-reducer.ts, cloud-shell-selectors.ts):
    New actions, reducer state, and selectors for managing detached sessions
  • DetachedPodExec.tsx (new): Component that renders a detached pod terminal; adopts a transferred WebSocket or falls back to a fresh exec connection
  • detached-ws-registry.ts (new): Global registry for handing off live WebSocket connections from PodConnect to DetachedPodExec
  • MultiTabbedTerminal.tsx: Renders detached sessions as additional tabs; hides Cloud Shell tabs when Web Terminal Operator is not installed; auto-selects newly detached tab; suppresses Cloud Shell keepalive ticks on detached tabs
  • CloudShellDrawer.tsx: Conditionally hides "Open terminal in new tab" when DevWorkspace is unavailable; shows session counter badge (X/5 detached)
  • CloudShell.tsx: Opens drawer when detached sessions exist, even without DevWorkspace
  • cloud-shell-dispatchers.ts: Clears detached sessions on drawer close
  • pod-connect.tsx: Adds "Detach to Cloud Shell" button; transfers live WebSocket to registry on detach; skips sending exit on cleanup when detached; disables button at session limit with informative tooltip
  • NodeTerminal.tsx: Sets stdinOnce: false so debug pods survive attach disconnection; preserves debug namespace when session is detached
  • debug-terminal.tsx: Skips debug pod deletion when the pod is detached to the drawer

Key behaviors:

  • Works with or without the Web Terminal Operator installed
  • Max 5 detached sessions; new detach is blocked at the limit (not evicted) with a tooltip explaining the cap
  • Session counter (X/5 detached) shown in drawer header when detached sessions exist
  • WebSocket handoff: the live connection is transferred from PodConnect to DetachedPodExec, avoiding a second exec/attach call (critical for node debug pods where exec may fail)
  • Node debug terminals: stdinOnce:false keeps the pod alive after the original attach disconnects; namespace cleanup is skipped for detached sessions
  • Closing the drawer clears all detached sessions
  • Closing the last detached tab (when no Cloud Shell tabs) closes the drawer

Test cases

  1. Navigate to a running pod > Terminal tab > click "Detach to Cloud Shell"
    • Drawer opens with the detached pod terminal as the active tab
  2. Navigate away from the pod page > drawer persists with a live terminal
  3. Navigate to a node > Terminal tab > click "Detach to Cloud Shell"
    • Drawer opens; switch to Overview tab on the node page > detached terminal stays connected
  4. Detach 5 sessions > the "Detach to Cloud Shell" button is disabled with a tooltip explaining the limit
  5. Close a detached tab > counter updates; close the last tab > drawer closes
  6. Close Terminal button > drawer closes and all detached sessions are cleared
  7. Without Web Terminal Operator: no "Terminal 1" tab, no "Open in new tab" button, no "+" button

Additional info

Screenshots

Screenshot From 2026-04-10 21-05-38

@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@BabbarPB08: No Jira issue with key OCPBUGS-0000 exists in the tracker at https://redhat.atlassian.net.
Once a valid jira issue is referenced in the title of this pull request, request a refresh with /jira refresh.

Details

In response to this:

CONSOLE Features and Fixes

Jira: https://issues.redhat.com/browse/RFE-6966

Solution description

Adds the ability to "detach" a pod terminal session into the Cloud Shell drawer so it persists
across page navigation. This addresses a long-standing RFE where users lose their terminal
session when navigating away from a pod's terminal tab.

Changes:

  • Redux layer (cloud-shell-actions.ts, cloud-shell-reducer.ts, cloud-shell-selectors.ts):
    New actions, reducer state, and selectors for managing detached sessions
  • DetachedPodExec.tsx (new): Component that renders a detached pod terminal via WebSocket
  • MultiTabbedTerminal.tsx: Renders detached sessions as additional tabs; hides Cloud Shell
    tabs when Web Terminal Operator is not installed; auto-selects newly detached tab
  • CloudShellDrawer.tsx: Conditionally hides "Open terminal in new tab" when DevWorkspace is unavailable
  • CloudShell.tsx: Opens drawer when detached sessions exist, even without DevWorkspace
  • cloud-shell-dispatchers.ts: Clears detached sessions on drawer close
  • pod-connect.tsx: Adds "Detach to Cloud Shell" button to pod terminal toolbar

Key behaviors:

  • Works with or without the Web Terminal Operator installed
  • Max 5 detached sessions (oldest evicted), max 8 total tabs
  • Closing the drawer clears all detached sessions
  • Closing the last detached tab (when no Cloud Shell tabs) closes the drawer

Reviewers and assignees

@openshift/team-ux-review (UI changes)

Test cases

  1. Navigate to a running pod → Terminal tab → click "Detach to Cloud Shell"
    → Drawer opens with the detached pod terminal as the active tab
  2. Navigate away from the pod page → drawer persists with a live terminal
  3. Close the detached tab → drawer closes (when no other tabs)
  4. Close Terminal button → drawer closes and all detached sessions are cleared
  5. Without Web Terminal Operator: no "Terminal 1" tab, no "Open in new tab" button, no "+" button

Additional info

Screenshots

Screenshot From 2026-04-10 21-05-38

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested review from Leo6Leo and sg00dwin April 10, 2026 15:37
@openshift-ci openshift-ci bot added the component/core Related to console core functionality label Apr 10, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 10, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: BabbarPB08
Once this PR has been reviewed and has the lgtm label, please assign vikram-raj for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 10, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 10, 2026

Hi @BabbarPB08. Thanks for your PR.

I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@BabbarPB08: No Jira issue with key OCPBUGS-0000 exists in the tracker at https://redhat.atlassian.net.
Once a valid jira issue is referenced in the title of this pull request, request a refresh with /jira refresh.

Details

In response to this:

CONSOLE Features and Fixes

Jira: https://issues.redhat.com/browse/RFE-6966

Solution description

Adds the ability to "detach" a pod terminal session into the Cloud Shell drawer so it persists
across page navigation. This addresses a long-standing RFE where users lose their terminal
session when navigating away from a pod's terminal tab.

Changes:

  • Redux layer (cloud-shell-actions.ts, cloud-shell-reducer.ts, cloud-shell-selectors.ts):
    New actions, reducer state, and selectors for managing detached sessions
  • DetachedPodExec.tsx (new): Component that renders a detached pod terminal via WebSocket
  • MultiTabbedTerminal.tsx: Renders detached sessions as additional tabs; hides Cloud Shell
    tabs when Web Terminal Operator is not installed; auto-selects newly detached tab
  • CloudShellDrawer.tsx: Conditionally hides "Open terminal in new tab" when DevWorkspace is unavailable
  • CloudShell.tsx: Opens drawer when detached sessions exist, even without DevWorkspace
  • cloud-shell-dispatchers.ts: Clears detached sessions on drawer close
  • pod-connect.tsx: Adds "Detach to Cloud Shell" button to pod terminal toolbar

Key behaviors:

  • Works with or without the Web Terminal Operator installed
  • Max 5 detached sessions (oldest evicted), max 8 total tabs
  • Closing the drawer clears all detached sessions
  • Closing the last detached tab (when no Cloud Shell tabs) closes the drawer

Reviewers and assignees

@openshift/team-ux-review (UI changes)

Test cases

  1. Navigate to a running pod → Terminal tab → click "Detach to Cloud Shell"
    → Drawer opens with the detached pod terminal as the active tab
  2. Navigate away from the pod page → drawer persists with a live terminal
  3. Close the detached tab → drawer closes (when no other tabs)
  4. Close Terminal button → drawer closes and all detached sessions are cleared
  5. Without Web Terminal Operator: no "Terminal 1" tab, no "Open in new tab" button, no "+" button

Additional info

Screenshots

Screenshot From 2026-04-10 21-05-38

Summary by CodeRabbit

Release Notes

  • New Features
  • Added support for detached terminal sessions that persist independently within Cloud Shell
  • Users can now detach pod terminal connections to keep them running in the background
  • Cloud Shell drawer displays detached sessions even when not actively expanded
  • Support for managing multiple detached sessions (up to 8 concurrent sessions)

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 10, 2026

📝 Walkthrough

Walkthrough

This pull request introduces detached cloud shell sessions, enabling users to open individual pod terminal connections as separate, persistent tabs within the cloud shell drawer. The implementation adds a new DetachedPodExec component for WebSocket-based pod exec communication with base64 encoding, extends Redux state management with detached session actions and reducers (capping at 8 sessions with deduplication), and integrates feature-flag gating around detached functionality. The cloud shell drawer now renders when either expanded or when detached sessions exist. The multi-tabbed terminal dynamically manages both numeric and detached-session tabs with unified close handling, while the pod-connect UI gains a "Detach to Cloud Shell" button to dispatch new detached sessions.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
frontend/packages/webterminal-plugin/src/redux/reducers/cloud-shell-reducer.ts (1)

11-53: ⚠️ Potential issue | 🟠 Major

Detached-session cap/eviction logic does not match required behavior.

This reducer currently uses cap 8 and drops new sessions at limit. Required behavior is max 5 detached sessions with oldest eviction.

Proposed fix
-const MAX_DETACHED_SESSIONS = 8;
+const MAX_DETACHED_SESSIONS = 5;
...
     case Actions.AddDetachedSession: {
-      if (state.detachedSessions.length >= MAX_DETACHED_SESSIONS) {
-        return state;
-      }
-      if (state.detachedSessions.some((s) => s.id === action.payload.id)) {
-        return state;
-      }
+      const withoutDuplicate = state.detachedSessions.filter((s) => s.id !== action.payload.id);
+      const next = [...withoutDuplicate, action.payload].slice(-MAX_DETACHED_SESSIONS);
       return {
         ...state,
-        detachedSessions: [...state.detachedSessions, action.payload],
+        detachedSessions: next,
       };
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@frontend/packages/webterminal-plugin/src/redux/reducers/cloud-shell-reducer.ts`
around lines 11 - 53, The detached-session cap and eviction are wrong: change
MAX_DETACHED_SESSIONS from 8 to 5 and update the AddDetachedSession handling so
that when adding a new session (in the reducer case Actions.AddDetachedSession)
you still skip duplicates (state.detachedSessions.some(...)) but instead of
returning state when length >= MAX_DETACHED_SESSIONS you evict the oldest
session and append the new one (e.g., create a new detachedSessions array by
slicing off the first element and concatenating the incoming action.payload) so
the array never exceeds MAX_DETACHED_SESSIONS and oldest sessions are removed
first.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@frontend/packages/webterminal-plugin/src/components/cloud-shell/MultiTabbedTerminal.tsx`:
- Around line 58-64: When switching focus to a detached tab in
MultiTabbedTerminal (the useEffect that watches detachedSessions and calls
setActiveTabKey with `${DETACHED_PREFIX}${newest.id}`), we must also stop the
activity keepalive by clearing tickNamespace and tickWorkspace so the RAF loop
no longer calls sendActivityTick for the old Cloud Shell; update the same logic
paths (the detached switch at lines referenced and any other tab-switch handlers
around handleTabChange/openTab/closeTab) to explicitly reset tickNamespace and
tickWorkspace (or invoke the existing stop/cleanup method that halts
sendActivityTick) whenever the active tab becomes a detached tab (detect via
DETACHED_PREFIX) or when the last Cloud Shell tab is closed so the RAF loop
stops.
- Around line 26-27: The component currently initializes and updates
terminalTabs and activeTabKey based on counts which breaks when detachedSessions
mount with existing items or when sessions are replaced; update logic to derive
terminalTabs and activeTabKey from detachedSessions identities (e.g., use
detachedSessions.map(s => s.id) or keys) rather than detachedSessions.length,
initialize useState from that identity list, and add a useEffect watching
detachedSessions to: 1) replace terminalTabs with the current detached session
ids, and 2) if activeTabKey is missing or points to a removed id,
setActiveTabKey to the first detached session id (or a sensible fallback).
Target the functions/state variables terminalTabs, setTerminalTabs,
activeTabKey, setActiveTabKey and the detachedSessions reducer-derived value.

In
`@frontend/packages/webterminal-plugin/src/redux/actions/cloud-shell-dispatchers.ts`:
- Around line 53-59: The click handler toggles expansion when isExpanded ===
false but detachedSessions.length > 0, causing the drawer to open instead of
invoking the detached-session close flow; update the useCallback in
cloud-shell-dispatchers so that if detachedSessions.length > 0 you call
confirmClose() (or the existing detached-session clear/close routine) regardless
of isExpanded, otherwise fall back to
dispatch(setCloudShellExpanded(!isExpanded)); adjust the conditional logic
around isExpanded, isActive, detachedSessions.length and keep confirmClose,
setCloudShellExpanded, isExpanded, isActive and detachedSessions references
intact.

In `@frontend/public/components/pod-connect.tsx`:
- Around line 160-172: The detached session is missing the shell/command context
so DetachedPodExec falls back to /bin/sh; update the detachToCloudShell caller
to include the current exec command when dispatching addDetachedSession (e.g.,
add a command property populated from the current session state/variable that
holds the shell or exec command), and ensure the DetachedPodExec consumer reads
that command from the DetachedSession object to use instead of defaulting to
/bin/sh; adjust the addDetachedSession payload and any related types/interfaces
accordingly so the command is persisted and restored on reconnect.

---

Outside diff comments:
In
`@frontend/packages/webterminal-plugin/src/redux/reducers/cloud-shell-reducer.ts`:
- Around line 11-53: The detached-session cap and eviction are wrong: change
MAX_DETACHED_SESSIONS from 8 to 5 and update the AddDetachedSession handling so
that when adding a new session (in the reducer case Actions.AddDetachedSession)
you still skip duplicates (state.detachedSessions.some(...)) but instead of
returning state when length >= MAX_DETACHED_SESSIONS you evict the oldest
session and append the new one (e.g., create a new detachedSessions array by
slicing off the first element and concatenating the incoming action.payload) so
the array never exceeds MAX_DETACHED_SESSIONS and oldest sessions are removed
first.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 73755716-b690-47b9-b8a4-7b67e60e6ca4

📥 Commits

Reviewing files that changed from the base of the PR and between 8390b37 and cc61cce.

📒 Files selected for processing (9)
  • frontend/packages/webterminal-plugin/src/components/cloud-shell/CloudShell.tsx
  • frontend/packages/webterminal-plugin/src/components/cloud-shell/CloudShellDrawer.tsx
  • frontend/packages/webterminal-plugin/src/components/cloud-shell/DetachedPodExec.tsx
  • frontend/packages/webterminal-plugin/src/components/cloud-shell/MultiTabbedTerminal.tsx
  • frontend/packages/webterminal-plugin/src/redux/actions/cloud-shell-actions.ts
  • frontend/packages/webterminal-plugin/src/redux/actions/cloud-shell-dispatchers.ts
  • frontend/packages/webterminal-plugin/src/redux/reducers/cloud-shell-reducer.ts
  • frontend/packages/webterminal-plugin/src/redux/reducers/cloud-shell-selectors.ts
  • frontend/public/components/pod-connect.tsx
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • frontend/packages/webterminal-plugin/src/components/cloud-shell/CloudShellDrawer.tsx
  • frontend/packages/webterminal-plugin/src/redux/reducers/cloud-shell-selectors.ts
  • frontend/packages/webterminal-plugin/src/components/cloud-shell/CloudShell.tsx
  • frontend/public/components/pod-connect.tsx
  • frontend/packages/webterminal-plugin/src/redux/actions/cloud-shell-actions.ts
  • frontend/packages/webterminal-plugin/src/redux/actions/cloud-shell-dispatchers.ts
  • frontend/packages/webterminal-plugin/src/redux/reducers/cloud-shell-reducer.ts
  • frontend/packages/webterminal-plugin/src/components/cloud-shell/MultiTabbedTerminal.tsx
  • frontend/packages/webterminal-plugin/src/components/cloud-shell/DetachedPodExec.tsx
🔇 Additional comments (5)
frontend/packages/webterminal-plugin/src/components/cloud-shell/CloudShellDrawer.tsx (1)

79-88: Good feature-flag guard for the external terminal link.

This keeps the action hidden when DevWorkspace is unavailable and prevents a dead-end UX path.

frontend/packages/webterminal-plugin/src/redux/reducers/cloud-shell-selectors.ts (1)

28-33: Selector + hook addition looks solid.

The null-safe fallback to [] is a good defensive default for downstream tab logic.

frontend/packages/webterminal-plugin/src/components/cloud-shell/CloudShell.tsx (1)

23-27: This correctly enables detached-session-only drawer rendering.

The open || hasDetachedSessions behavior aligns with the persistent detached tab UX.

frontend/packages/webterminal-plugin/src/redux/actions/cloud-shell-actions.ts (1)

4-44: Action/type additions are clean and consistent.

The detached-session action surface is well-structured and integrates cleanly into the existing typed action union.

frontend/packages/webterminal-plugin/src/components/cloud-shell/DetachedPodExec.tsx (1)

51-134: WebSocket lifecycle and reconnect flow are implemented cleanly.

Connection setup, teardown, and error-to-reconnect UX are well structured for detached terminal sessions.

@BabbarPB08 BabbarPB08 changed the title OCPBUGS-0000: Add persistent pod terminal sessions to Cloud Shell drawer CONSOLE-5183: Add persistent pod terminal sessions to Cloud Shell drawer Apr 10, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 10, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

openshift-ci-robot commented Apr 10, 2026

@BabbarPB08: This pull request references CONSOLE-5183 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

CONSOLE Features and Fixes

Jira: https://issues.redhat.com/browse/RFE-6966

Solution description

Adds the ability to "detach" a pod terminal session into the Cloud Shell drawer so it persists
across page navigation. This addresses a long-standing RFE where users lose their terminal
session when navigating away from a pod's terminal tab.

Changes:

  • Redux layer (cloud-shell-actions.ts, cloud-shell-reducer.ts, cloud-shell-selectors.ts):
    New actions, reducer state, and selectors for managing detached sessions
  • DetachedPodExec.tsx (new): Component that renders a detached pod terminal via WebSocket
  • MultiTabbedTerminal.tsx: Renders detached sessions as additional tabs; hides Cloud Shell
    tabs when Web Terminal Operator is not installed; auto-selects newly detached tab
  • CloudShellDrawer.tsx: Conditionally hides "Open terminal in new tab" when DevWorkspace is unavailable
  • CloudShell.tsx: Opens drawer when detached sessions exist, even without DevWorkspace
  • cloud-shell-dispatchers.ts: Clears detached sessions on drawer close
  • pod-connect.tsx: Adds "Detach to Cloud Shell" button to pod terminal toolbar

Key behaviors:

  • Works with or without the Web Terminal Operator installed
  • Max 5 detached sessions (oldest evicted), max 8 total tabs
  • Closing the drawer clears all detached sessions
  • Closing the last detached tab (when no Cloud Shell tabs) closes the drawer

Reviewers and assignees

@openshift/team-ux-review (UI changes)

Test cases

  1. Navigate to a running pod → Terminal tab → click "Detach to Cloud Shell"
    → Drawer opens with the detached pod terminal as the active tab
  2. Navigate away from the pod page → drawer persists with a live terminal
  3. Close the detached tab → drawer closes (when no other tabs)
  4. Close Terminal button → drawer closes and all detached sessions are cleared
  5. Without Web Terminal Operator: no "Terminal 1" tab, no "Open in new tab" button, no "+" button

Additional info

Screenshots

Screenshot From 2026-04-10 21-05-38

Summary by CodeRabbit

Release Notes

  • New Features
  • Added support for detached terminal sessions that persist independently within Cloud Shell
  • Users can now detach pod terminal connections to keep them running in the background
  • Cloud Shell drawer displays detached sessions even when not actively expanded
  • Support for managing multiple detached sessions (up to 8 concurrent sessions)

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@BabbarPB08
Copy link
Copy Markdown
Author

/jira refresh

@openshift-ci-robot
Copy link
Copy Markdown
Contributor

openshift-ci-robot commented Apr 10, 2026

@BabbarPB08: This pull request references CONSOLE-5183 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@BabbarPB08 BabbarPB08 force-pushed the feat/persistent-terminal-sessions branch from cc61cce to fa69c1d Compare April 10, 2026 15:52
Integrates detachable terminal sessions into the existing Cloud Shell
drawer, allowing pod and node debug terminals to persist across page
navigation.

Key changes:
- WebSocket handoff: when detaching, the live WebSocket is transferred
  from PodConnect to DetachedPodExec via a global registry, avoiding
  the need for a second exec/attach connection.
- PodConnect skips sending 'exit' on cleanup when a session is detached,
  keeping the underlying pod alive.
- Node debug pods use stdinOnce:false so the container survives attach
  disconnection; namespace cleanup is skipped for detached sessions.
- Debug terminal pod deletion is skipped when the pod is detached.
- Session limit capped at 5 with the detach button disabled at the cap
  and a counter badge shown in the drawer header.
- Cloud Shell keepalive ticks are suppressed for detached pod tabs.
- Drawer close handler properly clears detached sessions.
@BabbarPB08 BabbarPB08 force-pushed the feat/persistent-terminal-sessions branch from fa69c1d to 6dd5268 Compare April 10, 2026 19:59
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

openshift-ci-robot commented Apr 10, 2026

@BabbarPB08: This pull request references CONSOLE-5183 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

CONSOLE Features and Fixes

Jira: https://issues.redhat.com/browse/RFE-6966

Solution description

Adds the ability to "detach" a pod or node debug terminal session into the Cloud Shell drawer so it persists across page navigation. This addresses a long-standing RFE where users lose their terminal session when navigating away from a pod's terminal tab.

Changes:

  • Redux layer (cloud-shell-actions.ts, cloud-shell-reducer.ts, cloud-shell-selectors.ts):
    New actions, reducer state, and selectors for managing detached sessions
  • DetachedPodExec.tsx (new): Component that renders a detached pod terminal; adopts a transferred WebSocket or falls back to a fresh exec connection
  • detached-ws-registry.ts (new): Global registry for handing off live WebSocket connections from PodConnect to DetachedPodExec
  • MultiTabbedTerminal.tsx: Renders detached sessions as additional tabs; hides Cloud Shell tabs when Web Terminal Operator is not installed; auto-selects newly detached tab; suppresses Cloud Shell keepalive ticks on detached tabs
  • CloudShellDrawer.tsx: Conditionally hides "Open terminal in new tab" when DevWorkspace is unavailable; shows session counter badge (X/5 detached)
  • CloudShell.tsx: Opens drawer when detached sessions exist, even without DevWorkspace
  • cloud-shell-dispatchers.ts: Clears detached sessions on drawer close
  • pod-connect.tsx: Adds "Detach to Cloud Shell" button; transfers live WebSocket to registry on detach; skips sending exit on cleanup when detached; disables button at session limit with informative tooltip
  • NodeTerminal.tsx: Sets stdinOnce: false so debug pods survive attach disconnection; preserves debug namespace when session is detached
  • debug-terminal.tsx: Skips debug pod deletion when the pod is detached to the drawer

Key behaviors:

  • Works with or without the Web Terminal Operator installed
  • Max 5 detached sessions; new detach is blocked at the limit (not evicted) with a tooltip explaining the cap
  • Session counter (X/5 detached) shown in drawer header when detached sessions exist
  • WebSocket handoff: the live connection is transferred from PodConnect to DetachedPodExec, avoiding a second exec/attach call (critical for node debug pods where exec may fail)
  • Node debug terminals: stdinOnce:false keeps the pod alive after the original attach disconnects; namespace cleanup is skipped for detached sessions
  • Closing the drawer clears all detached sessions
  • Closing the last detached tab (when no Cloud Shell tabs) closes the drawer

Test cases

  1. Navigate to a running pod > Terminal tab > click "Detach to Cloud Shell"
  • Drawer opens with the detached pod terminal as the active tab
  1. Navigate away from the pod page > drawer persists with a live terminal
  2. Navigate to a node > Terminal tab > click "Detach to Cloud Shell"
  • Drawer opens; switch to Overview tab on the node page > detached terminal stays connected
  1. Detach 5 sessions > the "Detach to Cloud Shell" button is disabled with a tooltip explaining the limit
  2. Close a detached tab > counter updates; close the last tab > drawer closes
  3. Close Terminal button > drawer closes and all detached sessions are cleared
  4. Without Web Terminal Operator: no "Terminal 1" tab, no "Open in new tab" button, no "+" button

Additional info

Screenshots

Screenshot From 2026-04-10 21-05-38

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@BabbarPB08
Copy link
Copy Markdown
Author

/jira refresh

@openshift-ci-robot
Copy link
Copy Markdown
Contributor

openshift-ci-robot commented Apr 11, 2026

@BabbarPB08: This pull request references CONSOLE-5183 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@BabbarPB08
Copy link
Copy Markdown
Author

/jira refresh

@openshift-ci-robot
Copy link
Copy Markdown
Contributor

openshift-ci-robot commented Apr 11, 2026

@BabbarPB08: This pull request references CONSOLE-5183 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/core Related to console core functionality jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants