3 Commits
Author SHA1 Message Date
terminarandClaude Opus 5.5 586e76889c gui/window (Windows): give the keyboard focus to WebView2
The host window never moved the focus into the WebView2 control, so a
page got no keys after the start or after Alt-Tab until it was
clicked. Move it on WM_SETFOCUS and once the control exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 21:34:08 +01:00
terminarandClaude Opus 5.5 5dd4a86b68 TODO: core/gui resident app with a prewarmed WebView (proposal from yamc)
Startup measurements on macOS and what was tried without effect.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 21:15:35 +01:00
terminarandClaude Opus 5.5 975340b5f7 fix(configcmd): config create --output - prints the template to stdout
It wrote a file named "-" in the working directory instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-28 12:33:03 +01:00
4 changed files with 60 additions and 3 deletions

No files matched your search

+22
View File
@@ -55,6 +55,28 @@ speculatively.
size and maximized state across starts (macOS and Windows; size and maximized state across starts (macOS and Windows;
`gui/v0.2.0`, 2026-11-15). `gui/v0.2.0`, 2026-11-15).
- [ ] `core/gui`: Linux/FreeBSD backend (WebKitGTK) -- see gui/README.md. - [ ] `core/gui`: Linux/FreeBSD backend (WebKitGTK) -- see gui/README.md.
- [ ] `core/gui`: resident app with a prewarmed WebView, for a start
under 300 ms (proposal from yamc, 2026-11-29, for its H-STARTUP;
see yamc `docs/spec/gui-comparison.md`). Measured on macOS (Apple
Silicon, warm): NSApp setup ~65 ms, WKWebView init ~45 ms, window
~25 ms, then ~190 ms until the web content process asks for the
first resource and ~150 ms for WebKit's first paint -- ~550 ms to
the first frame, ~340 ms of it WebKit's own, which only advances
while the main run loop runs. Tried without effect (yamc,
2026-11-29): `loadRequest` right after the WKWebView exists
(before the window is built, also before `finishLaunching`),
spinning the run loop after it, building the app's state in
parallel -- the first request still comes ~200 ms after the main
thread is free. So a fresh process stays at ~500 ms or more.
Proposal: keep the process alive after its last window (macOS: a
normal Dock app; Windows: a background process), hold one hidden
WebView with the page loaded in reserve, and let a new start hand
its arguments to the running instance (single instance, e.g. a
socket in the runtime dir), which shows the reserve window and
prepares the next. Needs several windows per process, a
reserve-window API, and the same on WebView2. The first start
stays at ~550 ms. Only worth it once a program needs it (yamc's
Gio-vs-WebView choice is still open).
- [x] `core/tui`: shared TUI kernel (themes, styles, Paint/Outer, - [x] `core/tui`: shared TUI kernel (themes, styles, Paint/Outer,
ListState, text helpers) as the nested module ListState, text helpers) as the nested module
`yetano.dev/yetano/core/tui` (`tui/v0.1.0`). `yetano.dev/yetano/core/tui` (`tui/v0.1.0`).
+7 -3
View File
@@ -2,7 +2,7 @@
// Yetano program standard (docs/program-conventions.md and ADR-0012 in // Yetano program standard (docs/program-conventions.md and ADR-0012 in
// the yetano meta-repository): // the yetano meta-repository):
// //
// <program> config create [--minimal|--full] [--force] [--output <file>] // <program> config create [--minimal|--full] [--force] [--output <file>|-]
// <program> config validate // <program> config validate
// <program> config upgrade [--write] // <program> config upgrade [--write]
// <program> config path // <program> config path
@@ -201,7 +201,7 @@ func usage(s Spec, w io.Writer) {
} }
fmt.Fprintf(w, `usage: %[1]s config <subcommand> [--config <file>] fmt.Fprintf(w, `usage: %[1]s config <subcommand> [--config <file>]
create [--minimal|--full] [--force] [--output <file>] create [--minimal|--full] [--force] [--output <file>|-]
write a commented starter configuration (minimal by default) write a commented starter configuration (minimal by default)
validate check the configuration file the program would use validate check the configuration file the program would use
upgrade [--write] upgrade [--write]
@@ -342,7 +342,7 @@ func (s Spec) create(explicit string, args []string, stdout, stderr io.Writer) i
minimal := fs.Bool("minimal", false, "write the minimal starter configuration (default)") minimal := fs.Bool("minimal", false, "write the minimal starter configuration (default)")
full := fs.Bool("full", false, "write the fully commented reference configuration") full := fs.Bool("full", false, "write the fully commented reference configuration")
force := fs.Bool("force", false, "overwrite the file if it already exists") force := fs.Bool("force", false, "overwrite the file if it already exists")
output := fs.String("output", "", "file to write (default: --config, else the file the program would use, else "+s.filename()+" in the user config directory -- the system one as root)") output := fs.String("output", "", "file to write, - for stdout (default: --config, else the file the program would use, else "+s.filename()+" in the user config directory -- the system one as root)")
if code := parse(fs, args); code >= 0 { if code := parse(fs, args); code >= 0 {
return code return code
} }
@@ -356,6 +356,10 @@ func (s Spec) create(explicit string, args []string, stdout, stderr io.Writer) i
} }
path := *output path := *output
if path == "-" { // the template on stdout, nothing written
io.WriteString(stdout, content)
return ExitOK
}
if path == "" { if path == "" {
var err error var err error
if path, err = s.defaultCreatePath(explicit); err != nil { if path, err = s.defaultCreatePath(explicit); err != nil {
+21
View File
@@ -190,6 +190,27 @@ func TestCreateExplicitAndOutput(t *testing.T) {
} }
} }
// --output - prints the template and writes no file (not one named "-").
func TestCreateOutputStdout(t *testing.T) {
root := t.TempDir()
s := testSpec(root)
work := filepath.Join(root, "work")
if err := os.MkdirAll(work, 0o755); err != nil {
t.Fatal(err)
}
t.Chdir(work)
code, out, errOut := run(t, s, "", "create", "--full", "--output", "-")
if code != ExitOK || out != fullTemplate || errOut != "" {
t.Fatalf("create --output -: exit %d, stdout %q, stderr %q", code, out, errOut)
}
if _, err := os.Stat(filepath.Join(work, "-")); !errors.Is(err, os.ErrNotExist) {
t.Errorf("create --output - wrote a file named \"-\": %v", err)
}
if code, out, _ := run(t, s, "", "create", "--output=-"); code != ExitOK || out != minimalTemplate {
t.Errorf("create --output=-: exit %d, stdout %q", code, out)
}
}
func TestValidate(t *testing.T) { func TestValidate(t *testing.T) {
root := t.TempDir() root := t.TempDir()
s := testSpec(root) s := testSpec(root)
+10
View File
@@ -67,6 +67,7 @@ const (
wmDestroy = 0x0002 wmDestroy = 0x0002
wmMove = 0x0003 wmMove = 0x0003
wmSize = 0x0005 wmSize = 0x0005
wmSetFocus = 0x0007
wmClose = 0x0010 wmClose = 0x0010
wmQuit = 0x0012 wmQuit = 0x0012
wmMoving = 0x0216 wmMoving = 0x0216
@@ -193,6 +194,7 @@ func newBackend(opt Options) (backend, string, string, error) {
return nil, "", "", errors.New("window: WebView2 could not be created (is the Microsoft Edge WebView2 Runtime installed?)") return nil, "", "", errors.New("window: WebView2 could not be created (is the Microsoft Edge WebView2 Runtime installed?)")
} }
c.Resize() c.Resize()
c.Focus() // the window got WM_SETFOCUS before the control existed
if s, err := c.GetSettings(); err == nil { if s, err := c.GetSettings(); err == nil {
_ = s.PutAreDevToolsEnabled(opt.Debug) _ = s.PutAreDevToolsEnabled(opt.Debug)
_ = s.PutAreDefaultContextMenusEnabled(opt.Debug) _ = s.PutAreDefaultContextMenusEnabled(opt.Debug)
@@ -220,6 +222,14 @@ func wndproc(hwnd, msg, wp, lp uintptr) uintptr {
_ = b.chromium.NotifyParentWindowPositionChanged() _ = b.chromium.NotifyParentWindowPositionChanged()
} }
b.reportFrame() b.reportFrame()
case wmSetFocus:
// The keyboard focus belongs in the WebView2 control (its own
// child window): without this a page gets no keys after the
// start or after Alt-Tab until it is clicked.
if b.chromium != nil {
b.chromium.Focus()
}
return 0
case wmApp: case wmApp:
b.runQueue() b.runQueue()
return 0 return 0