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

Method handleClearSession

pkg/tui/tui.go:1426–1462  ·  view source on GitHub ↗

handleClearSession resets the current tab by creating a fresh session in the same working directory.

()

Source from the content-addressed store, hash-verified

1424// handleClearSession resets the current tab by creating a fresh session
1425// in the same working directory.
1426func (m *appModel) handleClearSession() (tea.Model, tea.Cmd) {
1427 activeID := m.supervisor.ActiveID()
1428
1429 // Cleanup old editor for the active session.
1430 if ed, ok := m.editors[activeID]; ok {
1431 ed.Cleanup()
1432 }
1433
1434 // Create a fresh session in the same app, preserving the working dir.
1435 m.application.NewSession()
1436 newSess := m.application.Session()
1437
1438 // Rebuild all per-session UI components.
1439 m.initSessionComponents(activeID, m.application, newSess)
1440 m.dialogMgr = dialog.New()
1441 m.supervisor.SetRunnerTitle(activeID, "")
1442 m.sessionState.SetSessionTitle("")
1443 m.sessionState.SetPreviousMessage(nil)
1444
1445 // Update persisted tab to point to the new session.
1446 if m.tuiStore != nil {
1447 ctx := m.ctx()
1448 oldPersistedID := m.persistedSessionID(activeID)
1449 if err := m.tuiStore.UpdateTabSessionID(ctx, oldPersistedID, newSess.ID); err != nil {
1450 slog.WarnContext(ctx, "Failed to update tab session ID after clear", "error", err)
1451 }
1452 }
1453 m.persistActiveTab(newSess.ID)
1454
1455 m.reapplyKeyboardEnhancements()
1456
1457 return m, tea.Sequence(
1458 m.chatPage.Init(),
1459 m.resizeAll(),
1460 m.editor.Focus(),
1461 )
1462}
1463
1464// handleSpawnSession spawns a new session.
1465func (m *appModel) handleSpawnSession(workingDir string) (tea.Model, tea.Cmd) {

Callers 1

updateMethod · 0.95

Calls 15

initSessionComponentsMethod · 0.95
persistedSessionIDMethod · 0.95
persistActiveTabMethod · 0.95
resizeAllMethod · 0.95
NewFunction · 0.92
ActiveIDMethod · 0.80
SessionMethod · 0.80
SetRunnerTitleMethod · 0.80
SetSessionTitleMethod · 0.80
SetPreviousMessageMethod · 0.80
UpdateTabSessionIDMethod · 0.80

Tested by

no test coverage detected