feat: better logs page

This commit is contained in:
adamdottv
2025-05-06 14:22:37 -05:00
parent e387b1f16c
commit b638dafe5f
8 changed files with 280 additions and 36 deletions

View File

@@ -439,7 +439,8 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return a, nil
}
if a.currentPage == page.LogsPage {
return a, a.moveToPage(page.ChatPage)
// Always allow returning from logs page, even when agent is busy
return a, a.moveToPageUnconditional(page.ChatPage)
}
}
case key.Matches(msg, keys.Logs):
@@ -562,8 +563,9 @@ func (a *appModel) RegisterCommand(cmd dialog.Command) {
}
func (a *appModel) moveToPage(pageID page.PageID) tea.Cmd {
if a.app.CoderAgent.IsBusy() {
// For now we don't move to any page if the agent is busy
// Allow navigating to logs page even when agent is busy
if a.app.CoderAgent.IsBusy() && pageID != page.LogsPage {
// Don't move to other pages if the agent is busy
return util.ReportWarn("Agent is busy, please wait...")
}
@@ -583,6 +585,24 @@ func (a *appModel) moveToPage(pageID page.PageID) tea.Cmd {
return tea.Batch(cmds...)
}
// moveToPageUnconditional is like moveToPage but doesn't check if the agent is busy
func (a *appModel) moveToPageUnconditional(pageID page.PageID) tea.Cmd {
var cmds []tea.Cmd
if _, ok := a.loadedPages[pageID]; !ok {
cmd := a.pages[pageID].Init()
cmds = append(cmds, cmd)
a.loadedPages[pageID] = true
}
a.previousPage = a.currentPage
a.currentPage = pageID
if sizable, ok := a.pages[a.currentPage].(layout.Sizeable); ok {
cmd := sizable.SetSize(a.width, a.height)
cmds = append(cmds, cmd)
}
return tea.Batch(cmds...)
}
func (a appModel) View() string {
components := []string{
a.pages[a.currentPage].View(),