From ec745129258ae800065e302a2a40b54488cbca08 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 10 Feb 2026 09:52:34 +0200 Subject: Add tmux popup history storage and consolidate state files to XDG_STATE_HOME - Add StateDir() helper function respecting XDG_STATE_HOME (~/.local/state/hexai/) - Implement JSONL-based history storage for tmux popup submissions - New history.go with AppendHistory() and GetHistory() functions - Store timestamp, agent name, cwd, and submitted text - Comprehensive unit tests for history functionality - Integrate history append into tmux edit workflow after successful submission - Move logs from /tmp/ to persistent state directory: - hexai-lsp.log: ~/.local/state/hexai/hexai-lsp.log - hexai-tmux-edit.log: ~/.local/state/hexai/hexai-tmux-edit.log - Update README.md with File Locations section documenting XDG directories - Fix pre-existing test failures by isolating project config in unit tests - Panic on state directory creation failure instead of silent fallback All unit tests pass. Follows XDG Base Directory Specification for proper state file management with persistence across reboots. Co-Authored-By: Claude Sonnet 4.5 --- cmd/hexai-lsp/main.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'cmd/hexai-lsp/main.go') diff --git a/cmd/hexai-lsp/main.go b/cmd/hexai-lsp/main.go index 3704cbf..828d0f8 100644 --- a/cmd/hexai-lsp/main.go +++ b/cmd/hexai-lsp/main.go @@ -14,7 +14,8 @@ import ( ) func main() { - logPath := flag.String("log", "/tmp/hexai-lsp.log", "path to log file (optional)") + defaultLog := defaultLogPath() + logPath := flag.String("log", defaultLog, "path to log file (optional)") defaultCfg := defaultConfigPath() configPath := flag.String("config", "", fmt.Sprintf("path to config file (default: %s)", defaultCfg)) showVersion := flag.Bool("version", false, "print version and exit") @@ -37,3 +38,15 @@ func defaultConfigPath() string { } return path } + +// defaultLogPath returns the default LSP log file path in the state directory. +// Falls back to /tmp if state directory cannot be determined. +// defaultLogPath returns the default LSP log file path in the state directory. +// Panics if state directory cannot be created. +func defaultLogPath() string { + stateDir, err := appconfig.StateDir() + if err != nil { + panic(fmt.Sprintf("cannot create state directory: %v", err)) + } + return fmt.Sprintf("%s/hexai-lsp.log", stateDir) +} -- cgit v1.2.3