@@ -1,37 +1,82 @@
1package page
1package page
4+ "github.com/charmbracelet/bubbles/key"
4 tea "github.com/charmbracelet/bubbletea"
5 tea "github.com/charmbracelet/bubbletea"
6+ "github.com/charmbracelet/lipgloss"
5 "github.com/kujtimiihoxha/opencode/internal/tui/components/logs"
7 "github.com/kujtimiihoxha/opencode/internal/tui/components/logs"
6 "github.com/kujtimiihoxha/opencode/internal/tui/layout"
8 "github.com/kujtimiihoxha/opencode/internal/tui/layout"
9+ "github.com/kujtimiihoxha/opencode/internal/tui/styles"
9var LogsPage PageID = "logs"
12var LogsPage PageID = "logs"
11−type logsPage struct {
14+type LogPage interface {
12− table logs.TableComponent
15+ tea.Model
13− details logs.DetailComponent
16+ layout.Sizeable
15−
19+type logsPage struct {
16−func (p *logsPage) Init() tea.Cmd {
20+ width, height int
17− return nil
21+ table layout.Container
22+ details layout.Container
20func (p *logsPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
25func (p *logsPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
26+ switch msg := msg.(type) {
27+ case tea.WindowSizeMsg:
29+ p.height = msg.Height
30+ p.table.SetSize(msg.Width, msg.Height/2)
31+ p.details.SetSize(msg.Width, msg.Height/2)
35+ table, cmd := p.table.Update(msg)
36+ cmds = append(cmds, cmd)
37+ p.table = table.(layout.Container)
38+ details, cmd := p.details.Update(msg)
39+ cmds = append(cmds, cmd)
40+ p.details = details.(layout.Container)
21− return p, nil
42+ return p, tea.Batch(cmds...)
24func (p *logsPage) View() string {
45func (p *logsPage) View() string {
46+ style := styles.BaseStyle.Width(p.width).Height(p.height)
47+ return style.Render(lipgloss.JoinVertical(lipgloss.Top,
25− return p.table.View() + "\n" + p.details.View()
49+ p.details.View(),
53+func (p *logsPage) BindingKeys() []key.Binding {
54+ return p.table.BindingKeys()
28−func NewLogsPage() tea.Model {
57+// GetSize implements LogPage.
29− return layout.NewBentoLayout(
58+func (p *logsPage) GetSize() (int, int) {
30− layout.BentoPanes{
59+ return p.width, p.height
31− layout.BentoRightTopPane: logs.NewLogsTable(),
60+}
32− layout.BentoRightBottomPane: logs.NewLogsDetails(),
61+
62+// SetSize implements LogPage.
63+func (p *logsPage) SetSize(width int, height int) {
66+ p.table.SetSize(width, height/2)
67+ p.details.SetSize(width, height/2)
34− layout.WithBentoLayoutCurrentPane(layout.BentoRightTopPane),
69+
35− layout.WithBentoLayoutRightTopHeightRatio(0.5),
70+func (p *logsPage) Init() tea.Cmd {
77+func NewLogsPage() LogPage {
79+ table: layout.NewContainer(logs.NewLogsTable(), layout.WithBorderAll(), layout.WithBorderColor(styles.ForgroundDim)),
80+ details: layout.NewContainer(logs.NewLogsDetails(), layout.WithBorderAll(), layout.WithBorderColor(styles.ForgroundDim)),