summaryrefslogtreecommitdiffhomepage
path: root/internal/tui/components
diff options
context:
space:
mode:
authoradamdottv <[email protected]>2025-05-06 14:22:37 -0500
committeradamdottv <[email protected]>2025-05-06 14:22:37 -0500
commitb638dafe5fb2b6fcdd6d9b64502a7808f3e81eb5 (patch)
tree6f6729fcc08a042812b642ef6acb8fc4d9db9b9b /internal/tui/components
parente387b1f16c2a7630c7f2ea29b39d4f50b1760ad7 (diff)
downloadopencode-b638dafe5fb2b6fcdd6d9b64502a7808f3e81eb5.tar.gz
opencode-b638dafe5fb2b6fcdd6d9b64502a7808f3e81eb5.zip
feat: better logs page
Diffstat (limited to 'internal/tui/components')
-rw-r--r--internal/tui/components/logs/details.go21
-rw-r--r--internal/tui/components/logs/table.go44
2 files changed, 53 insertions, 12 deletions
diff --git a/internal/tui/components/logs/details.go b/internal/tui/components/logs/details.go
index 9d7713bbf..7bbfd17dc 100644
--- a/internal/tui/components/logs/details.go
+++ b/internal/tui/components/logs/details.go
@@ -25,6 +25,7 @@ type detailCmp struct {
width, height int
currentLog logging.LogMessage
viewport viewport.Model
+ focused bool
}
func (i *detailCmp) Init() tea.Cmd {
@@ -37,12 +38,21 @@ func (i *detailCmp) Init() tea.Cmd {
}
func (i *detailCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
+ var cmd tea.Cmd
switch msg := msg.(type) {
case selectedLogMsg:
if msg.ID != i.currentLog.ID {
i.currentLog = logging.LogMessage(msg)
i.updateContent()
}
+ case tea.KeyMsg:
+ // Only process keyboard input when focused
+ if !i.focused {
+ return i, nil
+ }
+ // Handle keyboard input for scrolling
+ i.viewport, cmd = i.viewport.Update(msg)
+ return i, cmd
}
return i, nil
@@ -141,3 +151,14 @@ func NewLogsDetails() DetailComponent {
viewport: viewport.New(0, 0),
}
}
+
+// Focus implements the focusable interface
+func (i *detailCmp) Focus() {
+ i.focused = true
+ i.viewport.SetYOffset(i.viewport.YOffset)
+}
+
+// Blur implements the blurable interface
+func (i *detailCmp) Blur() {
+ i.focused = false
+}
diff --git a/internal/tui/components/logs/table.go b/internal/tui/components/logs/table.go
index a6a39c198..fe30c6aa0 100644
--- a/internal/tui/components/logs/table.go
+++ b/internal/tui/components/logs/table.go
@@ -21,7 +21,8 @@ type TableComponent interface {
}
type tableCmp struct {
- table table.Model
+ table table.Model
+ focused bool
}
type selectedLogMsg logging.LogMessage
@@ -38,24 +39,30 @@ func (i *tableCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
i.setRows()
return i, nil
}
- prevSelectedRow := i.table.SelectedRow()
+
+ // Only process keyboard input when focused
+ if _, ok := msg.(tea.KeyMsg); ok && !i.focused {
+ return i, nil
+ }
+
t, cmd := i.table.Update(msg)
cmds = append(cmds, cmd)
i.table = t
selectedRow := i.table.SelectedRow()
if selectedRow != nil {
- if prevSelectedRow == nil || selectedRow[0] == prevSelectedRow[0] {
- var log logging.LogMessage
- for _, row := range logging.List() {
- if row.ID == selectedRow[0] {
- log = row
- break
- }
- }
- if log.ID != "" {
- cmds = append(cmds, util.CmdHandler(selectedLogMsg(log)))
+ // Always send the selected log message when a row is selected
+ // This fixes the issue where navigation doesn't update the detail pane
+ // when returning to the logs page
+ var log logging.LogMessage
+ for _, row := range logging.List() {
+ if row.ID == selectedRow[0] {
+ log = row
+ break
}
}
+ if log.ID != "" {
+ cmds = append(cmds, util.CmdHandler(selectedLogMsg(log)))
+ }
}
return i, tea.Batch(cmds...)
}
@@ -141,3 +148,16 @@ func NewLogsTable() TableComponent {
table: tableModel,
}
}
+
+// Focus implements the focusable interface
+func (i *tableCmp) Focus() {
+ i.focused = true
+ i.table.Focus()
+}
+
+// Blur implements the blurable interface
+func (i *tableCmp) Blur() {
+ i.focused = false
+ // Table doesn't have a Blur method, but we can implement it here
+ // to satisfy the interface
+}