diff --git a/README.de.md b/README.de.md index 56cdbcf..99f5187 100644 --- a/README.de.md +++ b/README.de.md @@ -100,7 +100,7 @@ nicht als Beweis. Die Liste: Palette *Logwache: Meldungen* oder `w` im Log-Blick - **Befehlspalette** (Strg+Leertaste): ein Eingabefeld für alles, Text wird Ziel oder Frage; ohne Text nur Häufiges, Verbindungen und Ordner je Bereich (Sitzung, Tabs, Ansicht, Netzwerk, Team …), Tippen findet alles direkt - **Ghost-Text** beim Tippen (Tab übernimmt) - **Folgebefehle** nach jedem Enter (Alt+1…4 fügt ein) - - **Ziel-Modus / Agent** (F2): Ziel setzen, die KI schlägt Schritt für Schritt genau einen Befehl mit Begründung vor, du bestätigst + - **Ziel-Modus / Agent** (F2): Ziel setzen, die KI schlägt Schritt für Schritt genau einen Befehl mit Begründung vor, du bestätigst. Text im Panel (Ziel, Schritte, Ausgaben, Fehlermeldungen) lässt sich mit der Maus markieren und wird gleich kopiert - **Agent-Modus** (F2, Tab wählt den Modus): Der Agent arbeitet selbstständig bis zum Ziel. Er führt Befehle aus, sieht Ausgabe und Exit-Code, legt Skripte per SFTP in `~/.sshtermy-agent//` an und führt sie aus (erst Probelauf). Stufen: *Vorsichtig* (Standard; nur Lesendes läuft allein), *Normal* (alles außer Gefahr, sudo und Code in der Zeile wie `python -c`, `bash -c`, `eval`; als root angemeldet oder unter Windows fragt jede Änderung, weil es dort kein sudo zum Anhalten gibt), *Voll* (auch sudo). @@ -331,6 +331,7 @@ sshtermy mcp # MCP-Server für KI-Clients (stdin/stdout), siehe „ | | Tab | Schritt für Schritt → Agent *Vorsichtig* → *Normal* → *Voll* → *Erst planen* | | Agent-Modus | Esc / ? / v / x | anhalten / Anweisung geben / Skript ansehen / beenden; am Ende `s` als Runbook speichern, `r` Skripte auf dem Host löschen, `c` Ergebnis kopieren, `l` ganz lesen | | Ziel-/Agent-/Plan-Panel, KI fragen | Bild↑ / Bild↓, Mausrad | langen Inhalt blättern (Zusammenfassung, Plan, Antwort) | +| | Ziehen / Doppelklick / Dreifachklick, Rechtsklick | Text im Panel markieren (Ziel, Schritte, Ausgaben, Fehlermeldungen) und gleich kopieren (Zwischenablage + OSC 52): Wort / Zeile; Rechtsklick kopiert die Markierung erneut | | Plan-Modus | ↑↓ / Leertaste / e / v / ? | Schritt wählen / streichen oder zurückholen / ändern / Skript ansehen / neu planen | | | Tab / ⏎ / x | Ausführung (Schritt für Schritt oder Agent-Stufe) / freigeben und ausführen / verwerfen; Strg+S speichert den Plan als Runbook | | KI-Eingaben | ⇧⏎ / Strg+J | neue Zeile in Ziel, Frage und Palette (lange Texte brechen automatisch um, das Feld wächst mit) | diff --git a/README.md b/README.md index 232bd89..ed185ca 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ lets them in. The AI status report treats syslog lines as hints, not as proof. T - **Command palette** (Ctrl+Space): one input field for everything; text becomes a goal or a question; without text only frequent actions, connections and one folder per area (session, tabs, view, network, team …), typing finds everything directly - **Ghost text** while typing (Tab accepts) - **Follow-up commands** after every Enter (Alt+1…4 inserts) - - **Goal mode / agent** (F2): set a goal, the AI suggests exactly one command at a time with a reason, you confirm + - **Goal mode / agent** (F2): set a goal, the AI suggests exactly one command at a time with a reason, you confirm. Text in the panel (goal, steps, output, error messages) can be selected with the mouse and is copied right away - **Agent mode** (F2, Tab picks the mode): the agent works on its own until the goal is reached. It runs commands, sees their output and exit code, writes scripts via SFTP to `~/.sshtermy-agent//` and runs them (dry run first). Levels: *Careful* (default; only read-only commands run on their own), *Normal* (everything except danger, sudo and inline code such as `python -c`, `bash -c`, `eval`; signed in as root or on Windows every change asks, because there is no sudo to stop at), @@ -322,6 +322,7 @@ sshtermy mcp # MCP server for AI clients (stdin/stdout), see “sshT | | Tab | step by step → agent *Careful* → *Normal* → *Full* → *Plan first* | | Agent mode | Esc / ? / v / x | pause / give an instruction / view the script / end; at the end `s` save as runbook, `r` delete the scripts on the host, `c` copy the result, `l` read it in full | | Goal/agent/plan panel, Ask AI | PgUp / PgDn, mouse wheel | scroll long content (summary, plan, answer) | +| | drag / double-click / triple-click, right-click | select text in the panel (goal, steps, output, error messages) and copy it right away (clipboard + OSC 52): word / line; right-click copies the selection again | | Plan mode | ↑↓ / Space / e / v / ? | choose step / remove or restore / edit / view script / re-plan | | | Tab / ⏎ / x | how it runs (step by step or agent level) / approve and run / discard; Ctrl+S saves the plan as a runbook | | AI inputs | ⇧⏎ / Ctrl+J | new line in goal, question and palette (long texts wrap automatically, the field grows) | diff --git a/internal/i18n/en_panelsel.go b/internal/i18n/en_panelsel.go new file mode 100644 index 0000000..9d7df46 --- /dev/null +++ b/internal/i18n/en_panelsel.go @@ -0,0 +1,10 @@ +package i18n + +// Markieren und Kopieren im Seitenpanel (eigene Datei gegen Konflikte in en.go). +func init() { + for de, e := range map[string]string{ + "markieren + kopieren, auch im Panel": "select + copy, also in the panel", + } { + en[de] = e + } +} diff --git a/internal/ui/help.go b/internal/ui/help.go index 71af60c..6b7a481 100644 --- a/internal/ui/help.go +++ b/internal/ui/help.go @@ -296,7 +296,7 @@ var helpSections = []helpSection{ {hcNone, "◦", "Maus", "", false, [][2]string{ {"Klick", "Tabs, Listen, Felder"}, {"Doppelklick", "öffnen / Wort"}, - {"Ziehen", "markieren + kopieren"}, + {"Ziehen", "markieren + kopieren, auch im Panel"}, {"Rechtsklick", "einfügen"}, {"Rechtsklick Link", "Menü: Verbinden, Ping"}, {"Rechtsklick Tab", "Menü: umbenennen, schließen …"}, diff --git a/internal/ui/mouse.go b/internal/ui/mouse.go index b0c6326..ab91a0b 100644 --- a/internal/ui/mouse.go +++ b/internal/ui/mouse.go @@ -128,6 +128,11 @@ func (a *App) mouse(msg tea.MouseMsg) tea.Cmd { } } + // Seitenpanel (Ziel, KI fragen, Begleiter): Text markieren und kopieren + if cmd, ok := a.panelSelMouse(s, msg, clicks); ok { + return cmd + } + if isWheel { up := m.Button == tea.MouseWheelUp if m.Button != tea.MouseWheelUp && m.Button != tea.MouseWheelDown { @@ -610,6 +615,7 @@ func (a *App) modalKeys() [][2]string { // mouseHelp: Abschnitt für die Hilfe (F1). const mouseHelp = `Maus Klick auf Tabs, Listen, Vorschläge, Felder, Fußzeile · Doppelklick öffnet Terminal: Ziehen markiert + kopiert · Doppel-/Dreifachklick Wort/Zeile + Ziel-/Agent-Panel, KI fragen: ebenso, Rechtsklick kopiert die Markierung Rechtsklick fügt ein, auf Link/IP/Host öffnet er ein Menü · Strg+Klick öffnet URL Rad blättert im Verlauf (Esc zurück) htop, mc, vim, tmux bekommen die Maus · Shift+Ziehen markiert trotzdem diff --git a/internal/ui/panels.go b/internal/ui/panels.go index c4e0e42..768def8 100644 --- a/internal/ui/panels.go +++ b/internal/ui/panels.go @@ -9,6 +9,7 @@ import ( tea "charm.land/bubbletea/v2" "charm.land/lipgloss/v2" + "github.com/charmbracelet/x/ansi" "github.com/db9979/sshtermy/internal/agent" "github.com/db9979/sshtermy/internal/domain" @@ -442,6 +443,9 @@ func (a *App) runProposal(s *session, cmd string, insertOnly bool) { func (a *App) panelMsg(s *session, msg tea.Msg) tea.Cmd { k, isKey := msg.(tea.KeyPressMsg) + if isKey { + s.psel = nil // Tippen hebt die Markierung auf + } if isKey && k.String() == "esc" && s.panel == panelGoal && s.goal.agentRunning() { a.agentPause(s, i18n.T("von dir angehalten (Esc)")) return nil @@ -842,6 +846,7 @@ func (a *App) viewPanel(s *session, w, h int) string { if s.panel != s.panelSeen { s.panelSeen, s.panelAt = s.panel, time.Now() s.pscroll = panelScroll{} + s.psel = nil } inner := w - 4 var b strings.Builder @@ -868,8 +873,12 @@ func (a *App) viewPanel(s *session, w, h int) string { ps.markSeen, ps.pinned = ps.mark, false } var out string + var sel panelSel + if s.psel != nil { + sel = *s.psel + } if m.ok && m.raw == raw && m.w == w && m.h == h && m.focus == s.panelFocus && m.style == a.styleGen && m.kind == s.panel && m.top == top && - m.pinned == ps.pinned && m.start == ps.start { + m.pinned == ps.pinned && m.start == ps.start && m.sel == sel { out = m.out } else { style := st.Panel @@ -877,10 +886,18 @@ func (a *App) viewPanel(s *session, w, h int) string { style = st.PanelFocus } content := lipgloss.NewStyle().Width(inner).Render(raw) - lines := a.scrollPanelLines(s, strings.Split(content, "\n"), h-2, top, inner) + all := strings.Split(content, "\n") + s.pplain = s.pplain[:0] + for _, l := range all { + s.pplain = append(s.pplain, ansi.Strip(l)) + } + lines := a.scrollPanelLines(s, all, h-2, top, inner) + if selectablePanel(s.panel) { + a.highlightPanelSel(s, lines, ps.start, inner) + } out = style.Width(w).Height(h).MaxHeight(h).Render(strings.Join(lines, "\n")) *m = panelMemo{raw: raw, w: w, h: h, focus: s.panelFocus, style: a.styleGen, kind: s.panel, top: top, out: out, ok: true, - pinned: ps.pinned, start: ps.start} + pinned: ps.pinned, start: ps.start, sel: sel} } if d := time.Since(s.panelAt); motionLevel() > 0 && d < fadeInDur*2 { out = fadeANSI(out, st.T, easeOut(float64(d)/float64(fadeInDur*2))) // Panel blendet ein @@ -901,6 +918,7 @@ type panelMemo struct { // Blättern (panelscroll.go) pinned bool start int + sel panelSel // Markierung (panelsel.go) } func wrap(s string, w int) string { return lipgloss.NewStyle().Width(w).Render(s) } diff --git a/internal/ui/panelsel.go b/internal/ui/panelsel.go new file mode 100644 index 0000000..2e59796 --- /dev/null +++ b/internal/ui/panelsel.go @@ -0,0 +1,251 @@ +package ui + +import ( + "strings" + "unicode" + "unicode/utf8" + + tea "charm.land/bubbletea/v2" + "github.com/atotto/clipboard" + "github.com/charmbracelet/x/ansi" + + "github.com/db9979/sshtermy/internal/i18n" +) + +// Markieren im Seitenpanel (Ziel/Agent/Plan, KI fragen, Begleiter) +// +// Die Maus gehört sshTermy, also kann das Terminalfenster dort nichts +// markieren. Deshalb markiert sshTermy selbst, wie im Terminal: Ziehen +// markiert, Loslassen kopiert (Zwischenablage + OSC 52), Doppelklick = Wort, +// Dreifachklick = Zeile, Rechtsklick kopiert die Markierung. Über den Rand +// ziehen blättert mit. Anklickbares (Hinweise, Antwortvorschläge) bleibt +// anklickbar; Ziehen fängt dann daneben an. + +// pselPos: Stelle im Panelinhalt (Zeile des ganzen Inhalts, Spalte in Zellen). +type pselPos struct{ line, col int } + +func (p pselPos) before(q pselPos) bool { + return p.line < q.line || (p.line == q.line && p.col < q.col) +} + +type panelSel struct { + a, b pselPos + dragging bool +} + +// norm: Anfang vor Ende. +func (p panelSel) norm() (pselPos, pselPos) { + if p.b.before(p.a) { + return p.b, p.a + } + return p.a, p.b +} + +func (p panelSel) empty() bool { return p.a == p.b } + +// selectablePanel: in welchen Panels markiert sshTermy selbst? +func selectablePanel(k panelKind) bool { + return k == panelGoal || k == panelAsk || k == panelCompanion +} + +// panelTextPos: Stelle im Panelinhalt unter (x, y). ok = false außerhalb der +// Textfläche (Rahmen, unter dem Inhalt). Mit clampIt wird auf die Fläche +// begrenzt (Ziehen über den Rand); dy sagt dann, ob oben (-1) oder unten (+1) +// hinausgezogen wurde. +func (a *App) panelTextPos(s *session, x, y int, clampIt bool) (p pselPos, dy int, ok bool) { + r := a.termRect(s) + pw := a.panelShown(s) + x0, y0 := r.x+r.w-pw+2, r.y+1 // Rahmen + Innenabstand + w := pw - 4 + vis := s.pscroll.vis + if s.pscroll.total <= vis || vis <= 0 { + vis = s.pscroll.total + } + if w <= 0 || vis <= 0 { + return p, 0, false + } + row, col := y-y0, x-x0 + if row < 0 { + dy = -1 + } else if row >= vis { + dy = 1 + } + if !clampIt && (dy != 0 || col < 0 || col >= w) { + return p, 0, false + } + row, col = clamp(row, 0, vis-1), clamp(col, 0, w) + return pselPos{line: s.pscroll.start + row, col: col}, dy, true +} + +// panelSelMouse: Markieren im Panel. ok = false: Ereignis gehört nicht hierher. +func (a *App) panelSelMouse(s *session, msg tea.MouseMsg, clicks int) (tea.Cmd, bool) { + if a.scr != scrTerminal || s == nil || a.modal != nil || a.pal != nil || a.pick != nil || + !selectablePanel(s.panel) || s.files.open || (s.panel == panelHost && s.host.live.wide) { + return nil, false + } + if a.panelCollapsed(s) && !s.panelFocus { + return nil, false // nur die schmale Leiste ist zu sehen + } + m := msg.Mouse() + _, isClick := msg.(tea.MouseClickMsg) + _, isRelease := msg.(tea.MouseReleaseMsg) + _, isMotion := msg.(tea.MouseMotionMsg) + + if sel := s.psel; sel != nil && sel.dragging { + switch { + case isMotion: + p, dy, _ := a.panelTextPos(s, m.X, m.Y, true) + if dy != 0 && s.scrollPanel(dy) { // über den Rand: mitblättern + p.line += dy + } + sel.b = p + return nil, true + case isRelease: + sel.dragging = false + if sel.empty() { + s.psel = nil + return nil, true + } + return a.copyPanelSel(s), true + } + return nil, true + } + + if !isClick || !a.inPanel(s, m.X, m.Y) { + return nil, false + } + switch m.Button { + case tea.MouseRight: + if s.psel != nil && !s.psel.empty() { + cmd := a.copyPanelSel(s) + s.psel = nil + return cmd, true + } + return nil, false + case tea.MouseLeft: + default: + return nil, false + } + // Anklickbares bleibt anklickbar (Hinweise, Vorschläge, Runbooks); nur + // große Blöcke (KI-Karten) lassen sich zusätzlich markieren. + if act := a.z.at(m.X, m.Y, false); act != nil && !act.block { + s.psel = nil + return nil, false + } + p, _, ok := a.panelTextPos(s, m.X, m.Y, false) + if !ok { + s.psel = nil + return nil, false + } + s.panelFocus = true + switch { + case clicks == 2: + s.psel = a.panelWordAt(s, p) + return a.copyPanelSel(s), true + case clicks >= 3: + s.psel = &panelSel{a: pselPos{p.line, 0}, b: pselPos{p.line, 1 << 20}} + return a.copyPanelSel(s), true + } + s.psel = &panelSel{a: p, b: p, dragging: true} + // Klick auf eine KI-Karte wählt sie weiterhin aus. + if act := a.z.at(m.X, m.Y, false); act != nil { + return act.click(m, false), true + } + return nil, true +} + +// panelWordAt: Wort unter p (Leerzeichen trennen). +func (a *App) panelWordAt(s *session, p pselPos) *panelSel { + if p.line < 0 || p.line >= len(s.pplain) { + return nil + } + cells := []rune{} + for _, r := range s.pplain[p.line] { + cells = append(cells, r) + for i := 1; i < ansi.StringWidth(string(r)); i++ { + cells = append(cells, 0) // zweite Zelle breiter Zeichen + } + } + space := func(i int) bool { return i >= len(cells) || (cells[i] != 0 && unicode.IsSpace(cells[i])) } + if space(p.col) { + return nil + } + l, r := p.col, p.col + for l > 0 && !space(l-1) { + l-- + } + for r+1 < len(cells) && !space(r+1) { + r++ + } + return &panelSel{a: pselPos{p.line, l}, b: pselPos{p.line, r + 1}} +} + +// panelSelText: markierter Text, Zeilen ohne Leerzeichen am Ende. +func (s *session) panelSelText() string { + if s.psel == nil { + return "" + } + a, b := s.psel.norm() + var out []string + for l := max(0, a.line); l <= b.line && l < len(s.pplain); l++ { + line := s.pplain[l] + from, to := 0, ansi.StringWidth(line) + if l == a.line { + from = a.col + } + if l == b.line { + to = min(to, b.col) + } + t := "" + if to > from { + t = ansi.Cut(line, from, to) + } + out = append(out, strings.TrimRight(t, " ")) + } + return strings.Trim(strings.Join(out, "\n"), "\n") +} + +// copyPanelSel kopiert die Markierung im Panel (Betriebssystem + OSC 52). +func (a *App) copyPanelSel(s *session) tea.Cmd { + text := s.panelSelText() + if strings.TrimSpace(text) == "" { + return nil + } + go func() { _ = clipboard.WriteAll(text) }() + if lines := strings.Count(text, "\n") + 1; lines > 1 { + a.flash(i18n.T("Kopiert: ") + plural(lines, i18n.T("Zeile"), i18n.T("Zeilen"))) + } else { + n := utf8.RuneCountInString(text) + a.flash(i18n.T("Kopiert: ") + plural(n, i18n.T("Zeichen"), i18n.T("Zeichen"))) + } + return tea.SetClipboard(text) +} + +// highlightPanelSel hebt die Markierung in den sichtbaren Panelzeilen hervor. +// start: Inhaltszeile der ersten sichtbaren Zeile, w: Breite der Textfläche. +func (a *App) highlightPanelSel(s *session, lines []string, start, w int) { + if s.psel == nil || s.psel.empty() { + return + } + p, q := s.psel.norm() + hl := a.s.Selected + for i := range lines { + l := start + i + if l < p.line || l > q.line { + continue + } + from, to := 0, w + if l == p.line { + from = p.col + } + if l == q.line { + to = min(w, q.col) + } + if to <= from { + continue + } + line := lines[i] + plain := ansi.Strip(ansi.Cut(line, from, to)) + lines[i] = ansi.Cut(line, 0, from) + hl.Render(plain) + ansi.Cut(line, to, max(w, ansi.StringWidth(line))) + } +} diff --git a/internal/ui/panelsel_test.go b/internal/ui/panelsel_test.go new file mode 100644 index 0000000..8a15605 --- /dev/null +++ b/internal/ui/panelsel_test.go @@ -0,0 +1,123 @@ +package ui + +import ( + "strings" + "testing" + "time" + + tea "charm.land/bubbletea/v2" + "github.com/charmbracelet/x/ansi" + + "github.com/db9979/sshtermy/internal/domain" +) + +// Im Ziel-Panel lässt sich Text mit der Maus markieren und kopieren: +// Ziehen, Doppelklick (Wort), Dreifachklick (Zeile), Rechtsklick. +func TestGoalPanelSelectCopy(t *testing.T) { + a, s, _ := agentSession(t, domain.Connection{Alias: "lab-01"}, lvlNormal) + a.w, a.h, a.intro = 160, 40, nil + a.resizeAll() + g := &s.goal + g.busy = false + g.err = "Antwort des Modells nicht lesbar: XYZ123 kaputt" + s.panelFocus = false + + at := func(word string) (int, int) { + t.Helper() + lines := strings.Split(ansi.Strip(a.View().Content), "\n") + for y, l := range lines { + if i := strings.Index(l, word); i >= 0 { + return ansi.StringWidth(l[:i]), y + } + } + t.Fatalf("%q nicht gefunden:\n%s", word, strings.Join(lines, "\n")) + return 0, 0 + } + x, y := at("XYZ123") + if !a.inPanel(s, x, y) { + t.Fatalf("XYZ123 bei %d,%d liegt nicht im Panel", x, y) + } + + // Ziehen über „XYZ123 kaputt“ (umbrochen auf zwei Zeilen) + kx, ky := at("kaputt") + a.mouse(tea.MouseClickMsg{X: x, Y: y, Button: tea.MouseLeft}) + a.mouse(tea.MouseMotionMsg{X: x + 5, Y: y, Button: tea.MouseLeft}) + a.mouse(tea.MouseMotionMsg{X: kx + 6, Y: ky, Button: tea.MouseLeft}) + cmd := a.mouse(tea.MouseReleaseMsg{X: kx + 6, Y: ky, Button: tea.MouseLeft}) + if got := s.panelSelText(); got != "XYZ123\nkaputt" { + t.Fatalf("Markierung = %q\n%s", got, ansi.Strip(a.View().Content)) + } + if cmd == nil { + t.Fatal("Loslassen muss kopieren (OSC 52)") + } + s.panelAt = time.Now().Add(-time.Hour) // ohne Einblenden + view := a.View().Content + if !strings.Contains(view, a.s.Selected.Render("kaputt")) { + t.Fatal("Markierung wird nicht hervorgehoben") + } + plain := strings.Split(ansi.Strip(view), "\n") + if w := ansi.StringWidth(plain[y]); w != a.w || !strings.Contains(plain[y], "XYZ123 │") { + t.Fatalf("Panelzeile verrutscht (%d Spalten): %q", w, plain[y]) + } + + // Doppelklick: Wort + a.click = clickState{} + a.mouse(tea.MouseClickMsg{X: x + 2, Y: y, Button: tea.MouseLeft}) + a.mouse(tea.MouseReleaseMsg{X: x + 2, Y: y, Button: tea.MouseLeft}) + a.mouse(tea.MouseClickMsg{X: x + 2, Y: y, Button: tea.MouseLeft}) + if got := s.panelSelText(); got != "XYZ123" { + t.Fatalf("Doppelklick = %q", got) + } + // Dreifachklick: ganze Zeile + a.mouse(tea.MouseClickMsg{X: x + 2, Y: y, Button: tea.MouseLeft}) + if got := s.panelSelText(); !strings.HasPrefix(got, "× Antwort des Modells") || !strings.Contains(got, "XYZ123") { + t.Fatalf("Dreifachklick = %q", got) + } + + // mehrere Zeilen: vom Ziel bis zum Fehler + a.click = clickState{} + gx, gy := at("Logrotation einrichten") + a.mouse(tea.MouseClickMsg{X: gx, Y: gy, Button: tea.MouseLeft}) + a.mouse(tea.MouseMotionMsg{X: x + 6, Y: y, Button: tea.MouseLeft}) + a.mouse(tea.MouseReleaseMsg{X: x + 6, Y: y, Button: tea.MouseLeft}) + got := s.panelSelText() + if !strings.HasPrefix(got, "Logrotation einrichten") || !strings.HasSuffix(got, "XYZ123") || strings.Count(got, "\n") < 2 { + t.Fatalf("mehrzeilig = %q", got) + } + // Rechtsklick kopiert und hebt auf + if cmd := a.mouse(tea.MouseClickMsg{X: x, Y: y, Button: tea.MouseRight}); cmd == nil || s.psel != nil { + t.Fatal("Rechtsklick muss die Markierung kopieren") + } + // Taste hebt die Markierung auf + a.click = clickState{} + a.mouse(tea.MouseClickMsg{X: x, Y: y, Button: tea.MouseLeft}) + a.mouse(tea.MouseMotionMsg{X: x + 3, Y: y, Button: tea.MouseLeft}) + a.mouse(tea.MouseReleaseMsg{X: x + 3, Y: y, Button: tea.MouseLeft}) + a.panelMsg(s, runeKey('x')) + if s.psel != nil { + t.Fatal("Tippen muss die Markierung aufheben") + } +} + +// Klickbare Hinweise im Panel bleiben klickbar und starten keine Markierung. +func TestGoalPanelHintsStillClick(t *testing.T) { + a, s, _ := agentSession(t, domain.Connection{Alias: "lab-01"}, lvlNormal) + a.w, a.h, a.intro = 160, 40, nil + a.resizeAll() + s.goal.busy = false + s.goal.done, s.goal.doneReason = true, "alles erledigt" + lines := strings.Split(ansi.Strip(a.View().Content), "\n") + for y, l := range lines { + if i := strings.Index(l, "ganz lesen"); i >= 0 { + a.mouse(tea.MouseClickMsg{X: ansi.StringWidth(l[:i]), Y: y, Button: tea.MouseLeft}) + if s.psel != nil { + t.Fatal("Klick auf Hinweis darf nicht markieren") + } + if a.modal == nil || a.modal.kind != mText { + t.Fatal("Klick auf „l ganz lesen“ wirkt nicht mehr") + } + return + } + } + t.Fatal("Hinweis nicht gefunden") +} diff --git a/internal/ui/session.go b/internal/ui/session.go index 1143c95..7fa74ca 100644 --- a/internal/ui/session.go +++ b/internal/ui/session.go @@ -78,6 +78,8 @@ type session struct { viewMemo termMemo // letztes Terminalbild (perf.go: termView) panelMemo panelMemo // letzte Seitenleiste (panels.go: viewPanel) pscroll panelScroll // Blättern in der Seitenleiste (panelscroll.go) + psel *panelSel // Markierung in der Seitenleiste (panelsel.go) + pplain []string // Seitenleiste als Klartext, je Inhaltszeile (zum Kopieren) notice noticeKind // Markierung im Tab: Befehl fertig, Glocke (notify.go) unseen bool // neue Ausgabe, solange der Tab verdeckt war (motion.go) diff --git a/site/de/index.html b/site/de/index.html index 7810436..fb65b94 100644 --- a/site/de/index.html +++ b/site/de/index.html @@ -102,7 +102,7 @@ sudo apt update && sudo apt install sshtermy

