MCPcopy Create free account
hub / github.com/diillson/chatcli / acquireOperationContext

Method acquireOperationContext

cli/cli_llm.go:152–163  ·  view source on GitHub ↗

acquireOperationContext creates the cancellable context that drives the turn and stashes its cancel func in cli.operationCancel so /reset can interrupt mid-turn. The returned release closure clears the slot and fires cancel exactly once.

(parent context.Context)

Source from the content-addressed store, hash-verified

150// interrupt mid-turn. The returned release closure clears the slot and
151// fires cancel exactly once.
152func (cli *ChatCLI) acquireOperationContext(parent context.Context) (context.Context, func()) {
153 ctx, cancel := context.WithCancel(parent)
154 cli.mu.Lock()
155 cli.operationCancel = cancel
156 cli.mu.Unlock()
157 return ctx, func() {
158 cli.mu.Lock()
159 cli.operationCancel = nil
160 cli.mu.Unlock()
161 cancel()
162 }
163}
164
165// fireUserPromptSubmitHook publishes the UserPromptSubmit event when the
166// hook manager is enabled. Best-effort: hooks run asynchronously and any

Calls 2

LockMethod · 0.80
UnlockMethod · 0.80