Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/charmbracelet/bubbles v1.0.0
github.com/charmbracelet/bubbletea v1.3.10
github.com/charmbracelet/lipgloss v1.1.0
github.com/charmbracelet/x/ansi v0.11.6
github.com/mark3labs/mcp-go v0.43.2
github.com/mattn/go-isatty v0.0.20
github.com/spf13/cobra v1.10.2
Expand All @@ -18,7 +19,6 @@ require (
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/charmbracelet/colorprofile v0.4.1 // indirect
github.com/charmbracelet/x/ansi v0.11.6 // indirect
github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
github.com/charmbracelet/x/term v0.2.2 // indirect
github.com/clipperhouse/displaywidth v0.9.0 // indirect
Expand Down
76 changes: 76 additions & 0 deletions internal/tui/debug.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package tui

import (
"fmt"
"log"
"os"
"strings"
"sync"

"github.com/charmbracelet/x/ansi"
)

var (
debugLogger *log.Logger
debugOnce sync.Once
)

// debugLog writes a message to the debug log file.
// Only active when FR8_TUI_DEBUG=1. Log file: /tmp/fr8-tui-debug.log
func debugLog(format string, args ...any) {
debugOnce.Do(func() {
if os.Getenv("FR8_TUI_DEBUG") != "1" {
return
}
f, err := os.OpenFile("/tmp/fr8-tui-debug.log", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
if err != nil {
return
}
debugLogger = log.New(f, "", log.Ltime|log.Lmicroseconds)

// Dump environment info on first call
debugLogger.Printf("=== fr8 TUI debug log ===")
debugLogger.Printf("TERM=%s", os.Getenv("TERM"))
debugLogger.Printf("TERM_PROGRAM=%s", os.Getenv("TERM_PROGRAM"))
debugLogger.Printf("TERM_PROGRAM_VERSION=%s", os.Getenv("TERM_PROGRAM_VERSION"))
debugLogger.Printf("COLORTERM=%s", os.Getenv("COLORTERM"))
debugLogger.Printf("TERMINAL_EMULATOR=%s", os.Getenv("TERMINAL_EMULATOR"))
debugLogger.Printf("LANG=%s", os.Getenv("LANG"))

// Test box-drawing character widths
chars := []struct {
name string
ch string
}{
{"╭", "╭"}, {"╮", "╮"}, {"╰", "╰"}, {"╯", "╯"},
{"│", "│"}, {"─", "─"}, {"▸", "▸"}, {"▶", "▶"},
{"●", "●"}, {"✓", "✓"}, {"✗", "✗"}, {"·", "·"},
}
for _, c := range chars {
debugLogger.Printf("char %s: ansi.StringWidth=%d len(bytes)=%d", c.name, ansi.StringWidth(c.ch), len(c.ch))
}
})

if debugLogger != nil {
debugLogger.Printf(format, args...)
}
}

// debugLogView logs diagnostic info about the final rendered view.
func debugLogView(view string, modelWidth, modelHeight int) {
if debugLogger == nil {
return
}
lines := strings.Split(view, "\n")
debugLog("--- View render: model.width=%d model.height=%d lines=%d ---", modelWidth, modelHeight, len(lines))
for i, line := range lines {
w := ansi.StringWidth(line)
marker := ""
if w != modelWidth {
marker = fmt.Sprintf(" *** MISMATCH (expected %d)", modelWidth)
}
if i < 30 || marker != "" { // Log first 30 lines, plus any mismatches
debugLog(" line[%2d] width=%3d%s", i, w, marker)
}
}
}
10 changes: 7 additions & 3 deletions internal/tui/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ func renderHelp(m model) string {
sections.WriteString(formatHelpLine("j/↓", "Move down"))
sections.WriteString(formatHelpLine("k/↑", "Move up"))
sections.WriteString(formatHelpLine("enter", "Select / drill down"))
sections.WriteString(formatHelpLine("esc", "Back / cancel"))
sections.WriteString(formatHelpLine("esc", "Back / cancel / clear selection"))
sections.WriteString(formatHelpLine("/", "Filter list"))
sections.WriteString(formatHelpLine("ctrl+r", "Refresh data"))
sections.WriteString(formatHelpLine("ctrl+l", "Redraw screen"))
sections.WriteString(formatHelpLine("?", "Toggle this help"))
sections.WriteString(formatHelpLine("q", "Quit"))

Expand All @@ -33,8 +36,9 @@ func renderHelp(m model) string {
sections.WriteString(breadcrumbActiveStyle.Render("Workspace List"))
sections.WriteString("\n")
sections.WriteString(formatHelpLine("n", "Create new workspace"))
sections.WriteString(formatHelpLine("r", "Run dev server"))
sections.WriteString(formatHelpLine("x", "Stop dev server"))
sections.WriteString(formatHelpLine("space", "Toggle selection for bulk operations"))
sections.WriteString(formatHelpLine("r", "Run dev server (or run all selected)"))
sections.WriteString(formatHelpLine("x", "Stop dev server (or stop all selected)"))
sections.WriteString(formatHelpLine("t", "Attach to running session"))
sections.WriteString(formatHelpLine("s", "Open shell"))
sections.WriteString(formatHelpLine("o", "Open with configured opener"))
Expand Down
20 changes: 20 additions & 0 deletions internal/tui/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ type keyMap struct {
Attach key.Binding
RunAllGlobal key.Binding
StopAllGlobal key.Binding
Filter key.Binding
Select key.Binding
Refresh key.Binding
Redraw key.Binding
Help key.Binding
Quit key.Binding
Yes key.Binding
Expand Down Expand Up @@ -85,6 +89,22 @@ var keys = keyMap{
key.WithKeys("X"),
key.WithHelp("X", "global stop"),
),
Filter: key.NewBinding(
key.WithKeys("/"),
key.WithHelp("/", "filter"),
),
Select: key.NewBinding(
key.WithKeys(" "),
key.WithHelp("space", "select"),
),
Refresh: key.NewBinding(
key.WithKeys("ctrl+r"),
key.WithHelp("ctrl+r", "refresh"),
),
Redraw: key.NewBinding(
key.WithKeys("ctrl+l"),
key.WithHelp("ctrl+l", "redraw"),
),
Help: key.NewBinding(
key.WithKeys("?"),
key.WithHelp("?", "help"),
Expand Down
23 changes: 23 additions & 0 deletions internal/tui/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/protocollar/fr8/internal/gh"
"github.com/protocollar/fr8/internal/git"
"github.com/protocollar/fr8/internal/registry"
"github.com/protocollar/fr8/internal/tmux"
"github.com/protocollar/fr8/internal/userconfig"
)

Expand Down Expand Up @@ -121,3 +122,25 @@ type createRequestMsg struct {
name string
rootPath string
}

// Toast notifications
type toastTickMsg struct{}

// Multi-select batch operations
type batchStartResultMsg struct {
started int
err error
}

type batchStopResultMsg struct {
stopped int
err error
}

// Auto-refresh
type autoRefreshTickMsg struct{}

type autoRefreshResultMsg struct {
sessions []tmux.Session
err error
}
Loading