handleSpawnSession spawns a new session.
(workingDir string)
| 1463 | |
| 1464 | // handleSpawnSession spawns a new session. |
| 1465 | func (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. |
| 1490 | func (m *appModel) openWorkingDirPicker() (tea.Model, tea.Cmd) { |
no test coverage detected