mirror of
https://github.com/db9979/sshtermy.git
synced 2026-12-06 04:34:08 +01:00
Ziel-Modus: Text im Panel mit der Maus markieren und kopieren (#128)
Ziehen markiert, Loslassen kopiert (Zwischenablage + OSC 52), Doppelklick Wort, Dreifachklick Zeile, Rechtsklick kopiert die Markierung erneut. Über den Rand ziehen blättert mit. Klickbare Hinweise und Antwortvorschläge bleiben klickbar. Doku: README, Webseite, Hilfe, Kurzreferenz. Claude-Session: https://claude.ai/code/session_018i4GUg4eR8Nb3dh2Bj5GFs Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
4a3d969f60
commit
cbdce03063
15 files changed
+425
-13
No files matched your search
+2
-1
@@ -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/<lauf>/` 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) |
|
||||
|
||||
@@ -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/<run>/` 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) |
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -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 …"},
|
||||
|
||||
@@ -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
|
||||
|
||||
+21
-3
@@ -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) }
|
||||
|
||||
@@ -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)))
|
||||
}
|
||||
}
|
||||
@@ -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")
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
+2
-2
@@ -102,7 +102,7 @@ sudo apt update && sudo apt install sshtermy</pre></div>
|
||||
<div class="demo">
|
||||
<div class="text">
|
||||
<h3>Agent-Modus: das Ziel selbstständig erreichen</h3>
|
||||
<p>Im Ziel-Modus (<kbd>F2</kbd>) schaltet <kbd>Tab</kbd> 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: <em>Vorsichtig</em> (Standard, nur Lesendes allein), <em>Normal</em> (als root fragt jede Änderung) oder <em>Voll</em> (auch sudo). Gefährliche Befehle und alles, was Geheimnisse liest, warten immer auf dich, <kbd>Esc</kbd> hält an, <kbd>?</kbd> gibt eine Anweisung. Am Ende steht die vollständige Zusammenfassung: blättern, mit <kbd>c</kbd> kopieren oder mit <kbd>l</kbd> ganz lesen. Mit <em>Erst planen</em> sieht er sich nur lesend um, schreibt einen vollständigen Plan, und du streichst oder änderst Schritte, bevor du mit <kbd>⏎</kbd> freigibst.</p>
|
||||
<p>Im Ziel-Modus (<kbd>F2</kbd>) schaltet <kbd>Tab</kbd> 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: <em>Vorsichtig</em> (Standard, nur Lesendes allein), <em>Normal</em> (als root fragt jede Änderung) oder <em>Voll</em> (auch sudo). Gefährliche Befehle und alles, was Geheimnisse liest, warten immer auf dich, <kbd>Esc</kbd> hält an, <kbd>?</kbd> gibt eine Anweisung. Am Ende steht die vollständige Zusammenfassung: blättern, mit <kbd>c</kbd> kopieren oder mit <kbd>l</kbd> ganz lesen. Jeder Text im Panel, auch Fehlermeldungen, lässt sich mit der Maus markieren und wird gleich kopiert. Mit <em>Erst planen</em> sieht er sich nur lesend um, schreibt einen vollständigen Plan, und du streichst oder änderst Schritte, bevor du mit <kbd>⏎</kbd> freigibst.</p>
|
||||
</div>
|
||||
<figure><img src="../bilder/16-agent.png" alt="Agent-Modus komprimiert alte Logs: rechts der Plan, ein Skript lief als Probelauf" loading="lazy"></figure>
|
||||
</div>
|
||||
@@ -202,7 +202,7 @@ sudo apt update && sudo apt install sshtermy</pre></div>
|
||||
<tr><td><kbd>Alt</kbd>+<kbd>1</kbd>…<kbd>4</kbd></td><td>Folgebefehl einfügen</td></tr>
|
||||
<tr><td><kbd>Alt</kbd>+<kbd>0</kbd></td><td>Nach einem Fehler: Ursache und Fix</td></tr>
|
||||
<tr><td><kbd>F2</kbd></td><td>Ziel-Modus (Agent)</td></tr>
|
||||
<tr><td><kbd>F2</kbd> → <kbd>c</kbd> / <kbd>l</kbd></td><td>Agent fertig: Ergebnis kopieren / ganz lesen; <kbd>Bild↑</kbd>/<kbd>Bild↓</kbd> oder Mausrad blättern im Panel</td></tr>
|
||||
<tr><td><kbd>F2</kbd> → <kbd>c</kbd> / <kbd>l</kbd></td><td>Agent fertig: Ergebnis kopieren / ganz lesen; <kbd>Bild↑</kbd>/<kbd>Bild↓</kbd> oder Mausrad blättern im Panel; mit der Maus ziehen markiert und kopiert Text im Panel (Ziel, Schritte, Ausgaben, Fehler)</td></tr>
|
||||
<tr><td><kbd>F3</kbd></td><td>KI fragen, mit Terminal-Kontext; <kbd>Esc</kbd> bricht die Antwort ab, <kbd>n</kbd> neue Frage, <kbd>f</kbd> Folgefrage, <kbd>u</kbd> Fix übernehmen, wenn ein Kartenbefehl fehlschlug</td></tr>
|
||||
<tr><td><kbd>Alt</kbd>+<kbd>K</kbd> / <kbd>Alt</kbd>+<kbd>J</kbd></td><td>KI-Begleiter: Stufe (aus, leise, gesprächig, Coach) / Begleiter-Leiste</td></tr>
|
||||
<tr><td><kbd>F4</kbd> / <kbd>F5</kbd> / <kbd>F6</kbd></td><td>Tunnel / Dateien (SFTP) / Host-Übersicht</td></tr>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+2
-2
@@ -102,7 +102,7 @@ sudo apt update && sudo apt install sshtermy</pre></div>
|
||||
<div class="demo">
|
||||
<div class="text">
|
||||
<h3>Agent mode: reach the goal on its own</h3>
|
||||
<p>In goal mode (<kbd>F2</kbd>) <kbd>Tab</kbd> switches to the agent. It runs commands, reads their output, writes scripts via SFTP and runs them, dry run first. You pick the level: <em>Careful</em> (default, read-only on its own), <em>Normal</em> (signed in as root every change asks) or <em>Full</em> (sudo too). Dangerous commands and anything that reads secrets always wait for you, <kbd>Esc</kbd> pauses, <kbd>?</kbd> gives an instruction. At the end you get the complete summary: scroll it, copy it with <kbd>c</kbd> or read it in full with <kbd>l</kbd>. With <em>Plan first</em> it only looks around read-only, writes a full plan, and you remove or change steps before you approve it with <kbd>⏎</kbd>.</p>
|
||||
<p>In goal mode (<kbd>F2</kbd>) <kbd>Tab</kbd> switches to the agent. It runs commands, reads their output, writes scripts via SFTP and runs them, dry run first. You pick the level: <em>Careful</em> (default, read-only on its own), <em>Normal</em> (signed in as root every change asks) or <em>Full</em> (sudo too). Dangerous commands and anything that reads secrets always wait for you, <kbd>Esc</kbd> pauses, <kbd>?</kbd> gives an instruction. At the end you get the complete summary: scroll it, copy it with <kbd>c</kbd> or read it in full with <kbd>l</kbd>. Any text in the panel, error messages included, can be selected with the mouse and is copied right away. With <em>Plan first</em> it only looks around read-only, writes a full plan, and you remove or change steps before you approve it with <kbd>⏎</kbd>.</p>
|
||||
</div>
|
||||
<figure><img src="bilder/16-agent.png" alt="Agent mode compresses old logs: plan on the right, a script ran as a dry run" loading="lazy"></figure>
|
||||
</div>
|
||||
@@ -201,7 +201,7 @@ sudo apt update && sudo apt install sshtermy</pre></div>
|
||||
<tr><td><kbd>Ctrl</kbd>+<kbd>Space</kbd></td><td>Command palette</td></tr>
|
||||
<tr><td><kbd>F1</kbd></td><td>Help</td></tr>
|
||||
<tr><td><kbd>F2</kbd></td><td>Goal mode (agent)</td></tr>
|
||||
<tr><td><kbd>F2</kbd> → <kbd>c</kbd> / <kbd>l</kbd></td><td>Agent finished: copy the result / read it in full; <kbd>PgUp</kbd>/<kbd>PgDn</kbd> or the mouse wheel scroll the panel</td></tr>
|
||||
<tr><td><kbd>F2</kbd> → <kbd>c</kbd> / <kbd>l</kbd></td><td>Agent finished: copy the result / read it in full; <kbd>PgUp</kbd>/<kbd>PgDn</kbd> or the mouse wheel scroll the panel; drag with the mouse to select and copy text in the panel (goal, steps, output, errors)</td></tr>
|
||||
<tr><td><kbd>F3</kbd></td><td>Ask AI with terminal context; <kbd>Esc</kbd> stops the answer, <kbd>n</kbd> new question, <kbd>f</kbd> follow-up, <kbd>u</kbd> use the fix after a failed card command</td></tr>
|
||||
<tr><td><kbd>Alt</kbd>+<kbd>K</kbd> / <kbd>Alt</kbd>+<kbd>J</kbd></td><td>AI companion: level (off, quiet, chatty, coach) / companion sidebar</td></tr>
|
||||
<tr><td><kbd>F4</kbd> / <kbd>F5</kbd> / <kbd>F6</kbd></td><td>Tunnels / files (SFTP) / host overview</td></tr>
|
||||
|
||||
@@ -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'],
|
||||
|
||||
@@ -1 +1 @@
|
||||
effab76bd4289d6e0056dadb3608072a44a9d4aec267337f670f8cfc314cf5fb
|
||||
6667a1e018387e71ce40a201dac8b3c1dc675a37d2fccc273f27a2f5f834d13a
|
||||
Reference in new issue
Block a user