diff --git a/README.de.md b/README.de.md index f22c39a..04eaec1 100644 --- a/README.de.md +++ b/README.de.md @@ -235,7 +235,9 @@ nicht als Beweis. Die Liste: Palette *Logwache: Meldungen* oder `w` im Log-Blick sich (geprüft werden die im Manager sichtbaren Verbindungen, ein Ordner sofort beim Aufklappen; Einstellung „Online-Punkt“: aus, sichtbare, alle), die Details zeigen den Verlauf der Erreichbarkeit und bei verbundenen Servern CPU/RAM/Platte als Balken. Beim Verbinden zeigt eine Karte die Schritte (Verbindung, Host-Schlüssel, Anmelden, Shell) mit Zeiten und einem - Fortschrittsbalken mit Lichtlauf, danach blendet die Shell von oben ein. Die KI-Antwort schimmert „denkt nach …“ und + Fortschrittsbalken mit Lichtlauf, danach blendet die Shell von oben ein. Was du beim Verbinden schon tippst, geht + 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 „▲ zäh“ bei schlechter Leitung). In der geteilten Ansicht leuchtet die Trennlinie neben dem aktiven Bereich, beim diff --git a/README.md b/README.md index ce84906..9ac1764 100644 --- a/README.md +++ b/README.md @@ -229,7 +229,8 @@ lets them in. The AI status report treats syslog lines as hints, not as proof. T the connections visible in the manager, a folder is checked as soon as you expand it; settings “Online dot”: off, visible, all), and the details show the reachability history and CPU/RAM/disk bars for connected servers. While connecting, a card shows 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. The AI answer shimmers “thinking …” and types out smoothly, panels fade in. In the command + 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 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 diff --git a/internal/i18n/en_typeahead.go b/internal/i18n/en_typeahead.go new file mode 100644 index 0000000..fd1dc69 --- /dev/null +++ b/internal/i18n/en_typeahead.go @@ -0,0 +1,12 @@ +package i18n + +// Texte für Vorausgetipptes beim Verbinden (internal/ui/typeahead.go). +func init() { + for de, e := range map[string]string{ + "Vorausgetippter Text verworfen: kein Prompt erkannt": "Text typed ahead discarded: no prompt detected", + "Getippt: ": "Typed: ", + "kommt am Prompt an · Esc bricht ab": "goes to the prompt · Esc cancels", + } { + en[de] = e + } +} diff --git a/internal/ui/app.go b/internal/ui/app.go index 080587f..f9c2228 100644 --- a/internal/ui/app.go +++ b/internal/ui/app.go @@ -409,9 +409,11 @@ func (a *App) coreMsg(msg tea.Msg) (tea.Cmd, bool) { if !a.sessionVisible(s) { s.unseen = true } - clip = a.takeClipboard(s) + clip = tea.Batch(a.takeClipboard(s), a.aheadTick(s)) } return tea.Batch(a.listen(), clip, a.onOutputFrame(time.Now()), a.takePixels(m.sid)), true + case aheadMsg: + return a.onAhead(m), true case tea.FocusMsg: a.blurred = false a.clearNotices() @@ -861,6 +863,7 @@ func (a *App) onTick() tea.Cmd { a.noticeBell(s) } a.alertTick(s) + a.flushAhead(s) // vorausgetippt beim Verbinden (typeahead.go) s.recordLatency(time.Now()) a.shareTick(s) if c := a.takeClipboard(s); c != nil { diff --git a/internal/ui/intro.go b/internal/ui/intro.go index 3b99038..d19ff77 100644 --- a/internal/ui/intro.go +++ b/internal/ui/intro.go @@ -118,8 +118,18 @@ func (a *App) introMsg(msg tea.Msg) (tea.Cmd, bool) { } return introFrame(), true case tea.KeyPressMsg, tea.MouseClickMsg: - a.intro = nil // überspringen; die Taste selbst wirkt nicht weiter - return nil, true + if !introFits(a.w, a.h) { + // Fenster zu klein: Die Animation ist gar nicht zu sehen (View + // zeigt dann gleich die Oberfläche). Die Taste nicht zum + // Überspringen verbrauchen, sonst geht sie unbemerkt verloren. + a.intro = nil + return nil, false + } + a.intro = nil // überspringen + if k, ok := msg.(tea.KeyPressMsg); ok && a.scr == scrUnlock && introTypes(k) { + return nil, false // schon das Passwort getippt: das Zeichen zählt mit + } + return nil, true // sonst wirkt die Taste nicht weiter case unlockedMsg: if m.err == nil { a.intro.unlocked = true @@ -128,6 +138,14 @@ func (a *App) introMsg(msg tea.Msg) (tea.Cmd, bool) { return nil, false } +// introTypes: Zeichen, das in das Passwortfeld dahinter gehört (kein +// Leerzeichen, kein Kürzel): Wer während der Animation schon das +// Master-Passwort tippt, verliert sonst das erste Zeichen und bekommt +// „Falsches Passwort“. +func introTypes(k tea.KeyPressMsg) bool { + return k.Text != "" && k.Text != " " && k.Mod&(tea.ModCtrl|tea.ModAlt|tea.ModMeta|tea.ModSuper) == 0 +} + // ---------------------------------------------------------------- Logo // Pixel-Bitmaps: zwei Pixelzeilen ergeben eine Zeichenzeile (▀ ▄ █). diff --git a/internal/ui/intro_test.go b/internal/ui/intro_test.go index b38d92b..62bb4b8 100644 --- a/internal/ui/intro_test.go +++ b/internal/ui/intro_test.go @@ -65,10 +65,12 @@ func TestIntroSkipAndDisable(t *testing.T) { if !strings.Contains(ansi.Strip(a.View().Content), "überspringt") { t.Fatal("Animation wird nicht gezeigt") } - // Taste überspringt und wird verschluckt + // Taste überspringt und wird verschluckt (Manager dahinter) + a.scr = scrManager if _, ok := a.introMsg(tea.KeyPressMsg{Code: 'q', Text: "q"}); !ok || a.intro != nil { t.Fatal("Taste hat die Animation nicht beendet") } + a.scr = scrUnlock // Zeit abgelaufen a.intro = &introState{start: time.Now().Add(-introDur * 1100 * time.Millisecond)} if cmd, ok := a.introMsg(introFrameMsg(time.Now())); !ok || cmd != nil || a.intro != nil { @@ -94,3 +96,30 @@ func TestIntroSkipAndDisable(t *testing.T) { t.Fatal("kleines Fenster sollte die Animation auslassen") } } + +// Erste Taste darf nicht unbemerkt verloren gehen: Ist die Animation nicht +// zu sehen (Fenster zu klein), geht die Taste normal weiter. Steht das +// Passwortfeld dahinter, zählt ein getipptes Zeichen schon mit. +func TestIntroKeepsFirstKey(t *testing.T) { + a := &App{s: NewStyles(Nacht), keys: newKeymap(nil), intro: &introState{start: time.Now()}} + a.w, a.h = 30, 10 // zu klein, View zeigt keine Animation + if introFits(a.w, a.h) { + t.Fatal("Testfenster ist nicht zu klein") + } + if _, ok := a.introMsg(tea.KeyPressMsg{Code: 'l', Text: "l"}); ok || a.intro != nil { + t.Fatal("unsichtbare Animation hat die Taste verschluckt") + } + + a.w, a.h = 120, 40 + a.scr = scrUnlock + a.intro = &introState{start: time.Now()} + if _, ok := a.introMsg(tea.KeyPressMsg{Code: 'g', Text: "g"}); ok || a.intro != nil { + t.Fatal("erstes Zeichen des Passworts verschluckt") + } + for _, k := range []tea.KeyPressMsg{{Code: tea.KeyEnter}, {Code: tea.KeyEscape}, {Code: tea.KeySpace, Text: " "}, {Code: 'c', Mod: tea.ModCtrl}} { + a.intro = &introState{start: time.Now()} + if _, ok := a.introMsg(k); !ok { + t.Fatalf("%s sollte nur überspringen", k.String()) + } + } +} diff --git a/internal/ui/motion2.go b/internal/ui/motion2.go index fa6f52a..66dcaae 100644 --- a/internal/ui/motion2.go +++ b/internal/ui/motion2.go @@ -79,6 +79,16 @@ func (a *App) connectCard(s *session, w int) string { if s.connNote != "" { lines = append(lines, "", on(st.T.Warn, false).Render(trunc(s.connNote, inner))) } + if len(s.ahead) > 0 { // vorausgetippt (typeahead.go): sichtbar, dass nichts verloren geht + lbl := i18n.T("Getippt: ") + txt := string(s.ahead) + if n := inner - lipgloss.Width(lbl) - 1; utf8.RuneCountInString(txt) > n { + r := []rune(txt) + txt = "…" + string(r[len(r)-max(0, n-1):]) + } + lines = append(lines, "", on(st.T.Muted, false).Render(lbl)+on(st.T.Text, true).Render(txt+"▏"), + on(st.T.Muted, false).Render(trunc(i18n.T("kommt am Prompt an · Esc bricht ab"), inner))) + } for i, l := range lines { lines[i] = l + on(st.T.Text, false).Render(strings.Repeat(" ", max(0, inner-lipgloss.Width(l)))) } diff --git a/internal/ui/session.go b/internal/ui/session.go index 5904396..cbbca8b 100644 --- a/internal/ui/session.go +++ b/internal/ui/session.go @@ -70,6 +70,8 @@ type session struct { sudo *sshx.Sudo // geprüftes sudo für Dateiaktionen (filesudo.go), nur im Speicher sudoFor *sshx.Client // Verbindung, für die sudo gilt startPending bool // Startbefehl der Verbindung noch nicht getippt (connextra.go) + ahead []rune // beim Verbinden vorausgetippt, wartet auf den Prompt (typeahead.go) + aheadTicking bool tmuxScroll tmuxScroller // Blättern in tmux (tmuxscroll.go) tmuxHinted bool muxPending bool // tmux/screen nach dem Neuverbinden anhängen diff --git a/internal/ui/terminal.go b/internal/ui/terminal.go index 1ee84f5..b0083e7 100644 --- a/internal/ui/terminal.go +++ b/internal/ui/terminal.go @@ -333,6 +333,9 @@ func (a *App) updateTerminal(msg tea.Msg) tea.Cmd { } return nil } + if s.state == stConnecting { + return a.connectingKey(s, m) // Text wartet auf den Prompt (typeahead.go) + } if s.state != stConnected { if cmd, ok := a.closedKey(s, key); ok { return cmd diff --git a/internal/ui/typeahead.go b/internal/ui/typeahead.go new file mode 100644 index 0000000..ca6c7e0 --- /dev/null +++ b/internal/ui/typeahead.go @@ -0,0 +1,106 @@ +package ui + +import ( + "time" + + tea "charm.land/bubbletea/v2" + + "github.com/db9979/sshtermy/internal/agent" + "github.com/db9979/sshtermy/internal/i18n" +) + +// Vorausgetippt: Wer gleich nach der Auswahl eines Servers lostippt, ist +// schneller als der Verbindungsaufbau. Früher gingen diese Tasten +// verloren (die erste Eingabe „wurde nicht angenommen“), ein „x“ schloss +// sogar den Tab und ⏎ startete die Verbindung ein zweites Mal. +// +// Jetzt: Text wird gesammelt und auf der Karte „Verbinde mit …“ gezeigt. +// Steht der Prompt, tippt sshTermy ihn dort ein. ⏎ wird nie vorausgeschickt +// (der Gefahren-Check sieht die Zeile erst am Prompt), Esc bricht ab. +// Kommt statt eines Prompts eine Passwort- oder Login-Abfrage, wird der +// Text verworfen statt dort zu landen. + +const ( + aheadMax = 256 // Zeichen + aheadWait = 8 * time.Second // länger kein Prompt: verwerfen +) + +// connectingKey: Taste, während die Verbindung noch aufgebaut wird. +func (a *App) connectingKey(s *session, k tea.KeyPressMsg) tea.Cmd { + switch k.String() { + case "esc": + a.closeTab(s) + return nil + case "backspace": + if n := len(s.ahead); n > 0 { + s.ahead = s.ahead[:n-1] + } + return nil + case "ctrl+u": + s.ahead = nil + return nil + } + if k.Text == "" || k.Mod&(tea.ModCtrl|tea.ModAlt|tea.ModMeta|tea.ModSuper) != 0 { + return nil // ⏎, Pfeile, Kürzel: erst nach dem Verbinden + } + for _, r := range k.Text { + if r >= 0x20 && r != 0x7f && len(s.ahead) < aheadMax { + s.ahead = append(s.ahead, r) + } + } + return nil +} + +// flushAhead: Vorausgetipptes an den Prompt, sobald er steht (Sekundentakt +// und neue Ausgabe). Startbefehl, Abfragen und tmux/screen haben Vorrang. +func (a *App) flushAhead(s *session) { + if len(s.ahead) == 0 { + return + } + if s.state != stConnected && s.state != stConnecting { + s.ahead = nil // Verbindung gescheitert oder Tab zu + return + } + if s.state != stConnected || s.term == nil { + return + } + if s.detached() { + s.ahead = nil // eigenes Fenster: dort wird getippt + return + } + busy := s.startPending || s.muxPending || s.cap.active() + if !busy && s.term.AtIdlePrompt() && !agent.LooksLikeSecretPrompt(s.term.CursorLine()) && + time.Since(s.lastOutput) > 250*time.Millisecond { + txt := string(s.ahead) + s.ahead = nil + s.term.SendText(txt) + return + } + if !s.connectedAt.IsZero() && time.Since(s.connectedAt) > aheadWait { + s.ahead = nil + a.flash(i18n.T("Vorausgetippter Text verworfen: kein Prompt erkannt")) + } +} + +type aheadMsg struct{ sid int } + +// aheadTick: nach neuer Ausgabe kurz warten (Prompt fertig?) und dann +// prüfen, statt bis zum nächsten Sekundentakt. +func (a *App) aheadTick(s *session) tea.Cmd { + if len(s.ahead) == 0 || s.aheadTicking { + return nil + } + s.aheadTicking = true + sid := s.id + return tea.Tick(300*time.Millisecond, func(time.Time) tea.Msg { return aheadMsg{sid} }) +} + +func (a *App) onAhead(m aheadMsg) tea.Cmd { + s := a.byID(m.sid) + if s == nil { + return nil + } + s.aheadTicking = false + a.flushAhead(s) + return nil +} diff --git a/internal/ui/typeahead_test.go b/internal/ui/typeahead_test.go new file mode 100644 index 0000000..ca57dcc --- /dev/null +++ b/internal/ui/typeahead_test.go @@ -0,0 +1,88 @@ +package ui + +import ( + "strings" + "testing" + "time" + + tea "charm.land/bubbletea/v2" + "github.com/charmbracelet/x/ansi" + + "github.com/db9979/sshtermy/internal/domain" +) + +func typeKeys(a *App, s string) { + for _, r := range s { + a.Update(tea.KeyPressMsg{Code: r, Text: string(r)}) + } +} + +// Gleich nach der Server-Auswahl lostippen: nichts geht verloren, „x“ +// schließt keinen Tab, ⏎ verbindet nicht doppelt und wird nie vorausgeschickt. +func TestTypeAheadWhileConnecting(t *testing.T) { + t.Setenv("SSHTERMY_NO_INTRO", "1") + a := dangerApp(t) + c := domain.Connection{Alias: "web", Host: "10.0.0.5", Username: "admin"} + s, out := typedSession(c, "", "") + s.state = stConnecting + a.sessions, a.cur = []*session{s}, 0 + + typeKeys(a, "lxs") + a.Update(tea.KeyPressMsg{Code: tea.KeyBackspace}) + a.Update(tea.KeyPressMsg{Code: tea.KeyBackspace}) + typeKeys(a, "s -x") + a.Update(tea.KeyPressMsg{Code: tea.KeyEnter}) + if len(a.sessions) != 1 || s.state != stConnecting { + t.Fatalf("Tippen beim Verbinden hat den Tab verändert: %d Tabs, Zustand %v", len(a.sessions), s.state) + } + if got := string(s.ahead); got != "ls -x" { + t.Fatalf("vorausgetippt %q, erwartet %q", got, "ls -x") + } + if card := ansi.Strip(a.connectCard(s, 58)); !strings.Contains(card, "ls -x") { + t.Fatalf("Karte zeigt das Getippte nicht:\n%s", card) + } + + // verbunden, Prompt steht: Text landet dort, ohne ⏎ + s.state, s.connectedAt = stConnected, time.Now() + _, _ = s.term.Write([]byte("admin@web:~$ ")) + s.lastOutput = time.Now().Add(-time.Second) + a.flushAhead(s) + time.Sleep(50 * time.Millisecond) + if got := out.String(); got != "ls -x" { + t.Fatalf("an den Server ging %q, erwartet %q", got, "ls -x") + } + if len(s.ahead) != 0 { + t.Fatal("Puffer nicht geleert") + } +} + +// Kommt statt des Prompts eine Passwortabfrage, landet der Text nicht dort. +func TestTypeAheadNotIntoPasswordPrompt(t *testing.T) { + t.Setenv("SSHTERMY_NO_INTRO", "1") + a := dangerApp(t) + s, out := typedSession(domain.Connection{Alias: "sw", Host: "10.0.0.9"}, "", "") + s.state = stConnecting + a.sessions, a.cur = []*session{s}, 0 + typeKeys(a, "geheim") + + s.state, s.connectedAt = stConnected, time.Now().Add(-aheadWait-time.Second) + _, _ = s.term.Write([]byte("Password: ")) + s.lastOutput = time.Now().Add(-time.Second) + a.flushAhead(s) + time.Sleep(50 * time.Millisecond) + if out.String() != "" { + t.Fatalf("Text ging an die Passwortabfrage: %q", out.String()) + } + if len(s.ahead) != 0 { + t.Fatal("nach Ablauf nicht verworfen") + } + + // Esc beim Verbinden bricht weiter ab + s2, _ := typedSession(domain.Connection{Alias: "x", Host: "h"}, "", "") + s2.state = stConnecting + a.sessions, a.cur = []*session{s2}, 0 + a.Update(tea.KeyPressMsg{Code: tea.KeyEscape}) + if len(a.sessions) != 0 { + t.Fatal("Esc schließt den Tab beim Verbinden nicht mehr") + } +} diff --git a/site/de/index.html b/site/de/index.html index 7f0b57b..65c10ca 100644 --- a/site/de/index.html +++ b/site/de/index.html @@ -174,7 +174,7 @@ sudo apt update && sudo apt install sshtermy
Verschlüsselte .sshteam-Pakete und Team-Ordner, die die Verbindungen aller aktuell halten, ohne Passwörter.
26 Themes mit Live-Vorschau, von Polarnacht, Abendrot und Tusche bis Papier und Minze, dazu Hochkontrast und Farbenblind, eigene Farben, vier Symbol-Stile, jede Taste frei belegbar.
Eine Kopfzeile mit Tabs links und dem Zustand der Sitzung rechts, rote Marke ▲ PRODUKTIV statt roter Fläche, unten eine F-Tasten-Leiste (1Hilfe 2Ziel 3KI …). Der Manager zeigt rechts nur, was zur Auswahl gehört, ein Ordner seinen Inhalt mit Status. Die Hilfe (F1) hat Reiter, tippen filtert.
Verbindungsaufbau als Karte mit Schritten und Lichtlauf, Tabs leuchten bei Erfolg und Fehler auf, Karte beim Überfahren eines Tabs, atmende Online-Punkte (geprüft wird nur, was sichtbar ist) und Lastbalken, KI-Antwort tippt sich, Palette mit leuchtenden Treffern, Latenzkurve in der Kopfzeile, gleitender Rahmen in der geteilten Ansicht, Dialoge mit Schatten und wahlweise runden Ecken. Voll, dezent oder aus.
Verbindungsaufbau als Karte mit Schritten und Lichtlauf (was du dabei tippst, wartet auf den Prompt), Tabs leuchten bei Erfolg und Fehler auf, Karte beim Überfahren eines Tabs, atmende Online-Punkte (geprüft wird nur, was sichtbar ist) und Lastbalken, KI-Antwort tippt sich, Palette mit leuchtenden Treffern, Latenzkurve in der Kopfzeile, gleitender Rahmen in der geteilten Ansicht, Dialoge mit Schatten und wahlweise runden Ecken. Voll, dezent oder aus.
Barrierearmer Modus ohne Animationen, mit Formen statt nur Farben. Debug-Protokoll für Fehlerberichte (--debug), bereinigt von Hosts, IPs und Passwörtern. Adaptive Bildrate bei Ausgabeflut, dazu eine Leistungsanzeige in der Palette, die die Zeichenzeit in Worten bewertet.
Sofort sperren oder nach 5 bis 60 Minuten Leerlauf; Sitzungen laufen hinter der Sperre weiter. Master-Passwort und Windows-Anmeldung jederzeit änderbar.
Claude und andere KI-Clients nutzen deine Verbindungen über sshtermy mcp: standardmäßig nur lesend, alles andere erst nach deiner Bestätigung.
Encrypted .sshteam packages and team folders that keep everyone's connections up to date, without passwords.
26 themes with live preview, from Polar night, Synthwave and Ink to Paper and Mint, plus high contrast and color blindness, your own colors, four icon styles, every shortcut can be changed.
One header line with tabs on the left and the session state on the right, a red ▲ PRODUCTION badge instead of a red bar, a function key bar at the bottom (1Help 2Goal 3AI …). The manager shows only what belongs to the selection, a folder its contents with status. Help (F1) has tabs, typing filters.
Connecting as a card with steps and a light sweep, tabs flash on success and errors, a card when hovering a tab, breathing online dots (only visible connections are checked) and load bars, the AI answer types out, palette matches light up, latency curve in the header, a frame gliding between split panes, dialogs with shadows and optional round corners. Full, subtle or off.
Connecting as a card with steps and a light sweep (text typed meanwhile waits for the prompt), tabs flash on success and errors, a card when hovering a tab, breathing online dots (only visible connections are checked) and load bars, the AI answer types out, palette matches light up, latency curve in the header, a frame gliding between split panes, dialogs with shadows and optional round corners. Full, subtle or off.
Accessible mode without animations and with shapes instead of color only. Debug log for bug reports (--debug), saved cleaned of hosts, IPs and passwords. Adaptive frame rate when output floods, plus a performance display in the palette that rates draw time in plain words.
Lock now or after 5 to 60 minutes idle; sessions keep running behind the lock. Change the master password or the Windows sign-in any time.
Claude and other AI clients use your saved connections via sshtermy mcp: read-only by default, anything else only after you confirm.