Phase 5: TUI client (Bubbletea)

- cmd/tui/main.go: entry point with --server, --token, --version flags
- cmd/tui/config.go: config from ~/.config/dumpster/config.yaml or env vars
- cmd/tui/auth.go: login flow, session cookie management
- cmd/tui/api.go: HTTP client for servers, channels, messages, voice
- cmd/tui/model.go: root bubbletea model with state management
- cmd/tui/theme.go: Gruvbox dark lipgloss styles
- cmd/tui/servers.go: server bar with [D] style initials
- cmd/tui/channels.go: channel list with #text and 🔊 voice
- cmd/tui/chat.go: IRC-style message viewport with colored usernames
- cmd/tui/input.go: message input with > _ prompt
- cmd/tui/members.go: member list with ●/◐/○ status
- cmd/tui/ws.go: WebSocket client for real-time events
- cmd/tui/voice.go: voice state tracking and mute toggle
- cmd/tui/keys.go: vim-style keybindings (j/k, g/G, Tab, /, etc)
- cmd/tui/views.go: multi-pane layout rendering
- Makefile: added build-tui and run-tui targets
- go.mod/go.sum: added charmbracelet dependencies
This commit is contained in:
2026-06-28 17:46:19 -04:00
parent 297cc47631
commit 2a6b3830d5
18 changed files with 2288 additions and 17 deletions
+59
View File
@@ -0,0 +1,59 @@
package main
import (
"fmt"
"os"
"path/filepath"
"gopkg.in/yaml.v3"
)
type Config struct {
ServerURL string `yaml:"server_url"`
Token string `yaml:"token"`
}
func configDir() string {
home, _ := os.UserHomeDir()
return filepath.Join(home, ".config", "dumpster")
}
func configPath() string {
return filepath.Join(configDir(), "config.yaml")
}
// LoadConfig loads config from file, then overlays env vars.
func LoadConfig() (*Config, error) {
cfg := &Config{
ServerURL: "http://localhost:8080",
}
// Try to load from file
data, err := os.ReadFile(configPath())
if err == nil {
_ = yaml.Unmarshal(data, cfg)
}
// Env var overrides
if v := os.Getenv("DUMPSTER_SERVER"); v != "" {
cfg.ServerURL = v
}
if v := os.Getenv("DUMPSTER_TOKEN"); v != "" {
cfg.Token = v
}
return cfg, nil
}
// SaveConfig writes the config to disk.
func SaveConfig(cfg *Config) error {
dir := configDir()
if err := os.MkdirAll(dir, 0o700); err != nil {
return fmt.Errorf("create config dir: %w", err)
}
data, err := yaml.Marshal(cfg)
if err != nil {
return fmt.Errorf("marshal config: %w", err)
}
return os.WriteFile(configPath(), data, 0o600)
}