Agent-Modus: das Ziel selbstständig erreichen

-

Im Ziel-Modus (F2) schaltet Tab auf den Agenten. Er führt Befehle aus, liest die Ausgabe, legt Skripte per SFTP an und startet sie, zuerst als Probelauf. Du wählst die Stufe: Vorsichtig (Standard, nur Lesendes allein), Normal (als root fragt jede Änderung) oder Voll (auch sudo). Gefährliche Befehle und alles, was Geheimnisse liest, warten immer auf dich, Esc hält an, ? gibt eine Anweisung. Am Ende steht die vollständige Zusammenfassung: blättern, mit c kopieren oder mit l ganz lesen. Mit Erst planen sieht er sich nur lesend um, schreibt einen vollständigen Plan, und du streichst oder änderst Schritte, bevor du mit ⏎ freigibst.

+

Im Ziel-Modus (F2) schaltet Tab auf den Agenten. Er führt Befehle aus, liest die Ausgabe, legt Skripte per SFTP an und startet sie, zuerst als Probelauf. Du wählst die Stufe: Vorsichtig (Standard, nur Lesendes allein), Normal (als root fragt jede Änderung) oder Voll (auch sudo). Gefährliche Befehle und alles, was Geheimnisse liest, warten immer auf dich, Esc hält an, ? gibt eine Anweisung. Am Ende steht die vollständige Zusammenfassung: blättern, mit c kopieren oder mit l ganz lesen. Jeder Text im Panel, auch Fehlermeldungen, lässt sich mit der Maus markieren und wird gleich kopiert. Mit Erst planen sieht er sich nur lesend um, schreibt einen vollständigen Plan, und du streichst oder änderst Schritte, bevor du mit ⏎ freigibst.

