From ba358cdc19a66b7ff4725c57186c87b89de69ffc Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 21:01:03 +0000 Subject: [PATCH] =?UTF-8?q?Auswahlbalken=20in=20Men=C3=BCs=20folgt=20sofor?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Der Balken der Befehlspalette blendete nach jedem Zeilenwechsel 160 ms lang ein, die alte Zeile leuchtete 260 ms nach. Bei gehaltener Pfeiltaste erreichte der Balken so nie die volle Farbe und zog sichtbar hinterher. Beides entfällt, ebenso das Einblenden der Auswahl im Manager. Dazu wird der abgedunkelte Hintergrund samt Schatten unter einem Modal gemerkt und das Modal per stamp() aufgelegt statt jedes Bild durch den Compositor zu schicken: Palette-Bild 5,4 → 2,8 ms (BenchmarkPaletteSettingsDown). Gilt im Terminal und im eigenen Fenster. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_018i4GUjTRTrHBSswRGU7Zmr --- README.de.md | 2 +- README.md | 2 +- internal/ui/app.go | 34 +++++++++++++++++++++++---- internal/ui/manager.go | 8 ++----- internal/ui/motion.go | 1 - internal/ui/motion2.go | 8 +------ internal/ui/palette.go | 11 ++------- internal/ui/palsel_test.go | 47 ++++++++++++++++++++++++++++++++++++++ internal/ui/palstyle.go | 15 +----------- internal/ui/perf_test.go | 14 ++++++++++++ 10 files changed, 98 insertions(+), 44 deletions(-) create mode 100644 internal/ui/palsel_test.go diff --git a/README.de.md b/README.de.md index 3cfba78..f362cfd 100644 --- a/README.de.md +++ b/README.de.md @@ -246,7 +246,7 @@ nicht als Beweis. Die Liste: Palette *Logwache: Meldungen* oder `w` im Log-Blick nicht verloren: Die Karte zeigt es, und es landet am Prompt, sobald die Shell steht (⏎ wird nie vorausgeschickt, Esc bricht ab). Die KI-Antwort schimmert „denkt nach …“ und tippt sich gleichmäßig, Panels blenden ein. In der Befehlspalette leuchten die getroffenen Buchstaben, die Zeilen - blenden nacheinander ein und die Auswahl gleitet weich. Die Kopfzeile zeigt die Latenz als kleine Kurve (rot und + blenden nacheinander ein und der Auswahlbalken folgt den Pfeiltasten sofort. Die Kopfzeile zeigt die Latenz als kleine Kurve (rot und „▲ zäh“ bei schlechter Leitung). In der geteilten Ansicht leuchtet die Trennlinie neben dem aktiven Bereich, beim Wechsel und beim Zoom (Alt+Z) gleitet ein Rahmen mit. Gezeichnet wird nur, solange sich etwas bewegt; Barrierearm schaltet alles ab diff --git a/README.md b/README.md index 615f2aa..1a598a9 100644 --- a/README.md +++ b/README.md @@ -238,7 +238,7 @@ lets them in. The AI status report treats syslog lines as hints, not as proof. T the steps (connection, host key, login, shell) with timings and a progress bar with a light sweep, then the shell fades in from the top. Text you type while it connects is not lost: the card shows it, and it lands at the prompt as soon as the shell is ready (⏎ is never sent ahead, Esc cancels). The AI answer shimmers “thinking …” and types out smoothly, panels fade in. In the command - palette the matched letters light up, rows fade in one after another and the selection glides. The header shows + palette the matched letters light up, rows fade in one after another; the selection bar follows the arrow keys instantly. The header shows the latency as a small curve (red and “▲ sluggish” on a bad line). In split view the divider next to the active pane lights up, and a frame glides along when you switch panes or zoom (Alt+Z). Redraws only happen while something moves; accessible mode turns it all off diff --git a/internal/ui/app.go b/internal/ui/app.go index c63a9c3..3781b3a 100644 --- a/internal/ui/app.go +++ b/internal/ui/app.go @@ -168,6 +168,7 @@ type App struct { toasts []toastItem // Einblendungen oben rechts (toast.go) perf perfState // Bildrate und Leistungsanzeige (perf.go) styleGen int // zählt Theme-Wechsel (termView) + ovMemo overlayMemo // Hintergrund unter dem Modal (overlay) toastTicking bool animTicking bool // Takt für Bewegung (motion.go) hov hoverState // Karte unter der Maus (motion.go) @@ -1267,12 +1268,35 @@ func (a *App) overlay(base, box string) string { } a.z.rects = a.z.rects[:0] box = a.z.scan(box, x, y) - layers := []*lipgloss.Layer{lipgloss.NewLayer(base)} - if shadowsOn() { - layers = a.shadowLayers(base, x, y, bw, bh) // frames.go + return stamp(a.overlayBackground(base, x, y, bw, bh), box, x, y, a.w) +} + +// overlayMemo: abgedunkelter Hintergrund samt Schatten unter dem Modal. +// Beim Blättern in der Befehlspalette ändert sich nur das Modal; der +// Hintergrund darunter bleibt gleich. Ihn jedes Bild neu abzudunkeln und +// durch den Compositor zu schicken kostete den Großteil der Zeichenzeit, +// der Auswahlbalken zog dadurch spürbar nach. +type overlayMemo struct { + base string + x, y, bw, bh int + gen, w, h int + shadow bool + out string +} + +func (a *App) overlayBackground(base string, x, y, bw, bh int) string { + m := &a.ovMemo + sh := shadowsOn() + if m.out != "" && m.base == base && m.x == x && m.y == y && m.bw == bw && m.bh == bh && + m.gen == a.styleGen && m.w == a.w && m.h == a.h && m.shadow == sh { + return m.out } - c := lipgloss.NewCompositor(append(layers, lipgloss.NewLayer(box).X(x).Y(y).Z(2))...) - return c.Render() + out := base + if sh { + out = lipgloss.NewCompositor(a.shadowLayers(base, x, y, bw, bh)...).Render() // frames.go + } + *m = overlayMemo{base: base, x: x, y: y, bw: bw, bh: bh, gen: a.styleGen, w: a.w, h: a.h, shadow: sh, out: out} + return out } func plural(n int, one, many string) string { diff --git a/internal/ui/manager.go b/internal/ui/manager.go index 2a68dca..9a11b63 100644 --- a/internal/ui/manager.go +++ b/internal/ui/manager.go @@ -460,11 +460,7 @@ func (a *App) viewManager() string { m.top = clamp(m.top, 0, max(0, len(rows)-listH)) now := time.Now() if m.sel != m.selSeen { - m.selSeen, m.selAt = m.sel, now // Auswahl blendet ein, Balken füllen sich - } - selK := 1.0 - if motionLevel() > 0 { - selK = easeOut(float64(now.Sub(m.selAt)) / float64(selFadeDur)) + m.selSeen, m.selAt = m.sel, now // Balken der Detailspalte füllen sich } if len(rows) > listH { info += s.Muted.Render(fmt.Sprintf(i18n.T(" %d–%d von %d"), m.top+1, min(len(rows), m.top+listH), len(rows))) @@ -511,7 +507,7 @@ func (a *App) viewManager() string { if i == m.sel { // Auswahl: Hintergrund über die ganze Zeile, Punkt und // Symbol behalten ihre Farbe (rot = nicht erreichbar). - bg := mixColor(s.T.Bg, s.T.Surface2, selK) + bg := s.T.Surface2 // Auswahl sofort voll da, ohne Einblenden sel := s.Selected.Background(bg) stripeSel, _ := a.stripe(c, bg) body := sel.Render(indent) + glyph(pdot, dotC, bg) + sel.Render(" ") + glyph(picon, iconC, bg) + sel.Render(" "+alias+" "+target) diff --git a/internal/ui/motion.go b/internal/ui/motion.go index f82c13c..56c3a93 100644 --- a/internal/ui/motion.go +++ b/internal/ui/motion.go @@ -97,7 +97,6 @@ const ( animSlow = 250 * time.Millisecond // Pulsieren, Atmen tabFlashDur = 1200 * time.Millisecond barFillDur = 450 * time.Millisecond - selFadeDur = 160 * time.Millisecond hoverDelay = 450 * time.Millisecond downBlink = 4 * time.Second // Manager: Punkt blinkt, nachdem ein Host ausfiel ) diff --git a/internal/ui/motion2.go b/internal/ui/motion2.go index 66dcaae..85ec517 100644 --- a/internal/ui/motion2.go +++ b/internal/ui/motion2.go @@ -217,10 +217,7 @@ func (q *askState) typing() bool { type palMotion struct { query string queryAt time.Time - sel int - selAt time.Time opened bool - prevSel int // vorher gewählte Zeile (Nachleuchten, palstyle.go) // changed: Label des zuletzt umgeschalteten Werts (leuchtet kurz) changed string changedAt time.Time @@ -240,14 +237,11 @@ func (p *palette) track(now time.Time) { if !p.mo.opened || q != p.mo.query { p.mo.opened, p.mo.query, p.mo.queryAt = true, q, now } - if p.sel != p.mo.sel { - p.mo.prevSel, p.mo.sel, p.mo.selAt = p.mo.sel, p.sel, now - } } // animating: braucht die Palette gerade schnelle Bilder? func (p *palette) animating(now time.Time) bool { - return now.Sub(p.mo.queryAt) < palHitGlow || now.Sub(p.mo.selAt) < max(selFadeDur, palTrailDur) || + return now.Sub(p.mo.queryAt) < palHitGlow || now.Sub(p.mo.changedAt) < palGlowDur } diff --git a/internal/ui/palette.go b/internal/ui/palette.go index 12280ca..50ececb 100644 --- a/internal/ui/palette.go +++ b/internal/ui/palette.go @@ -1244,18 +1244,11 @@ func (a *App) viewPalette() string { } hits := fuzzyHits(query, label) // getroffene Buchstaben leuchten (motion2.go) line := iconStyle.Render(it.icon) + " " + hitLabel(label, hits, labelStyle, st.Accent.Bold(true), glow) + st.Muted.Render(sub) + strings.Repeat(" ", gap) + hint - if k := p.trailK(i, now); k > 0 { - // Nachleuchten: die alte Auswahl verblasst, der Balken „gleitet“. - line = lipgloss.NewStyle().Background(mixColor(st.T.Surface, st.T.Accent, 0.35*k)).Width(w - 4).Render(ansi.Strip(line)) - } if i == p.sel { // Auswahl als Balken in Akzentfarbe mit ▶ (wie der aktive Tab). + // Sofort voll da, ohne Einblenden oder Nachleuchten: bei + // gehaltener Pfeiltaste wirkte der Balken sonst träge. fill := st.T.Accent - if motionLevel() > 0 { - if k := easeOut(float64(now.Sub(p.mo.selAt)) / float64(selFadeDur)); k < 1 { - fill = mixColor(st.T.Surface, st.T.Accent, k) - } - } ink := inkOn(st.T, fill) mark := "▶" + strings.Repeat(" ", max(0, lipgloss.Width(it.icon)-1)) bar := lipgloss.NewStyle().Background(fill).Foreground(ink) diff --git a/internal/ui/palsel_test.go b/internal/ui/palsel_test.go new file mode 100644 index 0000000..5fadda9 --- /dev/null +++ b/internal/ui/palsel_test.go @@ -0,0 +1,47 @@ +package ui + +import ( + "testing" + "time" +) + +// Der Auswahlbalken folgt der Pfeiltaste sofort: kein Einblenden, kein +// Nachleuchten, also auch keine schnellen Zwischenbilder nur dafür. +func TestPaletteSelectionInstant(t *testing.T) { + a := newPaletteTestApp(t) + a.intro, a.scr = nil, scrManager + a.pal.menu = "settings" + a.View() + p := a.pal + p.mo.queryAt = time.Now().Add(-time.Hour) // Öffnen ist längst vorbei + before := a.View().Content + p.sel++ + after := a.View().Content + if before == after { + t.Fatal("Auswahl hat sich im Bild nicht bewegt") + } + if p.animating(time.Now()) { + t.Fatal("Auswahlwechsel braucht Zwischenbilder, der Balken zieht nach") + } + // Bild direkt danach ist schon das Endbild. + time.Sleep(300 * time.Millisecond) + if again := a.View().Content; again != after { + t.Fatal("Balken verändert sich nach dem Wechsel noch") + } +} + +// Der abgedunkelte Hintergrund unter dem Modal wird nur einmal berechnet. +func TestOverlayBackgroundMemo(t *testing.T) { + a := newPaletteTestApp(t) + a.intro, a.scr = nil, scrManager + a.View() + first := a.ovMemo.out + if first == "" { + t.Fatal("kein Hintergrund gemerkt") + } + a.pal.sel++ + a.View() + if a.ovMemo.out != first { + t.Fatal("Hintergrund wurde neu berechnet, obwohl er gleich blieb") + } +} diff --git a/internal/ui/palstyle.go b/internal/ui/palstyle.go index fd28905..c693510 100644 --- a/internal/ui/palstyle.go +++ b/internal/ui/palstyle.go @@ -197,8 +197,7 @@ func palTitle(s string) string { // ---------------------------------------------------------------- Bewegung const ( - palTrailDur = 260 * time.Millisecond // Nachleuchten der alten Auswahl - palGlowDur = 650 * time.Millisecond // umgeschalteter Wert leuchtet + palGlowDur = 650 * time.Millisecond // umgeschalteter Wert leuchtet ) // palChanged merkt sich, welcher Wert gerade umgeschaltet wurde. @@ -218,18 +217,6 @@ func (p *palette) glowK(label string, now time.Time) float64 { return 1 - easeOut(float64(d)/float64(palGlowDur)) } -// trailK: Nachleuchten der vorher gewählten Zeile (1 … 0). -func (p *palette) trailK(i int, now time.Time) float64 { - if motionLevel() == 0 || i != p.mo.prevSel || i == p.sel { - return 0 - } - d := now.Sub(p.mo.selAt) - if d >= palTrailDur { - return 0 - } - return 1 - easeOut(float64(d)/float64(palTrailDur)) -} - // ---------------------------------------------------------------- Fußzeile // palKeys: Tasten unten, passend zum gewählten Eintrag. diff --git a/internal/ui/perf_test.go b/internal/ui/perf_test.go index a744533..150743d 100644 --- a/internal/ui/perf_test.go +++ b/internal/ui/perf_test.go @@ -282,3 +282,17 @@ func TestReachVisibleOnly(t *testing.T) { t.Fatal("drittes Weiterschalten schaltet nicht aus") } } + +// Befehlspalette (Einstellungen) bei ↓: jede Taste zeichnet die Palette neu. +func BenchmarkPaletteSettingsDown(b *testing.B) { + a := manyConnsApp(b, 50) + a.openPalette() + a.pal.menu = "settings" + a.View() + b.ReportAllocs() + n := len(a.paletteItems()) + for b.Loop() { + a.pal.sel = (a.pal.sel + 1) % max(1, n) + a.View() + } +}