summaryrefslogtreecommitdiff
path: root/internal/hexaiaction
diff options
context:
space:
mode:
Diffstat (limited to 'internal/hexaiaction')
-rw-r--r--internal/hexaiaction/run.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/internal/hexaiaction/run.go b/internal/hexaiaction/run.go
index a5f47cf..2a1f940 100644
--- a/internal/hexaiaction/run.go
+++ b/internal/hexaiaction/run.go
@@ -23,13 +23,15 @@ var (
newClientFromApp = llmutils.NewClientFromApp
)
+type configPathKey struct{}
+
// selectedCustom carries the chosen custom action (if any) from the TUI submenu
// to the executor. Cleared after use.
var selectedCustom *appconfig.CustomAction
func Run(ctx context.Context, stdin io.Reader, stdout, stderr io.Writer) error {
logger := log.New(stderr, "hexai-tmux-action ", log.LstdFlags|log.Lmsgprefix)
- cfg := appconfig.Load(logger)
+ cfg := appconfig.LoadWithOptions(logger, appconfig.LoadOptions{ConfigPath: configPathFromContext(ctx)})
if cfg.StatsWindowMinutes > 0 {
stats.SetWindow(time.Duration(cfg.StatsWindowMinutes) * time.Minute)
}
@@ -77,6 +79,24 @@ func Run(ctx context.Context, stdin io.Reader, stdout, stderr io.Writer) error {
return nil
}
+// WithConfigPath attaches a config path override to the context for Run/RunCommand.
+func WithConfigPath(ctx context.Context, path string) context.Context {
+ if ctx == nil {
+ ctx = context.Background()
+ }
+ return context.WithValue(ctx, configPathKey{}, strings.TrimSpace(path))
+}
+
+func configPathFromContext(ctx context.Context) string {
+ if ctx == nil {
+ return ""
+ }
+ if v, ok := ctx.Value(configPathKey{}).(string); ok {
+ return strings.TrimSpace(v)
+ }
+ return ""
+}
+
func executeAction(ctx context.Context, kind ActionKind, parts InputParts, cfg appconfig.App, client chatDoer, stderr io.Writer) (string, error) {
switch kind {
case ActionSkip: