MCPcopy
hub / github.com/docker/docker-agent / handleSpawnSession

Method handleSpawnSession

pkg/tui/tui.go:1465–1487  ·  view source on GitHub ↗

handleSpawnSession spawns a new session.

(workingDir string)

Source from the content-addressed store, hash-verified

1463
1464// handleSpawnSession spawns a new session.
1465func (m *appModel) handleSpawnSession(workingDir string) (tea.Model, tea.Cmd) {
1466 // If no working dir specified, open the picker
1467 if workingDir == "" {
1468 return m.openWorkingDirPicker()
1469 }
1470
1471 // Spawn the new session
1472 ctx := m.ctx()
1473 sessionID, err := m.supervisor.SpawnSession(ctx, workingDir)
1474 if err != nil {
1475 return m, notification.ErrorCmd("Failed to spawn session: " + err.Error())
1476 }
1477
1478 // Persist the new tab (for new tabs, persisted ID == runtime tab ID).
1479 if m.tuiStore != nil {
1480 if err := m.tuiStore.AddTab(ctx, sessionID, workingDir); err != nil {
1481 slog.WarnContext(ctx, "Failed to persist new tab", "error", err)
1482 }
1483 }
1484
1485 // Switch to the new session
1486 return m.handleSwitchTab(sessionID)
1487}
1488
1489// openWorkingDirPicker opens the working directory picker dialog.
1490func (m *appModel) openWorkingDirPicker() (tea.Model, tea.Cmd) {

Callers 3

updateMethod · 0.95
handleCloseTabMethod · 0.95
handleMouseClickMethod · 0.95

Calls 6

openWorkingDirPickerMethod · 0.95
handleSwitchTabMethod · 0.95
ErrorCmdFunction · 0.92
SpawnSessionMethod · 0.80
AddTabMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected