Skip to content

Stage 3: Gio port of the main window (cmd/leanterm-native) - #11

Merged
Suvukaraz merged 16 commits into
claude/web-layer-go-fyne-migration-hhprm8from
arena/16ff4199-leanterm
Nov 20, 2026
Merged

Suvukaraz merged 16 commits into
claude/web-layer-go-fyne-migration-hhprm8from
arena/16ff4199-leanterm

Conversation

@Suvukaraz

Copy link
Copy Markdown
Owner

Summary

Stage 3 of the Gio migration: the web GUI's main window is ported to a pure-Go GUI under cmd/leanterm-native, built on the gtk widget set (internal/gui/gtk) instead of the Wails/Svelte frontend.

Heads-up on the base: this branch is cut from claude/web-layer-go-fyne-migration-hhprm8 (the migration line), not from main — the two have no common history, so this PR deliberately contains only this branch's 9 commits.

What's in it

cmd/leanterm-native — the MainWindow.svelte equivalent on Gio:

  • connection tree (render/expand), notebook with tabs and splits, per-tab terminal views, engine selection (ghostty/vt)
  • command panel / button bar wiring, toolbar buttons, quit chain (editor-unsaved → running SFTP transfers → open sessions → ConfirmExit), delete confirmation, lock overlay
  • search panel with web-GUI keys (Enter = next, Shift+Enter = previous, Escape = close), global shortcuts (F9/F2/Delete/Ctrl+F/Ctrl+S/Ctrl+Alt+L/Ctrl+Q) gated on terminal-focus and dialog state
  • context menus (tree, tabs) with keyboard navigation and window-edge clamping, add/rename/delete/quit dialogs, notes persistence, info tab with cached screenshot thumbnails
  • -quit-after self-test flag that exits through the UI thread; drops on Windows via Win32 subclassing (internal/gui/dnd)