Agent-Modus komprimiert alte Logs: rechts der Plan, ein Skript lief als Probelauf
@@ -202,7 +202,7 @@ sudo apt update && sudo apt install sshtermy Alt+1…4Folgebefehl einfügen Alt+0Nach einem Fehler: Ursache und Fix F2Ziel-Modus (Agent) - F2 → c / lAgent fertig: Ergebnis kopieren / ganz lesen; Bild↑/Bild↓ oder Mausrad blättern im Panel + F2 → c / lAgent fertig: Ergebnis kopieren / ganz lesen; Bild↑/Bild↓ oder Mausrad blättern im Panel; mit der Maus ziehen markiert und kopiert Text im Panel (Ziel, Schritte, Ausgaben, Fehler) F3KI fragen, mit Terminal-Kontext; Esc bricht die Antwort ab, n neue Frage, f Folgefrage, u Fix übernehmen, wenn ein Kartenbefehl fehlschlug Alt+K / Alt+JKI-Begleiter: Stufe (aus, leise, gesprächig, Coach) / Begleiter-Leiste F4 / F5 / F6Tunnel / Dateien (SFTP) / Host-Übersicht diff --git a/site/handout/sshtermy-kurzreferenz-de.pdf b/site/handout/sshtermy-kurzreferenz-de.pdf index 4bec413..312aacd 100644 Binary files a/site/handout/sshtermy-kurzreferenz-de.pdf and b/site/handout/sshtermy-kurzreferenz-de.pdf differ diff --git a/site/handout/sshtermy-quickref-en.pdf b/site/handout/sshtermy-quickref-en.pdf index 2f6a080..75b0412 100644 Binary files a/site/handout/sshtermy-quickref-en.pdf and b/site/handout/sshtermy-quickref-en.pdf differ diff --git a/site/index.html b/site/index.html index 8f9f117..c411105 100644 --- a/site/index.html +++ b/site/index.html @@ -102,7 +102,7 @@ sudo apt update && sudo apt install sshtermy

