Skip to content

fix(tui): cycle workspace scope to a known workspace, not a hardcoded "default" - #4126

Open
udsy19 wants to merge 1 commit into
NVIDIA:mainfrom
udsy19:fix/tui-workspace-cycle-default
Open

udsy19 wants to merge 1 commit into
NVIDIA:mainfrom
udsy19:fix/tui-workspace-cycle-default

Conversation

@udsy19

@udsy19 udsy19 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Summary

The dashboard workspace-scope shortcut (w) permanently breaks for any principal whose visible workspace list does not contain "default": after one cycle it oscillates between the all scope and a nonexistent "default" workspace, and the named workspaces can never be selected again.

Root cause

App::cycle_workspace (crates/openshell-tui/src/app.rs) leaves the all scope by hardcoding self.current_workspace = "default", then walks forward via position(current) + 1. But workspace_names comes from the server's ListWorkspaces, which is membership-scoped per principal (openshell-server/src/grpc/workspace.rs::membership_filter_subject) — a non-admin only sees workspaces they belong to. If that list omits "default" (e.g. ["team-a","team-b"]), the next press has position("default") == None, hitting the wrap-to-all arm, so the selector is stuck between all and a phantom forever and the follow-up refresh queries a workspace the user isn't in.

Fix

Leave the all scope by returning to the first known workspace (workspace_names.first()), only entering named scope when at least one workspace is known. The stale current_workspace = "default" assignments in the all-scope branches are removed (unused while all_workspaces is set; workspace_display() returns "all").

Tests

cycle_workspace_without_default_stays_on_real_workspaces (app.rs): with ["team-a","team-b"], every named-scope landing must be a real workspace and both must be reachable. Fails before (cycled to 'default', which is not a known workspace), passes after. cargo test -p openshell-tui: 88 passed (the sibling default-first test still passes).

`cycle_workspace` hardcoded "default" when entering the named-workspace
scope from the "all" scope (and when wrapping around). This assumed the
server-provided `workspace_names` list always contains "default" and lists
it first.

That assumption does not hold: the TUI populates `workspace_names` from
`ListWorkspaces`, which is membership-scoped per principal. A non-admin
user who is not a member of the "default" workspace receives a list that
omits it entirely. In that case, after one full cycle the scope indicator
lands on "default" — a workspace that does not exist in the list — and the
next cycle finds no match, flipping straight back to "all". The user can
never return to any of their real workspaces by cycling.

Enter the named scope at `workspace_names.first()` instead, and only when
at least one workspace is known. The stale `current_workspace = "default"`
writes in the "all" branches are dropped since `current_workspace` is
unused while `all_workspaces` is set.

Signed-off-by: Udaya Tejas <udayatejas2004@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Oct 2, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@udsy19
udsy19 requested review from a team, derekwaynecarr, mrunalp and sjenning as code owners October 2, 2026 15:15
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

All contributors have signed the DCO ✍️ ✅
Posted by the DCO Assistant Lite bot.

@udsy19

udsy19 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

I have read the DCO document and I hereby sign the DCO.

@udsy19

udsy19 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

recheck

This branch has not been deployed

No deployments
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