Enabling work in internal/gui/gtk and internal/services:

  • Paned: NewPaned() with a negative "unset" sentinel (even split) and Force50 (the web GUI's "Force split tabs to 50%" option, which also disables the drag); context menus clamp to the window; popup positioning; TextArea, Logo, stage-3 icons, shift-click range selection
  • Dialog: gradient banner for AddRenameNode-style dialogs; SystemService.Version; SftpService.RunningTransfers for the quit-confirmation
  • Prompter on gtk.Dialog (like PromptDialog.svelte); Escape closes the confirm dialogs as "No" (editor-unsaved case → shows the editor, matching QuitConfirm.svelte)

Verification

  • Headless Linux: builds with -tags "nowayland nox11 novulkan", go vet clean, gofmt clean, go test ./internal/... all pass
  • go.mod is untouched (no replace directives committed)

Not verified at runtime — no X display was available in the build environment. On a desktop (or in CI), check: tree expand, connections open/focus, toolbar buttons, quit chain incl. the editor-unsaved No → editor path, lock overlay, notes persist, screenshots render, split rendering and ForceSplit50, search keys, and DnD on Windows. Note .github/workflows/gio.yml only triggers on main and claude/** and currently covers cmd/leanterm-gio; it does not exercise cmd/leanterm-native yet.

Known gaps (later stages)

  • No native file chooser yet (services report a user-visible error instead)
  • LeanEdit is stage 7 — "show the editor" is a stub, drops only report paths
  • X11/Wayland drops are not supported by Gio (Windows only for now)

Arena and others added 16 commits November 19, 2026 23:12
The backend's questions are now answered in the same dialogs as the web
GUI: host key decisions and confirmations render their option buttons
(default = first for unknown host keys and confirmations, no default for
changed keys), other requests render their options as a choice list or
one text field per field (secrets behind a Show checkbox, Remember
available when asked). Enter in a field submits, Return picks the
default, Escape cancels; the dialog re-queues like before.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Tree rows can be dragged onto a group (or the root) to move them, like
the web GUI's TreeView: the press arms a drag, a 4px threshold activates
it (the pointer is grabbed, losing handlers get Cancel), the drop target
lights up in a faded accent, an invalid target (a connection, a dragged
node or one of its descendants) shows a not-allowed cursor. Releasing on
a valid target emits TreeDrop with the dragged ids (the selection when
the pressed row is in it, else the row alone).

Notebook tabs can be dragged to another position when Reorderable is
set: a 3px accent insertion line shows where the tab would land,
releasing emits TabMoved{From,To} and the moved tab stays selected.
The web GUI has no tab moving; LeanTerm's tabs can be moved (stage 3).

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…ction

- gtk.TextArea: multiline area styled like Entry (padding 8px, focus
  border, mono font option) for the info page's notes field.
- gtk.Logo: LeanTerm_Icon.svg redrawn with Gio paths (gradients, SFTP
  sidebar, SSH prompt, frame); no SVG rasterizer is available.
- fonts: Nerd Fonts glyphs the main window needs (save, copy, cut,
  paste, play, star outline, list, minus, edit, exchange, question,
  external link, file, folder-plus, undo/redo, stop, globe);
  TestSymbolsFontHasAllIcons verifies them.
- gtk.Tree: Shift adds to the selection (like the web GUI).
- Interaction tests for TextArea (types, disabled ignores input) and
  Logo (square size).

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
The web quit confirmation counts transfers from the frontend store; the
native GUI has no Go-side query for in-flight downloads/uploads. Count
them in the manager instead (incremented for the whole
Download/UploadWithOptions call, the way the web counts a transfer until
the service call resolves).

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
- gtk.Dialog gets a Banner field rendering .banner-fill (light:
  #007aff to #2fedde, dark: #1f5fa8 to #1a8f88 gradient, 2.2em bold
  text) instead of the title bar, like Dialog.svelte's bannerText.
- services.SystemService.Version returns 1.2.1 (matches
  frontend/package.json); the About dialog reads it from there.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
cmd/leanterm-native: the web GUI's MainWindow on the gtk widget set -
connection tree, notebook with splits (ForceSplit50), per-tab engines,
search panel (Enter/Shift+Enter/Escape), global shortcuts, command and
tab context menus, add/rename/delete/quit chain with the editor-unsaved
check, lock overlay, info tab, notes persistence, drops, focus fixes.

gtk: Paned gets NewPaned/-1 unset sentinel and Force50; context menus
clamp to the window; Stack alignment fix in the native layout.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Escape/the close button answers 'cancel', which the quit chain treats as
'No' (editor-unsaved case shows the editor, otherwise nothing).

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
The grid is painted every frame; decode+scale the PNG only when the file
on disk changed (mtime+size), bounding the cache to 32 entries.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
The timer only requests the quit (flag + invalidate); the frame loop calls
exitNow, so closeAll no longer races the event loop and UI state/saves run
through the normal path.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
The Go fallbacks were registered under the same name, weight and style
as the faces from fontconfig, and Gio picked the Go ones: the GUI used Go
instead of Inter (a wide hyphen, "demo–ssh") and Go Mono in terminals.
The fallbacks are now only added where no system face exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015aXakHn68PyjDGZEbyyGFD
- gtk.Tree recomputes its rows after input, so an expanded group shows
  its children in the click's frame; Tree and Notebook ask for another
  frame when they queue events (callers read them before Layout).
  Before, the window only updated on the next pointer move.
- The tree's root is expanded at startup and stays so on Collapse all
  (TreeView.svelte).
- The pointer position for context menus comes from a pass-through area
  on top of the window; the old one lay below all others and only saw
  the pointer where nothing else was, so menus opened at the top left.
- Edit connection(s) and Copy Password are enabled like in
  ConnectionTree.svelte (Edit reports that its window is not ported).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015aXakHn68PyjDGZEbyyGFD
- Button bar as MainButtonBar.svelte: normal GTK buttons with colored
  icons, padding 3px 6px, the bg-to-header gradient, the full width
  (it was CP buttons and left a white strip on the right).
- Info page as ConnectionPanel.svelte's welcome box: monospace, the
  bordered box, title/subtitle/logo/list sized with the CSS clamp()s of
  the window width, logo and list side by side or wrapped.
- The Info tab is there from the start; its icon is the light bulb.
- Terminal tabs: the title without the engine, the status color on the
  title (bold) like Notebook.svelte, not on the icon.
- Terminal status bar as TerminalTab.svelte's: 30px, 11px text, the
  terminal and cluster icons, "Status: <last message or state>", the
  file browser toggle (its panel is stage 5) and the Info button.
- The left notebook keeps its tabs across frames: they were recreated
  every frame, which lost their clicks (Favourites/History could not be
  selected). Their icons are colored like the web GUI's.
- Tree: the root's orange network icon; colored toolbar icons.
- gtk: Button.IconColor, Text.Widget, line height for wrapped text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015aXakHn68PyjDGZEbyyGFD
… the keys

- gtk.Menu's dismiss area passes the click on: like ContextMenu.svelte
  (which closes on pointerdown without stopping it), a click on a button
  closes the menu and presses the button. Before, the first click after
  a menu only closed it.
- While a tree or tab menu is open, the window's global keys are off, so
  Escape reaches the menu (it was taken by the search's Escape).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015aXakHn68PyjDGZEbyyGFD
- gio.yml builds cmd/leanterm-native for Linux and Windows (and runs on
  its changes); under Xvfb it opens build/gio/demo-config, expands a
  group, opens the tree menu and a local shell (screenshots as
  artifacts) and checks that -quit-after exits cleanly; on Windows it
  starts and quits the window.
- docs/gio-migration.md: stage 3, the side-by-side check against the
  Wails build and the findings (shadowed system fonts, redraws, widget
  state across frames, pointer position, synthetic clicks).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015aXakHn68PyjDGZEbyyGFD
When no frame comes to quit in within 10s, the self-test logs all
goroutine stacks and exits with code 3; the Windows CI step prints the
log in every case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015aXakHn68PyjDGZEbyyGFD
Subscribing the window in the ViewEvent handler deadlocked with Gio's
window thread (stage 0's finding), so the window hung at its start; the
new CI run showed it. dnd.Enable runs in a goroutine as in the
prototype, once per window, and the CI checks that drops are enabled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015aXakHn68PyjDGZEbyyGFD
@Suvukaraz
Suvukaraz merged commit eff29e8 into claude/web-layer-go-fyne-migration-hhprm8 Nov 20, 2026
3 checks passed
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