diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-17 11:28:19 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-17 11:28:19 +0200 |
| commit | 6f1c8bf7a36eb7044ed7aad30f84664cbbf0d303 (patch) | |
| tree | dd2ac6e1433177fb59c167a12fa0b4b91132f34a /internal/hexaiaction | |
| parent | 10562cc510f64d5ac38aeb76f03e18eb76cca40f (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')
| -rw-r--r-- | internal/hexaiaction/prompts.go | 8 | ||||
| -rw-r--r-- | internal/hexaiaction/run.go | 32 |
2 files changed, 34 insertions, 6 deletions
diff --git a/internal/hexaiaction/prompts.go b/internal/hexaiaction/prompts.go index 8cf8c48..03a9441 100644 --- a/internal/hexaiaction/prompts.go +++ b/internal/hexaiaction/prompts.go @@ -38,10 +38,6 @@ func providerOf(c any) string { return "llm" } -func canonicalProvider(name string) string { - return llmutils.CanonicalProvider(name) -} - // selectActionTemperature resolves the effective temperature for a code action, // delegating GPT-5 override logic to llmutils.ResolveTemperature. func selectActionTemperature(cfg actionConfig, provider string, entry appconfig.SurfaceConfig, model string) (float64, bool) { @@ -148,14 +144,14 @@ func reqOptsFrom(cfg actionConfig) requestArgs { if core.MaxTokens > 0 { opts = append(opts, llm.WithMaxTokens(core.MaxTokens)) } - provider := canonicalProvider(core.Provider) + provider := llmutils.CanonicalProvider(core.Provider) entries := providers.CodeActionConfigs if len(entries) == 0 { entries = []appconfig.SurfaceConfig{{Provider: core.Provider, Model: strings.TrimSpace(llmutils.DefaultModelForProvider(fullCfg, provider))}} } primary := entries[0] if strings.TrimSpace(primary.Provider) != "" { - provider = canonicalProvider(primary.Provider) + provider = llmutils.CanonicalProvider(primary.Provider) } model := strings.TrimSpace(primary.Model) if model == "" { 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 { |
