diff options
| author | adamdottv <[email protected]> | 2025-05-08 07:43:31 -0500 |
|---|---|---|
| committer | adamdottv <[email protected]> | 2025-05-08 07:58:37 -0500 |
| commit | bab17d75208ffca043ff85c258ec42507d955a1e (patch) | |
| tree | 7a497b108ecba5a4a8a82b7ddc727fc2c240c435 /internal/tui | |
| parent | 051d7d7936abbb20a2d165d5a356fc6fe0199a27 (diff) | |
| download | opencode-bab17d75208ffca043ff85c258ec42507d955a1e.tar.gz opencode-bab17d75208ffca043ff85c258ec42507d955a1e.zip | |
feat: session manager
Diffstat (limited to 'internal/tui')
| -rw-r--r-- | internal/tui/components/dialog/session.go | 5 | ||||
| -rw-r--r-- | internal/tui/page/chat.go | 9 |
2 files changed, 10 insertions, 4 deletions
diff --git a/internal/tui/components/dialog/session.go b/internal/tui/components/dialog/session.go index a29fa7131..174e4bed9 100644 --- a/internal/tui/components/dialog/session.go +++ b/internal/tui/components/dialog/session.go @@ -91,8 +91,11 @@ func (s *sessionDialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return s, nil case key.Matches(msg, sessionKeys.Enter): if len(s.sessions) > 0 { + selectedSession := s.sessions[s.selectedIdx] + // Update the session manager with the selected session + session.SetCurrentSession(selectedSession.ID) return s, util.CmdHandler(SessionSelectedMsg{ - Session: s.sessions[s.selectedIdx], + Session: selectedSession, }) } case key.Matches(msg, sessionKeys.Escape): diff --git a/internal/tui/page/chat.go b/internal/tui/page/chat.go index 8afd18c22..afb9c8a4c 100644 --- a/internal/tui/page/chat.go +++ b/internal/tui/page/chat.go @@ -128,17 +128,20 @@ func (p *chatPage) clearSidebar() tea.Cmd { func (p *chatPage) sendMessage(text string, attachments []message.Attachment) tea.Cmd { var cmds []tea.Cmd if p.session.ID == "" { - session, err := p.app.Sessions.Create(context.Background(), "New Session") + newSession, err := p.app.Sessions.Create(context.Background(), "New Session") if err != nil { return util.ReportError(err) } - p.session = session + p.session = newSession + // Update the current session in the session manager + session.SetCurrentSession(newSession.ID) + cmd := p.setSidebar() if cmd != nil { cmds = append(cmds, cmd) } - cmds = append(cmds, util.CmdHandler(chat.SessionSelectedMsg(session))) + cmds = append(cmds, util.CmdHandler(chat.SessionSelectedMsg(newSession))) } _, err := p.app.CoderAgent.Run(context.Background(), p.session.ID, text, attachments...) |
