mirror of
https://github.com/db9979/sshtermy.git
synced 2026-12-05 12:24:08 +01:00
Ideen aus herdr: Wartet-Marke, KI-Agenten, Tabs zurück, Hintergrunddienst (#168)
* Ideen aus herdr: Wartet-Marke, KI-Agenten, Tabs zurück, Hintergrunddienst u. a. - Wartet-Marke ? je Tab (Passwort, [j/N], Taste, Pager), Alt+G springt hin - KI-Coding-Agenten im Tab erkennen (Claude Code, Codex, Gemini CLI …): arbeitet / wartet auf Freigabe (◆ + Desktop-Meldung) / fertig - Tabs vom letzten Mal beim Start wieder öffnen (fragen / immer / nie) - Klick auf Desktop-Meldung (Linux) bzw. Fenster nach vorn springt in den Tab - MCP: open_tab, send_input, wait_tab (mit Rückfrage), list_tabs mit Status - Hintergrunddienst: Sitzungen laufen nach Schließen weiter, Strg+Q → a - Markieren per Tastatur Alt+C, Bildschirm + Verlauf leeren Alt+X - Kopfzeile: Uhrzeit und eigener Befehl - Doku: README, Webseite, Kurzreferenz Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018i4GUjdQjzrs26BYCfbBCH * Hintergrunddienst unter Windows immer erreichbar Eine Named Pipe ist nur verbindbar, solange ein Accept wartet. Der Hub nimmt jetzt ständig im Hintergrund an, sonst hielt HubAlive den Dienst zwischen zwei Fenstern für tot und es konnte ein zweiter starten (TestHubReattach auf windows-latest). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018i4GUjdQjzrs26BYCfbBCH --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
5944419133
commit
cca761a1a2
70 files changed
+3228
-119
No files matched your search
+17
-2
@@ -29,6 +29,13 @@ sshTermy ist eine schlanke Terminal-Anwendung (TUI, eine einzige Datei, ~9 MB, k
|
||||
- **Wake-on-LAN**: Ein ausgeschalteter Rechner im eigenen Netz lässt sich aus dem Manager wecken (Klick auf „Wake-on-LAN senden“, Palette „aufwecken“ oder `w` im getrennten Tab). Die MAC-Adresse merkt sich sshTermy beim ersten Verbinden von selbst oder du trägst sie unter Erweitert ein.
|
||||
- **Platzhalter in Schnellbefehlen**: `systemctl restart {{dienst}}` fragt beim Ausführen nach dem Wert, `{{dienst:nginx}}` schlägt einen vor; der letzte Wert steht beim nächsten Mal schon da. Macht erst der eingesetzte Wert den Befehl gefährlich, fragt sshTermy nach.
|
||||
- **Zurückblättern**: Mausrad oder ⇧Bild↑ / ⇧Bild↓ blättern im Verlauf, ⇧Pos1 springt an seinen Anfang, ⇧Ende oder Esc zurück nach unten. Neue Ausgabe schiebt die Ansicht beim Lesen nicht weg.
|
||||
- **Wer auf dich wartet**: Ein Tab, der auf ein Passwort, eine `[j/N]`-Frage, eine Taste oder im Pager (`--More--`) wartet, bekommt ein `?` in der Tab-Leiste; Alt+G springt zum nächsten Tab, der wartet oder sich gemeldet hat. **KI-Coding-Agenten** im Tab (Claude Code, Codex, Gemini CLI, OpenCode, Copilot CLI, Cursor Agent, Qwen Code) werden erkannt: Der Tab zeigt, ob der Agent arbeitet, auf deine Freigabe wartet (`◆`, dazu eine Desktop-Meldung) oder fertig ist. Die Tab-Liste (Alt+T) zeigt den Zustand als Text.
|
||||
- **Klick auf die Desktop-Meldung** (Linux; unter Windows und macOS, wenn du sshTermy nach vorn holst) springt direkt in den Tab, um den es ging.
|
||||
- **Tabs vom letzten Mal**: Beim Start bietet sshTermy an, die Tabs (mit geteilter Ansicht) der letzten Sitzung wieder zu öffnen; Befehlspalette › „Tabs vom letzten Mal“ stellt auf immer oder nie.
|
||||
- **Hintergrunddienst** (Befehlspalette › „Hintergrunddienst“, wenn sshTermy in einem Terminal läuft): Sitzungen laufen weiter, wenn du das Terminalfenster schließt; `sshtermy` erneut starten hängt sich wieder an. Strg+Q bietet dann neben Beenden `a` = abkoppeln (Fenster zu, Sitzungen laufen weiter).
|
||||
- **Markieren per Tastatur** (Alt+C): mit Pfeilen oder hjkl bewegen, `w`/`b`/`e` wortweise, `v` beginnt die Markierung, `V` ganze Zeilen, `y` kopiert, Esc beendet.
|
||||
- **Bildschirm leeren** (Alt+X): leert Bildschirm und Verlauf, die Eingabezeile bleibt (auch in der Befehlspalette).
|
||||
- **Eigene Kopfzeilen-Felder**: Die Kopfzeile zeigt auf Wunsch die Uhrzeit und die erste Zeile eines eigenen Befehls, etwa `git -C ~/repo branch --show-current` oder `cat /sys/class/power_supply/BAT0/capacity` (Befehlspalette › „Kopfzeile“; läuft alle 30 s, `@60` am Ende ändert das).
|
||||
- **Suche über alle Tabs** (Alt+S): ein Suchbegriff, die Treffer aus dem Verlauf aller offenen Tabs in einer Liste; ⏎ springt in den Tab an genau diese Zeile.
|
||||
- **Befehle als Blöcke**: Alt+Bild↑ / Alt+Bild↓ springt im Verlauf von Befehl zu Befehl, Alt+O listet die Befehle des Tabs (mit Uhrzeit, Dauer, ✓/×): ⏎ springt hin, Strg+C kopiert genau diese Ausgabe, Strg+K gibt Befehl und Ausgabe an „KI fragen“, Strg+L zeigt sie groß.
|
||||
- **Neuer Tab über den Manager**: `+` in der Tab-Leiste, Alt+N oder ein Klick aufs Logo `>_ sshTermy` öffnet den Verbindungs-Manager mit Ordnern, Suche und Tags; die gewählte Verbindung (⏎ oder Doppelklick) öffnet sich in einem zusätzlichen Tab, die bisherigen Tabs bleiben offen. Esc führt ohne neuen Tab zurück.
|
||||
@@ -243,7 +250,7 @@ nicht als Beweis. Die Liste: Palette *Logwache: Meldungen* oder `w` im Log-Blick
|
||||
„▲ 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
|
||||
- **MCP-Server** (`sshtermy mcp`, Protokoll 2026-07-28, ältere Clients gehen weiter): Claude und andere KI-Clients können Verbindungen auflisten und lesende Befehle ausführen, alles andere erst nach deiner Bestätigung in sshTermy
|
||||
- **MCP-Server** (`sshtermy mcp`, Protokoll 2026-07-28, ältere Clients gehen weiter): Claude und andere KI-Clients können Verbindungen auflisten und lesende Befehle ausführen, alles andere erst nach deiner Bestätigung in sshTermy; mit Rückfrage auch Tabs öffnen, in einen Tab tippen und auf ihn warten
|
||||
- **Audit-Protokoll** (Einstellungen › Protokolle & Logs): wer hat wann auf welchem Host was getan: Verbindungen, Befehle
|
||||
(auch aus Agent-Modus und Broadcast), Dateiübertragungen, Config-Sicherungen, geänderte Verbindungen,
|
||||
Master-Passwort, Gesamtsicherungen und KI-Anfragen (nur Host/Modell). Jede Zeile ist verkettet und mit einem
|
||||
@@ -363,6 +370,9 @@ sshtermy mcp # MCP-Server für KI-Clients (stdin/stdout), siehe „
|
||||
| | F7 / F8 | vorheriger / nächster Tab |
|
||||
| | Alt+T | alle Tabs (Liste: springen, schließen, umbenennen, duplizieren, verschieben) |
|
||||
| | Alt+S | in allen offenen Tabs suchen, ⏎ springt zur Trefferzeile |
|
||||
| | Alt+G | zum nächsten Tab, der wartet (`?`, Passwort, `[j/N]`, Pager) oder sich gemeldet hat (`◆` KI-Agent wartet auf Freigabe, ✓/×) |
|
||||
| | Alt+C | per Tastatur markieren: Pfeile/hjkl, w/b/e, v markieren, V Zeilen, y kopieren, Esc beenden |
|
||||
| | Alt+X | Bildschirm und Verlauf leeren, die Eingabezeile bleibt |
|
||||
| | Alt+Bild↑ / Alt+Bild↓ / Alt+O | zum vorigen / nächsten Befehl springen / Befehle des Tabs als Liste (⏎ hinspringen, Strg+C Ausgabe kopieren, Strg+K KI fragen, Strg+L lesen) |
|
||||
| | Alt+N / Alt+W | neuer Tab / Tab schließen (auch `+` und `×` in der Tab-Leiste; `+`, Alt+N und ein Klick aufs Logo `>_ sshTermy` öffnen den Verbindungs-Manager: ⏎ oder Doppelklick startet die Verbindung in einem zusätzlichen Tab, die offenen Tabs bleiben, Esc führt zurück; Rechtsklick auf einen Tab öffnet sein Menü mit *Verbindung bearbeiten …* (Farbe, Notiz) und *Daneben zeigen (geteilt)*, Maus darauf zeigt Ziel, Dauer und Latenz) |
|
||||
| | Alt+L | lokale Shell in neuem Tab (auch im Manager; Palette: `lokal`, `pwsh`, `cmd`, `wsl`, `zsh` …) |
|
||||
@@ -412,7 +422,7 @@ sshtermy mcp # MCP-Server für KI-Clients (stdin/stdout), siehe „
|
||||
| | z / Z / b / x / d / a | KI-Zusammenfassung / alle Treffer zusammenfassen / Änderungsbericht / Export (md, txt, cast) / löschen / Mitschreiben an/aus |
|
||||
| KI-Einstellungen | Strg+T / Strg+L | Endpunkt testen / Modell aus der Liste des Endpunkts wählen |
|
||||
| Überall | Strg+Leertaste | Befehlspalette: ⏎ als Ziel starten, Tab KI fragen, ↑↓ Vorschlag/Tunnel/Verbindung wählen; `log` = KI wertet Ausgabe aus, `farb` = Farbregeln |
|
||||
| | F1 / F12 / Strg+Q | Hilfe / Über + Update / beenden (fragt bei offenen Verbindungen; Strg+Q nochmal = beenden) |
|
||||
| | F1 / F12 / Strg+Q | Hilfe / Über + Update / beenden (fragt bei offenen Verbindungen; Strg+Q nochmal = beenden; mit Hintergrunddienst `a` = abkoppeln) |
|
||||
| | F1, dann ←/→ / tippen | Hilfe: Reiter Terminal, KI, Manager, Logs, Überall (der passende ist vorn) / über alle Reiter filtern, Esc leert |
|
||||
| | F12 → l / F12 → w | Sprache wechseln (Deutsch ↔ Englisch) / Was ist neu |
|
||||
| Eigenes Fenster | Strg+⇧V · ⇧Einfg (Windows auch Strg+V, Mac ⌘V) / Strg + · Strg − · Strg 0 (Mac: ⌘) | einfügen / Schrift größer · kleiner · Standard (auch Strg + Mausrad, wird gemerkt); F11 Vollbild; auf dem Mac wirkt ⌘ als Alt, ⌥ schreibt weiter @ [ ] { } \| ~ |
|
||||
@@ -658,6 +668,11 @@ sshTermy muss laufen und entsperrt sein; `sshtermy mcp` ist nur die Brücke und
|
||||
`ki-aus`/`ki-lokal` oder KI-Datenschutz „KI aus“ tauchen nie auf. Geheimnisse in Ausgaben werden entfernt, jeder
|
||||
Aufruf steht im Audit-Protokoll.
|
||||
|
||||
Mit Rückfrage können KI-Clients Tabs auch **steuern**: `open_tab` öffnet eine Verbindung in einem neuen Tab, `send_input`
|
||||
tippt Text in einen Tab (ein lesender Befehl am Prompt läuft direkt, alles andere fragt vorher, Passwörter und
|
||||
Steuerzeichen werden abgelehnt), `wait_tab` wartet, bis der Tab wieder am Prompt ist, auf eine Eingabe wartet, einen Text
|
||||
zeigt oder still wird (höchstens 10 Minuten). `list_tabs` meldet je Tab, ob er arbeitet, am Prompt ist oder wartet.
|
||||
|
||||
```
|
||||
claude mcp add sshtermy -- sshtermy mcp
|
||||
```
|
||||
|
||||
@@ -29,6 +29,13 @@ sshTermy is a lean terminal application (TUI, a single file, ~9 MB, no installer
|
||||
- **Wake-on-LAN**: a powered-off machine in your own network can be woken from the manager (click “Send Wake-on-LAN”, palette “wake”, or `w` in a disconnected tab). sshTermy remembers the MAC address on the first connect, or you enter it under Advanced.
|
||||
- **Placeholders in quick commands**: `systemctl restart {{service}}` asks for the value when run, `{{service:nginx}}` suggests one; the last value is prefilled next time. If only the inserted value makes the command dangerous, sshTermy asks first.
|
||||
- **Scroll back**: mouse wheel or ⇧PgUp / ⇧PgDn scroll through the scrollback, ⇧Home jumps to its start, ⇧End or Esc back to the bottom. New output does not push the view away while you read.
|
||||
- **Who is waiting for you**: a tab that waits for a password, a `[y/N]` question, a key or a pager (`--More--`) gets a `?` in the tab bar; Alt+G jumps to the next tab that waits or has a notice. **AI coding agents** in a tab (Claude Code, Codex, Gemini CLI, OpenCode, Copilot CLI, Cursor Agent, Qwen Code) are recognized: the tab shows whether the agent is working, waiting for your approval (`◆`, plus a desktop notification) or done. The tab list (Alt+T) shows the state as text.
|
||||
- **Click on a desktop notification** (Linux; on Windows and macOS by bringing sshTermy to the front) jumps straight into the tab it was about.
|
||||
- **Tabs from last time**: when you start sshTermy, it offers to reopen the tabs (with split view) of the last session; palette › “Tabs from last time” sets it to always or never.
|
||||
- **Background service** (palette › “Background service”, when sshTermy runs in a terminal): sessions keep running when you close the terminal window; start `sshtermy` again to attach. Ctrl+Q then offers `a` = detach (window closes, sessions keep running) next to quitting.
|
||||
- **Select by keys** (Alt+C): move with arrows or hjkl, `w`/`b`/`e` by word, `v` starts the selection, `V` whole lines, `y` copies, Esc ends.
|
||||
- **Clear screen** (Alt+X): clears screen and scrollback, the input line stays (also in the palette).
|
||||
- **Own header fields**: the header can show the time and the first line of a command of your choice, e.g. `git -C ~/repo branch --show-current` or `cat /sys/class/power_supply/BAT0/capacity` (palette › “Header”; runs every 30 s, `@60` at the end changes it).
|
||||
- **Search across all tabs** (Alt+S): one search term, the hits from the scrollback of all open tabs in one list; ⏎ jumps to the tab at exactly that line.
|
||||
- **Commands as blocks**: Alt+PgUp / Alt+PgDn jumps from command to command in the scrollback, Alt+O lists the commands of the tab (with time, duration, ✓/×): ⏎ jumps there, Ctrl+C copies just that output, Ctrl+K hands command and output to “Ask AI”, Ctrl+L shows it in full.
|
||||
- **New tab via the manager**: `+` in the tab bar, Alt+N or a click on the `>_ sshTermy` logo opens the connection manager with folders, search and tags; the connection you pick (⏎ or double-click) opens in an additional tab, the current tabs stay open. Esc goes back without a new tab.
|
||||
@@ -235,7 +242,7 @@ lets them in. The AI status report treats syslog lines as hints, not as proof. T
|
||||
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
|
||||
- **MCP server** (`sshtermy mcp`, protocol 2026-07-28, older clients keep working): Claude and other AI clients can list your connections and run read-only commands, anything else only after you confirm in sshTermy
|
||||
- **MCP server** (`sshtermy mcp`, protocol 2026-07-28, older clients keep working): Claude and other AI clients can list your connections and run read-only commands, anything else only after you confirm in sshTermy; with confirmation they can also open tabs, type into a tab and wait for it
|
||||
- **Audit log** (Settings › Logs & audit): who did what and when, on which host: connections, commands (also from the
|
||||
agent mode and broadcast), file transfers, config backups, changed connections, master password, full backups and
|
||||
AI requests (host/model only). Each line is chained and signed with a key from the store, so changes, deleted or
|
||||
@@ -352,6 +359,9 @@ sshtermy mcp # MCP server for AI clients (stdin/stdout), see “sshT
|
||||
| | F7 / F8 | previous / next tab |
|
||||
| | Alt+T | all tabs (list: jump, close, rename, duplicate, move) |
|
||||
| | Alt+S | search in all open tabs, ⏎ jumps to the matching line |
|
||||
| | Alt+G | go to the next tab that waits (`?`, password, `[y/N]`, pager) or has a notice (`◆` AI agent waiting for approval, ✓/×) |
|
||||
| | Alt+C | select by keys: arrows/hjkl, w/b/e, v select, V lines, y copy, Esc end |
|
||||
| | Alt+X | clear screen and scrollback, the input line stays |
|
||||
| | Alt+PgUp / Alt+PgDn / Alt+O | jump to the previous / next command / list of the tab's commands (⏎ jump, Ctrl+C copy output, Ctrl+K ask AI, Ctrl+L read) |
|
||||
| | Alt+N / Alt+W | new tab / close tab (also `+` and `×` in the tab bar; `+`, Alt+N and a click on the `>_ sshTermy` logo open the connection manager: ⏎ or a double-click starts the connection in an additional tab, the open tabs stay, Esc goes back; right-click a tab for its menu with *Edit connection …* (color, note) and *Show alongside (split)*, hover it for target, duration and latency) |
|
||||
| | Alt+L | local shell in a new tab (also in the manager; palette: `local`, `pwsh`, `cmd`, `wsl`, `zsh` …) |
|
||||
@@ -401,7 +411,7 @@ sshtermy mcp # MCP server for AI clients (stdin/stdout), see “sshT
|
||||
| | z / Z / b / x / d / a | AI summary / summarize all matches / change report / export (md, txt, cast) / delete / recording on/off |
|
||||
| AI settings | Ctrl+T / Ctrl+L | test endpoint / choose a model from the endpoint's list |
|
||||
| Everywhere | Ctrl+Space | command palette: ⏎ start as goal, Tab ask AI, ↑↓ choose suggestion/tunnel/connection; `log` = AI analyzes output, `color` = color rules |
|
||||
| | F1 / F12 / Ctrl+Q | help / about + update / quit (asks while connections are open; Ctrl+Q again = quit) |
|
||||
| | F1 / F12 / Ctrl+Q | help / about + update / quit (asks while connections are open; Ctrl+Q again = quit; with the background service `a` = detach) |
|
||||
| | F1, then ←/→ / type | help: tabs Terminal, AI, Manager, Logs, Everywhere (the matching one first) / filter across all tabs, Esc clears |
|
||||
| | F12 → l / F12 → w | switch language (English ↔ German) / what's new |
|
||||
| Own window | Ctrl+⇧V · ⇧Insert (Windows also Ctrl+V, Mac ⌘V) / Ctrl + · Ctrl − · Ctrl 0 (Mac: ⌘) | paste / font size bigger · smaller · default (also Ctrl + mouse wheel, remembered); F11 full screen; on the Mac ⌘ acts as Alt, ⌥ keeps typing @ [ ] { } \| ~ |
|
||||
@@ -646,6 +656,11 @@ runs only after you press `y` in sshTermy; dangerous commands need `y` twice). C
|
||||
`sshtermy mcp` is only a bridge and holds no data. Connections tagged `no-ai`/`ai-local`, or AI privacy “AI off”, are
|
||||
never shown. Secrets in output are redacted, every call lands in the audit log.
|
||||
|
||||
With confirmation, AI clients can also **control** tabs: `open_tab` opens a connection in a new tab, `send_input`
|
||||
types text into a tab (a read-only command at the prompt runs directly, anything else asks first, passwords and control
|
||||
characters are refused), `wait_tab` waits until the tab is back at the prompt, waits for input, shows a text or goes quiet
|
||||
(at most 10 minutes). `list_tabs` reports for each tab whether it is working, at the prompt or waiting.
|
||||
|
||||
```
|
||||
claude mcp add sshtermy -- sshtermy mcp
|
||||
```
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
tea "charm.land/bubbletea/v2"
|
||||
"github.com/charmbracelet/colorprofile"
|
||||
"github.com/charmbracelet/x/term"
|
||||
|
||||
"github.com/db9979/sshtermy/internal/crash"
|
||||
"github.com/db9979/sshtermy/internal/detach"
|
||||
"github.com/db9979/sshtermy/internal/i18n"
|
||||
"github.com/db9979/sshtermy/internal/store"
|
||||
"github.com/db9979/sshtermy/internal/ui"
|
||||
"github.com/db9979/sshtermy/internal/update"
|
||||
"github.com/db9979/sshtermy/internal/winstate"
|
||||
)
|
||||
|
||||
// Hintergrunddienst (Idee aus herdr): Mit „Hintergrunddienst“ in den
|
||||
// Einstellungen startet „sshtermy“ im Terminal nicht mehr die Oberfläche
|
||||
// selbst, sondern einen Prozess ohne Terminal („sshtermy keep-serve“), und
|
||||
// dockt an ihn an. Schließt man das Terminalfenster oder koppelt mit
|
||||
// Strg+Q → a ab, laufen Verbindungen, Tunnel und Befehle weiter; „sshtermy“
|
||||
// hängt sich wieder an. Ohne Einstellung bleibt alles wie bisher; läuft
|
||||
// schon ein Dienst, hängt sich „sshtermy“ immer an ihn (zwei Oberflächen
|
||||
// auf demselben Datenordner gäbe es sonst).
|
||||
|
||||
const keepProfileEnv = "SSHTERMY_KEEP_PROFILE"
|
||||
|
||||
func keepDir(dir string) string { return filepath.Join(dir, "keep") }
|
||||
|
||||
// keepWanted: im Terminal und Dienst eingeschaltet oder schon laufend?
|
||||
func keepWanted(dir string) bool {
|
||||
if dir == "" || os.Getenv("SSHTERMY_NO_KEEP") != "" || !term.IsTerminal(os.Stdin.Fd()) || !term.IsTerminal(os.Stdout.Fd()) {
|
||||
return false
|
||||
}
|
||||
return winstate.Load(dir).Keep || detach.HubAlive(keepDir(dir))
|
||||
}
|
||||
|
||||
// keepAttach startet bei Bedarf den Dienst und dockt an. ok = false: Dienst
|
||||
// ließ sich nicht starten, dann normal ohne ihn weiter.
|
||||
func keepAttach(dir string, flags []string) (code int, ok bool) {
|
||||
kd := keepDir(dir)
|
||||
if !detach.HubAlive(kd) {
|
||||
self, err := os.Executable()
|
||||
if err != nil {
|
||||
return 0, false
|
||||
}
|
||||
c := exec.Command(self, append([]string{"keep-serve"}, flags...)...)
|
||||
prof := colorprofile.Detect(os.Stdout, os.Environ())
|
||||
c.Env = append(os.Environ(), keepProfileEnv+"="+strconv.Itoa(int(prof)))
|
||||
detachProcess(c)
|
||||
if err := c.Start(); err != nil {
|
||||
return 0, false
|
||||
}
|
||||
go c.Wait() //nolint:errcheck
|
||||
if err := detach.WaitHub(kd, 15*time.Second); err != nil {
|
||||
return 0, false
|
||||
}
|
||||
}
|
||||
return ui.Attach(kd), true
|
||||
}
|
||||
|
||||
// runKeepServe: der Dienst selbst. Wartet auf das erste Fenster, startet
|
||||
// dann die Oberfläche mit dessen Größe und reicht sie an jedes weitere
|
||||
// Fenster durch, bis sshTermy wirklich beendet wird.
|
||||
func runKeepServe(dir string, noIntro, debug bool) int {
|
||||
log.SetOutput(io.Discard)
|
||||
kd := keepDir(dir)
|
||||
if detach.HubAlive(kd) {
|
||||
return 0 // läuft schon
|
||||
}
|
||||
hub, err := detach.ListenHub(kd)
|
||||
if err != nil {
|
||||
return 1
|
||||
}
|
||||
defer hub.Close()
|
||||
type first struct {
|
||||
c *detach.Conn
|
||||
cols, rows int
|
||||
err error
|
||||
}
|
||||
ch := make(chan first, 1)
|
||||
go func() { c, cols, rows, err := hub.Accept(); ch <- first{c, cols, rows, err} }()
|
||||
var f first
|
||||
select {
|
||||
case f = <-ch:
|
||||
case <-time.After(time.Minute):
|
||||
return 1 // niemand hat angedockt
|
||||
}
|
||||
if f.err != nil {
|
||||
return 1
|
||||
}
|
||||
st, err := store.Open()
|
||||
if err != nil {
|
||||
f.c.Bye(err.Error())
|
||||
return 1
|
||||
}
|
||||
app, err := ui.New(st)
|
||||
if err != nil {
|
||||
f.c.Bye(err.Error())
|
||||
return 1
|
||||
}
|
||||
if noIntro {
|
||||
app.SkipIntro()
|
||||
}
|
||||
if debug {
|
||||
app.ForceDebug()
|
||||
}
|
||||
scr := detach.NewScreen()
|
||||
inR, inW := io.Pipe()
|
||||
opts := []tea.ProgramOption{tea.WithInput(inR), tea.WithOutput(scr), tea.WithWindowSize(f.cols, f.rows),
|
||||
tea.WithEnvironment(os.Environ()), tea.WithoutSignalHandler()}
|
||||
if n, err := strconv.Atoi(os.Getenv(keepProfileEnv)); err == nil {
|
||||
opts = append(opts, tea.WithColorProfile(colorprofile.Profile(n)))
|
||||
}
|
||||
p := tea.NewProgram(app, opts...)
|
||||
app.SetKeeper(func(msg string) {
|
||||
scr.Bye(msg)
|
||||
go p.Send(tea.BlurMsg{}) // niemand schaut zu (aus Update heraus: nicht blockieren)
|
||||
})
|
||||
serve := func(c *detach.Conn, cols, rows int, again bool) {
|
||||
scr.Attach(c, i18n.T("sshTermy wurde in einem anderen Fenster angehängt."))
|
||||
// Send wartet, bis die Oberfläche läuft: daher nebenher
|
||||
go func() {
|
||||
if again {
|
||||
p.Send(tea.WindowSizeMsg{Width: cols, Height: rows})
|
||||
p.Send(tea.ClearScreen()) // neues Fenster: alles neu zeichnen
|
||||
}
|
||||
p.Send(tea.FocusMsg{})
|
||||
}()
|
||||
go func() {
|
||||
for {
|
||||
ev, err := c.Read()
|
||||
if err != nil {
|
||||
if scr.Drop(c) {
|
||||
p.Send(tea.BlurMsg{})
|
||||
}
|
||||
return
|
||||
}
|
||||
if len(ev.Input) > 0 {
|
||||
_, _ = inW.Write(ev.Input)
|
||||
}
|
||||
if ev.Cols > 0 {
|
||||
p.Send(tea.WindowSizeMsg{Width: ev.Cols, Height: ev.Rows})
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
serve(f.c, f.cols, f.rows, false)
|
||||
go func() {
|
||||
for {
|
||||
c, cols, rows, err := hub.Accept()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
serve(c, cols, rows, true)
|
||||
}
|
||||
}()
|
||||
guard := crash.Start(st.Dir)
|
||||
_, err = p.Run()
|
||||
bye := ""
|
||||
if errors.Is(err, tea.ErrProgramPanic) {
|
||||
raw := guard.Panic()
|
||||
if r, werr := crash.Write(st.Dir, crash.KindUI, raw, st.Sensitive()); werr == nil {
|
||||
bye = i18n.T("sshTermy ist abgestürzt. Bericht: ") + r.Path
|
||||
}
|
||||
}
|
||||
guard.Close()
|
||||
if err == nil {
|
||||
update.Confirm()
|
||||
}
|
||||
if app.Restart() {
|
||||
bye = i18n.T("Update installiert: bitte sshtermy neu starten.")
|
||||
}
|
||||
scr.Bye(bye)
|
||||
inW.Close()
|
||||
return 0
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
//go:build !windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// detachProcess: eigene Sitzung ohne Terminal, überlebt das Schließen des Fensters.
|
||||
func detachProcess(c *exec.Cmd) {
|
||||
c.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//go:build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// detachProcess: ohne Konsole und eigene Prozessgruppe, überlebt das
|
||||
// Schließen des Terminalfensters.
|
||||
func detachProcess(c *exec.Cmd) {
|
||||
const detached, newGroup, noWindow = 0x00000008, 0x00000200, 0x08000000
|
||||
c.SysProcAttr = &syscall.SysProcAttr{CreationFlags: detached | newGroup | noWindow, HideWindow: true}
|
||||
}
|
||||
@@ -62,6 +62,14 @@ func main() {
|
||||
fail(err)
|
||||
}
|
||||
return
|
||||
case "keep-serve":
|
||||
// Hintergrunddienst ohne Terminal (keep.go), von „sshtermy“ gestartet
|
||||
var noIntro, debug bool
|
||||
for _, a := range os.Args[2:] {
|
||||
noIntro = noIntro || a == "-no-intro"
|
||||
debug = debug || a == "-debug"
|
||||
}
|
||||
os.Exit(runKeepServe(dir, noIntro, debug))
|
||||
case "attach":
|
||||
// neues Fenster eines abgetrennten Tabs (⇧F10), siehe internal/detach;
|
||||
// „-window“: aus dem eigenen Fenster heraus, also wieder ein eigenes
|
||||
@@ -113,6 +121,19 @@ func main() {
|
||||
}
|
||||
|
||||
windowed := wantWindow(*forceWindow, *forceTUI)
|
||||
// Hintergrunddienst: andocken statt selbst starten (keep.go)
|
||||
if !windowed && *crashTest == "" && keepWanted(dir) {
|
||||
var flags []string
|
||||
if *noIntro {
|
||||
flags = append(flags, "-no-intro")
|
||||
}
|
||||
if *debug {
|
||||
flags = append(flags, "-debug")
|
||||
}
|
||||
if code, ok := keepAttach(dir, flags); ok {
|
||||
os.Exit(code)
|
||||
}
|
||||
}
|
||||
if windowed {
|
||||
hideConsole()
|
||||
ui.EnablePixelImages()
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
// Package codeagent erkennt KI-Coding-Agenten (Claude Code, Codex, Gemini
|
||||
// CLI, OpenCode, Copilot CLI, Cursor Agent …), die in einem Terminal laufen,
|
||||
// und ihren Zustand: arbeitet, wartet auf eine Freigabe, bereit. sshTermy
|
||||
// zeigt das am Tab und meldet sich, wenn ein Agent auf dem Server auf dich
|
||||
// wartet oder fertig ist. Gelesen wird nur der sichtbare Bildschirm und der
|
||||
// Fenstertitel; an den Agenten geht nichts.
|
||||
package codeagent
|
||||
|
||||
import (
|
||||
"path"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// State: was der Agent gerade tut.
|
||||
type State int
|
||||
|
||||
const (
|
||||
Unknown State = iota // Agent erkannt, Zustand nicht
|
||||
Idle // wartet auf die nächste Aufgabe
|
||||
Working // arbeitet
|
||||
Blocked // wartet auf eine Freigabe oder Antwort
|
||||
)
|
||||
|
||||
func (s State) String() string {
|
||||
return [...]string{"unknown", "idle", "working", "blocked"}[s]
|
||||
}
|
||||
|
||||
type agentDef struct {
|
||||
name string
|
||||
cmds []string // Programmnamen in der Befehlszeile
|
||||
marker *regexp.Regexp // Kennzeichen auf dem Bildschirm oder im Titel
|
||||
idle *regexp.Regexp // Fußzeile / Eingabefeld im Leerlauf
|
||||
working *regexp.Regexp // eigene Arbeitsanzeige
|
||||
blocked *regexp.Regexp // eigene Freigabe-Dialoge
|
||||
}
|
||||
|
||||
var agents = []agentDef{
|
||||
{
|
||||
name: "Claude Code",
|
||||
cmds: []string{"claude", "claude-code"},
|
||||
marker: regexp.MustCompile(`(?i)claude code|\? for shortcuts|✻ welcome to claude`),
|
||||
idle: regexp.MustCompile(`(?i)\? for shortcuts|shift\+tab to cycle|auto-accept edits on|plan mode on`),
|
||||
working: regexp.MustCompile(`(?i)\besc to interrupt\b`),
|
||||
blocked: regexp.MustCompile(`(?i)do you want to (proceed|make this edit|create|allow|run)|❯\s*1\.\s*yes|enter to (confirm|select)\s*·\s*esc to cancel`),
|
||||
},
|
||||
{
|
||||
name: "Codex",
|
||||
cmds: []string{"codex"},
|
||||
marker: regexp.MustCompile(`(?i)openai codex|>_ codex|\bcontext left\b`),
|
||||
idle: regexp.MustCompile(`(?i)⏎ send|context left|ctrl\+j newline|⌃j newline`),
|
||||
working: regexp.MustCompile(`(?i)\besc to interrupt\b`),
|
||||
blocked: regexp.MustCompile(`(?i)would you like to (run|make|apply)|allow command\?|approve this|›\s*1\.\s*yes`),
|
||||
},
|
||||
{
|
||||
name: "Gemini CLI",
|
||||
cmds: []string{"gemini"},
|
||||
marker: regexp.MustCompile(`(?i)gemini cli|type your message or @path`),
|
||||
idle: regexp.MustCompile(`(?i)type your message or @path`),
|
||||
working: regexp.MustCompile(`(?i)\besc to cancel\b`),
|
||||
blocked: regexp.MustCompile(`(?i)allow execution|apply this change\?|●\s*1\.\s*yes|waiting for user confirmation`),
|
||||
},
|
||||
{
|
||||
name: "OpenCode",
|
||||
cmds: []string{"opencode"},
|
||||
marker: regexp.MustCompile(`(?i)\bopencode\b`),
|
||||
idle: regexp.MustCompile(`(?i)ctrl\+p commands|tab switch agent`),
|
||||
working: regexp.MustCompile(`(?i)\besc (to )?interrupt\b`),
|
||||
blocked: regexp.MustCompile(`(?i)permission required|allow once|allow always`),
|
||||
},
|
||||
{
|
||||
name: "Copilot CLI",
|
||||
cmds: []string{"copilot"},
|
||||
marker: regexp.MustCompile(`(?i)github copilot`),
|
||||
working: regexp.MustCompile(`(?i)\besc to (cancel|interrupt)\b`),
|
||||
blocked: regexp.MustCompile(`(?i)do you want to (run|allow|proceed)|❯\s*1\.\s*yes`),
|
||||
},
|
||||
{
|
||||
name: "Cursor Agent",
|
||||
cmds: []string{"cursor-agent", "agent"},
|
||||
marker: regexp.MustCompile(`(?i)cursor agent`),
|
||||
working: regexp.MustCompile(`(?i)ctrl\+c to stop|\besc to (interrupt|cancel)\b`),
|
||||
blocked: regexp.MustCompile(`(?i)run this command\?|\(y\) \(enter\)|allow \(y\)|reject \(`),
|
||||
},
|
||||
{
|
||||
name: "Qwen Code",
|
||||
cmds: []string{"qwen"},
|
||||
marker: regexp.MustCompile(`(?i)qwen code`),
|
||||
idle: regexp.MustCompile(`(?i)type your message or @path`),
|
||||
working: regexp.MustCompile(`(?i)\besc to cancel\b`),
|
||||
blocked: regexp.MustCompile(`(?i)allow execution|apply this change\?|waiting for user confirmation`),
|
||||
},
|
||||
}
|
||||
|
||||
// FromCommand: Name des Agenten, wenn die Befehlszeile ihn startet
|
||||
// („claude“, „npx @openai/codex“, „/usr/local/bin/gemini -p …“), sonst "".
|
||||
func FromCommand(cmd string) string {
|
||||
f := strings.Fields(cmd)
|
||||
// Vorsätze überspringen: sudo, env, npx/bunx/pnpm dlx, VAR=wert
|
||||
for len(f) > 0 {
|
||||
w := f[0]
|
||||
switch {
|
||||
case w == "sudo" || w == "env" || w == "npx" || w == "bunx" || w == "exec" || w == "nohup" || w == "time":
|
||||
f = f[1:]
|
||||
continue
|
||||
case (w == "pnpm" || w == "yarn") && len(f) > 1 && f[1] == "dlx":
|
||||
f = f[2:]
|
||||
continue
|
||||
case strings.Contains(w, "=") && !strings.HasPrefix(w, "-"):
|
||||
f = f[1:]
|
||||
continue
|
||||
case strings.HasPrefix(w, "-"):
|
||||
f = f[1:] // Schalter von npx & Co.
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
if len(f) == 0 {
|
||||
return ""
|
||||
}
|
||||
prog := path.Base(strings.ReplaceAll(f[0], `\`, "/"))
|
||||
prog = strings.TrimSuffix(strings.TrimSuffix(prog, ".exe"), ".cmd")
|
||||
// npm-Pakete: @anthropic-ai/claude-code, @openai/codex, @google/gemini-cli
|
||||
switch {
|
||||
case strings.Contains(f[0], "claude-code"):
|
||||
return "Claude Code"
|
||||
case strings.HasSuffix(f[0], "/codex"):
|
||||
return "Codex"
|
||||
case strings.Contains(f[0], "gemini-cli"):
|
||||
return "Gemini CLI"
|
||||
}
|
||||
for _, d := range agents {
|
||||
for _, c := range d.cmds {
|
||||
if prog == c {
|
||||
if c == "agent" && d.name == "Cursor Agent" {
|
||||
continue // „agent“ allein ist zu allgemein
|
||||
}
|
||||
return d.name
|
||||
}
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// FromScreen: Name des Agenten anhand von Titel und Bildschirm, sonst "".
|
||||
func FromScreen(screen, title string) string {
|
||||
for _, d := range agents {
|
||||
if d.marker.MatchString(title) || d.marker.MatchString(screen) {
|
||||
return d.name
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func def(name string) *agentDef {
|
||||
for i := range agents {
|
||||
if agents[i].name == name {
|
||||
return &agents[i]
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// allgemeine Zeichen, die viele Agenten teilen
|
||||
var (
|
||||
anyWorking = regexp.MustCompile(`(?i)\besc to (interrupt|cancel)\b`)
|
||||
anyBlocked = regexp.MustCompile(`(?i)do you want to (proceed|run|allow|make)|would you like to run|allow (once|always|execution)|permission required`)
|
||||
// Spinner vorn im Fenstertitel (Claude Code, Codex): arbeitet
|
||||
titleSpin = regexp.MustCompile(`^[⠀-⣿◐◓◑◒✳✻✽✶·✢*]\s`)
|
||||
)
|
||||
|
||||
// Detect: Zustand des Agenten name auf diesem Bildschirm (die letzten
|
||||
// Zeilen genügen). seen = der Agent ist am Bildschirm zu erkennen (sonst
|
||||
// hat er sich vermutlich beendet).
|
||||
func Detect(name, screen, title string) (st State, seen bool) {
|
||||
d := def(name)
|
||||
if d == nil {
|
||||
return Unknown, false
|
||||
}
|
||||
// nur der untere Teil zählt: Freigaben und Fußzeilen stehen unten,
|
||||
// ältere Ausgabe weiter oben soll nichts auslösen
|
||||
lines := strings.Split(screen, "\n")
|
||||
if len(lines) > 14 {
|
||||
lines = lines[len(lines)-14:]
|
||||
}
|
||||
tail := strings.Join(lines, "\n")
|
||||
match := func(rx *regexp.Regexp) bool { return rx != nil && rx.MatchString(tail) }
|
||||
seen = match(d.marker) || match(d.idle) || match(d.working) || match(d.blocked) ||
|
||||
d.marker.MatchString(title)
|
||||
switch {
|
||||
case match(d.blocked) || anyBlocked.MatchString(tail):
|
||||
return Blocked, true
|
||||
case match(d.working) || anyWorking.MatchString(tail) || titleSpin.MatchString(title):
|
||||
return Working, true
|
||||
case match(d.idle):
|
||||
return Idle, true
|
||||
}
|
||||
if seen {
|
||||
return Idle, true
|
||||
}
|
||||
return Unknown, false
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package codeagent
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestFromCommand(t *testing.T) {
|
||||
for cmd, want := range map[string]string{
|
||||
"claude": "Claude Code",
|
||||
"claude --resume": "Claude Code",
|
||||
"npx -y @anthropic-ai/claude-code": "Claude Code",
|
||||
"codex exec 'fix tests'": "Codex",
|
||||
"npx @openai/codex": "Codex",
|
||||
"FOO=1 gemini -p hallo": "Gemini CLI",
|
||||
"/usr/local/bin/opencode": "OpenCode",
|
||||
"sudo -E claude": "Claude Code",
|
||||
"cursor-agent": "Cursor Agent",
|
||||
"agent": "",
|
||||
"ls -l": "",
|
||||
"vim claude.md": "",
|
||||
"": "",
|
||||
} {
|
||||
if got := FromCommand(cmd); got != want {
|
||||
t.Errorf("FromCommand(%q) = %q, will %q", cmd, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDetectClaude(t *testing.T) {
|
||||
working := "● Ich lese die Dateien.\n\n✻ Thinking… (12s · ↑ 1.2k tokens · esc to interrupt)\n\n╭──────╮\n│ > │\n╰──────╯\n ? for shortcuts"
|
||||
if st, seen := Detect("Claude Code", working, "✳ Fix tests"); st != Working || !seen {
|
||||
t.Fatalf("arbeitet: %v %v", st, seen)
|
||||
}
|
||||
blocked := " Bash command\n\n rm -rf build\n Remove build output\n\n Do you want to proceed?\n ❯ 1. Yes\n 2. Yes, and don't ask again\n 3. No, and tell Claude what to do differently (esc)"
|
||||
if st, _ := Detect("Claude Code", blocked, "Claude Code"); st != Blocked {
|
||||
t.Fatalf("Freigabe: %v", st)
|
||||
}
|
||||
idle := "● Fertig, alle Tests laufen.\n\n╭──────╮\n│ > │\n╰──────╯\n ? for shortcuts"
|
||||
if st, seen := Detect("Claude Code", idle, "Claude Code"); st != Idle || !seen {
|
||||
t.Fatalf("bereit: %v %v", st, seen)
|
||||
}
|
||||
// zurück an der Shell: nichts mehr zu sehen
|
||||
if _, seen := Detect("Claude Code", "user@web:~$ ", "user@web: ~"); seen {
|
||||
t.Fatal("Shell als Agent erkannt")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDetectCodexGemini(t *testing.T) {
|
||||
if st, _ := Detect("Codex", "• Working (5s • esc to interrupt)\n\n› \n ⏎ send ⌃J newline", "codex"); st != Working {
|
||||
t.Fatalf("Codex arbeitet: %v", st)
|
||||
}
|
||||
if st, _ := Detect("Codex", "Would you like to run the following command?\n\n $ npm test\n\n› 1. Yes, proceed\n 2. No", ""); st != Blocked {
|
||||
t.Fatalf("Codex Freigabe: %v", st)
|
||||
}
|
||||
if st, _ := Detect("Gemini CLI", "⠏ Reading files (esc to cancel, 3s)", ""); st != Working {
|
||||
t.Fatalf("Gemini arbeitet: %v", st)
|
||||
}
|
||||
if st, _ := Detect("Gemini CLI", "Allow execution of: 'ls'?\n● 1. Yes, allow once", ""); st != Blocked {
|
||||
t.Fatalf("Gemini Freigabe: %v", st)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFromScreen(t *testing.T) {
|
||||
if FromScreen("✻ Welcome to Claude Code!", "") != "Claude Code" {
|
||||
t.Fatal("Claude-Banner")
|
||||
}
|
||||
if FromScreen("$ ls\nfoo bar", "bash") != "" {
|
||||
t.Fatal("Shell als Agent")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package detach
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Hintergrunddienst (Idee aus herdr): sshTermy läuft als eigener Prozess
|
||||
// ohne Terminal weiter („sshtermy keep-serve“), das Terminalfenster dockt
|
||||
// mit „sshtermy“ nur an (Attach) und reicht Tasten, Größe und Bild roh
|
||||
// durch. Schließt man das Fenster oder koppelt ab, laufen alle Sitzungen
|
||||
// weiter; der nächste Start hängt sich wieder an. Der Ordner liegt im
|
||||
// Datenordner (nur für den eigenen Benutzer lesbar) und enthält Adresse
|
||||
// und Zugangswort; das Zugangswort bleibt, solange der Dienst läuft.
|
||||
|
||||
// Hub nimmt nacheinander beliebig viele Fenster an (immer nur eines zur Zeit).
|
||||
type Hub struct {
|
||||
dir string // Adresse + Zugangswort
|
||||
sock string // Ordner des Sockets (Unix)
|
||||
ln net.Listener
|
||||
token []byte
|
||||
conns chan hubConn
|
||||
done chan struct{}
|
||||
once sync.Once
|
||||
}
|
||||
|
||||
type hubConn struct {
|
||||
c *Conn
|
||||
cols, rows int
|
||||
}
|
||||
|
||||
// ListenHub öffnet den Kanal des Hintergrunddienstes in dir.
|
||||
func ListenHub(dir string) (*Hub, error) {
|
||||
if err := os.MkdirAll(dir, 0o700); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_ = os.Chmod(dir, 0o700)
|
||||
tok := make([]byte, 32)
|
||||
if _, err := rand.Read(tok); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sock, err := os.MkdirTemp("", "sshtermy-keep-")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ln, addr, err := listen(sock)
|
||||
if err != nil {
|
||||
os.RemoveAll(sock)
|
||||
return nil, err
|
||||
}
|
||||
h := &Hub{dir: dir, sock: sock, ln: ln, token: []byte(hex.EncodeToString(tok)),
|
||||
conns: make(chan hubConn), done: make(chan struct{})}
|
||||
if err := writeFileAtomic(filepath.Join(dir, tokenFile), h.token); err != nil {
|
||||
h.Close()
|
||||
return nil, err
|
||||
}
|
||||
if err := writeFileAtomic(filepath.Join(dir, addrFile), []byte(addr)); err != nil {
|
||||
h.Close()
|
||||
return nil, err
|
||||
}
|
||||
go h.acceptLoop()
|
||||
return h, nil
|
||||
}
|
||||
|
||||
// acceptLoop nimmt immer an, auch während niemand Accept aufruft: Eine
|
||||
// Named Pipe (Windows) ist nur erreichbar, solange ein Accept wartet, sonst
|
||||
// hielte HubAlive den Dienst für tot und es startete ein zweiter.
|
||||
func (h *Hub) acceptLoop() {
|
||||
for {
|
||||
nc, err := h.ln.Accept()
|
||||
if err != nil {
|
||||
h.once.Do(func() { close(h.done) })
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
c, cols, rows, err := handshake(nc, h.token)
|
||||
if err != nil {
|
||||
nc.Close() // Probe von HubAlive oder falsches Zugangswort
|
||||
return
|
||||
}
|
||||
select {
|
||||
case h.conns <- hubConn{c, cols, rows}:
|
||||
case <-h.done:
|
||||
nc.Close()
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
func writeFileAtomic(p string, b []byte) error {
|
||||
if err := os.WriteFile(p+".tmp", b, 0o600); err != nil {
|
||||
return err
|
||||
}
|
||||
return os.Rename(p+".tmp", p)
|
||||
}
|
||||
|
||||
// Accept wartet auf das nächste Fenster (falsches Zugangswort: weiter warten).
|
||||
func (h *Hub) Accept() (*Conn, int, int, error) {
|
||||
select {
|
||||
case hc := <-h.conns:
|
||||
return hc.c, hc.cols, hc.rows, nil
|
||||
case <-h.done:
|
||||
return nil, 0, 0, net.ErrClosed
|
||||
}
|
||||
}
|
||||
|
||||
// Close beendet den Dienst-Kanal und entfernt Adresse und Zugangswort.
|
||||
func (h *Hub) Close() {
|
||||
h.ln.Close()
|
||||
h.once.Do(func() { close(h.done) })
|
||||
os.RemoveAll(h.sock)
|
||||
os.Remove(filepath.Join(h.dir, addrFile))
|
||||
os.Remove(filepath.Join(h.dir, tokenFile))
|
||||
}
|
||||
|
||||
// HubAlive: läuft in dir ein Hintergrunddienst, der antwortet?
|
||||
func HubAlive(dir string) bool {
|
||||
network, addr, err := readAddr(dir)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
nc, err := dialTimeout(network, addr, time.Second)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
nc.Close()
|
||||
return true
|
||||
}
|
||||
|
||||
// WaitHub wartet, bis der gerade gestartete Dienst antwortet.
|
||||
func WaitHub(dir string, d time.Duration) error {
|
||||
end := time.Now().Add(d)
|
||||
for time.Now().Before(end) {
|
||||
if HubAlive(dir) {
|
||||
return nil
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
return errors.New("detach: der Hintergrunddienst meldet sich nicht")
|
||||
}
|
||||
|
||||
func dialTimeout(network, addr string, d time.Duration) (net.Conn, error) {
|
||||
type res struct {
|
||||
c net.Conn
|
||||
err error
|
||||
}
|
||||
ch := make(chan res, 1)
|
||||
go func() { c, err := dial(network, addr); ch <- res{c, err} }()
|
||||
select {
|
||||
case r := <-ch:
|
||||
return r.c, r.err
|
||||
case <-time.After(d):
|
||||
go func() {
|
||||
if r := <-ch; r.c != nil {
|
||||
r.c.Close()
|
||||
}
|
||||
}()
|
||||
return nil, errors.New("detach: Zeitüberschreitung")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package detach
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestOnlcr(t *testing.T) {
|
||||
if got := string(onlcr([]byte("a\nb\r\nc\n"), false)); got != "a\r\nb\r\nc\r\n" {
|
||||
t.Fatalf("%q", got)
|
||||
}
|
||||
if got := string(onlcr([]byte("\nx"), true)); got != "\nx" {
|
||||
t.Fatalf("CR aus dem vorigen Block: %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestScreenPrelude(t *testing.T) {
|
||||
s := NewScreen()
|
||||
s.Write([]byte("\x1b[?1049h\x1b[?1000;1006h\x1b[?2004h\x1b[?25l\x1b[>1u\x1b]0;sshTermy · web1\x07"))
|
||||
s.Write([]byte("\x1b[?1000l"))
|
||||
pre := string(s.prelude())
|
||||
for _, want := range []string{"\x1b[?1049h", "\x1b[?1006h", "\x1b[?2004h", "\x1b[?25l", "\x1b[>1u", "\x1b]0;sshTermy · web1\x07"} {
|
||||
if !strings.Contains(pre, want) {
|
||||
t.Errorf("fehlt %q in %q", want, pre)
|
||||
}
|
||||
}
|
||||
if strings.Contains(pre, "?1000h") {
|
||||
t.Error("abgeschalteter Modus wird vorgespielt")
|
||||
}
|
||||
if !strings.HasPrefix(pre, "\x1b[?1049h") {
|
||||
t.Error("Alt-Bildschirm nicht zuerst")
|
||||
}
|
||||
}
|
||||
|
||||
// Ein Fenster dockt an, geht weg, ein zweites dockt an: der Dienst läuft
|
||||
// durch, das zweite bekommt die Modi und die weitere Ausgabe.
|
||||
func TestHubReattach(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
h, err := ListenHub(dir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer h.Close()
|
||||
if !HubAlive(dir) {
|
||||
t.Fatal("Dienst antwortet nicht")
|
||||
}
|
||||
scr := NewScreen()
|
||||
scr.Write([]byte("\x1b[?1049h"))
|
||||
|
||||
accept := func() *Conn {
|
||||
ch := make(chan *Conn, 1)
|
||||
go func() { c, _, _, _ := h.Accept(); ch <- c }()
|
||||
cl, err := Dial(dir, 80, 24)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(cl.Close)
|
||||
c := <-ch
|
||||
scr.Attach(c, "anderswo")
|
||||
m, err := cl.Next()
|
||||
if err != nil || !bytes.Contains(m.Output, []byte("\x1b[?1049h")) {
|
||||
t.Fatalf("Vorspann fehlt: %v %q", err, m.Output)
|
||||
}
|
||||
go func() {
|
||||
for {
|
||||
if _, err := cl.Next(); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
return c
|
||||
}
|
||||
c1 := accept()
|
||||
if !scr.Attached() {
|
||||
t.Fatal("nicht angedockt")
|
||||
}
|
||||
scr.Drop(c1)
|
||||
if scr.Attached() {
|
||||
t.Fatal("nach dem Weggehen noch angedockt")
|
||||
}
|
||||
scr.Write([]byte("läuft ohne Fenster weiter\n")) // darf nicht blockieren
|
||||
accept()
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
scr.Bye("")
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
package detach
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Screen ist das „Terminal“ des Hintergrunddienstes: bubbletea schreibt
|
||||
// hinein, Screen reicht es an das gerade angedockte Fenster weiter (oder
|
||||
// verwirft es, solange keines da ist). Damit ein neu angedocktes Fenster
|
||||
// richtig aussieht, merkt sich Screen die eingeschalteten Terminal-Modi
|
||||
// (Alt-Bildschirm, Maus, Bracketed Paste, Fokus, Tastatur-Protokoll) und
|
||||
// den Titel und spielt sie beim Andocken vor; das Bild zeichnet bubbletea
|
||||
// danach komplett neu.
|
||||
type Screen struct {
|
||||
mu sync.Mutex
|
||||
conn *Conn
|
||||
modes map[int]bool // DEC-Modi (CSI ? n h/l)
|
||||
kitty int // Flags des Kitty-Tastaturprotokolls (CSI > n u)
|
||||
title string
|
||||
tail []byte // Ende der letzten Ausgabe (Sequenzen über zwei Schreibvorgänge)
|
||||
lastCR bool // letzte Ausgabe endete auf \r
|
||||
}
|
||||
|
||||
func NewScreen() *Screen { return &Screen{modes: map[int]bool{}} }
|
||||
|
||||
var (
|
||||
decRx = regexp.MustCompile(`\x1b\[\?([0-9;]+)([hl])`)
|
||||
kittyRx = regexp.MustCompile(`\x1b\[([>=<])([0-9;]*)u`)
|
||||
titleRx = regexp.MustCompile(`\x1b\][02];([^\x07\x1b]*)(\x07|\x1b\\)`)
|
||||
)
|
||||
|
||||
// Write: Ausgabe von bubbletea.
|
||||
func (s *Screen) Write(p []byte) (int, error) {
|
||||
n := len(p)
|
||||
s.mu.Lock()
|
||||
s.track(p)
|
||||
c := s.conn
|
||||
if runtime.GOOS != "windows" {
|
||||
// Ohne TTY geht bubbletea davon aus, dass das Terminal \n wie ein
|
||||
// echtes TTY (ONLCR) als \r\n ausgibt; das angedockte Fenster ist
|
||||
// aber roh. Also hier übersetzen, genau wie ONLCR.
|
||||
p = onlcr(p, s.lastCR)
|
||||
if len(p) > 0 {
|
||||
s.lastCR = p[len(p)-1] == '\r'
|
||||
}
|
||||
}
|
||||
s.mu.Unlock()
|
||||
if c != nil {
|
||||
_ = c.nc.SetWriteDeadline(time.Now().Add(5 * time.Second))
|
||||
if _, err := c.Write(p); err != nil {
|
||||
s.Drop(c) // Fenster hängt oder ist weg: abkoppeln, weiterlaufen
|
||||
}
|
||||
}
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// onlcr: jedes \n, vor dem kein \r steht, wird \r\n.
|
||||
func onlcr(p []byte, prevCR bool) []byte {
|
||||
if bytes.IndexByte(p, '\n') < 0 {
|
||||
return p
|
||||
}
|
||||
out := make([]byte, 0, len(p)+16)
|
||||
for i, b := range p {
|
||||
if b == '\n' && !((i > 0 && p[i-1] == '\r') || (i == 0 && prevCR)) {
|
||||
out = append(out, '\r')
|
||||
}
|
||||
out = append(out, b)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func (s *Screen) track(p []byte) {
|
||||
buf := append(append([]byte(nil), s.tail...), p...)
|
||||
for _, m := range decRx.FindAllSubmatch(buf, -1) {
|
||||
on := string(m[2]) == "h"
|
||||
for _, f := range strings.Split(string(m[1]), ";") {
|
||||
if n, err := strconv.Atoi(f); err == nil {
|
||||
s.modes[n] = on
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, m := range kittyRx.FindAllSubmatch(buf, -1) {
|
||||
switch string(m[1]) {
|
||||
case ">", "=":
|
||||
n, _ := strconv.Atoi(strings.Split(string(m[2]), ";")[0])
|
||||
s.kitty = n
|
||||
case "<":
|
||||
s.kitty = 0
|
||||
}
|
||||
}
|
||||
for _, m := range titleRx.FindAllSubmatch(buf, -1) {
|
||||
s.title = string(m[1])
|
||||
}
|
||||
if len(buf) > 64 {
|
||||
buf = buf[len(buf)-64:]
|
||||
}
|
||||
s.tail = buf
|
||||
}
|
||||
|
||||
// prelude: Modi und Titel für ein neu angedocktes Fenster.
|
||||
func (s *Screen) prelude() []byte {
|
||||
var b strings.Builder
|
||||
keys := make([]int, 0, len(s.modes))
|
||||
for k, on := range s.modes {
|
||||
if on && k != 25 {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
}
|
||||
sort.Ints(keys)
|
||||
// Alt-Bildschirm zuerst, sonst landen die anderen Modi im falschen Puffer
|
||||
for _, alt := range []int{1049, 1047, 47} {
|
||||
if s.modes[alt] {
|
||||
b.WriteString("\x1b[?" + strconv.Itoa(alt) + "h")
|
||||
}
|
||||
}
|
||||
for _, k := range keys {
|
||||
if k == 1049 || k == 1047 || k == 47 {
|
||||
continue
|
||||
}
|
||||
b.WriteString("\x1b[?" + strconv.Itoa(k) + "h")
|
||||
}
|
||||
if on, ok := s.modes[25]; ok && !on {
|
||||
b.WriteString("\x1b[?25l")
|
||||
}
|
||||
if s.kitty > 0 {
|
||||
b.WriteString("\x1b[>" + strconv.Itoa(s.kitty) + "u")
|
||||
}
|
||||
if s.title != "" {
|
||||
b.WriteString("\x1b]0;" + s.title + "\x07")
|
||||
}
|
||||
return []byte(b.String())
|
||||
}
|
||||
|
||||
// Attach: c ist jetzt das Fenster; ein vorher angedocktes bekommt msg.
|
||||
func (s *Screen) Attach(c *Conn, msg string) {
|
||||
s.mu.Lock()
|
||||
old := s.conn
|
||||
s.conn = c
|
||||
pre := s.prelude()
|
||||
s.mu.Unlock()
|
||||
if old != nil {
|
||||
old.Bye(msg)
|
||||
}
|
||||
_, _ = c.Write(pre)
|
||||
}
|
||||
|
||||
// Drop: c ist weg (oder hängt). Nur wenn es noch das aktuelle Fenster ist.
|
||||
func (s *Screen) Drop(c *Conn) bool {
|
||||
s.mu.Lock()
|
||||
cur := s.conn == c
|
||||
if cur {
|
||||
s.conn = nil
|
||||
}
|
||||
s.mu.Unlock()
|
||||
if cur {
|
||||
c.Close()
|
||||
}
|
||||
return cur
|
||||
}
|
||||
|
||||
// Bye: das angedockte Fenster mit einer Meldung entlassen (Abkoppeln, Ende).
|
||||
func (s *Screen) Bye(msg string) {
|
||||
s.mu.Lock()
|
||||
c := s.conn
|
||||
s.conn = nil
|
||||
s.mu.Unlock()
|
||||
if c != nil {
|
||||
c.Bye(msg)
|
||||
}
|
||||
}
|
||||
|
||||
// Attached: ist gerade ein Fenster angedockt?
|
||||
func (s *Screen) Attached() bool {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
return s.conn != nil
|
||||
}
|
||||
@@ -85,7 +85,7 @@ func (s *Server) Accept(timeout time.Duration) (*Conn, int, int, error) {
|
||||
ch <- res{err: err}
|
||||
return
|
||||
}
|
||||
c, cols, rows, err := s.handshake(nc)
|
||||
c, cols, rows, err := handshake(nc, s.token)
|
||||
if err != nil {
|
||||
nc.Close() // falsches Zugangswort: weiter warten
|
||||
continue
|
||||
@@ -105,14 +105,14 @@ func (s *Server) Accept(timeout time.Duration) (*Conn, int, int, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) handshake(nc net.Conn) (*Conn, int, int, error) {
|
||||
func handshake(nc net.Conn, token []byte) (*Conn, int, int, error) {
|
||||
_ = nc.SetReadDeadline(time.Now().Add(5 * time.Second))
|
||||
defer nc.SetReadDeadline(time.Time{})
|
||||
h, err := readFrame(nc)
|
||||
if err != nil {
|
||||
return nil, 0, 0, err
|
||||
}
|
||||
if h.typ != frHello || subtle.ConstantTimeCompare(bytes.TrimSpace(h.p), s.token) != 1 {
|
||||
if h.typ != frHello || subtle.ConstantTimeCompare(bytes.TrimSpace(h.p), token) != 1 {
|
||||
return nil, 0, 0, errors.New("detach: falsches Zugangswort")
|
||||
}
|
||||
r, err := readFrame(nc)
|
||||
|
||||
@@ -548,6 +548,12 @@ type Settings struct {
|
||||
// NoDesktopNotify: dafür keine Benachrichtigung des Betriebssystems,
|
||||
// wenn das sshTermy-Fenster nicht im Vordergrund ist.
|
||||
NoDesktopNotify bool `json:"no_desktop_notify,omitempty"`
|
||||
// RestoreTabs: Tabs vom letzten Mal beim Start wieder öffnen:
|
||||
// "" = fragen, "always" = ohne Rückfrage, "never" = nie. Je Rechner.
|
||||
RestoreTabs string `json:"restore_tabs,omitempty"`
|
||||
// Header: eigene Felder in der Kopfzeile (Uhrzeit, Ausgabe eines lokalen
|
||||
// Befehls). Rein lokal: ein Befehl, der hier läuft, kommt nie per Sync.
|
||||
Header HeaderConfig `json:"header,omitempty"`
|
||||
// NoOSC52: Programme auf dem Server (tmux, vim) dürfen nicht in die
|
||||
// lokale Zwischenablage schreiben.
|
||||
NoOSC52 bool `json:"no_osc52,omitempty"`
|
||||
@@ -708,13 +714,22 @@ func (s Settings) SyncedPart() Settings {
|
||||
s.LastLayout, s.Editor, s.Schedules, s.KeysHere = nil, "", nil, nil // Zeitpläne: eigener Abgleich
|
||||
s.Debug, s.Audit, s.MCP = false, false, ""
|
||||
s.SyslogPort, s.SyslogAny = 0, false
|
||||
s.UpdateWaitH = 0 // Update-Kanal gilt je Rechner
|
||||
s.CmdSetApproved = nil // Freigaben gelten für die Team-Dateien dieses Rechners
|
||||
s.Share = ShareConfig{} // Teilen: Vorgaben und Weg gelten je Rechner (Vermittler sind lokal)
|
||||
s.Vuln = VulnConfig{} // Sicherheitscheck: Quelle/Spiegel/Ausnahmen je Rechner
|
||||
s.UpdateWaitH = 0 // Update-Kanal gilt je Rechner
|
||||
s.CmdSetApproved = nil // Freigaben gelten für die Team-Dateien dieses Rechners
|
||||
s.Share = ShareConfig{} // Teilen: Vorgaben und Weg gelten je Rechner (Vermittler sind lokal)
|
||||
s.Vuln = VulnConfig{} // Sicherheitscheck: Quelle/Spiegel/Ausnahmen je Rechner
|
||||
s.Header = HeaderConfig{} // lokaler Befehl in der Kopfzeile: nie per Sync
|
||||
s.RestoreTabs = "" // Tabs vom letzten Mal: je Rechner
|
||||
return s
|
||||
}
|
||||
|
||||
// HeaderConfig: eigene Felder rechts in der Kopfzeile.
|
||||
type HeaderConfig struct {
|
||||
Clock bool `json:"clock,omitempty"` // Uhrzeit HH:MM
|
||||
Cmd string `json:"cmd,omitempty"` // lokaler Befehl, erste Zeile der Ausgabe
|
||||
Every int `json:"every,omitempty"` // alle N Sekunden (0 = 30)
|
||||
}
|
||||
|
||||
// ShareConfig: Vorgaben für „Sitzung teilen“ (zuletzt gewählt). Rein lokal.
|
||||
type ShareConfig struct {
|
||||
Minutes int `json:"min,omitempty"` // Dauer, 0 = 30
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package i18n
|
||||
|
||||
// Ideen aus herdr: Tabs vom letzten Mal, Wartet-Marke, KI-Coding-Agenten,
|
||||
// MCP zum Steuern, Markieren per Tastatur, Bildschirm leeren, Kopfzeile,
|
||||
// Hintergrunddienst (ui/restore.go, waitmark.go, mcpcontrol.go, copymode.go,
|
||||
// clearscreen.go, headerfields.go, keeper.go, cmd/sshtermy/keep.go).
|
||||
func init() {
|
||||
for k, v := range enHerdr {
|
||||
en[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
var enHerdr = map[string]string{
|
||||
"\n\nj = tippen · n = ablehnen": "\n\ny = type · n = decline",
|
||||
"\n\nj zweimal = tippen · n = ablehnen": "\n\ny twice = type · n = decline",
|
||||
" vom letzten Mal wieder geöffnet": " from last time reopened",
|
||||
"%s ist fertig (%s)": "%s is done (%s)",
|
||||
"%s wartet auf deine Freigabe": "%s is waiting for your approval",
|
||||
"Abkoppeln: Fenster zu, Sitzungen laufen weiter": "Detach: close the window, sessions keep running",
|
||||
"Bildschirm und Verlauf geleert": "Screen and scrollback cleared",
|
||||
"Bildschirm und Verlauf leeren (Eingabezeile bleibt)": "Clear screen and scrollback (input line stays)",
|
||||
"Desktop-Meldung angeklickt": "desktop notification clicked",
|
||||
"Ein KI-Client möchte in %s tippen, %s:": "An AI client wants to type into %s, %s:",
|
||||
"Erst mit v (oder V für Zeilen) markieren": "Select with v first (or V for lines)",
|
||||
"Hintergrunddienst ab dem nächsten Start: Sitzungen laufen weiter, wenn du das Fenster schließt": "Background service from the next start: sessions keep running when you close the window",
|
||||
"Hintergrunddienst an": "Background service on",
|
||||
"Hintergrunddienst aus": "Background service off",
|
||||
"Hintergrunddienst aus ab dem nächsten Start (läuft gerade noch)": "Background service off from the next start (still running now)",
|
||||
"Hintergrunddienst: Sitzungen laufen weiter, wenn das Fenster zugeht": "Background service: sessions keep running when the window closes",
|
||||
"Kein Tab wartet und keiner hat eine Meldung": "No tab is waiting and none has a notice",
|
||||
"Kopfzeile: Uhrzeit zeigen": "Header: show the time",
|
||||
"Kopfzeile: eigener Befehl": "Header: own command",
|
||||
"Kopfzeile: eigener Befehl aus": "Header: own command off",
|
||||
"Kopfzeile: eigener Befehl gespeichert": "Header: own command saved",
|
||||
"Kopfzeile: eigener Befehl …": "Header: own command …",
|
||||
"Leeren geht nicht, solange ein Vollbildprogramm läuft (vim, less, htop)": "Cannot clear while a full-screen program runs (vim, less, htop)",
|
||||
"Läuft auf diesem Rechner, die erste Zeile der Ausgabe steht rechts in der Kopfzeile. Alle 30 s; anders mit „@Sekunden“ am Ende. Leer = aus. Beispiele:": "Runs on this computer; the first line of its output shows on the right of the header. Every 30 s; add “@seconds” at the end for another interval. Empty = off. Examples:",
|
||||
"MCP tippt in %s: %s": "MCP types into %s: %s",
|
||||
"MCP: Eingabe erlauben?": "MCP: allow input?",
|
||||
"MCP: Tab %s geöffnet": "MCP: opened tab %s",
|
||||
"Markieren per Tastatur (v, y kopiert)": "Select with the keyboard (v, y copies)",
|
||||
"Markieren per Tastatur geht nicht, solange ein Vollbildprogramm läuft (dort dessen eigene Tasten)": "Keyboard selection is not available while a full-screen program runs (use its own keys there)",
|
||||
"Markieren: Pfeile/hjkl bewegen · v markieren · V Zeilen · y kopieren · Esc beenden": "Select: arrows/hjkl move · v select · V lines · y copy · Esc quit",
|
||||
"Tabs vom letzten Mal beim Start öffnen": "Open the tabs from last time at start",
|
||||
"Tabs vom letzten Mal beim Start: ": "Tabs from last time at start: ",
|
||||
"Tabs vom letzten Mal wieder öffnen?": "Reopen the tabs from last time?",
|
||||
"Tipp: Mit dem Hintergrunddienst laufen Sitzungen weiter (Befehlspalette, „Hintergrunddienst“)": "Tip: with the background service, sessions keep running (command palette, “Background service”)",
|
||||
"Update installiert: bitte sshtermy neu starten.": "Update installed: please start sshtermy again.",
|
||||
"Wort": "word",
|
||||
"a = abkoppeln: Fenster zu, alle Sitzungen laufen im Hintergrund weiter (wieder anhängen: sshtermy)": "a = detach: close the window, all sessions keep running in the background (attach again: sshtermy)",
|
||||
"abkoppeln": "detach",
|
||||
"am Prompt": "at the prompt",
|
||||
"arbeitet": "working",
|
||||
"bewegen": "move",
|
||||
"in das laufende Programm": "into the running program",
|
||||
"j = trotzdem beenden (%s noch einmal = beenden) · n = abbrechen": "y = quit anyway (%s again = quit) · n = cancel",
|
||||
"j = öffnen · n = nicht jetzt\nImmer oder nie: Befehlspalette, „Tabs vom letzten Mal“ suchen": "y = open · n = not now\nAlways or never: command palette, search “Tabs from last time”",
|
||||
"mit geteilter Ansicht": "with split view",
|
||||
"nie": "never",
|
||||
"sshTermy abkoppeln oder beenden?": "Detach or quit sshTermy?",
|
||||
"sshTermy ist abgestürzt. Bericht: ": "sshTermy crashed. Report: ",
|
||||
"sshTermy läuft im Hintergrund weiter (%s). Wieder anhängen: sshtermy": "sshTermy keeps running in the background (%s). Attach again: sshtermy",
|
||||
"sshTermy wurde in einem anderen Fenster angehängt.": "sshTermy was attached in another window.",
|
||||
"von der Desktop-Meldung": "from the desktop notification",
|
||||
"wartet auf dich": "waiting for you",
|
||||
"wartet auf ein Passwort": "waiting for a password",
|
||||
"wartet auf eine Taste": "waiting for a key",
|
||||
"wartet auf ja/nein": "waiting for yes/no",
|
||||
"wartet im Pager (Leertaste/q)": "waiting in a pager (space/q)",
|
||||
"■ MARKIEREN": "■ SELECT",
|
||||
"Zum nächsten Tab, der wartet oder sich gemeldet hat": "Go to the next tab that waits or has a notice",
|
||||
"wartet auf Freigabe": "waiting for approval",
|
||||
"bereit": "ready",
|
||||
"Öffnen": "Open",
|
||||
"per Tastatur markieren: v / V, y kopiert": "select by keys: v / V, y copies",
|
||||
"Bildschirm + Verlauf leeren, Eingabe bleibt": "clear screen + scrollback, input stays",
|
||||
"zum Tab, der wartet (? / ◆) oder sich meldet": "go to the tab that waits (? / ◆) or has news",
|
||||
"abkoppeln (Hintergrunddienst läuft weiter)": "detach (background service keeps running)",
|
||||
}
|
||||
+16
-1
@@ -90,7 +90,7 @@ func num(desc string) map[string]any { return map[string]any{"type": "integer",
|
||||
var Tools = []Tool{
|
||||
{"list_connections", "List the SSH connections saved in sshTermy (alias, host, user, folder, tags, device type, OS). Never includes passwords or keys.",
|
||||
obj(map[string]any{"query": str("optional filter on alias, host, folder or tag")})},
|
||||
{"list_tabs", "List the terminal tabs currently open in sshTermy with their connection and state.", obj(map[string]any{})},
|
||||
{"list_tabs", "List the terminal tabs currently open in sshTermy with their connection and state. status tells whether the tab sits at its shell prompt, waits for input (password, yes/no, pager) or runs a coding agent (Claude Code, Codex …) that is working, waiting for approval or ready.", obj(map[string]any{})},
|
||||
{"read_tab", "Read the visible text and recent scrollback of an open tab (secrets are redacted).",
|
||||
obj(map[string]any{"tab": num("tab number from list_tabs"), "lines": num("how many lines from the end, default 100, max 1000")}, "tab")},
|
||||
{"run_command", "Run a shell command on a saved connection in a separate, invisible session and return its output. Read-only commands run directly; anything that could change the system needs the user's confirmation in sshTermy (or is refused, depending on the user's setting). Network devices (switches/routers) accept their CLI show commands.",
|
||||
@@ -99,6 +99,21 @@ var Tools = []Tool{
|
||||
"command": str("the command line"),
|
||||
"timeout_seconds": num("default 60, max 600"),
|
||||
}, "connection", "command")},
|
||||
{"open_tab", "Open a new visible terminal tab in sshTermy for a saved connection (needs the sshTermy setting “MCP access: with confirmation”). Returns the tab number; use wait_tab with until=prompt before typing.",
|
||||
obj(map[string]any{"connection": str("alias or ID of the connection (see list_connections)")}, "connection")},
|
||||
{"send_input", "Type text into an open tab, as if the user typed it, by default followed by Enter. At a shell prompt, read-only commands are typed directly; everything else (changing commands, answers to prompts, input for a running program or coding agent) needs the user's confirmation in sshTermy. Passwords are never typed. Use read_tab or wait_tab afterwards to see the result.",
|
||||
obj(map[string]any{
|
||||
"tab": num("tab number from list_tabs"),
|
||||
"text": str("the text to type"),
|
||||
"enter": map[string]any{"type": "boolean", "description": "press Enter after the text (default true)"},
|
||||
}, "tab", "text")},
|
||||
{"wait_tab", "Wait until something happens in an open tab and return its status and the last lines. until: prompt (back at the shell prompt, i.e. the command finished), input (the tab waits for input or a coding agent waits for approval or is ready), text (the given text appears on the screen), quiet (no output for 2 seconds).",
|
||||
obj(map[string]any{
|
||||
"tab": num("tab number from list_tabs"),
|
||||
"until": str("prompt, input, text or quiet (default prompt)"),
|
||||
"text": str("text to wait for (until=text)"),
|
||||
"timeout_seconds": num("default 120, max 600"),
|
||||
}, "tab")},
|
||||
}
|
||||
|
||||
// Backend führt Werkzeuge aus (im Brückenprozess: Weiterleitung an die App).
|
||||
|
||||
@@ -12,9 +12,19 @@ import (
|
||||
)
|
||||
|
||||
// Send zeigt title und body an und kehrt sofort zurück.
|
||||
func Send(title, body string) {
|
||||
func Send(title, body string) { SendClick(title, body, "", nil) }
|
||||
|
||||
// SendClick wie Send; klickt man die Meldung an, läuft click (in einer
|
||||
// eigenen Goroutine). Das klappt nur, wo das Bordmittel Klicks zurückmeldet
|
||||
// (Linux: notify-send --action --wait). Anderswo bleibt click ungenutzt,
|
||||
// sshTermy springt dann beim Zurückkehren ins Fenster in den Tab.
|
||||
// action ist die Beschriftung des Knopfs („Öffnen“).
|
||||
func SendClick(title, body, action string, click func()) {
|
||||
title, body = clean(title, 64), clean(body, 200)
|
||||
go func() { _ = send(title, body) }()
|
||||
if action = clean(action, 30); action == "" {
|
||||
action = "Open"
|
||||
}
|
||||
go func() { _ = send(title, body, action, click) }()
|
||||
}
|
||||
|
||||
// clean: einzeilig, ohne Steuerzeichen, höchstens n Zeichen.
|
||||
|
||||
@@ -2,7 +2,8 @@ package notify
|
||||
|
||||
import "os/exec"
|
||||
|
||||
func send(title, body string) error {
|
||||
// macOS: osascript kann keinen Klick zurückmelden (click bleibt ungenutzt).
|
||||
func send(title, body, _ string, _ func()) error {
|
||||
script := "display notification " + quoteAS(body) + " with title " + quoteAS(title)
|
||||
return exec.Command("osascript", "-e", script).Run()
|
||||
}
|
||||
@@ -2,8 +2,29 @@
|
||||
|
||||
package notify
|
||||
|
||||
import "os/exec"
|
||||
import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func send(title, body string) error {
|
||||
return exec.Command("notify-send", "--app-name=sshTermy", title, body).Run()
|
||||
// notifySend ist in Tests ersetzbar.
|
||||
var notifySend = func(args ...string) ([]byte, error) { return exec.Command("notify-send", args...).Output() }
|
||||
|
||||
func send(title, body, action string, click func()) error {
|
||||
if click == nil {
|
||||
_, err := notifySend("--app-name=sshTermy", title, body)
|
||||
return err
|
||||
}
|
||||
// --wait hält, bis die Meldung angeklickt oder geschlossen wird, und
|
||||
// schreibt dann den Namen der Aktion. Älteres libnotify kennt --action
|
||||
// nicht: dann ohne Klick.
|
||||
out, err := notifySend("--app-name=sshTermy", "--action=default="+action, "--wait", title, body)
|
||||
if err != nil {
|
||||
_, err = notifySend("--app-name=sshTermy", title, body)
|
||||
return err
|
||||
}
|
||||
if strings.TrimSpace(string(out)) == "default" {
|
||||
click()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
//go:build !windows && !darwin
|
||||
|
||||
package notify
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSendClickLinux(t *testing.T) {
|
||||
old := notifySend
|
||||
defer func() { notifySend = old }()
|
||||
var calls []string
|
||||
notifySend = func(args ...string) ([]byte, error) {
|
||||
calls = append(calls, strings.Join(args, " "))
|
||||
return []byte("default\n"), nil
|
||||
}
|
||||
clicked := false
|
||||
if err := send("t", "b", "Öffnen", func() { clicked = true }); err != nil || !clicked {
|
||||
t.Fatalf("Klick nicht gemeldet: %v %v", err, calls)
|
||||
}
|
||||
if !strings.Contains(calls[0], "--action=default=Öffnen") || !strings.Contains(calls[0], "--wait") {
|
||||
t.Fatalf("Aufruf: %v", calls)
|
||||
}
|
||||
|
||||
// altes notify-send ohne --action: einfache Meldung, kein Klick
|
||||
calls, clicked = nil, false
|
||||
notifySend = func(args ...string) ([]byte, error) {
|
||||
calls = append(calls, strings.Join(args, " "))
|
||||
if strings.Contains(calls[len(calls)-1], "--action") {
|
||||
return nil, errors.New("Unknown option --action")
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
if err := send("t", "b", "Open", func() { clicked = true }); err != nil || clicked || len(calls) != 2 {
|
||||
t.Fatalf("Rückfall: %v %v %v", err, clicked, calls)
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,8 @@ import (
|
||||
// Windows 10/11: Toast über die WinRT-Klassen, die PowerShell ohne Module
|
||||
// erreicht. Als Absender dient die AppID der PowerShell, die immer
|
||||
// registriert ist (eigene AppIDs bräuchten eine Verknüpfung im Startmenü).
|
||||
func send(title, body string) error {
|
||||
// Ein Klick aktiviert deshalb nur PowerShell und kommt nicht bei sshTermy an.
|
||||
func send(title, body, _ string, _ func()) error {
|
||||
xml := "<toast><visual><binding template=\"ToastGeneric\"><text>" + xmlEscape(title) +
|
||||
"</text><text>" + xmlEscape(body) + "</text></binding></visual></toast>"
|
||||
ps := "[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null;" +
|
||||
|
||||
@@ -88,6 +88,8 @@ var localSettings = map[string]bool{
|
||||
"Share": true,
|
||||
"FilesNoPeek": true, // Vorschau im Dateibrowser: Platz je Bildschirm
|
||||
"Vuln": true, // Sicherheitscheck je Rechner
|
||||
"Header": true, // eigener Befehl in der Kopfzeile läuft nur hier
|
||||
"RestoreTabs": true, // Tabs vom letzten Mal: je Rechner
|
||||
}
|
||||
|
||||
// ownMerge: gehen mit dem Sync, aber pro Eintrag statt als Teil der
|
||||
|
||||
@@ -305,3 +305,13 @@ func (t *Term) SnapshotAt(dst []uv.Cell, offset int) ([]uv.Cell, int, int) {
|
||||
}
|
||||
return dst, w, h
|
||||
}
|
||||
|
||||
// CellText: Inhalt einer Zelle im Gesamtpuffer ("" = leer oder zweite
|
||||
// Hälfte eines breiten Zeichens).
|
||||
func (t *Term) CellText(p Pos) string {
|
||||
c, ok := t.cellAt(t.ScrollbackLen(), p)
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
return c.Content
|
||||
}
|
||||
@@ -8,6 +8,7 @@ package termemu
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"image/color"
|
||||
"io"
|
||||
"regexp"
|
||||
@@ -498,3 +499,36 @@ func (t *Term) CommandOutput(cmd string, n int) (out, line string, found bool) {
|
||||
// Snapshot: der ganze Bildschirm als Zellen, unter einer Sperre kopiert
|
||||
// (eigenes Fenster, internal/gui). dst wird wiederverwendet.
|
||||
func (t *Term) Snapshot(dst []uv.Cell) ([]uv.Cell, int, int) { return t.emu.Snapshot(dst) }
|
||||
|
||||
// ClearKeepLine leert Bildschirm und Verlauf, die Zeile mit dem Cursor
|
||||
// (Prompt samt halb getippter Eingabe) rückt nach oben und bleibt stehen.
|
||||
// Vollbildprogramme (vim, less, htop) bleiben unberührt: false.
|
||||
func (t *Term) ClearKeepLine() bool {
|
||||
if t.AltScreen() {
|
||||
return false
|
||||
}
|
||||
x, y, _ := t.Cursor()
|
||||
var b strings.Builder
|
||||
if y > 0 {
|
||||
fmt.Fprintf(&b, "\x1b[%dS", y) // Cursorzeile nach oben schieben
|
||||
}
|
||||
// alles unter der ersten Zeile leeren, Cursor zurück an seine Spalte
|
||||
fmt.Fprintf(&b, "\x1b[2;1H\x1b[J\x1b[1;%dH", x+1)
|
||||
_, _ = t.emu.Write([]byte(b.String()))
|
||||
t.sb.clear()
|
||||
t.gen.Add(1)
|
||||
return true
|
||||
}
|
||||
|
||||
// ScreenText: nur der sichtbare Bildschirm als Klartext (ohne Verlauf),
|
||||
// Leerzeilen am Ende entfernt.
|
||||
func (t *Term) ScreenText() string {
|
||||
lines := strings.Split(t.emu.String(), "\n")
|
||||
for i, l := range lines {
|
||||
lines[i] = strings.TrimRight(l, " \r")
|
||||
}
|
||||
for len(lines) > 0 && lines[len(lines)-1] == "" {
|
||||
lines = lines[:len(lines)-1]
|
||||
}
|
||||
return strings.Join(lines, "\n")
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package termemu
|
||||
|
||||
import (
|
||||
"io"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
@@ -101,3 +102,37 @@ func TestCursorColorOSC(t *testing.T) {
|
||||
t.Errorf("112 setzt nicht zurück: %v", c)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClearKeepLine(t *testing.T) {
|
||||
tm := New(30, 5, io.Discard)
|
||||
for i := 0; i < 12; i++ {
|
||||
tm.Write([]byte("zeile " + strconv.Itoa(i) + "\r\n"))
|
||||
}
|
||||
tm.Write([]byte("user@web:~$ ls -l"))
|
||||
if tm.ScrollbackLen() == 0 {
|
||||
t.Fatal("Testaufbau: kein Verlauf")
|
||||
}
|
||||
if !tm.ClearKeepLine() {
|
||||
t.Fatal("nicht geleert")
|
||||
}
|
||||
if tm.ScrollbackLen() != 0 {
|
||||
t.Fatalf("Verlauf noch da: %d", tm.ScrollbackLen())
|
||||
}
|
||||
got := tm.PlainLines(10)
|
||||
if got != "user@web:~$ ls -l" {
|
||||
t.Fatalf("Bildschirm = %q", got)
|
||||
}
|
||||
if x, y, _ := tm.Cursor(); x != 17 || y != 0 {
|
||||
t.Fatalf("Cursor %d,%d", x, y)
|
||||
}
|
||||
// weiter tippen landet hinter der Eingabe
|
||||
tm.Write([]byte("a"))
|
||||
if tm.PlainLines(10) != "user@web:~$ ls -la" {
|
||||
t.Fatalf("danach = %q", tm.PlainLines(10))
|
||||
}
|
||||
// Vollbildprogramm: nichts anfassen
|
||||
tm.Write([]byte("\x1b[?1049h"))
|
||||
if tm.ClearKeepLine() {
|
||||
t.Fatal("Alt-Screen geleert")
|
||||
}
|
||||
}
|
||||
+28
-2
@@ -174,7 +174,18 @@ type App struct {
|
||||
rel *update.Release
|
||||
// restartPending: installierte, noch nicht gestartete Version.
|
||||
restartPending string
|
||||
restart bool // nach dem Beenden neu starten (siehe Restart)
|
||||
keeperDetach func(string) // Hintergrunddienst: Fenster abkoppeln (keeper.go)
|
||||
hdrOut string // eigener Befehl in der Kopfzeile: Ausgabe (headerfields.go)
|
||||
hdrFor string // … für diesen Befehl
|
||||
hdrAt time.Time // … zuletzt gestartet
|
||||
hdrBusy bool
|
||||
mcpWaits []*mcpWaiter // MCP wait_tab, die noch warten (mcpcontrol.go)
|
||||
jumpSID int // Tab der letzten Desktop-Meldung (notify.go)
|
||||
jumpAt time.Time // … und wann sie kam
|
||||
restoreArmed bool // Tabs vom letzten Mal angeboten, ab jetzt sichern (restore.go)
|
||||
restoreAt time.Time // letzte Sicherung der offenen Tabs
|
||||
restoreSig string // Inhalt der letzten Sicherung (nur bei Änderung schreiben)
|
||||
restart bool // nach dem Beenden neu starten (siehe Restart)
|
||||
lastKey time.Time
|
||||
|
||||
hl hlState // Farbregeln (highlight.go)
|
||||
@@ -416,8 +427,16 @@ func (a *App) coreMsg(msg tea.Msg) (tea.Cmd, bool) {
|
||||
return a.onAhead(m), true
|
||||
case tea.FocusMsg:
|
||||
a.blurred = false
|
||||
a.onRefocus() // nach einer Desktop-Meldung in deren Tab (notify.go)
|
||||
a.clearNotices()
|
||||
return nil, true
|
||||
case headerOutMsg:
|
||||
a.onHeaderOut(m)
|
||||
return nil, true
|
||||
case notifyClickMsg:
|
||||
a.jumpSID = 0
|
||||
a.jumpToNotified(m.sid, i18n.T("Desktop-Meldung angeklickt"))
|
||||
return nil, true
|
||||
case tea.BlurMsg:
|
||||
a.blurred = true
|
||||
return nil, true
|
||||
@@ -809,6 +828,7 @@ func (a *App) screenMsg(msg tea.Msg) tea.Cmd {
|
||||
type WindowClosedMsg struct{}
|
||||
|
||||
func (a *App) quit() tea.Cmd {
|
||||
a.restoreOnQuit() // offene Tabs fürs nächste Mal merken (restore.go)
|
||||
a.finishUndo() // offenes Löschen endgültig machen (undo.go)
|
||||
a.rememberLayout() // geteilte Ansicht als „Zuletzt“ (workspace.go)
|
||||
a.cleanupEdits()
|
||||
@@ -855,6 +875,11 @@ func (a *App) onTick() tea.Cmd {
|
||||
cmds = append(cmds, c)
|
||||
}
|
||||
a.watchTick()
|
||||
a.restoreTick(time.Now())
|
||||
a.mcpWaitTick(time.Now()) // MCP wait_tab (mcpcontrol.go)
|
||||
if c := a.headerTick(time.Now()); c != nil {
|
||||
cmds = append(cmds, c) // eigener Befehl in der Kopfzeile (headerfields.go)
|
||||
}
|
||||
if c := a.vgTick(); c != nil {
|
||||
cmds = append(cmds, c)
|
||||
}
|
||||
@@ -863,7 +888,8 @@ func (a *App) onTick() tea.Cmd {
|
||||
a.noticeBell(s)
|
||||
}
|
||||
a.alertTick(s)
|
||||
a.flushAhead(s) // vorausgetippt beim Verbinden (typeahead.go)
|
||||
a.waitTick(s, time.Now()) // wartet auf dich / KI-Agent (waitmark.go)
|
||||
a.flushAhead(s) // vorausgetippt beim Verbinden (typeahead.go)
|
||||
s.recordLatency(time.Now())
|
||||
a.shareTick(s)
|
||||
if c := a.takeClipboard(s); c != nil {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"github.com/db9979/sshtermy/internal/i18n"
|
||||
)
|
||||
|
||||
// Bildschirm und Verlauf leeren, Eingabezeile bleibt (Alt+X): der Prompt
|
||||
// samt halb getippter Eingabe rückt nach oben, alles andere ist weg. Anders
|
||||
// als `clear` oder Strg+L geht nichts an den Server, laufende Programme
|
||||
// merken nichts. Vollbildprogramme (vim, less, htop) bleiben unberührt.
|
||||
func (a *App) clearKeepLine(s *session) {
|
||||
if s == nil || s.term == nil {
|
||||
return
|
||||
}
|
||||
if !s.term.ClearKeepLine() {
|
||||
a.flash(i18n.T("Leeren geht nicht, solange ein Vollbildprogramm läuft (vim, less, htop)"))
|
||||
return
|
||||
}
|
||||
// alles, was auf Zeilen im Verlauf zeigt, gilt nicht mehr
|
||||
s.scroll, s.sel, s.selecting = 0, nil, false
|
||||
s.blocks, s.blockNav, s.blockScroll = nil, 0, 0
|
||||
s.search = searchState{}
|
||||
s.viewMemo = termMemo{}
|
||||
a.flash(i18n.T("Bildschirm und Verlauf geleert"))
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
|
||||
tea "charm.land/bubbletea/v2"
|
||||
|
||||
"github.com/db9979/sshtermy/internal/i18n"
|
||||
"github.com/db9979/sshtermy/internal/termemu"
|
||||
)
|
||||
|
||||
// Markieren per Tastatur (Alt+C, Idee aus herdr/tmux): ein Cursor wandert
|
||||
// durch Bildschirm und Verlauf, v/Leertaste beginnt eine Markierung, V
|
||||
// markiert ganze Zeilen, y oder ⏎ kopiert und beendet, Esc/q beendet.
|
||||
// Bewegen: Pfeile oder h/j/k/l, w/b/e Wort, 0/^/$ Zeile, g/G Anfang/Ende,
|
||||
// Bild↑/Bild↓ bzw. Strg+U/Strg+D halbe Seite. Die Ausgabe läuft weiter, der
|
||||
// Server bekommt keine Taste. Gut ohne Maus (uConsole, Laptop, SSH in SSH).
|
||||
|
||||
type copyMode struct {
|
||||
cur termemu.Pos // Cursor im Gesamtpuffer
|
||||
anchor *termemu.Pos // Beginn der Markierung, nil = keine
|
||||
lines bool // ganze Zeilen (V)
|
||||
}
|
||||
|
||||
func (a *App) startCopyMode(s *session) {
|
||||
if s.term == nil || s.term.AltScreen() {
|
||||
a.flash(i18n.T("Markieren per Tastatur geht nicht, solange ein Vollbildprogramm läuft (dort dessen eigene Tasten)"))
|
||||
return
|
||||
}
|
||||
x, y, _ := s.term.Cursor()
|
||||
cm := ©Mode{cur: termemu.Pos{Line: s.term.ScrollbackLen() - s.scroll + y, Col: x}}
|
||||
if s.scroll > 0 {
|
||||
cm.cur.Line = s.term.ScrollbackLen() - s.scroll // oben im zurückgeblätterten Bild
|
||||
cm.cur.Col = 0
|
||||
}
|
||||
s.copy = cm
|
||||
a.copyShow(s)
|
||||
a.flash(i18n.T("Markieren: Pfeile/hjkl bewegen · v markieren · V Zeilen · y kopieren · Esc beenden"))
|
||||
}
|
||||
|
||||
func (a *App) stopCopyMode(s *session) {
|
||||
s.copy, s.sel, s.scroll = nil, nil, 0
|
||||
}
|
||||
|
||||
// copyShow: Markierung (oder nur den Cursor) anzeigen und dorthin blättern.
|
||||
func (a *App) copyShow(s *session) {
|
||||
cm := s.copy
|
||||
_, rows := s.term.Size()
|
||||
sb := s.term.ScrollbackLen()
|
||||
cm.cur.Line = clamp(cm.cur.Line, 0, sb+rows-1)
|
||||
top := sb - s.scroll
|
||||
switch {
|
||||
case cm.cur.Line < top:
|
||||
s.scroll = sb - cm.cur.Line
|
||||
case cm.cur.Line > top+rows-1:
|
||||
s.scroll = sb - (cm.cur.Line - rows + 1)
|
||||
}
|
||||
s.scroll = clamp(s.scroll, 0, sb)
|
||||
sel := termemu.Sel{A: cm.cur, B: cm.cur}
|
||||
if cm.anchor != nil {
|
||||
sel.A = *cm.anchor
|
||||
if cm.lines {
|
||||
w, _ := s.term.Size()
|
||||
a1, b1 := sel.A, sel.B
|
||||
if b1.Before(a1) {
|
||||
a1, b1 = b1, a1
|
||||
}
|
||||
sel = termemu.Sel{A: termemu.Pos{Line: a1.Line}, B: termemu.Pos{Line: b1.Line, Col: w - 1}}
|
||||
}
|
||||
}
|
||||
s.sel = &sel
|
||||
}
|
||||
|
||||
// cellClass: 0 = leer, 1 = Wortzeichen, 2 = Satzzeichen. Punkt, Doppelpunkt,
|
||||
// Schrägstrich, Bindestrich, @ und ~ zählen zum Wort: so ist eine IP, ein
|
||||
// Pfad oder user@host mit w/e ein Wort.
|
||||
func cellClass(t *termemu.Term, p termemu.Pos) int {
|
||||
c := t.CellText(p)
|
||||
r, _ := utf8.DecodeRuneInString(c)
|
||||
switch {
|
||||
case c == "" || unicode.IsSpace(r):
|
||||
return 0
|
||||
case unicode.IsLetter(r) || unicode.IsDigit(r) || strings.ContainsRune("_.:/-@~", r):
|
||||
return 1
|
||||
}
|
||||
return 2
|
||||
}
|
||||
|
||||
// copyWord: nächster Wortanfang (dir 1), voriger Wortanfang (-1) oder
|
||||
// Wortende (e). Bleibt in der Zeile, springt am Rand in die nächste.
|
||||
func copyWord(t *termemu.Term, p termemu.Pos, dir int, end bool) termemu.Pos {
|
||||
w, _ := t.Size()
|
||||
last := t.Lines() - 1
|
||||
step := func(q termemu.Pos, d int) (termemu.Pos, bool) {
|
||||
q.Col += d
|
||||
if q.Col >= w {
|
||||
if q.Line >= last {
|
||||
return q, false
|
||||
}
|
||||
q.Line, q.Col = q.Line+1, 0
|
||||
} else if q.Col < 0 {
|
||||
if q.Line == 0 {
|
||||
return q, false
|
||||
}
|
||||
q.Line, q.Col = q.Line-1, w-1
|
||||
}
|
||||
return q, true
|
||||
}
|
||||
q, ok := p, true
|
||||
switch {
|
||||
case end: // Wortende: mindestens ein Schritt, Leeres überspringen, bis zum letzten Zeichen der Klasse
|
||||
if q, ok = step(q, 1); !ok {
|
||||
return p
|
||||
}
|
||||
for cellClass(t, q) == 0 {
|
||||
if q, ok = step(q, 1); !ok {
|
||||
return p
|
||||
}
|
||||
}
|
||||
cls := cellClass(t, q)
|
||||
for {
|
||||
n, ok := step(q, 1)
|
||||
if !ok || n.Line != q.Line || cellClass(t, n) != cls {
|
||||
return q
|
||||
}
|
||||
q = n
|
||||
}
|
||||
case dir > 0:
|
||||
cls := cellClass(t, q)
|
||||
for cls != 0 { // Rest des Worts
|
||||
n, ok := step(q, 1)
|
||||
if !ok {
|
||||
return q
|
||||
}
|
||||
if n.Line != q.Line || cellClass(t, n) != cls {
|
||||
q = n
|
||||
break
|
||||
}
|
||||
q = n
|
||||
}
|
||||
for cellClass(t, q) == 0 {
|
||||
if q, ok = step(q, 1); !ok {
|
||||
return p
|
||||
}
|
||||
}
|
||||
return q
|
||||
}
|
||||
// rückwärts: Leeres davor überspringen, dann an den Anfang des Worts
|
||||
if q, ok = step(q, -1); !ok {
|
||||
return p
|
||||
}
|
||||
for cellClass(t, q) == 0 {
|
||||
if q, ok = step(q, -1); !ok {
|
||||
return p
|
||||
}
|
||||
}
|
||||
cls := cellClass(t, q)
|
||||
for {
|
||||
n, ok := step(q, -1)
|
||||
if !ok || n.Line != q.Line || cellClass(t, n) != cls {
|
||||
return q
|
||||
}
|
||||
q = n
|
||||
}
|
||||
}
|
||||
|
||||
// lineEnd: letzte belegte Spalte der Zeile.
|
||||
func lineEnd(t *termemu.Term, l int) int {
|
||||
w, _ := t.Size()
|
||||
for x := w - 1; x > 0; x-- {
|
||||
if cellClass(t, termemu.Pos{Line: l, Col: x}) != 0 {
|
||||
return x
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (a *App) copyKey(s *session, m tea.KeyPressMsg) tea.Cmd {
|
||||
cm, t := s.copy, s.term
|
||||
if t == nil {
|
||||
s.copy = nil
|
||||
return nil
|
||||
}
|
||||
w, rows := t.Size()
|
||||
last := t.Lines() - 1
|
||||
key := m.String()
|
||||
switch key {
|
||||
case "esc", "q", "ctrl+c":
|
||||
a.stopCopyMode(s)
|
||||
return nil
|
||||
case "y", "enter", "ctrl+shift+c":
|
||||
if cm.anchor == nil {
|
||||
a.flash(i18n.T("Erst mit v (oder V für Zeilen) markieren"))
|
||||
return nil
|
||||
}
|
||||
cmd := a.copySel(s)
|
||||
a.stopCopyMode(s)
|
||||
return cmd
|
||||
case "v", "space":
|
||||
if cm.anchor != nil && !cm.lines {
|
||||
cm.anchor = nil
|
||||
} else {
|
||||
p := cm.cur
|
||||
cm.anchor, cm.lines = &p, false
|
||||
}
|
||||
case "V", "shift+v":
|
||||
if cm.anchor != nil && cm.lines {
|
||||
cm.anchor = nil
|
||||
} else {
|
||||
p := cm.cur
|
||||
cm.anchor, cm.lines = &p, true
|
||||
}
|
||||
case "left", "h":
|
||||
cm.cur.Col = max(0, cm.cur.Col-1)
|
||||
case "right", "l":
|
||||
cm.cur.Col = min(w-1, cm.cur.Col+1)
|
||||
case "up", "k":
|
||||
cm.cur.Line = max(0, cm.cur.Line-1)
|
||||
case "down", "j":
|
||||
cm.cur.Line = min(last, cm.cur.Line+1)
|
||||
case "w", "W":
|
||||
cm.cur = copyWord(t, cm.cur, 1, false)
|
||||
case "b", "B":
|
||||
cm.cur = copyWord(t, cm.cur, -1, false)
|
||||
case "e", "E":
|
||||
cm.cur = copyWord(t, cm.cur, 1, true)
|
||||
case "0", "home":
|
||||
cm.cur.Col = 0
|
||||
case "^":
|
||||
cm.cur.Col = 0
|
||||
for cm.cur.Col < w-1 && cellClass(t, cm.cur) == 0 {
|
||||
cm.cur.Col++
|
||||
}
|
||||
case "$", "end":
|
||||
cm.cur.Col = lineEnd(t, cm.cur.Line)
|
||||
case "g", "ctrl+home":
|
||||
cm.cur = termemu.Pos{}
|
||||
case "G", "shift+g", "ctrl+end":
|
||||
cm.cur = termemu.Pos{Line: last, Col: lineEnd(t, last)}
|
||||
case "pgup", "ctrl+u", "ctrl+b":
|
||||
cm.cur.Line = max(0, cm.cur.Line-max(1, rows/2))
|
||||
case "pgdown", "ctrl+d", "ctrl+f":
|
||||
cm.cur.Line = min(last, cm.cur.Line+max(1, rows/2))
|
||||
default:
|
||||
return nil // andere Tasten gehen nicht an den Server
|
||||
}
|
||||
a.copyShow(s)
|
||||
return nil
|
||||
}
|
||||
|
||||
// copyKeys: Tastenzeile im Markiermodus.
|
||||
func copyKeys(s *session) [][2]string {
|
||||
k := [][2]string{{"←↑↓→ hjkl", i18n.T("bewegen")}, {"w/b", i18n.T("Wort")}, {"0/$", i18n.T("Zeile")}, {"g/G", i18n.T("Anfang/Ende")}}
|
||||
if s.copy != nil && s.copy.anchor != nil {
|
||||
k = append(k, [2]string{"y/⏎", i18n.T("kopieren")})
|
||||
} else {
|
||||
k = append(k, [2]string{"v", i18n.T("markieren")}, [2]string{"V", i18n.T("Zeilen")})
|
||||
}
|
||||
return append(k, [2]string{"Esc", i18n.T("beenden")})
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
tea "charm.land/bubbletea/v2"
|
||||
|
||||
"github.com/db9979/sshtermy/internal/domain"
|
||||
)
|
||||
|
||||
func cmKey(k string) tea.KeyPressMsg {
|
||||
switch k {
|
||||
case "esc":
|
||||
return tea.KeyPressMsg{Code: tea.KeyEscape}
|
||||
case "enter":
|
||||
return tea.KeyPressMsg{Code: tea.KeyEnter}
|
||||
case "up":
|
||||
return tea.KeyPressMsg{Code: tea.KeyUp}
|
||||
case "alt+c":
|
||||
return tea.KeyPressMsg{Code: 'c', Mod: tea.ModAlt}
|
||||
}
|
||||
r := []rune(k)[0]
|
||||
return tea.KeyPressMsg{Code: r, Text: k}
|
||||
}
|
||||
|
||||
func TestCopyModeKeyboard(t *testing.T) {
|
||||
a := dangerApp(t)
|
||||
s, out := typedSession(domain.Connection{Alias: "web1"}, "", "")
|
||||
s.term.Write([]byte("eth0 10.0.0.5 up\r\neth1 192.168.1.7 down\r\n$ "))
|
||||
a.sessions, a.cur = []*session{s}, 0
|
||||
|
||||
a.updateTerminal(cmKey("alt+c"))
|
||||
if s.copy == nil {
|
||||
t.Fatal("Markiermodus nicht an")
|
||||
}
|
||||
// zwei Zeilen hoch, zum zweiten Wort, Wort markieren, kopieren
|
||||
a.updateTerminal(cmKey("k"))
|
||||
a.updateTerminal(cmKey("0"))
|
||||
a.updateTerminal(cmKey("w"))
|
||||
a.updateTerminal(cmKey("v"))
|
||||
a.updateTerminal(cmKey("e"))
|
||||
if got := s.term.Text(*s.sel); got != "192.168.1.7" {
|
||||
t.Fatalf("Markierung = %q", got)
|
||||
}
|
||||
a.updateTerminal(cmKey("y"))
|
||||
if s.copy != nil || s.sel != nil {
|
||||
t.Fatal("y beendet nicht")
|
||||
}
|
||||
if out.String() != "" {
|
||||
t.Fatalf("Tasten gingen an den Server: %q", out.String())
|
||||
}
|
||||
|
||||
// Zeilen markieren
|
||||
a.updateTerminal(cmKey("alt+c"))
|
||||
a.updateTerminal(cmKey("k"))
|
||||
a.updateTerminal(cmKey("k"))
|
||||
a.updateTerminal(cmKey("V"))
|
||||
a.updateTerminal(cmKey("j"))
|
||||
if got := s.term.Text(*s.sel); got != "eth0 10.0.0.5 up\neth1 192.168.1.7 down" {
|
||||
t.Fatalf("Zeilen = %q", got)
|
||||
}
|
||||
a.updateTerminal(cmKey("esc"))
|
||||
if s.copy != nil {
|
||||
t.Fatal("Esc beendet nicht")
|
||||
}
|
||||
}
|
||||
@@ -244,7 +244,7 @@ func (a *App) goalNotifyTick(s *session) {
|
||||
if a.lock != nil {
|
||||
body = i18n.T("Ziel-Modus wartet auf dich") // gesperrt: nichts verraten
|
||||
}
|
||||
a.sendDesktop("sshTermy · "+s.tabName(), body)
|
||||
a.sendDesktopFor(s, "sshTermy · "+s.tabName(), body)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ func TestGoalNotifyHiddenTab(t *testing.T) {
|
||||
a.cur = 1 // der Ziel-Tab ist verdeckt
|
||||
var sent []string
|
||||
old := desktopSend
|
||||
desktopSend = func(title, body string) { sent = append(sent, body) }
|
||||
desktopSend = func(title, body string, _ func()) { sent = append(sent, body) }
|
||||
defer func() { desktopSend = old }()
|
||||
|
||||
a.sessionMsg(stepMsg(s, agent.Step{Question: "Welcher Port?"}))
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
tea "charm.land/bubbletea/v2"
|
||||
|
||||
"github.com/db9979/sshtermy/internal/domain"
|
||||
"github.com/db9979/sshtermy/internal/i18n"
|
||||
)
|
||||
|
||||
// Eigene Felder in der Kopfzeile (Idee aus herdr): die Uhrzeit und/oder die
|
||||
// erste Zeile eines lokalen Befehls, z. B. VPN-Status, Ticketnummer, freier
|
||||
// Platz. Der Befehl läuft auf diesem Rechner alle N Sekunden (Standard 30)
|
||||
// mit 5 s Zeitlimit; er ist rein lokal und kommt nie per Sync von einem
|
||||
// anderen Rechner. Einstellen über die Palette („Kopfzeile“ suchen).
|
||||
|
||||
const (
|
||||
headerEveryDefault = 30
|
||||
headerEveryMin = 5
|
||||
headerTimeout = 5 * time.Second
|
||||
)
|
||||
|
||||
type headerOutMsg struct {
|
||||
cmd, out string
|
||||
}
|
||||
|
||||
func (a *App) headerCfg() domain.HeaderConfig { return a.st.Settings().Header }
|
||||
|
||||
// headerTick (aus onTick): Befehl fällig? Dann im Hintergrund starten.
|
||||
func (a *App) headerTick(now time.Time) tea.Cmd {
|
||||
h := a.headerCfg()
|
||||
cmd := strings.TrimSpace(h.Cmd)
|
||||
if cmd == "" || a.hdrBusy || a.scr == scrUnlock || a.lock != nil {
|
||||
return nil
|
||||
}
|
||||
every := h.Every
|
||||
if every <= 0 {
|
||||
every = headerEveryDefault
|
||||
}
|
||||
every = max(every, headerEveryMin)
|
||||
if now.Sub(a.hdrAt) < time.Duration(every)*time.Second && a.hdrFor == cmd {
|
||||
return nil
|
||||
}
|
||||
a.hdrBusy, a.hdrAt = true, now
|
||||
return func() tea.Msg { return headerOutMsg{cmd, runHeaderCmd(cmd)} }
|
||||
}
|
||||
|
||||
// runHeaderCmd: erste nicht leere Zeile der Ausgabe, ohne Steuerzeichen.
|
||||
func runHeaderCmd(cmd string) string {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), headerTimeout)
|
||||
defer cancel()
|
||||
var c *exec.Cmd
|
||||
if runtime.GOOS == "windows" {
|
||||
c = exec.CommandContext(ctx, "cmd", "/C", cmd)
|
||||
} else {
|
||||
c = exec.CommandContext(ctx, "sh", "-c", cmd)
|
||||
}
|
||||
hideConsole(c)
|
||||
out, err := c.Output()
|
||||
line := ""
|
||||
for _, l := range strings.Split(string(out), "\n") {
|
||||
if l = strings.TrimSpace(l); l != "" {
|
||||
line = l
|
||||
break
|
||||
}
|
||||
}
|
||||
line = strings.Map(func(r rune) rune {
|
||||
if r < 0x20 || r == 0x7f {
|
||||
return -1
|
||||
}
|
||||
return r
|
||||
}, line)
|
||||
if line == "" && err != nil {
|
||||
if ctx.Err() != nil {
|
||||
return "…"
|
||||
}
|
||||
return "×"
|
||||
}
|
||||
return trunc(line, 40)
|
||||
}
|
||||
|
||||
func (a *App) onHeaderOut(m headerOutMsg) {
|
||||
a.hdrBusy = false
|
||||
a.hdrOut, a.hdrFor = m.out, m.cmd
|
||||
}
|
||||
|
||||
// headerFields: die eigenen Felder als Abzeichen ("" = keine).
|
||||
func (a *App) headerFields() string {
|
||||
h := a.headerCfg()
|
||||
st := a.s
|
||||
var parts []string
|
||||
if strings.TrimSpace(h.Cmd) != "" && a.hdrOut != "" && a.hdrFor == strings.TrimSpace(h.Cmd) {
|
||||
parts = append(parts, st.Badge.Foreground(st.T.Text).Render(a.hdrOut))
|
||||
}
|
||||
if h.Clock {
|
||||
parts = append(parts, st.Badge.Foreground(st.T.Text).Render(time.Now().Format("15:04")))
|
||||
}
|
||||
return strings.Join(parts, "")
|
||||
}
|
||||
|
||||
func (a *App) toggleHeaderClock() tea.Cmd {
|
||||
_ = a.st.UpdateSettings(func(s *domain.Settings) { s.Header.Clock = !s.Header.Clock })
|
||||
return nil
|
||||
}
|
||||
|
||||
// askHeaderCmd: Befehl und Abstand einstellen („befehl“ oder „befehl @60“).
|
||||
func (a *App) askHeaderCmd() tea.Cmd {
|
||||
h := a.headerCfg()
|
||||
cur := h.Cmd
|
||||
if cur != "" && h.Every > 0 && h.Every != headerEveryDefault {
|
||||
cur += " @" + strconv.Itoa(h.Every)
|
||||
}
|
||||
m := inputModal(i18n.T("Kopfzeile: eigener Befehl"),
|
||||
i18n.T("Läuft auf diesem Rechner, die erste Zeile der Ausgabe steht rechts in der Kopfzeile. Alle 30 s; anders mit „@Sekunden“ am Ende. Leer = aus. Beispiele:")+
|
||||
"\n nmcli -t -f NAME connection show --active | head -1\n curl -s ifconfig.me @300\n powershell -c \"(Get-VpnConnection).ConnectionStatus\"",
|
||||
cur, func(v string) tea.Cmd {
|
||||
cmd, every := parseHeaderCmd(v)
|
||||
_ = a.st.UpdateSettings(func(s *domain.Settings) { s.Header.Cmd, s.Header.Every = cmd, every })
|
||||
a.hdrOut, a.hdrFor, a.hdrAt = "", "", time.Time{}
|
||||
if cmd == "" {
|
||||
a.flash(i18n.T("Kopfzeile: eigener Befehl aus"))
|
||||
} else {
|
||||
a.flashOK(i18n.T("Kopfzeile: eigener Befehl gespeichert"))
|
||||
}
|
||||
return nil
|
||||
})
|
||||
a.modal = m
|
||||
return m.in.Focus()
|
||||
}
|
||||
|
||||
// parseHeaderCmd: „befehl @60“ → befehl, 60.
|
||||
func parseHeaderCmd(v string) (string, int) {
|
||||
v = strings.TrimSpace(v)
|
||||
if i := strings.LastIndex(v, " @"); i > 0 {
|
||||
if n, err := strconv.Atoi(strings.TrimSpace(v[i+2:])); err == nil && n > 0 {
|
||||
return strings.TrimSpace(v[:i]), max(n, headerEveryMin)
|
||||
}
|
||||
}
|
||||
return v, 0
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/charmbracelet/x/ansi"
|
||||
|
||||
"github.com/db9979/sshtermy/internal/domain"
|
||||
)
|
||||
|
||||
func TestParseHeaderCmd(t *testing.T) {
|
||||
for in, want := range map[string]struct {
|
||||
cmd string
|
||||
every int
|
||||
}{
|
||||
"date": {"date", 0},
|
||||
"curl -s ifconfig.me @300": {"curl -s ifconfig.me", 300},
|
||||
"echo a@b": {"echo a@b", 0},
|
||||
"uptime @1": {"uptime", headerEveryMin},
|
||||
} {
|
||||
c, e := parseHeaderCmd(in)
|
||||
if c != want.cmd || e != want.every {
|
||||
t.Errorf("%q → %q %d", in, c, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestHeaderFieldsClockAndCmd(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("sh")
|
||||
}
|
||||
a := dangerApp(t)
|
||||
_ = a.st.UpdateSettings(func(s *domain.Settings) {
|
||||
s.Header = domain.HeaderConfig{Clock: true, Cmd: "printf '\\n VPN: an \\033[31m\\nrest'"}
|
||||
})
|
||||
cmd := a.headerTick(time.Now())
|
||||
if cmd == nil {
|
||||
t.Fatal("Befehl nicht gestartet")
|
||||
}
|
||||
if a.headerTick(time.Now()) != nil {
|
||||
t.Fatal("läuft doppelt")
|
||||
}
|
||||
a.coreMsg(cmd())
|
||||
got := ansi.Strip(a.headerFields())
|
||||
if !strings.Contains(got, "VPN: an [31m") || !strings.Contains(got, time.Now().Format("15:")) {
|
||||
t.Fatalf("Felder = %q", got)
|
||||
}
|
||||
if a.headerTick(time.Now()) != nil {
|
||||
t.Fatal("vor Ablauf erneut gestartet")
|
||||
}
|
||||
if a.headerTick(time.Now().Add(31*time.Second)) == nil {
|
||||
t.Fatal("nach 30 s nicht erneut")
|
||||
}
|
||||
}
|
||||
@@ -119,6 +119,8 @@ var helpSections = []helpSection{
|
||||
{"Mausrad / ⇧Bild↑ Bild↓", "im Verlauf zurückblättern (Esc: unten)"},
|
||||
{"⇧Pos1 / ⇧Ende", "Anfang / Ende des Verlaufs"},
|
||||
{"Strg+F", "im Verlauf suchen"},
|
||||
{"Alt+C", "per Tastatur markieren: v / V, y kopiert"},
|
||||
{"Alt+X", "Bildschirm + Verlauf leeren, Eingabe bleibt"},
|
||||
{"Alt+S", "in allen Tabs suchen"},
|
||||
{"Alt+O", "Befehle des Tabs: Ausgabe kopieren, an KI"},
|
||||
{"Alt+Bild↑ Bild↓", "von Befehl zu Befehl springen"},
|
||||
@@ -126,10 +128,12 @@ var helpSections = []helpSection{
|
||||
{"Alt+E", "Log-Blick: Auffälligkeiten"},
|
||||
{"F7 / F8", "Tab wechseln"},
|
||||
{"Alt+T", "alle Tabs (Liste)"},
|
||||
{"Alt+G", "zum Tab, der wartet (? / ◆) oder sich meldet"},
|
||||
{"Alt+N", "neuer Tab: Verbindung im Manager wählen"},
|
||||
{"Alt+L", "lokale Shell (neuer Tab)"},
|
||||
{"Alt+W", "Tab schließen"},
|
||||
{"F10", "zum Manager"},
|
||||
{"Strg+Q → a", "abkoppeln (Hintergrunddienst läuft weiter)"},
|
||||
{"Abbruch", "verbindet neu (⏎ / Esc)"},
|
||||
{"getrennt: e / k", "Verbindung bearbeiten / neuen Host-Key prüfen"},
|
||||
}},
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
//go:build !windows
|
||||
|
||||
package ui
|
||||
|
||||
import "os/exec"
|
||||
|
||||
func hideConsole(*exec.Cmd) {}
|
||||
@@ -0,0 +1,11 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// hideConsole: der Befehl der Kopfzeile soll kein Konsolenfenster aufblitzen lassen.
|
||||
func hideConsole(c *exec.Cmd) {
|
||||
c.SysProcAttr = &syscall.SysProcAttr{HideWindow: true, CreationFlags: 0x08000000} // CREATE_NO_WINDOW
|
||||
}
|
||||
@@ -213,7 +213,7 @@ func (a *App) alertTick(s *session) {
|
||||
if a.lock != nil {
|
||||
body = i18n.T("Farbregel hat angeschlagen") // gesperrt: keinen Inhalt verraten
|
||||
}
|
||||
a.sendDesktop("sshTermy · "+s.tabName(), body)
|
||||
a.sendDesktopFor(s, "sshTermy · "+s.tabName(), body)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
tea "charm.land/bubbletea/v2"
|
||||
|
||||
"github.com/db9979/sshtermy/internal/i18n"
|
||||
"github.com/db9979/sshtermy/internal/winstate"
|
||||
)
|
||||
|
||||
// Hintergrunddienst (Idee aus herdr): Ist er eingeschaltet, läuft sshTermy
|
||||
// als eigener Prozess ohne Terminal weiter, das Terminalfenster dockt nur an
|
||||
// (cmd/sshtermy keep.go, internal/detach hub.go). Strg+Q fragt dann:
|
||||
// a = abkoppeln (alles läuft weiter), j = wirklich beenden. Schließt man das
|
||||
// Terminalfenster einfach, ist das wie Abkoppeln. „sshtermy“ hängt sich
|
||||
// beim nächsten Start wieder an, auch aus einem anderen Terminal.
|
||||
|
||||
// SetKeeper: sshTermy läuft als Hintergrunddienst; detach entlässt das
|
||||
// angedockte Fenster mit einer Meldung.
|
||||
func (a *App) SetKeeper(detach func(msg string)) { a.keeperDetach = detach }
|
||||
|
||||
// Keeper: läuft sshTermy als Hintergrunddienst?
|
||||
func (a *App) Keeper() bool { return a.keeperDetach != nil }
|
||||
|
||||
// keepDetach: Fenster abkoppeln, Sitzungen laufen weiter.
|
||||
func (a *App) keepDetach() tea.Cmd {
|
||||
if a.keeperDetach == nil {
|
||||
return nil
|
||||
}
|
||||
a.saveRestoreAs(restoreSession) // falls der Rechner bis zum Wiederanhängen neu startet
|
||||
a.keeperDetach(i18n.F("sshTermy läuft im Hintergrund weiter (%s). Wieder anhängen: sshtermy",
|
||||
plural(len(a.liveSessions()), i18n.T("Sitzung"), i18n.T("Sitzungen"))))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) keepOn() bool { return a.st != nil && winstate.Load(a.st.Dir).Keep }
|
||||
|
||||
func (a *App) toggleKeep() tea.Cmd {
|
||||
s := winstate.Load(a.st.Dir)
|
||||
s.Keep = !s.Keep
|
||||
if err := winstate.Save(a.st.Dir, s); err != nil {
|
||||
a.flashErr(i18n.T("Einstellung nicht gespeichert: ") + err.Error())
|
||||
return nil
|
||||
}
|
||||
switch {
|
||||
case s.Keep && !a.Keeper():
|
||||
a.flashOK(i18n.T("Hintergrunddienst ab dem nächsten Start: Sitzungen laufen weiter, wenn du das Fenster schließt"))
|
||||
case !s.Keep && a.Keeper():
|
||||
a.flash(i18n.T("Hintergrunddienst aus ab dem nächsten Start (läuft gerade noch)"))
|
||||
case s.Keep:
|
||||
a.flash(i18n.T("Hintergrunddienst an"))
|
||||
default:
|
||||
a.flash(i18n.T("Hintergrunddienst aus"))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -82,6 +82,9 @@ const (
|
||||
actScrollDown action = "scroll_down"
|
||||
actScrollTop action = "scroll_top"
|
||||
actScrollBottom action = "scroll_bottom"
|
||||
actClearScreen action = "clear_screen"
|
||||
actNextNotice action = "next_notice"
|
||||
actCopyMode action = "copy_mode"
|
||||
)
|
||||
|
||||
// Schnellbefehle ⇧F1 … ⇧F8 (manche Terminals senden dafür F13 … F20).
|
||||
@@ -116,6 +119,7 @@ var actionDefs = []actionDef{
|
||||
{actNewTab, "Neuer Tab", "Terminal", []string{"alt+n"}},
|
||||
{actCloseTab, "Tab schließen", "Terminal", []string{"alt+w"}},
|
||||
{actTabList, "Alle Tabs (Liste)", "Terminal", []string{"alt+t"}},
|
||||
{actNextNotice, "Zum nächsten Tab, der wartet oder sich gemeldet hat", "Terminal", []string{"alt+g"}},
|
||||
{actQuickMenu, "Schnellbefehle (Liste)", "Terminal", []string{"f9"}},
|
||||
{actQuick[0], "Schnellbefehl 1", "Terminal", []string{"shift+f1", "f13"}},
|
||||
{actQuick[1], "Schnellbefehl 2", "Terminal", []string{"shift+f2", "f14"}},
|
||||
@@ -132,6 +136,8 @@ var actionDefs = []actionDef{
|
||||
{actScrollDown, "Im Verlauf eine Seite vorblättern", "Terminal", []string{"shift+pgdown"}},
|
||||
{actScrollTop, "Zum Anfang des Verlaufs", "Terminal", []string{"shift+home"}},
|
||||
{actScrollBottom, "Zurück nach unten (Ende des Verlaufs)", "Terminal", []string{"shift+end"}},
|
||||
{actCopyMode, "Markieren per Tastatur (v, y kopiert)", "Terminal", []string{"alt+c"}},
|
||||
{actClearScreen, "Bildschirm und Verlauf leeren (Eingabezeile bleibt)", "Terminal", []string{"alt+x"}},
|
||||
{actPrevCmd, "Zum vorigen Befehl springen", "Terminal", []string{"alt+pgup"}},
|
||||
{actNextCmd, "Zum nächsten Befehl springen", "Terminal", []string{"alt+pgdown"}},
|
||||
{actSplit, "Ansicht teilen (Aufteilung wählen)", "Terminal", []string{"ctrl+t"}},
|
||||
|
||||
@@ -618,7 +618,11 @@ func (a *App) announceWatch(al watchAlert, sid int) {
|
||||
s.notice = noticeLog
|
||||
}
|
||||
if (a.blurred || a.lock != nil) && a.desktopNotifyOn() {
|
||||
a.sendDesktop("sshTermy · "+al.Host, al.Title)
|
||||
if s := a.byID(sid); s != nil {
|
||||
a.sendDesktopFor(s, "sshTermy · "+al.Host, al.Title)
|
||||
} else {
|
||||
a.sendDesktop("sshTermy · "+al.Host, al.Title)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-5
@@ -147,6 +147,9 @@ func (a *App) onMCP(m mcpCallMsg) tea.Cmd {
|
||||
case "run_command":
|
||||
return a.mcpRun(m)
|
||||
default:
|
||||
if cmd, ok := a.mcpControl(m); ok {
|
||||
return cmd // open_tab, send_input, wait_tab (mcpcontrol.go)
|
||||
}
|
||||
return fail("unknown tool %s", m.tool)
|
||||
}
|
||||
return nil
|
||||
@@ -190,10 +193,11 @@ func (a *App) mcpConnections(q string) string {
|
||||
|
||||
func (a *App) mcpTabs() string {
|
||||
type tab struct {
|
||||
Tab int `json:"tab"`
|
||||
Alias string `json:"alias"`
|
||||
Host string `json:"host,omitempty"`
|
||||
State string `json:"state"`
|
||||
Tab int `json:"tab"`
|
||||
Alias string `json:"alias"`
|
||||
Host string `json:"host,omitempty"`
|
||||
State string `json:"state"`
|
||||
Status string `json:"status,omitempty"`
|
||||
}
|
||||
out := []tab{}
|
||||
for _, s := range a.sessions {
|
||||
@@ -208,7 +212,7 @@ func (a *App) mcpTabs() string {
|
||||
default:
|
||||
st = "not connected"
|
||||
}
|
||||
out = append(out, tab{s.id, s.conn.Alias, s.conn.Host, st})
|
||||
out = append(out, tab{s.id, s.conn.Alias, s.conn.Host, st, a.mcpStatus(s)})
|
||||
}
|
||||
b, _ := json.MarshalIndent(out, "", " ")
|
||||
return string(b)
|
||||
|
||||
@@ -0,0 +1,290 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
tea "charm.land/bubbletea/v2"
|
||||
|
||||
"github.com/db9979/sshtermy/internal/agent"
|
||||
"github.com/db9979/sshtermy/internal/audit"
|
||||
"github.com/db9979/sshtermy/internal/codeagent"
|
||||
"github.com/db9979/sshtermy/internal/i18n"
|
||||
"github.com/db9979/sshtermy/internal/safety"
|
||||
)
|
||||
|
||||
// MCP zum Steuern (Idee aus herdr): Ein KI-Client (Claude Code, Claude
|
||||
// Desktop …) kann über sshTermy sichtbare Tabs öffnen, hineintippen und
|
||||
// warten, bis etwas passiert. Damit bedient er mehrere Server oder einen
|
||||
// Coding-Agenten in einem anderen Tab, und du siehst alles mit.
|
||||
//
|
||||
// Regeln: nur bei „MCP-Zugriff: mit Rückfrage“. Am Shell-Prompt läuft ein
|
||||
// lesender Befehl (ohne sudo, ohne Geheimnisse) direkt; alles andere fragt
|
||||
// hier im Fenster (j, bei Gefahr j zweimal). Eingaben an laufende Programme
|
||||
// (Rückfragen, Coding-Agenten) fragen immer. Passwörter tippt der KI-Client
|
||||
// nie. Läuft im Tab ein Ziel oder der Agent-Modus, lehnt sshTermy ab.
|
||||
|
||||
const (
|
||||
mcpWaitDefault = 120 * time.Second
|
||||
mcpWaitMax = 600 * time.Second
|
||||
mcpQuiet = 2 * time.Second
|
||||
)
|
||||
|
||||
type mcpWaiter struct {
|
||||
sid int
|
||||
until string
|
||||
text string
|
||||
deadline time.Time
|
||||
since time.Time
|
||||
reply func(string, error)
|
||||
}
|
||||
|
||||
// mcpStatus: Zustand eines Tabs in einfachen Worten (Englisch, für die KI).
|
||||
func (a *App) mcpStatus(s *session) string {
|
||||
if s.term == nil || s.state != stConnected {
|
||||
return "not connected"
|
||||
}
|
||||
if w := s.agentW; w.name != "" {
|
||||
switch w.state {
|
||||
case codeagent.Working:
|
||||
return w.name + " working"
|
||||
case codeagent.Blocked:
|
||||
return w.name + " waiting for approval"
|
||||
}
|
||||
return w.name + " ready"
|
||||
}
|
||||
if kind, _ := waitKind(s); kind != "" {
|
||||
return map[string]string{"secret": "waiting for a password (the user types it)", string(agent.InputYesNo): "waiting for yes/no",
|
||||
string(agent.InputConfirm): "waiting for confirmation", string(agent.InputPager): "in a pager (space/q)", string(agent.InputAnyKey): "waiting for a key"}[kind]
|
||||
}
|
||||
if s.term.AtIdlePrompt() {
|
||||
return "at prompt"
|
||||
}
|
||||
return "running"
|
||||
}
|
||||
|
||||
// mcpControl: open_tab, send_input, wait_tab. false = kein Werkzeug von hier.
|
||||
func (a *App) mcpControl(m mcpCallMsg) (tea.Cmd, bool) {
|
||||
fail := func(f string, x ...any) (tea.Cmd, bool) { m.reply("", fmt.Errorf(f, x...)); return nil, true }
|
||||
switch m.tool {
|
||||
case "open_tab":
|
||||
if a.mcpLevel() != mcpAsk {
|
||||
return fail("opening tabs needs the sshTermy setting “MCP access: with confirmation”")
|
||||
}
|
||||
var p struct{ Connection string }
|
||||
_ = json.Unmarshal(m.args, &p)
|
||||
c, ok := a.mcpFind(strings.TrimSpace(p.Connection))
|
||||
switch {
|
||||
case !ok:
|
||||
return fail("no connection %q (see list_connections)", p.Connection)
|
||||
case !mcpAllowed(a, c):
|
||||
return fail("AI access is off for this connection (privacy tag)")
|
||||
}
|
||||
cur, scr := a.cur, a.scr
|
||||
cmd := a.connect(c)
|
||||
s := a.current()
|
||||
// nicht aus der Arbeit reißen: der neue Tab öffnet sich im Hintergrund
|
||||
if scr == scrTerminal && cur >= 0 && cur < len(a.sessions)-1 {
|
||||
a.focusSession(cur)
|
||||
}
|
||||
a.auditAdd(audit.EvAgent, auditConn(c), "MCP: Tab geöffnet")
|
||||
a.flash(i18n.F("MCP: Tab %s geöffnet", c.Alias))
|
||||
m.reply(fmt.Sprintf(`{"tab": %d, "alias": %q, "status": "connecting"}`, s.id, c.Alias), nil)
|
||||
return cmd, true
|
||||
case "send_input":
|
||||
return a.mcpSend(m), true
|
||||
case "wait_tab":
|
||||
return a.mcpWait(m), true
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func (a *App) mcpTab(id int) (*session, error) {
|
||||
s := a.byID(id)
|
||||
switch {
|
||||
case s == nil || s.term == nil:
|
||||
return nil, fmt.Errorf("no open tab %d (see list_tabs)", id)
|
||||
case !mcpAllowed(a, s.conn):
|
||||
return nil, errors.New("AI access is off for this connection (privacy tag)")
|
||||
}
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func (a *App) mcpSend(m mcpCallMsg) tea.Cmd {
|
||||
var p struct {
|
||||
Tab int
|
||||
Text string
|
||||
Enter *bool
|
||||
}
|
||||
_ = json.Unmarshal(m.args, &p)
|
||||
enter := p.Enter == nil || *p.Enter
|
||||
text := strings.TrimRight(p.Text, "\r\n")
|
||||
s, err := a.mcpTab(p.Tab)
|
||||
switch {
|
||||
case a.mcpLevel() != mcpAsk:
|
||||
err = errors.New("typing into tabs needs the sshTermy setting “MCP access: with confirmation”")
|
||||
case err != nil:
|
||||
case text == "" && !enter:
|
||||
err = errors.New("text is empty")
|
||||
case s.state != stConnected:
|
||||
err = errors.New("the tab is not connected (wait_tab until=prompt after open_tab)")
|
||||
case s.goal.active:
|
||||
err = errors.New("sshTermy's own goal/agent mode is running in this tab; try again later")
|
||||
case s.detached():
|
||||
err = errors.New("this tab runs in its own window")
|
||||
case agent.LooksLikeSecretPrompt(s.term.CursorLine()):
|
||||
err = errors.New("the tab asks for a password; only the user types it")
|
||||
case strings.ContainsAny(text, "\x00\x03\x04\x1b"):
|
||||
err = errors.New("control characters are not allowed; send plain text")
|
||||
}
|
||||
if err != nil {
|
||||
m.reply("", err)
|
||||
return nil
|
||||
}
|
||||
atPrompt := s.term.AtIdlePrompt() && s.agentW.name == ""
|
||||
kind := mcpKind(s.conn)
|
||||
oneLine := !strings.Contains(text, "\n")
|
||||
var dangers []safety.Finding
|
||||
if atPrompt {
|
||||
dangers = safety.Check(text, kind)
|
||||
}
|
||||
direct := atPrompt && oneLine && enter && safety.ReadOnly(text, kind) && len(dangers) == 0 &&
|
||||
safety.Sensitive(text) == "" && !safety.Elevated(text)
|
||||
do := func() tea.Cmd {
|
||||
a.auditAdd(audit.EvAgent, auditConn(s.conn), "MCP tippt: "+text)
|
||||
if atPrompt && enter && oneLine {
|
||||
a.beginCommand(s, text)
|
||||
a.sendLine(s, text)
|
||||
s.history = append(s.history, text)
|
||||
} else {
|
||||
s.term.SendText(strings.ReplaceAll(text, "\n", "\r"))
|
||||
if enter {
|
||||
s.term.SendText("\r")
|
||||
}
|
||||
}
|
||||
s.lastOutput = time.Now() // wait_tab wartet ab jetzt
|
||||
m.reply(fmt.Sprintf("typed into tab %d (%s); status was: %s", s.id, s.conn.Alias, a.mcpStatus(s)), nil)
|
||||
return nil
|
||||
}
|
||||
if direct {
|
||||
a.flash(i18n.F("MCP tippt in %s: %s", s.tabName(), trunc(text, 50)))
|
||||
return do()
|
||||
}
|
||||
if a.modal != nil {
|
||||
m.reply("", errors.New("sshTermy is busy with another dialog; try again in a moment"))
|
||||
return nil
|
||||
}
|
||||
where := i18n.T("am Prompt")
|
||||
if !atPrompt {
|
||||
where = i18n.T("in das laufende Programm") + " (" + a.mcpStatus(s) + ")"
|
||||
}
|
||||
body := i18n.F("Ein KI-Client möchte in %s tippen, %s:", s.tabName(), where) + "\n\n " + strings.ReplaceAll(trunc(text, 600), "\n", "\n ")
|
||||
if enter {
|
||||
body += " ⏎"
|
||||
}
|
||||
for _, d := range dangers {
|
||||
body += "\n▲ " + d.Reason
|
||||
}
|
||||
if len(dangers) > 0 {
|
||||
body += i18n.T("\n\nj zweimal = tippen · n = ablehnen")
|
||||
} else {
|
||||
body += i18n.T("\n\nj = tippen · n = ablehnen")
|
||||
}
|
||||
md := confirmModal(i18n.T("MCP: Eingabe erlauben?"), body, do)
|
||||
md.onCancel = func() tea.Cmd {
|
||||
a.auditAdd("mcp", auditConn(s.conn), "abgelehnt: "+text)
|
||||
m.reply("", errors.New("the user declined the input"))
|
||||
return nil
|
||||
}
|
||||
md.twice = len(dangers) > 0
|
||||
a.showAsync(md)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) mcpWait(m mcpCallMsg) tea.Cmd {
|
||||
var p struct {
|
||||
Tab int
|
||||
Until string
|
||||
Text string
|
||||
Timeout int `json:"timeout_seconds"`
|
||||
}
|
||||
_ = json.Unmarshal(m.args, &p)
|
||||
s, err := a.mcpTab(p.Tab)
|
||||
if err != nil {
|
||||
m.reply("", err)
|
||||
return nil
|
||||
}
|
||||
until := strings.ToLower(strings.TrimSpace(p.Until))
|
||||
if until == "" {
|
||||
until = "prompt"
|
||||
}
|
||||
switch until {
|
||||
case "prompt", "input", "quiet":
|
||||
case "text":
|
||||
if strings.TrimSpace(p.Text) == "" {
|
||||
m.reply("", errors.New("until=text needs text"))
|
||||
return nil
|
||||
}
|
||||
default:
|
||||
m.reply("", fmt.Errorf("until must be prompt, input, text or quiet, not %q", p.Until))
|
||||
return nil
|
||||
}
|
||||
d := mcpWaitDefault
|
||||
if p.Timeout > 0 {
|
||||
d = min(time.Duration(p.Timeout)*time.Second, mcpWaitMax)
|
||||
}
|
||||
now := time.Now()
|
||||
w := &mcpWaiter{sid: s.id, until: until, text: p.Text, deadline: now.Add(d), since: now, reply: m.reply}
|
||||
if !a.mcpWaitDone(w, now) {
|
||||
a.mcpWaits = append(a.mcpWaits, w)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// mcpWaitTick (aus onTick): erfüllte oder abgelaufene Wartende beantworten.
|
||||
func (a *App) mcpWaitTick(now time.Time) {
|
||||
keep := a.mcpWaits[:0]
|
||||
for _, w := range a.mcpWaits {
|
||||
if !a.mcpWaitDone(w, now) {
|
||||
keep = append(keep, w)
|
||||
}
|
||||
}
|
||||
a.mcpWaits = keep
|
||||
}
|
||||
|
||||
// mcpWaitDone: Bedingung erfüllt (oder Tab weg, Zeit um)? Dann antworten.
|
||||
func (a *App) mcpWaitDone(w *mcpWaiter, now time.Time) bool {
|
||||
s := a.byID(w.sid)
|
||||
if s == nil || s.term == nil {
|
||||
w.reply("", fmt.Errorf("tab %d was closed", w.sid))
|
||||
return true
|
||||
}
|
||||
quiet := now.Sub(s.lastOutput) >= mcpQuiet
|
||||
ok := false
|
||||
if s.state == stConnected {
|
||||
switch w.until {
|
||||
case "prompt":
|
||||
ok = quiet && s.term.AtIdlePrompt() && s.agentW.name == "" && now.Sub(w.since) >= 500*time.Millisecond
|
||||
case "input":
|
||||
st := s.agentW.state
|
||||
ok = (s.agentW.name != "" && (st == codeagent.Blocked || st == codeagent.Idle) && quiet) ||
|
||||
(s.agentW.name == "" && quiet && func() bool { k, _ := waitKind(s); return k != "" }())
|
||||
case "text":
|
||||
ok = strings.Contains(s.term.ScreenText(), w.text)
|
||||
case "quiet":
|
||||
ok = quiet
|
||||
}
|
||||
}
|
||||
if !ok && now.Before(w.deadline) {
|
||||
return false
|
||||
}
|
||||
head := "status: " + a.mcpStatus(s)
|
||||
if !ok {
|
||||
head = "timeout, " + head
|
||||
}
|
||||
w.reply(head+"\n\n"+agent.Redact(s.term.PlainLines(40)), nil)
|
||||
return true
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/db9979/sshtermy/internal/domain"
|
||||
)
|
||||
|
||||
func mcpCtlApp(t *testing.T, level string) (*App, *session, *syncBuf) {
|
||||
t.Helper()
|
||||
a := dangerApp(t)
|
||||
a.st.UpdateSettings(func(s *domain.Settings) { s.MCP = level })
|
||||
c, _ := a.st.UpsertConnection(domain.Connection{Alias: "web1", Host: "10.0.0.5", Username: "root"})
|
||||
s, out := typedSession(c, "root@web1:~# ", "")
|
||||
a.sessions, a.cur = []*session{s}, 0
|
||||
return a, s, out
|
||||
}
|
||||
|
||||
func TestMCPSendInputReadOnlyDirect(t *testing.T) {
|
||||
a, s, out := mcpCtlApp(t, mcpAsk)
|
||||
text, err, _ := mcpCall(a, "send_input", `{"tab":1,"text":"df -h"}`)
|
||||
if err != nil || a.modal != nil {
|
||||
t.Fatalf("lesender Befehl nicht direkt: %v %v", err, a.modal)
|
||||
}
|
||||
if !strings.Contains(text, "typed into tab 1") || !out.has("df -h\r") {
|
||||
t.Fatalf("nicht getippt: %q %q", text, out.String())
|
||||
}
|
||||
if s.run == nil || s.run.cmd != "df -h" {
|
||||
t.Fatal("Befehl nicht als Befehl erfasst")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMCPSendInputAsks(t *testing.T) {
|
||||
a, _, out := mcpCtlApp(t, mcpAsk)
|
||||
var got string
|
||||
var gotErr error
|
||||
a.onMCP(mcpCallMsg{tool: "send_input", args: []byte(`{"tab":1,"text":"rm -rf /var/www"}`), reply: func(t string, e error) { got, gotErr = t, e }})
|
||||
if a.modal == nil || !a.modal.twice {
|
||||
t.Fatalf("Gefahr ohne doppelte Rückfrage: %+v", a.modal)
|
||||
}
|
||||
if out.String() != "" {
|
||||
t.Fatal("vor der Freigabe getippt")
|
||||
}
|
||||
a.modal.onCancel()
|
||||
if gotErr == nil || got != "" {
|
||||
t.Fatal("Ablehnung nicht gemeldet")
|
||||
}
|
||||
|
||||
// nur lesen: Tippen abgelehnt
|
||||
b, _, _ := mcpCtlApp(t, mcpRead)
|
||||
if _, err, _ := mcpCall(b, "send_input", `{"tab":1,"text":"uptime"}`); err == nil {
|
||||
t.Fatal("„nur lesen“ darf nicht tippen")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMCPSendInputNoPasswords(t *testing.T) {
|
||||
a, s, _ := mcpCtlApp(t, mcpAsk)
|
||||
s.term.Write([]byte("\r\n[sudo] password for root: "))
|
||||
if _, err, _ := mcpCall(a, "send_input", `{"tab":1,"text":"hunter2"}`); err == nil || !strings.Contains(err.Error(), "password") {
|
||||
t.Fatalf("Passwort getippt: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMCPWaitTab(t *testing.T) {
|
||||
a, s, _ := mcpCtlApp(t, mcpAsk)
|
||||
var got string
|
||||
done := false
|
||||
s.lastOutput = time.Now()
|
||||
a.onMCP(mcpCallMsg{tool: "wait_tab", args: []byte(`{"tab":1,"until":"text","text":"fertig"}`), reply: func(t string, _ error) { got, done = t, true }})
|
||||
if done || len(a.mcpWaits) != 1 {
|
||||
t.Fatal("hat nicht gewartet")
|
||||
}
|
||||
s.term.Write([]byte("backup fertig\r\nroot@web1:~# "))
|
||||
a.mcpWaitTick(time.Now())
|
||||
if !done || !strings.Contains(got, "backup fertig") || len(a.mcpWaits) != 0 {
|
||||
t.Fatalf("Warten nicht beendet: %q", got)
|
||||
}
|
||||
|
||||
// Zeit um: Antwort mit timeout
|
||||
done = false
|
||||
a.onMCP(mcpCallMsg{tool: "wait_tab", args: []byte(`{"tab":1,"until":"text","text":"nie","timeout_seconds":1}`), reply: func(t string, _ error) { got, done = t, true }})
|
||||
a.mcpWaitTick(time.Now().Add(2 * time.Second))
|
||||
if !done || !strings.HasPrefix(got, "timeout") {
|
||||
t.Fatalf("kein timeout: %q", got)
|
||||
}
|
||||
|
||||
// am Prompt
|
||||
done = false
|
||||
s.lastOutput = time.Now().Add(-3 * time.Second)
|
||||
a.onMCP(mcpCallMsg{tool: "wait_tab", args: []byte(`{"tab":1}`), reply: func(t string, _ error) { got, done = t, true }})
|
||||
a.mcpWaitTick(time.Now().Add(time.Second))
|
||||
if !done || !strings.Contains(got, "status: at prompt") {
|
||||
t.Fatalf("Prompt nicht erkannt: %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMCPListTabsStatus(t *testing.T) {
|
||||
a, _, _ := mcpCtlApp(t, mcpRead)
|
||||
text, err, _ := mcpCall(a, "list_tabs", `{}`)
|
||||
if err != nil || !strings.Contains(text, `"status": "at prompt"`) {
|
||||
t.Fatalf("%v %s", err, text)
|
||||
}
|
||||
}
|
||||
@@ -74,9 +74,10 @@ type modal struct {
|
||||
anchored bool // am Mauszeiger statt mittig
|
||||
hints [][2]string // Tastenhinweise (setzt modalView aus modalKeys)
|
||||
|
||||
crash *crash.Report // nur Absturzbericht
|
||||
recap bool // Menü ist der Rückblick des Begleiters (companion.go)
|
||||
quit bool // Rückfrage beim Beenden (quitask.go)
|
||||
crash *crash.Report // nur Absturzbericht
|
||||
recap bool // Menü ist der Rückblick des Begleiters (companion.go)
|
||||
quit bool // Rückfrage beim Beenden (quitask.go)
|
||||
alt map[string]func() tea.Cmd // Bestätigung: weitere Tasten (z. B. a = abkoppeln)
|
||||
|
||||
guardUntil time.Time // von selbst aufgegangen: bis dahin keine Tasten (modalguard.go)
|
||||
twice bool // Bestätigen: Gefahr, j zweimal
|
||||
@@ -201,6 +202,10 @@ func (a *App) modalKey(k tea.KeyPressMsg) tea.Cmd {
|
||||
m.in, cmd = m.in.Update(k)
|
||||
return cmd
|
||||
case mConfirm:
|
||||
if f := m.alt[key]; f != nil {
|
||||
a.modal = nil
|
||||
return f()
|
||||
}
|
||||
switch yesNo(k) {
|
||||
case 1:
|
||||
if m.twice && !m.yesArmed {
|
||||
|
||||
@@ -585,6 +585,9 @@ func (a *App) modalKeys() [][2]string {
|
||||
keys = [][2]string{{yesKey(), i18n.T("vertrauen")}, {"n", i18n.T("abbrechen")}}
|
||||
case mConfirm:
|
||||
keys = [][2]string{{yesKey(), i18n.T("ja")}, {"n", i18n.T("nein")}}
|
||||
if a.modal.quit && a.modal.alt["a"] != nil {
|
||||
keys = [][2]string{{"a", i18n.T("abkoppeln")}, {yesKey(), i18n.T("beenden")}, {"n", i18n.T("abbrechen")}}
|
||||
}
|
||||
case mSecret:
|
||||
keys = [][2]string{{"⏎", i18n.T("senden")}, {"Esc", i18n.T("abbrechen")}}
|
||||
case mInput:
|
||||
|
||||
+66
-4
@@ -37,6 +37,8 @@ const (
|
||||
noticeBell
|
||||
noticeAlert // Farbregel mit „!“ hat angeschlagen (highlight.go)
|
||||
noticeLog // Logwache: neues Muster (logwatch.go)
|
||||
noticeWait // wartet auf eine Eingabe (waitmark.go)
|
||||
noticeAgent // KI-Coding-Agent wartet auf Freigabe (waitmark.go)
|
||||
)
|
||||
|
||||
func (a *App) notifyOn() bool { return !a.st.Settings().NoNotify }
|
||||
@@ -93,9 +95,65 @@ func (a *App) toggleOSC52() tea.Cmd {
|
||||
}
|
||||
|
||||
// sendDesktop: Benachrichtigung des Betriebssystems (in Tests abschaltbar).
|
||||
var desktopSend = notify.Send
|
||||
// click läuft, wenn man die Meldung anklickt (nur wo das System es meldet).
|
||||
var desktopSend = func(title, body string, click func()) {
|
||||
notify.SendClick(title, body, i18n.T("Öffnen"), click)
|
||||
}
|
||||
|
||||
func (a *App) sendDesktop(title, body string) { desktopSend(title, body) }
|
||||
func (a *App) sendDesktop(title, body string) { desktopSend(title, body, nil) }
|
||||
|
||||
// Klick auf eine Desktop-Meldung (oder zurück ins Fenster danach) führt in
|
||||
// den Tab, um den es ging. Linux meldet den Klick (notify-send --action);
|
||||
// Windows und macOS nicht: dort springt sshTermy beim nächsten Fokus hin,
|
||||
// wenn seit der Meldung keine Taste gedrückt wurde.
|
||||
|
||||
// jumpWindow: so lange nach der Meldung gilt der Sprung beim Zurückkehren.
|
||||
const jumpWindow = 30 * time.Minute
|
||||
|
||||
type notifyClickMsg struct{ sid int }
|
||||
|
||||
// sendDesktopFor: Meldung zu Tab s; merkt ihn für den Sprung.
|
||||
func (a *App) sendDesktopFor(s *session, title, body string) {
|
||||
a.jumpSID, a.jumpAt = s.id, time.Now()
|
||||
ev, sid := a.events, s.id
|
||||
desktopSend(title, body, func() {
|
||||
select {
|
||||
case ev <- notifyClickMsg{sid}:
|
||||
default:
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// jumpToNotified: in den gemeldeten Tab wechseln (Klick oder Fokus).
|
||||
func (a *App) jumpToNotified(sid int, why string) bool {
|
||||
s := a.byID(sid)
|
||||
if s == nil || a.lock != nil || a.scr == scrUnlock || a.modal != nil {
|
||||
return false
|
||||
}
|
||||
for i, x := range a.sessions {
|
||||
if x == s {
|
||||
if a.cur == i && a.scr == scrTerminal {
|
||||
return false
|
||||
}
|
||||
a.focusSession(i)
|
||||
a.scr = scrTerminal
|
||||
a.flash("→ " + s.tabName() + " · " + why)
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// onRefocus (tea.FocusMsg): seit der letzten Meldung nichts getippt? Dann
|
||||
// dorthin, wo die Meldung herkam.
|
||||
func (a *App) onRefocus() {
|
||||
sid, at := a.jumpSID, a.jumpAt
|
||||
a.jumpSID = 0
|
||||
if sid == 0 || time.Since(at) > jumpWindow || a.lastKey.After(at) {
|
||||
return
|
||||
}
|
||||
a.jumpToNotified(sid, i18n.T("von der Desktop-Meldung"))
|
||||
}
|
||||
|
||||
// sessionVisible: Ist der Tab gerade auf dem Bildschirm (aktiv oder in
|
||||
// einem Bereich der geteilten Ansicht)? Das Fenster selbst kann trotzdem im
|
||||
@@ -152,7 +210,7 @@ func (a *App) noticeDone(s *session, cmd string, dur time.Duration, failed, inte
|
||||
if a.lock != nil {
|
||||
body = i18n.T("Befehl ") + word // gesperrt: keinen Befehl verraten
|
||||
}
|
||||
a.sendDesktop("sshTermy · "+s.tabName(), body+" ("+fmtDur(dur)+")")
|
||||
a.sendDesktopFor(s, "sshTermy · "+s.tabName(), body+" ("+fmtDur(dur)+")")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,7 +228,7 @@ func (a *App) noticeBell(s *session) {
|
||||
s.bellAt = time.Now()
|
||||
a.flash("♦ " + s.tabName() + ": " + i18n.T("Glocke (BEL) im Terminal"))
|
||||
if (a.blurred || a.lock != nil) && a.desktopNotifyOn() {
|
||||
a.sendDesktop("sshTermy · "+s.tabName(), i18n.T("Glocke (BEL) im Terminal"))
|
||||
a.sendDesktopFor(s, "sshTermy · "+s.tabName(), i18n.T("Glocke (BEL) im Terminal"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,6 +245,10 @@ func (a *App) noticeGlyph(s *session) string {
|
||||
return a.s.Warn.Render("!")
|
||||
case noticeLog:
|
||||
return a.s.Danger.Render("▲")
|
||||
case noticeWait:
|
||||
return a.s.Warn.Bold(true).Render("?")
|
||||
case noticeAgent:
|
||||
return a.s.Warn.Bold(true).Render("◆")
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ func TestNoticeDoneInHiddenTab(t *testing.T) {
|
||||
a := dangerApp(t)
|
||||
var sent []string
|
||||
old := desktopSend
|
||||
desktopSend = func(title, body string) { sent = append(sent, title+"|"+body) }
|
||||
desktopSend = func(title, body string, _ func()) { sent = append(sent, title+"|"+body) }
|
||||
defer func() { desktopSend = old }()
|
||||
s1, _ := typedSession(domain.Connection{Alias: "web1"}, "$ ", "")
|
||||
s2, _ := typedSession(domain.Connection{Alias: "db1"}, "$ ", "")
|
||||
@@ -69,7 +69,7 @@ func TestNoticeDoneInHiddenTab(t *testing.T) {
|
||||
func TestBellAndClipboard(t *testing.T) {
|
||||
a := dangerApp(t)
|
||||
old := desktopSend
|
||||
desktopSend = func(string, string) {}
|
||||
desktopSend = func(string, string, func()) {}
|
||||
defer func() { desktopSend = old }()
|
||||
s1, _ := typedSession(domain.Connection{Alias: "a"}, "$ ", "")
|
||||
s2, _ := typedSession(domain.Connection{Alias: "b"}, "$ ", "")
|
||||
@@ -152,3 +152,45 @@ func TestCycleLockAfter(t *testing.T) {
|
||||
t.Fatal("fmtDur")
|
||||
}
|
||||
}
|
||||
|
||||
// Desktop-Meldung: Klick (Linux) oder Zurückkehren ins Fenster ohne
|
||||
// Tastendruck führt in den gemeldeten Tab.
|
||||
func TestDesktopNoticeJumpsToTab(t *testing.T) {
|
||||
a := dangerApp(t)
|
||||
var click func()
|
||||
old := desktopSend
|
||||
desktopSend = func(_, _ string, c func()) { click = c }
|
||||
defer func() { desktopSend = old }()
|
||||
s1, _ := typedSession(domain.Connection{Alias: "web1"}, "$ ", "")
|
||||
s2, _ := typedSession(domain.Connection{Alias: "db1"}, "$ ", "")
|
||||
s2.id = 2
|
||||
a.sessions, a.cur = []*session{s1, s2}, 0
|
||||
a.lastKey = time.Now().Add(-time.Minute)
|
||||
a.blurred = true
|
||||
|
||||
a.noticeDone(s2, "backup.sh", time.Minute, false, false)
|
||||
if click == nil {
|
||||
t.Fatal("keine Desktop-Meldung")
|
||||
}
|
||||
a.coreMsg(tea.FocusMsg{})
|
||||
if a.cur != 1 {
|
||||
t.Fatalf("nicht in den gemeldeten Tab gesprungen: %d", a.cur)
|
||||
}
|
||||
|
||||
// getippt nach der Meldung: kein Sprung beim Zurückkehren
|
||||
a.cur, a.blurred = 0, true
|
||||
a.noticeDone(s2, "backup.sh", time.Minute, false, false)
|
||||
a.lastKey = time.Now().Add(time.Second)
|
||||
a.coreMsg(tea.FocusMsg{})
|
||||
if a.cur != 0 {
|
||||
t.Fatal("trotz Tastendruck gesprungen")
|
||||
}
|
||||
|
||||
// Klick auf die Meldung (Linux) springt sofort
|
||||
click()
|
||||
m := <-a.events
|
||||
a.coreMsg(m)
|
||||
if a.cur != 1 {
|
||||
t.Fatal("Klick springt nicht")
|
||||
}
|
||||
}
|
||||
+21
-1
@@ -146,6 +146,10 @@ func (a *App) paletteItems() []palItem {
|
||||
add("tabs", palItem{icon: ic("split"), label: i18n.T("Arbeitsplätze …"), hint: a.keys.label(actWorkspace), keys: "workspace layout", run: func() tea.Cmd { return a.openWorkspaces() }})
|
||||
}
|
||||
add("", palItem{icon: ic("sshkey"), label: i18n.T("Jetzt sperren"), hint: i18n.T("Master-Passwort"), run: func() tea.Cmd { return a.lockNow() }})
|
||||
if a.Keeper() {
|
||||
add("", palItem{icon: ic("reconnect"), label: i18n.T("Abkoppeln: Fenster zu, Sitzungen laufen weiter"), hint: "sshtermy",
|
||||
keys: "abkoppeln detach hintergrund weiterlaufen schließen", run: func() tea.Cmd { return a.keepDetach() }})
|
||||
}
|
||||
actions = a.simpleHide(actions) // einfacher Modus (simple.go)
|
||||
for i := range actions {
|
||||
actions[i].group = pgAction
|
||||
@@ -534,7 +538,11 @@ func (a *App) palActsTerminal(add palAdd, s *session, inTerm bool) {
|
||||
}
|
||||
add("session",
|
||||
palItem{icon: ic("record"), label: recordLabel(s.recording()), pro: true, hint: "asciinema", run: func() tea.Cmd { return a.toggleRecording(s) }},
|
||||
palItem{icon: ic("export"), label: i18n.T("Terminal-Verlauf als Text exportieren"), hint: ".txt", run: func() tea.Cmd { return a.exportScrollback(s) }})
|
||||
palItem{icon: ic("export"), label: i18n.T("Terminal-Verlauf als Text exportieren"), hint: ".txt", run: func() tea.Cmd { return a.exportScrollback(s) }},
|
||||
palItem{icon: ic("copy"), label: i18n.T("Markieren per Tastatur (v, y kopiert)"), hint: a.keys.label(actCopyMode),
|
||||
keys: "copy kopieren markieren auswahl tastatur keyboard select vi tmux copy-mode", run: func() tea.Cmd { a.startCopyMode(s); return nil }},
|
||||
palItem{icon: ic("break"), label: i18n.T("Bildschirm und Verlauf leeren (Eingabezeile bleibt)"), hint: a.keys.label(actClearScreen),
|
||||
keys: "clear leeren löschen bildschirm screen verlauf scrollback cls reset", run: func() tea.Cmd { a.clearKeepLine(s); return nil }})
|
||||
if s.netDevice() {
|
||||
add("net", palItem{icon: ic("errors"), label: i18n.T("Syslog an sshTermy senden (Gerät einrichten) …"), hint: i18n.T("Logwache"),
|
||||
keys: "syslog logging remote logwache einrichten switch firewall", run: func() tea.Cmd { return a.askSyslogSetup(s) }})
|
||||
@@ -834,6 +842,18 @@ func (a *App) palMenuItems() []palItem {
|
||||
hide(palToggle(ic("news"), i18n.T("Meldung, wenn lange Befehle im Hintergrund fertig sind"), a.notifyOn(), "notify benachrichtigung glocke bell", func() tea.Cmd { return a.toggleNotify() })),
|
||||
hide(palToggle(ic("news"), i18n.T("Desktop-Benachrichtigung, wenn sshTermy im Hintergrund ist"), a.desktopNotifyOn(), "notify desktop benachrichtigung", func() tea.Cmd { return a.toggleDesktopNotify() })),
|
||||
palToggle(ic("explain"), i18n.T("Tastenzeile: Tasten erklären"), a.cheatOn(), "cheat fußzeile footer", func() tea.Cmd { return a.toggleCheat() }),
|
||||
// nur über die Suche („Tabs vom letzten Mal“), die Rückfrage beim Start nennt den Weg
|
||||
hide(palCycle(pgSetBehave, ic("reconnect"), i18n.T("Tabs vom letzten Mal beim Start öffnen"), restoreLabel(a.restoreMode()),
|
||||
"tabs wiederherstellen restore session sitzung weitermachen start letzte mal",
|
||||
func(dir int) tea.Cmd { return a.cycleRestore(dir) }).at(indexOf(restoreModes, a.restoreMode()), len(restoreModes))),
|
||||
// Hintergrunddienst (keeper.go): über die Suche, Hinweis beim Beenden
|
||||
hide(palToggle(ic("reconnect"), i18n.T("Hintergrunddienst: Sitzungen laufen weiter, wenn das Fenster zugeht"), a.keepOn(),
|
||||
"hintergrund dienst daemon keep detach abkoppeln weiterlaufen tmux server schließen", func() tea.Cmd { return a.toggleKeep() })),
|
||||
// Kopfzeile: nur über die Suche („Kopfzeile“, „Uhr“)
|
||||
hide(palToggle(ic("intro"), i18n.T("Kopfzeile: Uhrzeit zeigen"), a.headerCfg().Clock, "kopfzeile uhr uhrzeit clock zeit header statuszeile",
|
||||
func() tea.Cmd { return a.toggleHeaderClock() })),
|
||||
hide(palItem{group: pgSetBehave, menu: "settings", icon: ic("command"), label: i18n.T("Kopfzeile: eigener Befehl …"), hint: trunc(a.headerCfg().Cmd, 20),
|
||||
keys: "kopfzeile header statuszeile befehl command vpn feld field", run: func() tea.Cmd { return a.askHeaderCmd() }}),
|
||||
palCycle(pgSetBehave, ic("split"), i18n.T("Fenster beim Start"), winStartLabel(a.winStart()), "fenster vollbild fullscreen maximiert start window f11",
|
||||
func(dir int) tea.Cmd { return a.cycleWinStart(dir) }).at(winStartIdx(a.winStart()), 3),
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ func TestPaletteSettingsCompact(t *testing.T) {
|
||||
}
|
||||
sel("Meldung, wenn lange Befehle fertig sind")
|
||||
old := desktopSend
|
||||
desktopSend = func(string, string) {}
|
||||
desktopSend = func(string, string, func()) {}
|
||||
t.Cleanup(func() { desktopSend = old })
|
||||
a.paletteKey(tea.KeyPressMsg{Code: tea.KeyEnter})
|
||||
if a.notifyLevel() != 0 || !a.st.Settings().NoNotify {
|
||||
|
||||
@@ -40,7 +40,20 @@ func (a *App) askQuit() tea.Cmd {
|
||||
if len(live) == 1 {
|
||||
body = i18n.T("Diese Verbindung wird getrennt:") + "\n" + strings.Join(names, "\n")
|
||||
}
|
||||
if a.Keeper() {
|
||||
// Hintergrunddienst: abkoppeln ist der Normalfall (keeper.go)
|
||||
body = i18n.T("a = abkoppeln: Fenster zu, alle Sitzungen laufen im Hintergrund weiter (wieder anhängen: sshtermy)") +
|
||||
"\n\n" + body + "\n\n" + i18n.F("j = trotzdem beenden (%s noch einmal = beenden) · n = abbrechen", a.keys.label(actQuit))
|
||||
m := confirmModal(i18n.T("sshTermy abkoppeln oder beenden?"), body, func() tea.Cmd { return a.quit() })
|
||||
m.quit = true
|
||||
m.alt = map[string]func() tea.Cmd{"a": a.keepDetach}
|
||||
a.modal = m
|
||||
return nil
|
||||
}
|
||||
body += "\n\n" + i18n.F("Trotzdem beenden? (%s noch einmal = beenden)", a.keys.label(actQuit))
|
||||
if !a.keepOn() {
|
||||
body += "\n" + i18n.T("Tipp: Mit dem Hintergrunddienst laufen Sitzungen weiter (Befehlspalette, „Hintergrunddienst“)")
|
||||
}
|
||||
m := confirmModal(i18n.T("sshTermy beenden?"), body, func() tea.Cmd { return a.quit() })
|
||||
m.quit = true
|
||||
a.modal = m
|
||||
|
||||
+162
-13
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
tea "charm.land/bubbletea/v2"
|
||||
@@ -12,17 +13,37 @@ import (
|
||||
"github.com/db9979/sshtermy/internal/i18n"
|
||||
)
|
||||
|
||||
// Offene Sitzungen über einen Update-Neustart retten: Vor dem Beenden merkt
|
||||
// sich sshTermy, welche Tabs offen waren (nur Verweise, keine Geheimnisse),
|
||||
// und öffnet sie nach dem Entsperren der neuen Version wieder. tmux/screen
|
||||
// wird wie beim Auto-Reconnect wieder angehängt, laufende Arbeit bleibt so
|
||||
// auf dem Server erhalten.
|
||||
// Offene Sitzungen über einen Neustart retten: sshTermy merkt sich, welche
|
||||
// Tabs offen waren (nur Verweise, keine Geheimnisse), samt geteilter Ansicht,
|
||||
// und öffnet sie nach dem Entsperren wieder. tmux/screen wird wie beim
|
||||
// Auto-Reconnect wieder angehängt, laufende Arbeit bleibt so auf dem Server.
|
||||
//
|
||||
// Zwei Anlässe: der Update-Neustart (Grund "", ohne Rückfrage) und jeder
|
||||
// normale Start („Beim Start dort weitermachen“, Grund "session"). Für den
|
||||
// zweiten schreibt sshTermy die Datei beim Beenden und alle 30 Sekunden neu,
|
||||
// damit auch ein Absturz, Stromausfall oder das Herunterfahren des Rechners
|
||||
// nichts kostet. Settings.RestoreTabs: fragen (Standard), immer, nie.
|
||||
|
||||
const restoreName = "restore-tabs.json"
|
||||
|
||||
// restoreMaxAge: ältere Dateien (Absturz, Neustart abgebrochen) ignorieren.
|
||||
const restoreMaxAge = 30 * time.Minute
|
||||
|
||||
// restoreSessionMaxAge: „vom letzten Mal“ gilt zwei Wochen.
|
||||
const restoreSessionMaxAge = 14 * 24 * time.Hour
|
||||
|
||||
// restoreEvery: so oft wird die Liste der offenen Tabs gesichert.
|
||||
const restoreEvery = 30 * time.Second
|
||||
|
||||
const (
|
||||
restoreUpdate = "" // Update-Neustart
|
||||
restoreSession = "session" // Beenden, Absturz, Herunterfahren
|
||||
|
||||
restoreAsk = ""
|
||||
restoreAlways = "always"
|
||||
restoreNever = "never"
|
||||
)
|
||||
|
||||
type restoreTab struct {
|
||||
ConnID string `json:"conn_id,omitempty"`
|
||||
Adhoc *domain.Connection `json:"adhoc,omitempty"` // nicht gespeicherte Verbindung, ohne Geheimnisse
|
||||
@@ -32,6 +53,7 @@ type restoreTab struct {
|
||||
}
|
||||
|
||||
type restoreState struct {
|
||||
Reason string `json:"reason,omitempty"` // restoreUpdate oder restoreSession
|
||||
Saved time.Time `json:"saved"`
|
||||
Active int `json:"active"`
|
||||
Tabs []restoreTab `json:"tabs"`
|
||||
@@ -59,11 +81,14 @@ func adhocCopy(c domain.Connection) *domain.Connection {
|
||||
}
|
||||
|
||||
// saveRestore schreibt die offenen Tabs (vor dem Update-Neustart).
|
||||
func (a *App) saveRestore() {
|
||||
func (a *App) saveRestore() { a.saveRestoreAs(restoreUpdate) }
|
||||
|
||||
// saveRestoreAs: Grund restoreUpdate oder restoreSession.
|
||||
func (a *App) saveRestoreAs(reason string) {
|
||||
if a.st == nil || a.st.Dir == "" {
|
||||
return
|
||||
}
|
||||
st := restoreState{Saved: time.Now()}
|
||||
st := restoreState{Reason: reason, Saved: time.Now()}
|
||||
tabOf := map[int]int{} // Sitzungs-ID → Nummer in Tabs
|
||||
for i, s := range a.sessions {
|
||||
if s.state == stClosed {
|
||||
@@ -94,14 +119,77 @@ func (a *App) saveRestore() {
|
||||
}
|
||||
p := restorePath(a.st.Dir)
|
||||
if len(st.Tabs) == 0 {
|
||||
_ = os.Remove(p)
|
||||
if a.restoreSig != "-" {
|
||||
_ = os.Remove(p)
|
||||
a.restoreSig = "-"
|
||||
}
|
||||
return
|
||||
}
|
||||
// Nur schreiben, wenn sich an den Tabs etwas geändert hat (Zeit ausgenommen).
|
||||
sig, _ := json.Marshal(restoreState{Reason: st.Reason, Active: st.Active, Tabs: st.Tabs, Split: st.Split, FracX: st.FracX, FracY: st.FracY, Panes: st.Panes, Zoom: st.Zoom})
|
||||
if reason == restoreSession && string(sig) == a.restoreSig {
|
||||
return
|
||||
}
|
||||
b, err := json.Marshal(st)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
_ = os.WriteFile(p, b, 0o600)
|
||||
// erst vollständig schreiben, dann ersetzen: ein Stromausfall hinterlässt
|
||||
// nie eine halbe Datei
|
||||
if os.WriteFile(p+".tmp", b, 0o600) == nil && os.Rename(p+".tmp", p) == nil {
|
||||
a.restoreSig = string(sig)
|
||||
}
|
||||
}
|
||||
|
||||
// restoreMode: Einstellung „Tabs vom letzten Mal“ (fragen, immer, nie).
|
||||
func (a *App) restoreMode() string { return a.st.Settings().RestoreTabs }
|
||||
|
||||
// restoreTick (aus onTick): Tabs regelmäßig sichern, damit auch ein Absturz
|
||||
// oder das Herunterfahren nichts kostet. Erst nachdem die Tabs vom letzten
|
||||
// Mal angeboten wurden, sonst würde die leere Liste sie löschen.
|
||||
func (a *App) restoreTick(now time.Time) {
|
||||
if !a.restoreArmed || a.restart || a.restoreMode() == restoreNever || now.Sub(a.restoreAt) < restoreEvery {
|
||||
return
|
||||
}
|
||||
a.restoreAt = now
|
||||
a.saveRestoreAs(restoreSession)
|
||||
}
|
||||
|
||||
// restoreOnQuit (aus quit): beim normalen Beenden die Tabs merken.
|
||||
func (a *App) restoreOnQuit() {
|
||||
if !a.restoreArmed || a.restart {
|
||||
return // Update-Neustart hat seine Datei schon geschrieben
|
||||
}
|
||||
if a.restoreMode() == restoreNever {
|
||||
if a.st != nil && a.st.Dir != "" {
|
||||
_ = os.Remove(restorePath(a.st.Dir))
|
||||
}
|
||||
return
|
||||
}
|
||||
a.saveRestoreAs(restoreSession)
|
||||
}
|
||||
|
||||
func restoreLabel(m string) string {
|
||||
switch m {
|
||||
case restoreAlways:
|
||||
return i18n.T("immer")
|
||||
case restoreNever:
|
||||
return i18n.T("nie")
|
||||
}
|
||||
return i18n.T("fragen")
|
||||
}
|
||||
|
||||
var restoreModes = []string{restoreAsk, restoreAlways, restoreNever}
|
||||
|
||||
func (a *App) cycleRestore(dir int) tea.Cmd {
|
||||
m := restoreModes[cycleIndex(indexOf(restoreModes, a.restoreMode()), len(restoreModes), dir)]
|
||||
_ = a.st.UpdateSettings(func(s *domain.Settings) { s.RestoreTabs = m })
|
||||
if m == restoreNever && a.st.Dir != "" {
|
||||
_ = os.Remove(restorePath(a.st.Dir))
|
||||
a.restoreSig = ""
|
||||
}
|
||||
a.flash(i18n.T("Tabs vom letzten Mal beim Start: ") + restoreLabel(m))
|
||||
return nil
|
||||
}
|
||||
|
||||
// loadRestore liest und löscht die Datei (nur einmal wiederherstellen).
|
||||
@@ -116,18 +204,75 @@ func loadRestore(dir string, now time.Time) *restoreState {
|
||||
}
|
||||
_ = os.Remove(p)
|
||||
var st restoreState
|
||||
if json.Unmarshal(b, &st) != nil || len(st.Tabs) == 0 || now.Sub(st.Saved) > restoreMaxAge || st.Saved.After(now.Add(time.Minute)) {
|
||||
if json.Unmarshal(b, &st) != nil || len(st.Tabs) == 0 || st.Saved.After(now.Add(time.Minute)) {
|
||||
return nil
|
||||
}
|
||||
maxAge := restoreMaxAge
|
||||
if st.Reason == restoreSession {
|
||||
maxAge = restoreSessionMaxAge
|
||||
}
|
||||
if now.Sub(st.Saved) > maxAge {
|
||||
return nil
|
||||
}
|
||||
return &st
|
||||
}
|
||||
|
||||
// restoreTabs öffnet die vor dem Neustart offenen Tabs wieder (nach dem Entsperren).
|
||||
// restoreTabs öffnet die vor dem Neustart offenen Tabs wieder (nach dem
|
||||
// Entsperren). Nach einem normalen Beenden fragt sshTermy erst (Einstellung).
|
||||
func (a *App) restoreTabs() tea.Cmd {
|
||||
if a.restoreArmed {
|
||||
return nil // schon beim ersten Entsperren erledigt
|
||||
}
|
||||
a.restoreArmed = true
|
||||
st := loadRestore(a.st.Dir, time.Now())
|
||||
if st == nil {
|
||||
if st == nil || len(a.sessions) > 0 {
|
||||
return nil
|
||||
}
|
||||
if st.Reason != restoreSession {
|
||||
return a.openRestored(st)
|
||||
}
|
||||
switch a.restoreMode() {
|
||||
case restoreNever:
|
||||
return nil
|
||||
case restoreAlways:
|
||||
return a.openRestored(st)
|
||||
}
|
||||
var names []string
|
||||
for i, t := range st.Tabs {
|
||||
if i == 6 {
|
||||
names = append(names, i18n.F("… und %d weitere", len(st.Tabs)-i))
|
||||
break
|
||||
}
|
||||
names = append(names, " • "+a.restoreName(t))
|
||||
}
|
||||
body := strings.Join(names, "\n")
|
||||
if st.Split != "" {
|
||||
body += "\n\n" + i18n.T("mit geteilter Ansicht")
|
||||
}
|
||||
body += "\n\n" + i18n.T("j = öffnen · n = nicht jetzt\nImmer oder nie: Befehlspalette, „Tabs vom letzten Mal“ suchen")
|
||||
a.showAsync(confirmModal(i18n.T("Tabs vom letzten Mal wieder öffnen?"), body, func() tea.Cmd { return a.openRestored(st) }))
|
||||
return nil
|
||||
}
|
||||
|
||||
// restoreName: Anzeige eines gemerkten Tabs in der Rückfrage.
|
||||
func (a *App) restoreName(t restoreTab) string {
|
||||
if t.Title != "" {
|
||||
return t.Title
|
||||
}
|
||||
if c, ok := a.st.Connection(t.ConnID); ok && t.ConnID != "" {
|
||||
return c.Alias
|
||||
}
|
||||
if t.Adhoc != nil {
|
||||
if t.Adhoc.Alias != "" {
|
||||
return t.Adhoc.Alias
|
||||
}
|
||||
return t.Adhoc.Host
|
||||
}
|
||||
return "?"
|
||||
}
|
||||
|
||||
// openRestored: die gemerkten Tabs verbinden.
|
||||
func (a *App) openRestored(st *restoreState) tea.Cmd {
|
||||
var cmds []tea.Cmd
|
||||
first := len(a.sessions)
|
||||
made := make([]*session, len(st.Tabs)) // Tab-Nummer → neue Sitzung
|
||||
@@ -165,7 +310,11 @@ func (a *App) restoreTabs() tea.Cmd {
|
||||
a.restoreSplit(m, st, made)
|
||||
}
|
||||
a.scr = scrTerminal
|
||||
a.flashOK(plural(n, i18n.T("Sitzung"), i18n.T("Sitzungen")) + i18n.T(" von vor dem Update wieder geöffnet"))
|
||||
if st.Reason == restoreSession {
|
||||
a.flashOK(plural(n, i18n.T("Sitzung"), i18n.T("Sitzungen")) + i18n.T(" vom letzten Mal wieder geöffnet"))
|
||||
} else {
|
||||
a.flashOK(plural(n, i18n.T("Sitzung"), i18n.T("Sitzungen")) + i18n.T(" von vor dem Update wieder geöffnet"))
|
||||
}
|
||||
return tea.Batch(cmds...)
|
||||
}
|
||||
|
||||
|
||||
@@ -71,3 +71,84 @@ func TestRestoreIgnoresOldFile(t *testing.T) {
|
||||
t.Fatal("alte Datei benutzt")
|
||||
}
|
||||
}
|
||||
|
||||
// Beim Start dort weitermachen: normales Beenden merkt die Tabs, der nächste
|
||||
// Start fragt (Standard) und öffnet sie nach „j“.
|
||||
func TestRestoreSessionAsksOnNextStart(t *testing.T) {
|
||||
a := dangerApp(t)
|
||||
saved, err := a.st.UpsertConnection(domain.Connection{Alias: "web", Host: "127.0.0.1", Port: 1, Username: "admin", Auth: domain.AuthPassword, Password: "geheim"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
a.restoreArmed = true
|
||||
a.sessions = []*session{{id: 1, conn: saved, state: stConnected}}
|
||||
a.restoreOnQuit()
|
||||
|
||||
n, err := New(a.st)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
n.w, n.h = 120, 40
|
||||
if cmd := n.restoreTabs(); cmd != nil || len(n.sessions) != 0 {
|
||||
t.Fatal("ohne Rückfrage geöffnet")
|
||||
}
|
||||
if n.modal == nil || n.modal.kind != mConfirm || !strings.Contains(n.modal.body, "web") {
|
||||
t.Fatalf("keine Rückfrage: %+v", n.modal)
|
||||
}
|
||||
if cmd := n.modal.onYes(); cmd == nil || len(n.sessions) != 1 || n.sessions[0].conn.ID != saved.ID {
|
||||
t.Fatalf("nach j nicht geöffnet: %d Tabs", len(n.sessions))
|
||||
}
|
||||
}
|
||||
|
||||
func TestRestoreSessionModes(t *testing.T) {
|
||||
a := dangerApp(t)
|
||||
saved, _ := a.st.UpsertConnection(domain.Connection{Alias: "db", Host: "127.0.0.1", Port: 1, Username: "u"})
|
||||
a.restoreArmed = true
|
||||
a.sessions = []*session{{id: 1, conn: saved, state: stConnected}}
|
||||
|
||||
// „immer“: ohne Rückfrage
|
||||
_ = a.st.UpdateSettings(func(s *domain.Settings) { s.RestoreTabs = restoreAlways })
|
||||
a.restoreOnQuit()
|
||||
n, _ := New(a.st)
|
||||
n.w, n.h = 120, 40
|
||||
if n.restoreTabs() == nil || len(n.sessions) != 1 || n.modal != nil {
|
||||
t.Fatal("„immer“ hat nicht direkt geöffnet")
|
||||
}
|
||||
|
||||
// „nie“: keine Datei, nichts geöffnet
|
||||
_ = a.st.UpdateSettings(func(s *domain.Settings) { s.RestoreTabs = restoreNever })
|
||||
a.restoreSig = ""
|
||||
a.restoreOnQuit()
|
||||
if _, err := os.Stat(restorePath(a.st.Dir)); !os.IsNotExist(err) {
|
||||
t.Fatal("„nie“ schreibt trotzdem")
|
||||
}
|
||||
}
|
||||
|
||||
// Die Sicherung im Takt schreibt nur bei Änderungen und erst, wenn die Tabs
|
||||
// vom letzten Mal angeboten wurden (sonst löscht die leere Liste sie).
|
||||
func TestRestoreTickWaitsAndSkipsUnchanged(t *testing.T) {
|
||||
a := dangerApp(t)
|
||||
saved, _ := a.st.UpsertConnection(domain.Connection{Alias: "web", Host: "127.0.0.1", Port: 1, Username: "u"})
|
||||
p := restorePath(a.st.Dir)
|
||||
b, _ := json.Marshal(restoreState{Reason: restoreSession, Saved: time.Now(), Tabs: []restoreTab{{ConnID: saved.ID}}})
|
||||
_ = os.WriteFile(p, b, 0o600)
|
||||
|
||||
a.restoreTick(time.Now()) // noch nicht angeboten: Datei bleibt
|
||||
if _, err := os.Stat(p); err != nil {
|
||||
t.Fatal("Datei vor dem Angebot gelöscht")
|
||||
}
|
||||
a.restoreArmed = true
|
||||
a.sessions = []*session{{id: 1, conn: saved, state: stConnected}}
|
||||
a.restoreTick(time.Now())
|
||||
st1, _ := os.Stat(p)
|
||||
a.restoreAt = time.Time{}
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
a.restoreTick(time.Now())
|
||||
st2, _ := os.Stat(p)
|
||||
if !st1.ModTime().Equal(st2.ModTime()) {
|
||||
t.Fatal("unverändert und trotzdem neu geschrieben")
|
||||
}
|
||||
if loadRestore(a.st.Dir, time.Now().Add(7*24*time.Hour)) == nil {
|
||||
t.Fatal("eine Woche alte Sitzung nicht mehr angeboten")
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,9 @@ type session struct {
|
||||
flashCol color.Color // … in dieser Farbe
|
||||
latAt time.Time // Latenzverlauf für die Hover-Karte
|
||||
latHist []time.Duration
|
||||
bellAt time.Time // letzte gemeldete Glocke
|
||||
bellAt time.Time // letzte gemeldete Glocke
|
||||
wait waitState // wartet auf eine Eingabe (waitmark.go)
|
||||
agentW agentWatch // KI-Coding-Agent im Tab (waitmark.go)
|
||||
|
||||
editFS *sshx.RemoteFS // SFTP für Dateien im eigenen Editor (editor.go)
|
||||
alerts atomic.Pointer[alertScan] // Farbregeln mit „!“ (highlight.go)
|
||||
@@ -160,6 +162,7 @@ type session struct {
|
||||
sbSeen int // Scrollback-Länge beim letzten Bild
|
||||
sel *termemu.Sel // Markierung
|
||||
selecting bool // linke Taste gedrückt, Markierung wächst
|
||||
copy *copyMode // Markieren per Tastatur (copymode.go)
|
||||
fwdHeld bool // Taste gedrückt, Ereignisse gehen an den Server
|
||||
|
||||
// Bilder fürs äußere Terminal (pixels.go)
|
||||
|
||||
@@ -202,6 +202,10 @@ func (a *App) termHeader(s *session) string {
|
||||
func(tea.Mouse, bool) tea.Cmd { s.scroll, s.sel = 0, nil; return nil }) + " " + goal
|
||||
}
|
||||
hb := a.hostBadge(s)
|
||||
extra := a.headerFields() // Uhrzeit, eigener Befehl (headerfields.go)
|
||||
if s.copy != nil {
|
||||
goal = st.Badge.Foreground(st.T.Warn).Bold(true).Render(i18n.T("■ MARKIEREN")) + " " + goal
|
||||
}
|
||||
|
||||
// rechte Hälfte in Stufen: erst wer@wo, dann Leitung, Host, Tunnel und
|
||||
// zuletzt die Breite der KI-Anzeige opfern.
|
||||
@@ -216,6 +220,9 @@ func (a *App) termHeader(s *session) string {
|
||||
if stage < 2 && len(line) > 0 {
|
||||
parts = append(parts, strings.Join(line, ""))
|
||||
}
|
||||
if stage < 3 && extra != "" {
|
||||
parts = append(parts, extra)
|
||||
}
|
||||
if goal != "" {
|
||||
parts = append(parts, goal)
|
||||
}
|
||||
|
||||
@@ -265,6 +265,8 @@ func (a *App) tabListItems() []pickItem {
|
||||
hint = i18n.T("verbindet …")
|
||||
case s.state == stReconnect:
|
||||
hint = i18n.T("verbindet neu …")
|
||||
case a.tabStatus(s) != "":
|
||||
hint = a.tabStatus(s) // wartet / KI-Agent (waitmark.go)
|
||||
default:
|
||||
if n := len(s.history); n > 0 {
|
||||
hint = trunc(oneLine(s.history[n-1]), 22)
|
||||
@@ -276,6 +278,11 @@ func (a *App) tabListItems() []pickItem {
|
||||
hint += ago
|
||||
}
|
||||
}
|
||||
if g := a.noticeGlyph(s); g != "" {
|
||||
dot = g
|
||||
} else if g := a.agentGlyph(s); g != "" {
|
||||
dot = g
|
||||
}
|
||||
label := strconv.Itoa(i+1) + " " + dot + " " + s.tabName()
|
||||
if s.title != "" {
|
||||
label += " (" + s.conn.Alias + ")"
|
||||
|
||||
+25
-1
@@ -184,6 +184,18 @@ func (a *App) updateTerminal(msg tea.Msg) tea.Cmd {
|
||||
return cmd
|
||||
}
|
||||
}
|
||||
// Markieren per Tastatur (copymode.go): hat alle Tasten außer den F-Tasten
|
||||
if s.copy != nil && !s.panelFocus && !s.files.open {
|
||||
if m.Code >= tea.KeyF1 && m.Code <= tea.KeyF12 {
|
||||
a.stopCopyMode(s)
|
||||
} else {
|
||||
return a.copyKey(s, m)
|
||||
}
|
||||
}
|
||||
if a.keys.is(actCopyMode, key) && !s.panelFocus && !s.files.open && s.term != nil {
|
||||
a.startCopyMode(s)
|
||||
return nil
|
||||
}
|
||||
// Tippen beendet Markierung und Rückblick (Esc nur das)
|
||||
if s.scroll > 0 && key == "esc" && !s.panelFocus && !s.files.open {
|
||||
s.scroll, s.sel = 0, nil
|
||||
@@ -223,7 +235,9 @@ func (a *App) updateTerminal(msg tea.Msg) tea.Cmd {
|
||||
return a.vgKey(m) // Leiste „Vorgang“ hat die Tasten (vorgang_view.go)
|
||||
}
|
||||
// globale Tasten der Terminal-Ansicht (frei belegbar, siehe keymap.go)
|
||||
switch a.keys.which(key, actHelp, actAbout, actManager, actPrevTab, actNextTab, actFiles, actCheat, actQuickMenu, actNewTab, actCloseTab, actTabList, actSearchAll) {
|
||||
switch a.keys.which(key, actHelp, actAbout, actManager, actPrevTab, actNextTab, actFiles, actCheat, actQuickMenu, actNewTab, actCloseTab, actTabList, actSearchAll, actNextNotice) {
|
||||
case actNextNotice:
|
||||
return a.jumpNextNotice()
|
||||
case actSearchAll:
|
||||
return a.openSearchAll()
|
||||
case actNewTab:
|
||||
@@ -322,6 +336,10 @@ func (a *App) updateTerminal(msg tea.Msg) tea.Cmd {
|
||||
if a.keys.is(actSearch, key) {
|
||||
return a.openSearch(s)
|
||||
}
|
||||
if a.keys.is(actClearScreen, key) {
|
||||
a.clearKeepLine(s)
|
||||
return nil
|
||||
}
|
||||
if s.state == stReconnect {
|
||||
switch key {
|
||||
case "enter", "r":
|
||||
@@ -735,6 +753,9 @@ func (a *App) terminalKeys(s *session) [][2]string {
|
||||
if s.panelFocus {
|
||||
return a.panelKeys(s)
|
||||
}
|
||||
if s.copy != nil {
|
||||
return copyKeys(s)
|
||||
}
|
||||
if s.search.open {
|
||||
if s.search.list {
|
||||
return [][2]string{{"↑/↓", i18n.T("wählen")}, {"⏎", i18n.T("im Verlauf zeigen")}, {"Tab", i18n.T("Liste/Verlauf")}, {"Strg+E", i18n.T("Filter aus")}, {"Esc", i18n.T("Suche schließen")}}
|
||||
@@ -884,6 +905,9 @@ func (a *App) tabStrip(room int) string {
|
||||
if x.detached() {
|
||||
dot = st.AI.Render("↑") // läuft in eigenem Fenster
|
||||
}
|
||||
if g := a.agentGlyph(x); g != "" {
|
||||
dot = g // KI-Coding-Agent arbeitet / wartet (waitmark.go)
|
||||
}
|
||||
if g := a.noticeGlyph(x); g != "" {
|
||||
dot = g // Befehl fertig / Glocke, solange der Tab verdeckt war
|
||||
}
|
||||
|
||||
+1
-1
@@ -24,9 +24,9 @@
|
||||
Neuer Tab Alt+N
|
||||
Tab schließen Alt+W
|
||||
Alle Tabs (Liste) Alt+T
|
||||
Zum nächsten Tab, der wartet oder sich gemeldet hat Alt+G
|
||||
Schnellbefehle (Liste) F9
|
||||
Schnellbefehl 1 Shift+F1 / F13
|
||||
Schnellbefehl 2 Shift+F2 / F14
|
||||
|
||||
Alt+⏎ ist gesperrt: Windows Terminal schaltet damit auf Vollbild.
|
||||
Schriftgröße: Strg + Plus/Minus im Terminalfenster (macOS: ⌘ + / −)
|
||||
|
||||
+1
-1
@@ -24,9 +24,9 @@
|
||||
New tab Alt+N
|
||||
close tab Alt+W
|
||||
All tabs (list) Alt+T
|
||||
Go to the next tab that waits or has a notice Alt+G
|
||||
Quick commands (list) F9
|
||||
Quick command 1 Shift+F1 / F13
|
||||
Quick command 2 Shift+F2 / F14
|
||||
|
||||
Alt+⏎ is blocked: Windows Terminal uses it for full screen.
|
||||
Font size: Ctrl + plus/minus in the terminal window (macOS: ⌘ + / −)
|
||||
|
||||
+1
-1
@@ -24,9 +24,9 @@
|
||||
Neuer Tab Alt+N
|
||||
Tab schließen Alt+W
|
||||
Alle Tabs (Liste) Alt+T
|
||||
Zum nächsten Tab, der wartet oder sich gemeldet hat Alt+G
|
||||
Schnellbefehle (Liste) F9
|
||||
Schnellbefehl 1 Shift+F1 / F13
|
||||
Schnellbefehl 2 Shift+F2 / F14
|
||||
|
||||
Alt+⏎ ist gesperrt: Windows Terminal schaltet damit auf Vollbild.
|
||||
Schriftgröße: Strg + Plus/Minus im Terminalfenster (macOS: ⌘ + / −)
|
||||
|
||||
+1
-1
@@ -24,9 +24,9 @@
|
||||
New tab Alt+N
|
||||
close tab Alt+W
|
||||
All tabs (list) Alt+T
|
||||
Go to the next tab that waits or has a notice Alt+G
|
||||
Quick commands (list) F9
|
||||
Quick command 1 Shift+F1 / F13
|
||||
Quick command 2 Shift+F2 / F14
|
||||
|
||||
Alt+⏎ is blocked: Windows Terminal uses it for full screen.
|
||||
Font size: Ctrl + plus/minus in the terminal window (macOS: ⌘ + / −)
|
||||
|
||||
+23
-23
@@ -3,29 +3,29 @@
|
||||
┃│ │┃
|
||||
┃│ Terminal KI Manager Logs Überall tippen filtert │┃
|
||||
┃│ │┃
|
||||
┃│ ▸ Terminal hier ▣ Host-Übersicht F6 │┃
|
||||
┃│ F2 Ziel-Modus (Agent) r / ⏎ abfragen │┃
|
||||
┃│ F3 KI fragen b Switch-Config sichern │┃
|
||||
┃│ F4 Tunnel c Container (Docker, Podman, k8s) │┃
|
||||
┃│ F5 Dateien (SFTP) l Log-Blick │┃
|
||||
┃│ F6 Host-Übersicht s Sicherheitscheck · Switch: Firmware │┃
|
||||
┃│ F7 / F8 Tab wechseln h / a Härtungs-Check / Schlüssel-Inventar │┃
|
||||
┃│ F9 Schnellbefehle (Liste) i Inventar & Änderungen (e = CSV) │┃
|
||||
┃│ F9 → a häufigen Befehl übernehmen w Verlauf 24 h / 7 Tage │┃
|
||||
┃│ F10 zum Manager ↑ ↓ Sicherung wählen │┃
|
||||
┃│ ⇧F1…F8 Schnellbefehl ausführen d Diff zur Vorversion │┃
|
||||
┃│ ⇧F10 Tab in eigenes Fenster (Sitzung bleibt v Sicherung ansehen │┃
|
||||
┃│ offen) g Grenzwerte für Warnungen │┃
|
||||
┃│ Tab / → Ghost-Text übernehmen t Graphen: 5 min / 1 h │┃
|
||||
┃│ Alt+1…4 Folgebefehl einfügen z Graphen groß │┃
|
||||
┃│ Alt+0 Fehler: Warum? & Fix x Abfrage abbrechen │┃
|
||||
┃│ Alt+K KI-Begleiter: Aus/Leise/Gesprächig/Coach │┃
|
||||
┃│ Alt+J Begleiter-Leiste ▤ Dateien F5 │┃
|
||||
┃│ Alt+V Vorgang über mehrere Fenster (KI sieht F2 umbenennen │┃
|
||||
┃│ alle) Tab Seite wechseln │┃
|
||||
┃│ Strg+T Aufteilung wählen (1…7) ⏎ / 2×Klick öffnen, Datei ansehen │┃
|
||||
┃│ Strg+Pfeil Bereich wechseln (geteilt) ← / Bksp eine Ebene hoch │┃
|
||||
┃│ Alt+⇧Pfeil Trennlinie verschieben (Maus: ziehen) c / F6 kopieren (hoch/runter) │┃
|
||||
┃│ ▸ Terminal hier ↔ Tunnel F4 │┃
|
||||
┃│ F2 Ziel-Modus (Agent) ⏎ / Klick starten / stoppen │┃
|
||||
┃│ F3 KI fragen a mit Verbindung starten │┃
|
||||
┃│ F4 Tunnel o im Browser öffnen │┃
|
||||
┃│ F5 Dateien (SFTP) n neuer Tunnel │┃
|
||||
┃│ F6 Host-Übersicht e bearbeiten │┃
|
||||
┃│ F7 / F8 Tab wechseln d löschen │┃
|
||||
┃│ F9 Schnellbefehle (Liste) │┃
|
||||
┃│ F9 → a häufigen Befehl übernehmen ▣ Host-Übersicht F6 │┃
|
||||
┃│ F10 zum Manager r / ⏎ abfragen │┃
|
||||
┃│ ⇧F1…F8 Schnellbefehl ausführen b Switch-Config sichern │┃
|
||||
┃│ ⇧F10 Tab in eigenes Fenster (Sitzung bleibt c Container (Docker, Podman, k8s) │┃
|
||||
┃│ offen) l Log-Blick │┃
|
||||
┃│ Tab / → Ghost-Text übernehmen s Sicherheitscheck · Switch: Firmware │┃
|
||||
┃│ Alt+1…4 Folgebefehl einfügen h / a Härtungs-Check / Schlüssel-Inventar │┃
|
||||
┃│ Alt+0 Fehler: Warum? & Fix i Inventar & Änderungen (e = CSV) │┃
|
||||
┃│ Alt+K KI-Begleiter: Aus/Leise/Gesprächig/Coach w Verlauf 24 h / 7 Tage │┃
|
||||
┃│ Alt+J Begleiter-Leiste ↑ ↓ Sicherung wählen │┃
|
||||
┃│ Alt+V Vorgang über mehrere Fenster (KI sieht d Diff zur Vorversion │┃
|
||||
┃│ alle) v Sicherung ansehen │┃
|
||||
┃│ Strg+T Aufteilung wählen (1…7) g Grenzwerte für Warnungen │┃
|
||||
┃│ Strg+Pfeil Bereich wechseln (geteilt) t Graphen: 5 min / 1 h │┃
|
||||
┃│ Alt+⇧Pfeil Trennlinie verschieben (Maus: ziehen) z Graphen groß │┃
|
||||
┃│ │┃
|
||||
┃│ ROT Gefährliche Befehle brauchen zweimal ⏎ bzw. Alt+N. KI-Vorschläge werden nur eingefügt, nie ausgeführt. │┃
|
||||
┃│ Esc führt aus jedem Panel zurück ins Terminal. │┃
|
||||
|
||||
+23
-23
@@ -3,29 +3,29 @@
|
||||
┃│ │┃
|
||||
┃│ Terminal AI Manager Logs Everywhere type to filter │┃
|
||||
┃│ │┃
|
||||
┃│ ▸ Terminal here ▣ Host overview F6 │┃
|
||||
┃│ F2 Goal mode (agent) r / ⏎ query │┃
|
||||
┃│ F3 Ask AI b back up switch config │┃
|
||||
┃│ F4 Tunnel c Containers (Docker, Podman, k8s) │┃
|
||||
┃│ F5 Files (SFTP) l Log view │┃
|
||||
┃│ F6 Host overview s security check · switch: firmware │┃
|
||||
┃│ F7 / F8 switch tab h / a hardening check / key inventory │┃
|
||||
┃│ F9 Quick commands (list) i Inventory & changes (e = CSV) │┃
|
||||
┃│ F9 → a adopt a frequent command w History 24 h / 7 days │┃
|
||||
┃│ F10 to manager ↑ ↓ choose backup │┃
|
||||
┃│ ⇧F1…F8 run quick command d diff to previous │┃
|
||||
┃│ ⇧F10 Tab to own window (session stays open) v view backup │┃
|
||||
┃│ Tab / → accept ghost text g Warning limits │┃
|
||||
┃│ Alt+1…4 insert follow-up command t graphs: 5 min / 1 h │┃
|
||||
┃│ Alt+0 Error: Why? & Fix z graphs large │┃
|
||||
┃│ Alt+K AI companion: off/quiet/chatty/coach x cancel query │┃
|
||||
┃│ Alt+J Companion sidebar │┃
|
||||
┃│ Alt+V Task across several windows (AI sees all) ▤ Files F5 │┃
|
||||
┃│ Ctrl+T choose layout (1…7) F2 rename │┃
|
||||
┃│ Ctrl+arrow switch pane (split) Tab switch side │┃
|
||||
┃│ Alt+⇧arrow move divider (mouse: drag) ⏎ / 2×click open, view file │┃
|
||||
┃│ Alt+Z Zoom pane / back ← / Bksp one level up │┃
|
||||
┃│ Drag title swap panes c / F6 copy (up/down) │┃
|
||||
┃│ ▸ Terminal here ↔ Tunnel F4 │┃
|
||||
┃│ F2 Goal mode (agent) ⏎ / click start / stop │┃
|
||||
┃│ F3 Ask AI a start with connection │┃
|
||||
┃│ F4 Tunnel o open in browser │┃
|
||||
┃│ F5 Files (SFTP) n new tunnel │┃
|
||||
┃│ F6 Host overview e edit │┃
|
||||
┃│ F7 / F8 switch tab d delete │┃
|
||||
┃│ F9 Quick commands (list) │┃
|
||||
┃│ F9 → a adopt a frequent command ▣ Host overview F6 │┃
|
||||
┃│ F10 to manager r / ⏎ query │┃
|
||||
┃│ ⇧F1…F8 run quick command b back up switch config │┃
|
||||
┃│ ⇧F10 Tab to own window (session stays open) c Containers (Docker, Podman, k8s) │┃
|
||||
┃│ Tab / → accept ghost text l Log view │┃
|
||||
┃│ Alt+1…4 insert follow-up command s security check · switch: firmware │┃
|
||||
┃│ Alt+0 Error: Why? & Fix h / a hardening check / key inventory │┃
|
||||
┃│ Alt+K AI companion: off/quiet/chatty/coach i Inventory & changes (e = CSV) │┃
|
||||
┃│ Alt+J Companion sidebar w History 24 h / 7 days │┃
|
||||
┃│ Alt+V Task across several windows (AI sees all) ↑ ↓ choose backup │┃
|
||||
┃│ Ctrl+T choose layout (1…7) d diff to previous │┃
|
||||
┃│ Ctrl+arrow switch pane (split) v view backup │┃
|
||||
┃│ Alt+⇧arrow move divider (mouse: drag) g Warning limits │┃
|
||||
┃│ Alt+Z Zoom pane / back t graphs: 5 min / 1 h │┃
|
||||
┃│ Drag title swap panes z graphs large │┃
|
||||
┃│ │┃
|
||||
┃│ RED Dangerous commands need ⏎ twice or Alt+N. AI suggestions are only inserted, never run. │┃
|
||||
┃│ Esc leads back to the terminal from every panel. │┃
|
||||
|
||||
@@ -0,0 +1,270 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
tea "charm.land/bubbletea/v2"
|
||||
|
||||
"github.com/db9979/sshtermy/internal/agent"
|
||||
"github.com/db9979/sshtermy/internal/codeagent"
|
||||
"github.com/db9979/sshtermy/internal/i18n"
|
||||
)
|
||||
|
||||
// „Wartet auf dich“ (Idee aus herdr): Ein verdeckter Tab, der an einer
|
||||
// Eingabe hängt (Passwort/sudo, [Y/n], „Press any key“, --More--, less),
|
||||
// bekommt eine gelbe Marke „?“ und meldet sich einmal (Einblendung, im
|
||||
// Hintergrund auch als Desktop-Meldung). Alt+G springt zum nächsten Tab mit
|
||||
// Marke, wartende zuerst. Was du gesehen hast, bevor du den Tab verlassen
|
||||
// hast (z. B. ein offenes less), meldet sich nicht.
|
||||
//
|
||||
// KI-Coding-Agenten (codeagent): Läuft im Tab Claude Code, Codex, Gemini CLI
|
||||
// & Co., zeigt der Tab, ob der Agent arbeitet (◆ violett) oder auf eine
|
||||
// Freigabe wartet (◆ gelb). Wartet er im verdeckten Tab, kommt eine Meldung;
|
||||
// ist er nach mindestens 10 s Arbeit fertig, ebenso.
|
||||
|
||||
// waitQuiet: so lange ohne Ausgabe, bis eine Rückfrage als „wartet“ gilt.
|
||||
const waitQuiet = 1500 * time.Millisecond
|
||||
|
||||
// agentGone: so lange ohne Kennzeichen am Bildschirm, bis der Agent als
|
||||
// beendet gilt.
|
||||
const agentGone = 5 * time.Second
|
||||
|
||||
type waitState struct {
|
||||
kind string // agent.InputKind oder "secret"; "" = wartet nicht
|
||||
line string // Zeile mit der Rückfrage
|
||||
ack string // diese Rückfrage hast du schon gesehen
|
||||
}
|
||||
|
||||
type agentWatch struct {
|
||||
name string // erkannter Agent, "" = keiner
|
||||
state codeagent.State
|
||||
since time.Time // Beginn des Zustands
|
||||
lastSeen time.Time // zuletzt am Bildschirm erkannt
|
||||
gen uint64 // Terminal-Stand beim letzten Blick
|
||||
}
|
||||
|
||||
// waitTick (aus onTick, je Tab).
|
||||
func (a *App) waitTick(s *session, now time.Time) {
|
||||
if s.term == nil || s.state != stConnected || s.detached() {
|
||||
s.wait, s.agentW = waitState{}, agentWatch{}
|
||||
return
|
||||
}
|
||||
a.codeAgentTick(s, now)
|
||||
if s.agentW.name != "" || s.goal.active {
|
||||
s.wait.kind = "" // Agent oder Ziel-Modus melden sich selbst
|
||||
if s.notice == noticeWait {
|
||||
s.notice = noticeNone
|
||||
}
|
||||
return
|
||||
}
|
||||
if now.Sub(s.lastOutput) < waitQuiet {
|
||||
if s.wait.kind != "" && s.lastOutput.After(now.Add(-waitQuiet)) {
|
||||
s.wait.kind = "" // es geht weiter
|
||||
a.clearWaitNotice(s)
|
||||
}
|
||||
return
|
||||
}
|
||||
kind, line := waitKind(s)
|
||||
if kind == "" {
|
||||
if s.wait.kind != "" {
|
||||
s.wait.kind = ""
|
||||
a.clearWaitNotice(s)
|
||||
}
|
||||
s.wait.ack = ""
|
||||
return
|
||||
}
|
||||
if a.sessionVisible(s) && !a.blurred {
|
||||
s.wait.kind, s.wait.line, s.wait.ack = kind, line, line // du siehst es ja
|
||||
return
|
||||
}
|
||||
if line == s.wait.ack || (kind == s.wait.kind && line == s.wait.line) {
|
||||
s.wait.kind, s.wait.line = kind, line
|
||||
return // schon gesehen bzw. schon gemeldet
|
||||
}
|
||||
s.wait.kind, s.wait.line = kind, line
|
||||
if !a.notifyOn() {
|
||||
return
|
||||
}
|
||||
if !a.sessionVisible(s) {
|
||||
s.notice = noticeWait
|
||||
}
|
||||
msg := s.tabName() + ": " + waitLabel(kind)
|
||||
if kind != "secret" && line != "" {
|
||||
msg += " · " + trunc(line, 50)
|
||||
}
|
||||
a.pushToast(toastWarn, "? "+msg)
|
||||
if (a.blurred || a.lock != nil) && a.desktopNotifyOn() {
|
||||
body := waitLabel(kind)
|
||||
if a.lock == nil && kind != "secret" {
|
||||
body += ": " + trunc(line, 80)
|
||||
}
|
||||
a.sendDesktopFor(s, "sshTermy · "+s.tabName(), body)
|
||||
}
|
||||
}
|
||||
|
||||
// waitKind: wartet die Cursorzeile auf eine Eingabe?
|
||||
func waitKind(s *session) (string, string) {
|
||||
if s.term.AtIdlePrompt() {
|
||||
return "", ""
|
||||
}
|
||||
line := strings.TrimSpace(s.term.CursorLine())
|
||||
if agent.LooksLikeSecretPrompt(line) {
|
||||
return "secret", line
|
||||
}
|
||||
if k := agent.InputWait(line, s.term.AltScreen()); k != agent.InputNone {
|
||||
return string(k), line
|
||||
}
|
||||
return "", ""
|
||||
}
|
||||
|
||||
func waitLabel(kind string) string {
|
||||
switch kind {
|
||||
case "secret":
|
||||
return i18n.T("wartet auf ein Passwort")
|
||||
case string(agent.InputYesNo), string(agent.InputConfirm):
|
||||
return i18n.T("wartet auf ja/nein")
|
||||
case string(agent.InputPager):
|
||||
return i18n.T("wartet im Pager (Leertaste/q)")
|
||||
case string(agent.InputAnyKey):
|
||||
return i18n.T("wartet auf eine Taste")
|
||||
}
|
||||
return i18n.T("wartet auf dich")
|
||||
}
|
||||
|
||||
func (a *App) clearWaitNotice(s *session) {
|
||||
if s.notice == noticeWait || s.notice == noticeAgent {
|
||||
s.notice = noticeNone
|
||||
}
|
||||
}
|
||||
|
||||
// codeAgentTick: KI-Coding-Agent im Tab erkennen und Zustandswechsel melden.
|
||||
func (a *App) codeAgentTick(s *session, now time.Time) {
|
||||
w := &s.agentW
|
||||
gen := s.term.Gen()
|
||||
if gen == w.gen && w.name == "" {
|
||||
return // nichts Neues am Bildschirm
|
||||
}
|
||||
w.gen = gen
|
||||
screen := s.term.ScreenText()
|
||||
title := s.term.Title()
|
||||
if w.name == "" {
|
||||
name := ""
|
||||
if s.run != nil {
|
||||
name = codeagent.FromCommand(s.run.cmd)
|
||||
}
|
||||
if name == "" && !s.term.AtIdlePrompt() {
|
||||
name = codeagent.FromScreen(screen, title)
|
||||
}
|
||||
if name == "" {
|
||||
return
|
||||
}
|
||||
*w = agentWatch{name: name, since: now, lastSeen: now, gen: gen}
|
||||
}
|
||||
st, seen := codeagent.Detect(w.name, screen, title)
|
||||
if seen {
|
||||
w.lastSeen = now
|
||||
} else if now.Sub(w.lastSeen) > agentGone && (s.run == nil || s.term.AtIdlePrompt()) {
|
||||
*w = agentWatch{gen: gen} // beendet, zurück an der Shell
|
||||
a.clearWaitNotice(s)
|
||||
return
|
||||
}
|
||||
if st == codeagent.Unknown || st == w.state {
|
||||
return
|
||||
}
|
||||
prev, ran := w.state, now.Sub(w.since)
|
||||
w.state, w.since = st, now
|
||||
seenNow := a.sessionVisible(s) && !a.blurred
|
||||
switch {
|
||||
case st == codeagent.Blocked:
|
||||
if !seenNow {
|
||||
a.agentNotice(s, noticeAgent, i18n.F("%s wartet auf deine Freigabe", w.name))
|
||||
}
|
||||
case prev == codeagent.Working && st == codeagent.Idle && ran >= notifyAfter:
|
||||
if !seenNow {
|
||||
a.agentNotice(s, noticeOK, i18n.F("%s ist fertig (%s)", w.name, fmtDur(ran)))
|
||||
}
|
||||
default:
|
||||
if s.notice == noticeAgent {
|
||||
s.notice = noticeNone // Freigabe erteilt, es geht weiter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) agentNotice(s *session, kind noticeKind, text string) {
|
||||
if !a.notifyOn() {
|
||||
return
|
||||
}
|
||||
if !a.sessionVisible(s) {
|
||||
s.notice = kind
|
||||
}
|
||||
if kind == noticeAgent {
|
||||
a.pushToast(toastWarn, "◆ "+s.tabName()+": "+text)
|
||||
} else {
|
||||
a.flashOK("◆ " + s.tabName() + ": " + text)
|
||||
}
|
||||
if (a.blurred || a.lock != nil) && a.desktopNotifyOn() {
|
||||
a.sendDesktopFor(s, "sshTermy · "+s.tabName(), text)
|
||||
}
|
||||
}
|
||||
|
||||
// agentGlyph: Zustand des Agenten im Tab ("" = kein Agent).
|
||||
func (a *App) agentGlyph(s *session) string {
|
||||
switch s.agentW.state {
|
||||
case codeagent.Working:
|
||||
return a.s.AI.Render("◆")
|
||||
case codeagent.Blocked:
|
||||
return a.s.Warn.Render("◆")
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// tabStatus: Zustand als Wort für die Tab-Liste (Alt+T), "" = nichts Besonderes.
|
||||
func (a *App) tabStatus(s *session) string {
|
||||
if w := s.agentW; w.name != "" {
|
||||
switch w.state {
|
||||
case codeagent.Working:
|
||||
return "◆ " + w.name + " " + i18n.T("arbeitet")
|
||||
case codeagent.Blocked:
|
||||
return "◆ " + w.name + " " + i18n.T("wartet auf Freigabe")
|
||||
}
|
||||
return "◆ " + w.name + " " + i18n.T("bereit")
|
||||
}
|
||||
if s.wait.kind != "" {
|
||||
return "? " + waitLabel(s.wait.kind)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// noticeRank: Reihenfolge für Alt+G (kleiner = zuerst), -1 = keine Marke.
|
||||
func noticeRank(s *session) int {
|
||||
switch {
|
||||
case s.notice == noticeWait || s.notice == noticeAgent:
|
||||
return 0
|
||||
case s.notice == noticeFail || s.notice == noticeLog:
|
||||
return 1
|
||||
case s.notice != noticeNone:
|
||||
return 2
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
// jumpNextNotice (Alt+G): zum nächsten Tab mit Marke, Wartende zuerst; bei
|
||||
// gleichem Rang der nächste rechts vom aktuellen.
|
||||
func (a *App) jumpNextNotice() tea.Cmd {
|
||||
best, bestRank := -1, 99
|
||||
n := len(a.sessions)
|
||||
for k := 1; k <= n; k++ {
|
||||
i := (a.cur + k) % n
|
||||
if r := noticeRank(a.sessions[i]); r >= 0 && r < bestRank && i != a.cur {
|
||||
best, bestRank = i, r
|
||||
}
|
||||
}
|
||||
if best < 0 {
|
||||
a.flash(i18n.T("Kein Tab wartet und keiner hat eine Meldung"))
|
||||
return nil
|
||||
}
|
||||
a.focusSession(best)
|
||||
a.scr = scrTerminal
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/db9979/sshtermy/internal/codeagent"
|
||||
"github.com/db9979/sshtermy/internal/domain"
|
||||
)
|
||||
|
||||
func waitApp(t *testing.T) (*App, *session, *session) {
|
||||
t.Helper()
|
||||
a := dangerApp(t)
|
||||
s1, _ := typedSession(domain.Connection{Alias: "web1"}, "$ ", "")
|
||||
s2, _ := typedSession(domain.Connection{Alias: "db1"}, "", "")
|
||||
s2.id = 2
|
||||
a.sessions, a.cur = []*session{s1, s2}, 0
|
||||
return a, s1, s2
|
||||
}
|
||||
|
||||
// Verdeckter Tab hängt an [Y/n]: Marke, Einblendung, Alt+G springt hin.
|
||||
func TestWaitMarkHiddenTab(t *testing.T) {
|
||||
a, _, s2 := waitApp(t)
|
||||
var sent []string
|
||||
old := desktopSend
|
||||
desktopSend = func(_, body string, _ func()) { sent = append(sent, body) }
|
||||
defer func() { desktopSend = old }()
|
||||
|
||||
s2.term.Write([]byte("Need to get 12 MB.\r\nDo you want to continue? [Y/n] "))
|
||||
s2.lastOutput = time.Now().Add(-2 * time.Second)
|
||||
a.waitTick(s2, time.Now())
|
||||
if s2.notice != noticeWait || !toastHas(a, "ja/nein") {
|
||||
t.Fatalf("keine Marke/Einblendung: %v %+v", s2.notice, a.toasts)
|
||||
}
|
||||
if len(sent) != 0 {
|
||||
t.Fatal("Desktop-Meldung, obwohl das Fenster vorn ist")
|
||||
}
|
||||
if !strings.Contains(a.tabStatus(s2), "ja/nein") {
|
||||
t.Fatalf("Tab-Liste: %q", a.tabStatus(s2))
|
||||
}
|
||||
// nur einmal melden
|
||||
n := len(a.toasts)
|
||||
a.waitTick(s2, time.Now())
|
||||
if len(a.toasts) != n {
|
||||
t.Fatal("zweimal gemeldet")
|
||||
}
|
||||
a.coreMsg(nil)
|
||||
if cmd := a.jumpNextNotice(); cmd != nil || a.cur != 1 {
|
||||
t.Fatalf("Alt+G springt nicht: %d", a.cur)
|
||||
}
|
||||
}
|
||||
|
||||
// Was du gesehen hast, bevor du gewechselt hast (offenes less), meldet sich nicht.
|
||||
func TestWaitMarkSeenBeforeSwitch(t *testing.T) {
|
||||
a, _, s2 := waitApp(t)
|
||||
a.cur = 1
|
||||
s2.term.Write([]byte("Passwort für admin: "))
|
||||
s2.lastOutput = time.Now().Add(-2 * time.Second)
|
||||
a.waitTick(s2, time.Now()) // sichtbar: gesehen
|
||||
if s2.notice != noticeNone {
|
||||
t.Fatal("sichtbarer Tab markiert")
|
||||
}
|
||||
a.cur = 0
|
||||
a.waitTick(s2, time.Now())
|
||||
if s2.notice != noticeNone || len(a.toasts) != 0 {
|
||||
t.Fatal("gesehene Rückfrage nach dem Wechsel gemeldet")
|
||||
}
|
||||
}
|
||||
|
||||
// KI-Coding-Agent im verdeckten Tab: arbeitet → wartet auf Freigabe → Meldung.
|
||||
func TestCodeAgentBlockedNotifies(t *testing.T) {
|
||||
a, _, s2 := waitApp(t)
|
||||
var sent []string
|
||||
old := desktopSend
|
||||
desktopSend = func(_, body string, _ func()) { sent = append(sent, body) }
|
||||
defer func() { desktopSend = old }()
|
||||
a.blurred = true
|
||||
s2.run = &cmdRun{cmd: "claude", at: time.Now()}
|
||||
s2.term.Write([]byte("✻ Thinking… (3s · esc to interrupt)\r\n ? for shortcuts"))
|
||||
a.waitTick(s2, time.Now())
|
||||
if s2.agentW.name != "Claude Code" || s2.agentW.state != codeagent.Working {
|
||||
t.Fatalf("nicht erkannt: %+v", s2.agentW)
|
||||
}
|
||||
if !strings.Contains(a.agentGlyph(s2), "◆") {
|
||||
t.Fatal("kein Zeichen im Tab")
|
||||
}
|
||||
s2.term.Write([]byte("\x1b[2J\x1b[H Do you want to proceed?\r\n ❯ 1. Yes\r\n 2. No"))
|
||||
a.waitTick(s2, time.Now())
|
||||
if s2.agentW.state != codeagent.Blocked || s2.notice != noticeAgent {
|
||||
t.Fatalf("Freigabe nicht gemeldet: %+v %v", s2.agentW, s2.notice)
|
||||
}
|
||||
if len(sent) != 1 || !strings.Contains(sent[0], "Freigabe") {
|
||||
t.Fatalf("Desktop-Meldung: %v", sent)
|
||||
}
|
||||
// weiter gearbeitet: Marke weg
|
||||
s2.term.Write([]byte("\x1b[2J\x1b[H✻ Running… (esc to interrupt)"))
|
||||
a.waitTick(s2, time.Now())
|
||||
if s2.notice != noticeNone {
|
||||
t.Fatal("Marke bleibt nach der Freigabe")
|
||||
}
|
||||
// Agent beendet, zurück an der Shell
|
||||
s2.run = nil
|
||||
s2.term.Write([]byte("\x1b[2J\x1b[Huser@db1:~$ "))
|
||||
a.waitTick(s2, time.Now().Add(10*time.Second))
|
||||
if s2.agentW.name != "" {
|
||||
t.Fatalf("Agent bleibt nach dem Ende: %+v", s2.agentW)
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,9 @@ type State struct {
|
||||
HasXY bool `json:"has_xy,omitempty"`
|
||||
Full bool `json:"full,omitempty"` // zuletzt im Vollbild
|
||||
Max bool `json:"max,omitempty"` // zuletzt maximiert
|
||||
// Keep: sshTermy im Terminal als Hintergrunddienst starten; Sitzungen
|
||||
// laufen weiter, wenn das Fenster zugeht (cmd/sshtermy keep.go).
|
||||
Keep bool `json:"keep,omitempty"`
|
||||
}
|
||||
|
||||
// Mode: Startart mit Standardwert.
|
||||
|
||||
+6
-1
@@ -129,6 +129,9 @@ sudo apt update && sudo apt install sshtermy</pre></div>
|
||||
<div class="card"><h3>Fehlerverzeihend</h3><p>Beenden fragt bei offenen Verbindungen nach, Löschen lässt sich 10 Sekunden lang rückgängig machen, <kbd>Strg</kbd>+<kbd>T</kbd> im Formular testet die Verbindung vor dem Speichern, und fehlgeschlagene Verbindungen erklären in Klartext, was los ist (mit Taste zum Beheben, z. B. neuen Host-Key nach Neuinstallation übernehmen). Der einfache Modus blendet Profi-Funktionen aus.</p></div>
|
||||
<div class="card"><h3>Eigenes Fenster</h3><p>Kein Terminal nötig: Doppelklick auf die <code>.exe</code>, die <code>.app</code> öffnen oder <code>sshtermy -window</code>. Schrift, Nerd-Font-Symbole und Emoji sind eingebaut, jede Taste kommt an (Alt+⏎, ⇧F-Tasten, Strg+Leertaste), Bilder erscheinen pixelgenau, abgelegte Dateien werden hochgeladen, ⇧F10 öffnet ein zweites Fenster, das den Verlauf mitnimmt und mit Mausrad oder <kbd>⇧</kbd>+<kbd>Bild↑</kbd> blättert. Startet im Vollbild (<kbd>F11</kbd> schaltet um; maximiert oder „wie zuletzt“ in den Einstellungen), Schriftgröße und Fensterposition werden gemerkt. Im Terminal gestartet läuft es wie bisher im Terminal.</p></div>
|
||||
<div class="card"><h3>Ziel-Modus im Einsatz</h3><p><kbd>?</kbd> gibt der KI mitten im Ziel eine Anweisung, <kbd>⇧S</kbd> überspringt einen Schritt mit Grund. Fragt ein Befehl <code>[Y/n]</code> oder wartet ein Pager, zeigt das Panel Antwort-Knöpfe. Dateien, die ein Schritt ändert, werden vorher gesichert, <kbd>u</kbd> holt alle zurück; <kbd>f</kbd> startet ein Folgeziel, frühere Ziele stehen im Verlauf. Nach einem Verbindungsabbruch setzt <kbd>⏎</kbd> fort, und der Tab zeigt, wenn ein Ziel auf dich wartet.</p></div>
|
||||
<div class="card"><h3>Wer auf dich wartet</h3><p>Ein Tab, der auf ein Passwort, eine <code>[j/N]</code>-Frage oder im Pager wartet, bekommt ein <code>?</code>; <kbd>Alt</kbd>+<kbd>G</kbd> springt hin. KI-Coding-Agenten im Tab (Claude Code, Codex, Gemini CLI und mehr) werden erkannt: arbeitet, wartet auf deine Freigabe (<code>◆</code> plus Desktop-Meldung) oder fertig. Ein Klick auf die Desktop-Meldung öffnet den richtigen Tab.</p></div>
|
||||
<div class="card"><h3>Sitzungen laufen weiter</h3><p>Mit dem Hintergrunddienst überleben Sitzungen das Schließen des Terminalfensters; <code>sshtermy</code> hängt sich wieder an, <kbd>Strg</kbd>+<kbd>Q</kbd> → <kbd>a</kbd> koppelt ab. Beim Start bietet sshTermy an, die Tabs und die geteilte Ansicht vom letzten Mal wieder zu öffnen.</p></div>
|
||||
<div class="card"><h3>Tastatur & Kopfzeile</h3><p><kbd>Alt</kbd>+<kbd>C</kbd> markiert per Tastatur (<kbd>v</kbd>, <kbd>V</kbd> Zeilen, <kbd>y</kbd> kopiert), <kbd>Alt</kbd>+<kbd>X</kbd> leert Bildschirm und Verlauf, deine Eingabe bleibt. Die Kopfzeile zeigt auf Wunsch die Uhrzeit oder die Ausgabe eines eigenen Befehls (Git-Zweig, Akku …). KI-Clients können per MCP Tabs öffnen, tippen und warten, mit deiner Bestätigung.</p></div>
|
||||
<div class="card"><h3>Befehle als Blöcke</h3><p><kbd>Alt</kbd>+<kbd>Bild↑</kbd>/<kbd>Bild↓</kbd> springt im Verlauf von Befehl zu Befehl. <kbd>Alt</kbd>+<kbd>O</kbd> listet die Befehle des Tabs mit Uhrzeit, Dauer und Ergebnis: genau eine Ausgabe kopieren, an die KI geben oder groß lesen.</p></div>
|
||||
<div class="card"><h3>Echtes Terminal</h3><p>xterm-256color, Truecolor, vim, htop und tmux, Verlauf zum Zurückblättern (Mausrad oder <kbd>⇧</kbd>+<kbd>Bild↑</kbd>), Tabs, geteilte Ansicht, Suche.</p></div>
|
||||
<div class="card"><h3>Auto-Reconnect</h3><p>Reißt WLAN oder VPN ab, kommt die Sitzung von selbst zurück, mit Tunneln und tmux/screen. Nach Ruhezustand oder Netzwechsel wird jede Leitung binnen Sekunden geprüft.</p></div>
|
||||
@@ -231,6 +234,8 @@ sudo apt update && sudo apt install sshtermy</pre></div>
|
||||
<tr><td>Mausrad / <kbd>⇧</kbd>+<kbd>Bild↑</kbd>/<kbd>Bild↓</kbd></td><td>Im Verlauf zurückblättern; <kbd>⇧</kbd>+<kbd>Pos1</kbd> an den Anfang, <kbd>⇧</kbd>+<kbd>Ende</kbd> oder <kbd>Esc</kbd> zurück nach unten; in tmux über dessen Copy-Mode</td></tr>
|
||||
<tr><td><kbd>Strg</kbd>+<kbd>F</kbd></td><td>Im Verlauf suchen</td></tr>
|
||||
<tr><td><kbd>Alt</kbd>+<kbd>S</kbd></td><td>In allen offenen Tabs suchen</td></tr>
|
||||
<tr><td><kbd>Alt</kbd>+<kbd>G</kbd></td><td>Zum nächsten Tab, der wartet (<code>?</code>) oder sich gemeldet hat (<code>◆</code> KI-Agent wartet, ✓/×)</td></tr>
|
||||
<tr><td><kbd>Alt</kbd>+<kbd>C</kbd> / <kbd>Alt</kbd>+<kbd>X</kbd></td><td>Per Tastatur markieren (<kbd>v</kbd>, <kbd>V</kbd>, <kbd>y</kbd> kopiert, <kbd>Esc</kbd>) / Bildschirm und Verlauf leeren, Eingabe bleibt</td></tr>
|
||||
<tr><td><kbd>Alt</kbd>+<kbd>Bild↑</kbd> / <kbd>Bild↓</kbd> / <kbd>Alt</kbd>+<kbd>O</kbd></td><td>Zum vorigen / nächsten Befehl springen; Befehle des Tabs als Liste (Ausgabe kopieren, KI fragen)</td></tr>
|
||||
<tr><td><kbd>Leertaste</kbd> / <kbd>*</kbd></td><td>Manager: Verbindung markieren / alle sichtbaren; dann <kbd>e</kbd>, <kbd>v</kbd>, <kbd>d</kbd> für alle</td></tr>
|
||||
<tr><td>Manager → Rechtsklick</td><td>Menü zu Verbindung oder Ordner: verbinden, bearbeiten, verschieben, Tunnel, SSH-Key, Wake-on-LAN, löschen (Gruppen mit Trennlinien)</td></tr>
|
||||
@@ -256,7 +261,7 @@ sudo apt update && sudo apt install sshtermy</pre></div>
|
||||
<tr><td><kbd>Strg</kbd>+<kbd>T</kbd> (Verbindungsformular)</td><td>Verbindung testen: erreichbar, Host-Key, Anmeldung</td></tr>
|
||||
<tr><td><kbd>e</kbd> / <kbd>k</kbd> (getrennter Tab)</td><td>Verbindung bearbeiten / geänderten Host-Key vergleichen und übernehmen</td></tr>
|
||||
<tr><td><kbd>F10</kbd></td><td>Zurück zum Manager (Sitzungen laufen weiter)</td></tr>
|
||||
<tr><td><kbd>F1</kbd> / <kbd>F12</kbd> / <kbd>Strg</kbd>+<kbd>Q</kbd></td><td>Hilfe in Reitern (<kbd>←</kbd>/<kbd>→</kbd>, tippen filtert) / Über und Update / Beenden (fragt bei offenen Verbindungen)</td></tr>
|
||||
<tr><td><kbd>F1</kbd> / <kbd>F12</kbd> / <kbd>Strg</kbd>+<kbd>Q</kbd></td><td>Hilfe in Reitern (<kbd>←</kbd>/<kbd>→</kbd>, tippen filtert) / Über und Update / Beenden (fragt bei offenen Verbindungen; mit Hintergrunddienst <kbd>a</kbd> = abkoppeln)</td></tr>
|
||||
</table>
|
||||
<p>Alle Tasten lassen sich ändern: <kbd>b</kbd> im Manager. Die ganze Liste steht in der <a href="https://github.com/db9979/sshtermy/blob/main/README.de.md">README</a> und in der App (<kbd>F1</kbd>).</p>
|
||||
</section>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+6
-1
@@ -129,6 +129,9 @@ sudo apt update && sudo apt install sshtermy</pre></div>
|
||||
<div class="card"><h3>Forgiving</h3><p>Quitting asks while connections are open, deleting offers undo for 10 s, <kbd>Ctrl</kbd>+<kbd>T</kbd> in the form tests the connection before saving, and failed connections explain in plain language what's wrong (with a key to fix it, e.g. accept a new host key after a reinstall). Simple mode hides the pro features.</p></div>
|
||||
<div class="card"><h3>Own window</h3><p>No terminal needed: double-click the <code>.exe</code>, open the <code>.app</code> or run <code>sshtermy -window</code>. Font, Nerd Font symbols and emoji are built in, every key arrives (Alt+⏎, ⇧F-keys, Ctrl+Space), images show pixel-perfect, dropped files are uploaded, ⇧F10 opens a second window that takes the scrollback along and scrolls with the mouse wheel or <kbd>⇧</kbd>+<kbd>PgUp</kbd>. Starts in full screen (<kbd>F11</kbd> toggles; maximized or “as last time” in the settings), font size and window position are remembered. From a terminal it runs in the terminal as before.</p></div>
|
||||
<div class="card"><h3>Goal mode in daily use</h3><p><kbd>?</kbd> gives the AI an instruction mid-goal, <kbd>⇧S</kbd> skips a step with a reason. When a command asks <code>[Y/n]</code> or a pager waits, the panel shows answer buttons. Files a step changes are backed up first, <kbd>u</kbd> restores them all; <kbd>f</kbd> starts a follow-up goal, earlier goals are in the history. After a connection drop <kbd>⏎</kbd> continues, and the tab shows when a goal is waiting for you.</p></div>
|
||||
<div class="card"><h3>Who is waiting for you</h3><p>A tab waiting for a password, a <code>[y/N]</code> question or a pager gets a <code>?</code>; <kbd>Alt</kbd>+<kbd>G</kbd> jumps there. AI coding agents in a tab (Claude Code, Codex, Gemini CLI and more) are recognized: working, waiting for your approval (<code>◆</code> plus desktop notification) or done. A click on the desktop notification opens the right tab.</p></div>
|
||||
<div class="card"><h3>Sessions keep running</h3><p>With the background service, sessions survive closing the terminal window; <code>sshtermy</code> attaches again, <kbd>Ctrl</kbd>+<kbd>Q</kbd> → <kbd>a</kbd> detaches. At start sshTermy offers to reopen the tabs and split view from last time.</p></div>
|
||||
<div class="card"><h3>Keyboard & header</h3><p><kbd>Alt</kbd>+<kbd>C</kbd> selects by keyboard (<kbd>v</kbd>, <kbd>V</kbd> lines, <kbd>y</kbd> copies), <kbd>Alt</kbd>+<kbd>X</kbd> clears screen and scrollback but keeps your input. The header can show the time or the output of your own command (git branch, battery …). AI clients can open tabs, type and wait via MCP, with your confirmation.</p></div>
|
||||
<div class="card"><h3>Commands as blocks</h3><p><kbd>Alt</kbd>+<kbd>PgUp</kbd>/<kbd>PgDn</kbd> jumps from command to command in the scrollback. <kbd>Alt</kbd>+<kbd>O</kbd> lists the tab's commands with time, duration and result: copy exactly one output, hand it to the AI or read it in full.</p></div>
|
||||
<div class="card"><h3>Real terminal</h3><p>xterm-256color, truecolor, vim, htop and tmux, scrollback (mouse wheel or <kbd>⇧</kbd>+<kbd>PgUp</kbd>), tabs, split view, search.</p></div>
|
||||
<div class="card"><h3>Auto-reconnect</h3><p>When Wi-Fi or VPN drops, the session comes back by itself, with tunnels and tmux/screen. After sleep or a network change every line is checked within seconds.</p></div>
|
||||
@@ -230,6 +233,8 @@ sudo apt update && sudo apt install sshtermy</pre></div>
|
||||
<tr><td>Mouse wheel / <kbd>⇧</kbd>+<kbd>PgUp</kbd>/<kbd>PgDn</kbd></td><td>Scroll back in the scrollback; <kbd>⇧</kbd>+<kbd>Home</kbd> to its start, <kbd>⇧</kbd>+<kbd>End</kbd> or <kbd>Esc</kbd> back to the bottom; in tmux this uses its copy mode</td></tr>
|
||||
<tr><td><kbd>Ctrl</kbd>+<kbd>F</kbd></td><td>Search the scrollback</td></tr>
|
||||
<tr><td><kbd>Alt</kbd>+<kbd>S</kbd></td><td>Search in all open tabs</td></tr>
|
||||
<tr><td><kbd>Alt</kbd>+<kbd>G</kbd></td><td>Go to the next tab that waits (<code>?</code>) or has a notice (<code>◆</code> AI agent waiting, ✓/×)</td></tr>
|
||||
<tr><td><kbd>Alt</kbd>+<kbd>C</kbd> / <kbd>Alt</kbd>+<kbd>X</kbd></td><td>Select by keyboard (<kbd>v</kbd>, <kbd>V</kbd>, <kbd>y</kbd> copies, <kbd>Esc</kbd>) / clear screen and scrollback, input stays</td></tr>
|
||||
<tr><td><kbd>Alt</kbd>+<kbd>PgUp</kbd> / <kbd>PgDn</kbd> / <kbd>Alt</kbd>+<kbd>O</kbd></td><td>Jump to the previous / next command; list of the tab's commands (copy output, ask AI)</td></tr>
|
||||
<tr><td><kbd>Space</kbd> / <kbd>*</kbd></td><td>Manager: mark a connection / all visible; then <kbd>e</kbd>, <kbd>v</kbd>, <kbd>d</kbd> for all</td></tr>
|
||||
<tr><td>Manager → right-click</td><td>Menu for a connection or folder: connect, edit, move, tunnel, SSH key, Wake-on-LAN, delete (groups with separator lines)</td></tr>
|
||||
@@ -259,7 +264,7 @@ sudo apt update && sudo apt install sshtermy</pre></div>
|
||||
<tr><td><kbd>Tab</kbd> / <kbd>→</kbd></td><td>Accept ghost text</td></tr>
|
||||
<tr><td><kbd>Alt</kbd>+<kbd>1</kbd>…<kbd>4</kbd></td><td>Insert follow-up command</td></tr>
|
||||
<tr><td><kbd>Alt</kbd>+<kbd>0</kbd></td><td>After a failure: cause and fix</td></tr>
|
||||
<tr><td><kbd>Ctrl</kbd>+<kbd>Q</kbd></td><td>Quit (asks while connections are open)</td></tr>
|
||||
<tr><td><kbd>Ctrl</kbd>+<kbd>Q</kbd></td><td>Quit (asks while connections are open; with the background service <kbd>a</kbd> = detach)</td></tr>
|
||||
</table>
|
||||
<p>All shortcuts can be changed: <kbd>b</kbd> in the manager. The full list is in the <a href="https://github.com/db9979/sshtermy#usage">README</a> and in the app (<kbd>F1</kbd>).</p>
|
||||
</section>
|
||||
|
||||
@@ -20,10 +20,9 @@ export const de = {
|
||||
['F1', 'Hilfe: Reiter ←/→, tippen filtert'],
|
||||
['⇧F9', 'Tastenzeile mit Erklärungen'],
|
||||
['F10', 'Manager ↔ Terminal (Sitzungen laufen weiter)'],
|
||||
['F12', 'Über & Update'],
|
||||
['F12 w / l', 'Was ist neu / Sprache'],
|
||||
['F12 · w / l', 'Update · Neues / Sprache'],
|
||||
['F11', 'Vollbild (eigenes Fenster)'],
|
||||
['Strg+Q', 'beenden (fragt nach)'],
|
||||
['Strg+Q', 'beenden (fragt) · a abkoppeln'],
|
||||
]},
|
||||
{ t: 'Verbindungs-Manager', ic: '≡', key: 'F10', rows: [
|
||||
['⏎', 'verbinden'],
|
||||
@@ -54,14 +53,14 @@ export const de = {
|
||||
['F9', 'Schnellbefehle (Liste)'],
|
||||
['⇧F1 … ⇧F8', 'Schnellbefehl direkt ausführen'],
|
||||
['Mausrad / ⇧Bild↑↓', 'zurückblättern · ⇧Pos1/⇧Ende · Esc unten'],
|
||||
['Strg+F', 'im Verlauf suchen'],
|
||||
['Strg+F', 'suchen · Alt+C markieren · Alt+X leeren'],
|
||||
['⇧F10', 'Tab in eigenes Fenster / zurück'],
|
||||
]},
|
||||
{ t: 'Tabs', ic: '▭', rows: [
|
||||
['F7 / F8', 'Tab zurück / vor'],
|
||||
['Alt+N / Alt+W', 'neuer Tab (Manager, auch +) / Tab schließen'],
|
||||
['Alt+L', 'lokale Shell (PowerShell, zsh …)'],
|
||||
['Alt+T', 'Tab-Liste: ⏎ springen, 1…9 direkt'],
|
||||
['Alt+T / G', 'Tab-Liste · Tab, der wartet (? ◆)'],
|
||||
['Strg+R / D', '(Liste) umbenennen / duplizieren'],
|
||||
['Alt+S', 'in allen Tabs suchen'],
|
||||
['Alt+O', 'Befehle des Tabs · Alt+Bild↑↓ springt'],
|
||||
@@ -208,10 +207,9 @@ export const en = {
|
||||
['F1', 'help: tabs ←/→, type to filter'],
|
||||
['⇧F9', 'key bar with explanations'],
|
||||
['F10', 'manager ↔ terminal (sessions keep running)'],
|
||||
['F12', 'about & update'],
|
||||
['F12 w / l', "what's new / language"],
|
||||
['F12 · w / l', "update · what's new / language"],
|
||||
['F11', 'full screen (own window)'],
|
||||
['Ctrl+Q', 'quit (asks if connected)'],
|
||||
['Ctrl+Q', 'quit (asks if connected) · a = detach'],
|
||||
]},
|
||||
{ t: 'Connection manager', ic: '≡', key: 'F10', rows: [
|
||||
['⏎', 'connect'],
|
||||
@@ -242,14 +240,15 @@ export const en = {
|
||||
['F9', 'quick commands (list)'],
|
||||
['⇧F1 … ⇧F8', 'run a quick command directly'],
|
||||
['wheel / ⇧PgUp/Dn', 'scroll back · ⇧Home/⇧End · Esc bottom'],
|
||||
['Ctrl+F', 'search the scrollback'],
|
||||
['Ctrl+F', 'search · Alt+C select · Alt+X clear'],
|
||||
['Alt+C / X', 'select by keys (v, y) / clear screen'],
|
||||
['⇧F10', 'tab to its own window / back'],
|
||||
]},
|
||||
{ t: 'Tabs', ic: '▭', rows: [
|
||||
['F7 / F8', 'previous / next tab'],
|
||||
['Alt+N / Alt+W', 'new tab (manager, also +) / close tab'],
|
||||
['Alt+L', 'local shell (PowerShell, zsh …)'],
|
||||
['Alt+T', 'tab list: ⏎ jump, 1…9 direct'],
|
||||
['Alt+T / G', 'tab list · tab that waits (? ◆)'],
|
||||
['Ctrl+R / D', '(list) rename / duplicate'],
|
||||
['Alt+S', 'search in all tabs'],
|
||||
['Alt+O', 'tab commands · Alt+PgUp/Dn jumps'],
|
||||
|
||||
@@ -1 +1 @@
|
||||
a96bf3e05f8d6bff80f81e0398da656d66bee17b8b9b4d49b771839bd660b894
|
||||
20f6ea56eb032c506d286adef360278b5d918a568042070eec7f27db85915ed3
|
||||
Reference in new issue
Block a user