diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-11 08:34:41 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-11 08:34:41 +0300 |
| commit | e95f3fdf0a66ba05ba2c8fb7e755e107f9cf7991 (patch) | |
| tree | 412c7e21ec9c317beb99ed7fe0d4d93a7dacbe50 /internal/hexaiaction/run_more_test.go | |
| parent | 73dadb573f92dca310036e8793932e94277abd62 (diff) | |
Thread context.Context through blocking I/O entry points
Accept ctx as the first parameter on the blocking I/O entry points and
propagate it to downstream blocking calls so the work is cancellable from
the process entry point:
- appconfig.Load / LoadWithOptions: honor ctx before the blocking file
reads, returning defaults on a cancelled context.
- LSP: lsp.Server.Run(ctx) ties the serve loop to the caller context via a
new watchParentContext bridge (cancels the server context, aborting
in-flight LLM work). Threaded through hexailsp.Run/RunWithConfig/
RunWithFactory and runtimeconfig.Store.Reload.
- MCP: mcp.Server.Run(ctx) stops accepting requests once ctx is cancelled;
threaded through hexaimcp.Run/RunWithFactory/RunBackfill.
- editor: RunEditor/OpenTempAndEdit/OpenFile take ctx and use
exec.CommandContext so a cancelled context kills the editor subprocess;
threaded through hexaicli, hexaiaction and askcli call sites.
Top-level callers (cmd/hexai-lsp-server, cmd/hexai-mcp-server) now build a
signal-cancelled context (SIGINT/SIGTERM) so shutdown tears the run down
cleanly. Updated comments to explain the cancellation flow and added
cancellation tests for the LSP/MCP loops, editor, and config load.
All tests pass with -race; cross-package coverage 86.2%.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'internal/hexaiaction/run_more_test.go')
| -rw-r--r-- | internal/hexaiaction/run_more_test.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/internal/hexaiaction/run_more_test.go b/internal/hexaiaction/run_more_test.go index 67ffa96..97bcbe9 100644 --- a/internal/hexaiaction/run_more_test.go +++ b/internal/hexaiaction/run_more_test.go @@ -31,7 +31,7 @@ func TestRun_MissingAPIKey(t *testing.T) { func TestRun_NoInput_IsActionable(t *testing.T) { runner := NewRunner() - runner.loadConfig = func(context.Context, *log.Logger) appconfig.App { return appconfig.Load(nil) } + runner.loadConfig = func(context.Context, *log.Logger) appconfig.App { return appconfig.Load(context.Background(), nil) } runner.newClient = func(appconfig.App) (actionClient, error) { return llmFake{}, nil } runner.chooseAction = func(appconfig.App) (actionChoice, error) { return actionChoice{kind: ActionSkip}, nil @@ -62,7 +62,7 @@ func TestHandleDiagnosticsActionInvokesLLM(t *testing.T) { t.Setenv("HEXAI_TMUX_STATUS", "0") parts := InputParts{Diagnostics: []string{"warn1"}, Selection: "code"} client := &stubChatDoer{} - cfg := appconfig.Load(nil) + cfg := appconfig.Load(context.Background(), nil) if _, err := handleDiagnosticsAction(context.Background(), parts, &cfg, client); err != nil { t.Fatalf("handleDiagnosticsAction: %v", err) } @@ -84,7 +84,7 @@ func TestHandleSimplifyActionPassesSelection(t *testing.T) { t.Setenv("HEXAI_TMUX_STATUS", "0") parts := InputParts{Selection: "value := 1"} client := &stubChatDoer{} - cfg := appconfig.Load(nil) + cfg := appconfig.Load(context.Background(), nil) if _, err := handleSimplifyAction(context.Background(), parts, &cfg, client); err != nil { t.Fatalf("handleSimplifyAction: %v", err) } @@ -107,7 +107,7 @@ func TestHandleCustomActionUsesProvidedCustom(t *testing.T) { sel := appconfig.CustomAction{ID: "custom", Title: "Do", Instruction: "do it"} parts := InputParts{Selection: "text"} client := &stubChatDoer{} - cfg := appconfig.Load(nil) + cfg := appconfig.Load(context.Background(), nil) if _, err := handleCustomAction(context.Background(), parts, &cfg, client, &sel); err != nil { t.Fatalf("handleCustomAction: %v", err) } |
