Skip to content

Commit b2f9144

Browse files
adamdotdevinnipuna-perera
authored andcommitted
feat(tui): simpler layout, always stretched
1 parent 29cd5b4 commit b2f9144

File tree

9 files changed

+40
-54
lines changed

9 files changed

+40
-54
lines changed

packages/opencode/src/config/config.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ export namespace Config {
3131
const os = await import("os")
3232
result.username = os.userInfo().username
3333
}
34-
if (!result.layout) {
35-
result.layout = "auto"
36-
}
3734

3835
log.info("loaded", result)
3936

@@ -176,7 +173,7 @@ export namespace Config {
176173
.describe("Custom provider configurations and model overrides"),
177174
mcp: z.record(z.string(), Mcp).optional().describe("MCP (Model Context Protocol) server configurations"),
178175
instructions: z.array(z.string()).optional().describe("Additional instruction files or patterns to include"),
179-
layout: Layout.optional().describe("Layout to use for the TUI"),
176+
layout: Layout.optional().describe("@deprecated Always uses stretch layout."),
180177
experimental: z
181178
.object({
182179
hook: z

packages/tui/internal/app/constants.go

Lines changed: 0 additions & 4 deletions
This file was deleted.

packages/tui/internal/components/chat/editor.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,7 @@ func (m *editorComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
6464

6565
switch msg := msg.(type) {
6666
case tea.WindowSizeMsg:
67-
m.width = min(msg.Width-4, app.MAX_CONTAINER_WIDTH)
68-
if m.app.Config.Layout == opencode.LayoutConfigStretch {
69-
m.width = msg.Width - 4
70-
}
67+
m.width = msg.Width - 4
7168
return m, nil
7269
case spinner.TickMsg:
7370
m.spinner, cmd = m.spinner.Update(msg)
@@ -180,6 +177,11 @@ func (m *editorComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
180177
}
181178

182179
func (m *editorComponent) Content() string {
180+
width := m.width
181+
if m.app.Session.ID == "" {
182+
width = min(width, 80)
183+
}
184+
183185
t := theme.CurrentTheme()
184186
base := styles.NewStyle().Foreground(t.Text()).Background(t.Background()).Render
185187
muted := styles.NewStyle().Foreground(t.TextMuted()).Background(t.Background()).Render
@@ -188,7 +190,7 @@ func (m *editorComponent) Content() string {
188190
Bold(true)
189191
prompt := promptStyle.Render(">")
190192

191-
m.textarea.SetWidth(m.width - 6)
193+
m.textarea.SetWidth(width - 6)
192194
textarea := lipgloss.JoinHorizontal(
193195
lipgloss.Top,
194196
prompt,
@@ -200,7 +202,7 @@ func (m *editorComponent) Content() string {
200202
}
201203
textarea = styles.NewStyle().
202204
Background(t.BackgroundElement()).
203-
Width(m.width).
205+
Width(width).
204206
PaddingTop(1).
205207
PaddingBottom(1).
206208
BorderStyle(lipgloss.ThickBorder()).
@@ -236,7 +238,7 @@ func (m *editorComponent) Content() string {
236238
model = muted(m.app.Provider.Name) + base(" "+m.app.Model.Name)
237239
}
238240

239-
space := m.width - 2 - lipgloss.Width(model) - lipgloss.Width(hint)
241+
space := width - 2 - lipgloss.Width(model) - lipgloss.Width(hint)
240242
spacer := styles.NewStyle().Background(t.Background()).Width(space).Render("")
241243

242244
info := hint + spacer + model
@@ -247,9 +249,14 @@ func (m *editorComponent) Content() string {
247249
}
248250

249251
func (m *editorComponent) View() string {
252+
width := m.width
253+
if m.app.Session.ID == "" {
254+
width = min(width, 80)
255+
}
256+
250257
if m.Lines() > 1 {
251258
return lipgloss.Place(
252-
m.width,
259+
width,
253260
5,
254261
lipgloss.Center,
255262
lipgloss.Center,

packages/tui/internal/components/chat/messages.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,7 @@ func (m *messagesComponent) renderView() tea.Cmd {
146146

147147
orphanedToolCalls := make([]opencode.ToolPart, 0)
148148

149-
width := min(m.width, app.MAX_CONTAINER_WIDTH)
150-
if m.app.Config.Layout == opencode.LayoutConfigStretch {
151-
width = m.width
152-
}
149+
width := m.width // always use full width
153150

154151
for _, message := range m.app.Messages {
155152
var content string
@@ -320,13 +317,6 @@ func (m *messagesComponent) renderView() tea.Cmd {
320317
continue
321318
}
322319

323-
width := width
324-
if m.app.Config.Layout == opencode.LayoutConfigAuto &&
325-
part.Tool == "edit" &&
326-
part.State.Error == "" {
327-
width = min(m.width, app.EDIT_DIFF_MAX_WIDTH)
328-
}
329-
330320
if part.State.Status == opencode.ToolPartStateStatusCompleted || part.State.Status == opencode.ToolPartStateStatusError {
331321
key := m.cache.GenerateKey(casted.ID,
332322
part.ID,
@@ -419,10 +409,7 @@ func (m *messagesComponent) renderHeader() string {
419409
return ""
420410
}
421411

422-
headerWidth := min(m.width, app.MAX_CONTAINER_WIDTH)
423-
if m.app.Config.Layout == opencode.LayoutConfigStretch {
424-
headerWidth = m.width
425-
}
412+
headerWidth := m.width
426413

427414
t := theme.CurrentTheme()
428415
base := styles.NewStyle().Foreground(t.Text()).Background(t.Background()).Render

packages/tui/internal/tui/tui.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
439439
case tea.WindowSizeMsg:
440440
msg.Height -= 2 // Make space for the status bar
441441
a.width, a.height = msg.Width, msg.Height
442-
container := min(a.width, app.MAX_CONTAINER_WIDTH)
442+
container := min(a.width, 86)
443443
layout.Current = &layout.LayoutInfo{
444444
Viewport: layout.Dimensions{
445445
Width: a.width,

packages/tui/sdk/.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 22
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-d34620b462127c45497743c97fd3569f9e629d9fbd97c0707087eeddbd4b3de1.yml
3-
openapi_spec_hash: 23864c98d555350fe56f1d0e56f205c5
4-
config_hash: a8441af7cb2db855d79fd372ee3b9fb1
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-a1da357fcefd3105736841fbf44018022fade78e67ffc81e178cf9196da723ee.yml
3+
openapi_spec_hash: 9bd27afcc5b8f43d8e4223f7c984035f
4+
config_hash: 62b73a3397120578a992bffd1e69386a

packages/tui/sdk/api.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ Response Types:
6464

6565
- <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#Config">Config</a>
6666
- <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#KeybindsConfig">KeybindsConfig</a>
67-
- <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#LayoutConfig">LayoutConfig</a>
6867
- <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#McpLocalConfig">McpLocalConfig</a>
6968
- <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#McpRemoteConfig">McpRemoteConfig</a>
7069
- <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#ModeConfig">ModeConfig</a>

packages/tui/sdk/config.go

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ type Config struct {
5555
Instructions []string `json:"instructions"`
5656
// Custom keybind configurations
5757
Keybinds KeybindsConfig `json:"keybinds"`
58-
// Layout to use for the TUI
59-
Layout LayoutConfig `json:"layout"`
58+
// @deprecated Always uses stretch layout.
59+
Layout ConfigLayout `json:"layout"`
6060
// Minimum log level to write to log files
6161
LogLevel LogLevel `json:"log_level"`
6262
// MCP (Model Context Protocol) server configurations
@@ -197,6 +197,22 @@ func (r configExperimentalHookSessionCompletedJSON) RawJSON() string {
197197
return r.raw
198198
}
199199

200+
// @deprecated Always uses stretch layout.
201+
type ConfigLayout string
202+
203+
const (
204+
ConfigLayoutAuto ConfigLayout = "auto"
205+
ConfigLayoutStretch ConfigLayout = "stretch"
206+
)
207+
208+
func (r ConfigLayout) IsKnown() bool {
209+
switch r {
210+
case ConfigLayoutAuto, ConfigLayoutStretch:
211+
return true
212+
}
213+
return false
214+
}
215+
200216
type ConfigMcp struct {
201217
// Type of MCP server connection
202218
Type ConfigMcpType `json:"type,required"`
@@ -574,21 +590,6 @@ func (r keybindsConfigJSON) RawJSON() string {
574590
return r.raw
575591
}
576592

577-
type LayoutConfig string
578-
579-
const (
580-
LayoutConfigAuto LayoutConfig = "auto"
581-
LayoutConfigStretch LayoutConfig = "stretch"
582-
)
583-
584-
func (r LayoutConfig) IsKnown() bool {
585-
switch r {
586-
case LayoutConfigAuto, LayoutConfigStretch:
587-
return true
588-
}
589-
return false
590-
}
591-
592593
type McpLocalConfig struct {
593594
// Command and arguments to run the MCP server
594595
Command []string `json:"command,required"`

stainless.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ resources:
8282
mcpLocalConfig: McpLocalConfig
8383
mcpRemoteConfig: McpRemoteConfig
8484
modeConfig: ModeConfig
85-
layoutConfig: LayoutConfig
8685
methods:
8786
get: get /config
8887

0 commit comments

Comments
 (0)