feat: Task 16 — SSH Session Tab (multi-session)
- pkg/tui/session.go — SessionTab with live SSH terminal in a tab - pkg/tui/messages.go — quitMsg, openSessionMsg, sessionOutputMsg - pkg/tui/tabs.go — Tab.Close() interface, Add() returns tea.Cmd - pkg/tui/host_list_tab.go — Enter opens session tab, q quits - pkg/tui/tui.go — handle openSessionMsg/quitMsg, SetDataDir - cmd/hostkeeper/tui.go — pass dataDir to model
This commit is contained in:
+8
-2
@@ -12,6 +12,8 @@ type Tab interface {
|
||||
Update(tea.Msg) (Tab, tea.Cmd)
|
||||
View() string
|
||||
Name() string
|
||||
// Close is called when the tab is removed; implement for cleanup (e.g. disconnect SSH)
|
||||
Close()
|
||||
}
|
||||
|
||||
// TabManager manages multiple tabs
|
||||
@@ -38,10 +40,11 @@ func (tm *TabManager) Active() Tab {
|
||||
return tm.tabs[tm.active]
|
||||
}
|
||||
|
||||
// Add adds a new tab and switches to it
|
||||
func (tm *TabManager) Add(tab Tab) {
|
||||
// Add adds a new tab, switches to it, and returns its init command
|
||||
func (tm *TabManager) Add(tab Tab) tea.Cmd {
|
||||
tm.tabs = append(tm.tabs, tab)
|
||||
tm.active = len(tm.tabs) - 1
|
||||
return tab.Init()
|
||||
}
|
||||
|
||||
// Close removes the tab at index and returns the active tab
|
||||
@@ -50,6 +53,9 @@ func (tm *TabManager) Close(index int) Tab {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Call Close for cleanup (e.g. disconnect SSH)
|
||||
tm.tabs[index].Close()
|
||||
|
||||
tm.tabs = append(tm.tabs[:index], tm.tabs[index+1:]...)
|
||||
|
||||
if len(tm.tabs) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user