From 75cf6abd55bfb60324fc47cf91eac08dbb8b87b4 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 8 Sep 2025 12:02:40 +0300 Subject: docs: move tmux documentation to its own file --- docs/configuration.md | 19 +- docs/coverage.html | 89 +- docs/coverage.out | 10618 ++++++++++++++++++++-------------------- docs/helix-tmux-quickstart.md | 68 - docs/tmux.md | 109 + 5 files changed, 5556 insertions(+), 5347 deletions(-) delete mode 100644 docs/helix-tmux-quickstart.md create mode 100644 docs/tmux.md (limited to 'docs') diff --git a/docs/configuration.md b/docs/configuration.md index 95b65de..0b9e204 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -64,24 +64,7 @@ Editor integration Tmux status line -- Hexai can update a tmux user option during LLM activity. Add this to your `~/.tmux.conf` to display it: - - - `set -g status-right '#{@hexai_status} #[fg=colour8]| %H:%M'` - -- Status content is updated best‑effort at key moments: - - CLI: start (⏳ provider:model) and completion with compact stats (↑sent, ↓recv, rpm, reqs) - - LSP: initial heartbeat on client initialize, and periodic compact stats (provider, model, rpm, reqs, bytes) - - TUI action runner: ready (provider:model) and completion with compact stats - -- Toggle via environment: - - Enable (default): unset or `HEXAI_TMUX_STATUS=1` - - Disable: `HEXAI_TMUX_STATUS=0` - -- Theme and colors: - - Preset: `HEXAI_TMUX_STATUS_THEME=white-on-purple` (white fg on purple/magenta bg) - - Explicit: `HEXAI_TMUX_STATUS_FG=`, `HEXAI_TMUX_STATUS_BG=` (e.g., `white`, `magenta`, `colour5`) - - Colors use tmux’s `fg`/`bg` names; both methods wrap the entire `@hexai_status` segment. - - If truncated, increase width: `set -g status-right-length 120` +See the [tmux integration guide](docs/tmux.md) for details on configuring the status line. Code action prompts diff --git a/docs/coverage.html b/docs/coverage.html index 8560a58..059834b 100644 --- a/docs/coverage.html +++ b/docs/coverage.html @@ -71,13 +71,13 @@ - + - + @@ -113,7 +113,7 @@ - + @@ -123,7 +123,9 @@ - + + + @@ -1485,6 +1487,7 @@ import ( "codeberg.org/snonux/hexai/internal/editor" "codeberg.org/snonux/hexai/internal/logging" "codeberg.org/snonux/hexai/internal/llmutils" + "codeberg.org/snonux/hexai/internal/tmux" ) // Run executes the hexai-tmux-action command flow. @@ -1495,12 +1498,14 @@ var newClientFromApp = llmutils.NewClientFromApp func Run(ctx context.Context, stdin io.Reader, stdout, stderr io.Writer) error { logger := log.New(stderr, "hexai-tmux-action ", log.LstdFlags|log.Lmsgprefix) cfg := appconfig.Load(logger) - client, err := newClientFromApp(cfg) + cli, err := newClientFromApp(cfg) if err != nil { fmt.Fprintf(stderr, logging.AnsiBase+"hexai-tmux-action: LLM disabled: %v"+logging.AnsiReset+"\n", err) return err } - parts, err := ParseInput(stdin) + _ = tmux.SetStatus("hexai action ready " + cli.DefaultModel()) + var client chatDoer = cli + parts, err := ParseInput(stdin) if err != nil { fmt.Fprintln(stderr, logging.AnsiBase+"hexai-tmux-action: failed to read input"+logging.AnsiReset) return err @@ -1512,12 +1517,13 @@ func Run(ctx context.Context, stdin io.Reader, stdout, stderr io.Writer) error < if err != nil { return err } - out, err := executeAction(ctx, kind, parts, cfg, client, stderr) - if err != nil { - return err - } - io.WriteString(stdout, out) - return nil + out, err := executeAction(ctx, kind, parts, cfg, client, stderr) + if err != nil { + return err + } + io.WriteString(stdout, out) + _ = tmux.SetStatus("✅ " + cli.DefaultModel()) + return nil } func executeAction(ctx context.Context, kind ActionKind, parts InputParts, cfg appconfig.App, client chatDoer, stderr io.Writer) (string, error) { @@ -1745,6 +1751,7 @@ import ( "codeberg.org/snonux/hexai/internal/logging" "codeberg.org/snonux/hexai/internal/llm" "codeberg.org/snonux/hexai/internal/llmutils" + "codeberg.org/snonux/hexai/internal/tmux" ) // Run executes the Hexai CLI behavior given arguments and I/O streams. @@ -1851,8 +1858,10 @@ func buildMessagesFromConfig(cfg appconfig.App, input string) []llm.Message { - start := time.Now() - var output string + start := time.Now() + // Best-effort tmux status update + _ = tmux.SetStatus("⏳ " + client.Name() + ":" + client.DefaultModel()) + var output string if s, ok := client.(llm.Streamer); ok { var b strings.Builder if err := s.ChatStream(ctx, msgs, func(chunk string) { @@ -1870,10 +1879,11 @@ func runChat(ctx context.Context, client llm.Client, msgs []llm.Message, input s output = txt fmt.Fprint(out, output) } - dur := time.Since(start) - fmt.Fprintf(errw, "\n"+logging.AnsiBase+"done provider=%s model=%s time=%s in_bytes=%d out_bytes=%d"+logging.AnsiReset+"\n", - client.Name(), client.DefaultModel(), dur.Round(time.Millisecond), len(input), len(output)) - return nil + dur := time.Since(start) + fmt.Fprintf(errw, "\n"+logging.AnsiBase+"done provider=%s model=%s time=%s in_bytes=%d out_bytes=%d"+logging.AnsiReset+"\n", + client.Name(), client.DefaultModel(), dur.Round(time.Millisecond), len(input), len(output)) + _ = tmux.SetStatus("✅ " + client.DefaultModel() + " " + dur.Round(time.Millisecond).String()) + return nil } // printProviderInfo writes the provider/model line to stderr. @@ -5260,6 +5270,7 @@ import ( "codeberg.org/snonux/hexai/internal/llm" "codeberg.org/snonux/hexai/internal/logging" "codeberg.org/snonux/hexai/internal/textutil" + tmx "codeberg.org/snonux/hexai/internal/tmux" ) // Configurable inline trigger characters (default to '>') used by free helpers below. @@ -5312,7 +5323,11 @@ func (s *Server) logLLMStats() { rpm := float64(reqs) / mins sentPerMin := float64(sentTot) / mins recvPerMin := float64(recvTot) / mins - logging.Logf("lsp ", "llm stats reqs=%d avg_sent=%d avg_recv=%d sent_total=%d recv_total=%d rpm=%.2f sent_per_min=%.0f recv_per_min=%.0f", reqs, avgSent, avgRecv, sentTot, recvTot, rpm, sentPerMin, recvPerMin) + logging.Logf("lsp ", "llm stats reqs=%d avg_sent=%d avg_recv=%d sent_total=%d recv_total=%d rpm=%.2f sent_per_min=%.0f recv_per_min=%.0f", reqs, avgSent, avgRecv, sentTot, recvTot, rpm, sentPerMin, recvPerMin) + // Best-effort tmux status update + if s.llmClient != nil { + _ = tmx.SetStatus("LLM:" + s.llmClient.DefaultModel()) + } } // Completion prompt builders and filters @@ -6194,6 +6209,36 @@ func FindStrictInlineTag(line string) (text string, left, right int, ok bool)