@@ -4,6 +4,7 @@ import (
44 "context"
55 "image"
66 "regexp"
7+ "sync/atomic"
78 "time"
89
910 tea "charm.land/bubbletea/v2"
@@ -217,6 +218,7 @@ type Model struct {
217218 providerOpts provider.Options
218219 currentModelName string
219220 cachedModels []provider.TaggedModel // cached across all providers
221+ sharedProvider *atomic.Pointer[provider.Provider]
220222 // Pending tool calls: maps tool call ID → arguments for line extraction
221223 pendingToolCalls map[string]provider.ToolCall
222224
@@ -238,8 +240,8 @@ type Model struct {
238240 gitModified int
239241 gitRemoved int
240242
241- lastNetError string // Last LLM network error (truncated for display)
242- llmInFlight bool // True while an LLM turn is in progress
243+ lastNetError string // Last LLM network error (truncated for display)
244+ llmInFlight bool // True while an LLM turn is in progress
243245
244246 // Statusbar animation
245247 spinFrame int // Current braille spinner frame index
@@ -249,7 +251,7 @@ type Model struct {
249251 // New creates a new TUI model.
250252 // If resumeHistory is non-nil, the session is being resumed and messages are
251253 // loaded from the database instead of creating a fresh system prompt.
252-func New(prov provider.Provider, proxy *mcp.Proxy, tools []mcp.Tool, modelID string, db *store.Cache, sessionID string, idx *treesitter.Index, dt *delta.Tracker, ft FileReadResetter, providerConfigName string, pad llm.ScratchpadReader, resumeHistory []provider.Message, registry *provider.Registry, providerOpts provider.Options, syntaxTheme string) Model {
254+func New(prov provider.Provider, sharedProvider *atomic.Pointer[provider.Provider], proxy *mcp.Proxy, tools []mcp.Tool, modelID string, db *store.Cache, sessionID string, idx *treesitter.Index, dt *delta.Tracker, ft FileReadResetter, providerConfigName string, pad llm.ScratchpadReader, resumeHistory []provider.Message, registry *provider.Registry, providerOpts provider.Options, syntaxTheme string) Model {
253255 initTheme(syntaxTheme)
254256 sty := DefaultStyles()
255257 cursorStyle := lipgloss.NewStyle().Foreground(ColorHighlight)
@@ -313,6 +315,7 @@ func New(prov provider.Provider, proxy *mcp.Proxy, tools []mcp.Tool, modelID str
313315 registry: registry,
314316 providerOpts: providerOpts,
315317 currentModelName: modelID,
318+ sharedProvider: sharedProvider,
316319
317320 streamEntryStart: -1,
318321