Skip to content

feat(ui): S quits k10s into the pod shell in the real terminal - #38

Open
Devehab wants to merge 1 commit into
p10node:mainfrom
Devehab:feat/shell-out
Open

Devehab wants to merge 1 commit into
p10node:mainfrom
Devehab:feat/shell-out

Conversation

@Devehab

@Devehab Devehab commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Part 2 of #12. Part 1 is #34, and they don't touch the same lines.

S resolves the pod and container the same way s does, quits k10s, and main.go runs the shell in the terminal k10s was started from after p.Run() returns, same pattern as the /update relaunch. It prints k10s: shell into po/web-1 (namespace default) — exit the shell to get your prompt back first. k10s exits with the remote shell's exit code (CodeExitError), or 1 if the session itself fails.

  • domain.AShellOut ("shellout"), key S, label Shell (terminal), right under s. It sits next to AShell in podActions (k8s and mock) and isn't allowed in read-only.
  • Source.Shell runs in a tea.Cmd, since it's an API call. No shell (nil, nil or ErrNoShell) shows the no-shell toast and stays, other errors show the error, and a result that arrives after the view changed is dropped so it can't quit under you.
  • Store.Shell uses logTarget like ShellSession and maps ErrNoLogs to ErrNoShell.
  • Nothing on the quit path closes the source, and there's a test for that.
  • Help text, the README table, keybindings.md and ui.md mention it and say it quits k10s.

One difference from the issue: S is offered wherever s is, and today that's only Pods (wlActions has no AShell). So the "S on a Deployment" item isn't reachable from the UI yet. Store.Shell does resolve a Deployment to its pod now (tested), so adding AShell/AShellOut to wlActions is all it would take. I left that out because it changes what s offers too. Also, since the lookup is async, the "returned cmd is tea.Quit" check is on the Update that receives the result, not on fireAction itself.

Tests: internal/ui/external_shell_test.go covers quit + ExitShell(), the source staying open, the demo toast, a lookup error, a stale result, the S key and the Actions pane. S is added to the read-only key test and AShellOut to the domain read-only list. There's a k8s test that Shell lands on the same pod/container for a pod and a Deployment, and a main_test.go test for the exit code. I checked the new tests fail when I break the matching code. gofmt -l, go vet ./... and go test ./... pass, and the shell tests pass with -race. I haven't tried it against a live cluster.

Part 2 of p10node#12. S resolves the same pod and container as s, quits k10s,
and main.go runs the shell in the terminal k10s was started from, the
way /update's relaunch works. k10s exits with the shell's exit code.

- domain.AShellOut ("shellout"), key S, listed under s and offered
  where s is; not allowed in read-only.
- Source.Shell is resolved off the UI goroutine. No shell (demo) toasts
  and stays; a failed lookup shows the error; a result that arrives
  after the view changed is dropped.
- Store.Shell now uses logTarget like ShellSession, so it resolves
  workloads to a pod and returns ErrNoShell for kinds without one.
- Help text, README, keybindings.md and ui.md say that S quits k10s.

Signed-off-by: Ehab Kahwati <iehab.kahwati@gmail.com>

@junior junior left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice one, thanks! I tried it merged with current main and everything passes, -race included. It conflicts with main now (both sides added a test at the end of main_test.go), and it touches the same spot in main.go as #44, so I can merge main in once v0.1.10 is out, unless you'd rather do it yourself. Let's get it in right after v0.1.10.

@Devehab

Devehab commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for testing it! I'll merge main in myself once #44 and v0.1.10 are in, so both conflicts get sorted in one go.

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.

2 participants