summaryrefslogtreecommitdiff
path: root/internal/hexaiaction/run.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-17 11:28:19 +0200
committerPaul Buetow <paul@buetow.org>2026-03-17 11:28:19 +0200
commit6f1c8bf7a36eb7044ed7aad30f84664cbbf0d303 (patch)
treedd2ac6e1433177fb59c167a12fa0b4b91132f34a /internal/hexaiaction/run.go
parent10562cc510f64d5ac38aeb76f03e18eb76cca40f (diff)
Fix bugs, remove duplication, and clean up code quality issues
- Log swallowed JSON unmarshal errors in stats and LSP handlers - Fix debug log file handle leak in tmuxedit (return closer from initDebugLog) - Check f.Close() errors on write paths in promptstore and tmuxedit - Fix cacheGet TOCTOU race by using single write lock - Fix readInput to use passed stdin reader instead of os.Stdin.Stat() - Remove 45 'moved to' comment tombstones from lsp/handlers.go - Deduplicate canonicalProvider wrappers (use llmutils.CanonicalProvider directly) - Remove SetWindow side effect from stats.TakeSnapshot (pure read now) - Move duplicated splitLines to textutil.SplitLinesBytes - Collapse StatusSink.SetGlobal 10 params into GlobalStatus struct - Simplify LRU touchLocked to in-place delete-and-append Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'internal/hexaiaction/run.go')
-rw-r--r--internal/hexaiaction/run.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/internal/hexaiaction/run.go b/internal/hexaiaction/run.go
index 5b8bbc2..84cb9b1 100644
--- a/internal/hexaiaction/run.go
+++ b/internal/hexaiaction/run.go
@@ -16,6 +16,38 @@ import (
"codeberg.org/snonux/hexai/internal/tmux"
)
+// tmuxActionError formats an error with the hexai-tmux-action prefix for stderr output.
+type tmuxActionError struct {
+ inner error
+}
+
+func (e tmuxActionError) Error() string {
+ return logging.AnsiBase + "hexai-tmux-action: " + e.inner.Error() + logging.AnsiReset
+}
+
+func (e tmuxActionError) Unwrap() error {
+ return e.inner
+}
+
+// logTmuxActionError logs an error to stderr with the hexai-tmux-action prefix.
+func logTmuxActionError(stderr io.Writer, err error) error {
+ _, _ = fmt.Fprintf(stderr, "%v\n", tmuxActionError{err})
+ return err
+}
+
+// requireInput validates that input selection is not empty.
+func requireInput(sel string) error {
+ if strings.TrimSpace(sel) == "" {
+ return fmt.Errorf("no input provided on stdin")
+ }
+ return nil
+}
+
+// logAndReturnError logs an error to stderr and returns it (hexaiaction pattern).
+func logAndReturnError(stderr io.Writer, err error) error {
+ return logTmuxActionError(stderr, err)
+}
+
type configPathKey struct{}
type actionChoice struct {