Agent mode: reach the goal on its own

-

In goal mode (F2) Tab switches to the agent. It runs commands, reads their output, writes scripts via SFTP and runs them, dry run first. You pick the level: Careful (default, read-only on its own), Normal (signed in as root every change asks) or Full (sudo too). Dangerous commands and anything that reads secrets always wait for you, Esc pauses, ? gives an instruction. At the end you get the complete summary: scroll it, copy it with c or read it in full with l. With Plan first it only looks around read-only, writes a full plan, and you remove or change steps before you approve it with ⏎.

+

In goal mode (F2) Tab switches to the agent. It runs commands, reads their output, writes scripts via SFTP and runs them, dry run first. You pick the level: Careful (default, read-only on its own), Normal (signed in as root every change asks) or Full (sudo too). Dangerous commands and anything that reads secrets always wait for you, Esc pauses, ? gives an instruction. At the end you get the complete summary: scroll it, copy it with c or read it in full with l. Any text in the panel, error messages included, can be selected with the mouse and is copied right away. With Plan first it only looks around read-only, writes a full plan, and you remove or change steps before you approve it with ⏎.

Agent mode compresses old logs: plan on the right, a script ran as a dry run
@@ -201,7 +201,7 @@ sudo apt update && sudo apt install sshtermy Ctrl+SpaceCommand palette F1Help F2Goal mode (agent) - F2 → c / lAgent finished: copy the result / read it in full; PgUp/PgDn or the mouse wheel scroll the panel + F2 → c / lAgent finished: copy the result / read it in full; PgUp/PgDn or the mouse wheel scroll the panel; drag with the mouse to select and copy text in the panel (goal, steps, output, errors) F3Ask AI with terminal context; Esc stops the answer, n new question, f follow-up, u use the fix after a failed card command Alt+K / Alt+JAI companion: level (off, quiet, chatty, coach) / companion sidebar F4 / F5 / F6Tunnels / files (SFTP) / host overview diff --git a/tools/handout/content.mjs b/tools/handout/content.mjs index 4ccafe0..ef4b92d 100644 --- a/tools/handout/content.mjs +++ b/tools/handout/content.mjs @@ -76,7 +76,7 @@ export const de = { ['_Titel ziehen_', 'Bereiche tauschen'], ]}, { t: 'Maus', ic: '◦', rows: [ - ['_Ziehen_', 'markieren + kopieren'], + ['_Ziehen_', 'markieren + kopieren, auch im Panel'], ['_Rechtsklick_', 'einfügen · auf Link/IP: Menü'], ['Strg+_Klick_', 'URL im Browser öffnen'], ['⇧+_Ziehen_', 'markieren in htop / vim'], @@ -245,7 +245,7 @@ export const en = { ['_drag title_', 'swap panes'], ]}, { t: 'Mouse', ic: '◦', rows: [ - ['_drag_', 'select + copy'], + ['_drag_', 'select + copy, also in the panel'], ['_right-click_', 'paste · on a link/IP: menu'], ['Ctrl+_click_', 'open URL in the browser'], ['⇧+_drag_', 'select inside htop / vim'], diff --git a/tools/handout/keys.sha256 b/tools/handout/keys.sha256 index 38719e1..bda7e8c 100644 --- a/tools/handout/keys.sha256 +++ b/tools/handout/keys.sha256 @@ -1 +1 @@ -effab76bd4289d6e0056dadb3608072a44a9d4aec267337f670f8cfc314cf5fb +6667a1e018387e71ce40a201dac8b3c1dc675a37d2fccc273f27a2f5f834d13a