The open source coding agent.
TypeScript
feat(tui): simpler layout, always stretched
adamdotdevin611854e4b68a
diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.tsindex 5086e5bba7e..b6c2043875d 100644--- a/packages/opencode/src/config/config.ts+++ b/packages/opencode/src/config/config.ts@@ -31,9 +31,6 @@ export namespace Config {const os = await import("os")result.username = os.userInfo().username}- if (!result.layout) {- result.layout = "auto"- }log.info("loaded", result)@@ -176,7 +173,7 @@ export namespace Config {.describe("Custom provider configurations and model overrides"),mcp: z.record(z.string(), Mcp).optional().describe("MCP (Model Context Protocol) server configurations"),instructions: z.array(z.string()).optional().describe("Additional instruction files or patterns to include"),- layout: Layout.optional().describe("Layout to use for the TUI"),+ layout: Layout.optional().describe("@deprecated Always uses stretch layout."),experimental: z.object({hook: zdiff --git a/packages/tui/internal/app/constants.go b/packages/tui/internal/app/constants.godeleted file mode 100644index 0d37833f57f..00000000000--- a/packages/tui/internal/app/constants.go+++ /dev/null@@ -1,4 +0,0 @@-package app--const MAX_CONTAINER_WIDTH = 86-const EDIT_DIFF_MAX_WIDTH = 180diff --git a/packages/tui/internal/components/chat/editor.go b/packages/tui/internal/components/chat/editor.goindex 6875533429c..ef129765fb8 100644--- a/packages/tui/internal/components/chat/editor.go+++ b/packages/tui/internal/components/chat/editor.go@@ -64,10 +64,7 @@ func (m *editorComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {switch msg := msg.(type) {case tea.WindowSizeMsg:- m.width = min(msg.Width-4, app.MAX_CONTAINER_WIDTH)- if m.app.Config.Layout == opencode.LayoutConfigStretch {- m.width = msg.Width - 4- }+ m.width = msg.Width - 4return m, nilcase spinner.TickMsg:m.spinner, cmd = m.spinner.Update(msg)@@ -180,6 +177,11 @@ func (m *editorComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {}func (m *editorComponent) Content() string {+ width := m.width+ if m.app.Session.ID == "" {+ width = min(width, 80)+ }+t := theme.CurrentTheme()base := styles.NewStyle().Foreground(t.Text()).Background(t.Background()).Rendermuted := styles.NewStyle().Foreground(t.TextMuted()).Background(t.Background()).Render@@ -188,7 +190,7 @@ func (m *editorComponent) Content() string {Bold(true)prompt := promptStyle.Render(">")- m.textarea.SetWidth(m.width - 6)+ m.textarea.SetWidth(width - 6)textarea := lipgloss.JoinHorizontal(lipgloss.Top,prompt,@@ -200,7 +202,7 @@ func (m *editorComponent) Content() string {}textarea = styles.NewStyle().Background(t.BackgroundElement()).- Width(m.width).+ Width(width).PaddingTop(1).PaddingBottom(1).BorderStyle(lipgloss.ThickBorder()).@@ -236,7 +238,7 @@ func (m *editorComponent) Content() string {model = muted(m.app.Provider.Name) + base(" "+m.app.Model.Name)}- space := m.width - 2 - lipgloss.Width(model) - lipgloss.Width(hint)+ space := width - 2 - lipgloss.Width(model) - lipgloss.Width(hint)spacer := styles.NewStyle().Background(t.Background()).Width(space).Render("")info := hint + spacer + model@@ -247,9 +249,14 @@ func (m *editorComponent) Content() string {}func (m *editorComponent) View() string {+ width := m.width+ if m.app.Session.ID == "" {+ width = min(width, 80)+ }+if m.Lines() > 1 {return lipgloss.Place(- m.width,+ width,5,lipgloss.Center,lipgloss.Center,diff --git a/packages/tui/internal/components/chat/messages.go b/packages/tui/internal/components/chat/messages.goindex bf0c4d8f680..acc7b8879cf 100644--- a/packages/tui/internal/components/chat/messages.go+++ b/packages/tui/internal/components/chat/messages.go@@ -146,10 +146,7 @@ func (m *messagesComponent) renderView() tea.Cmd {orphanedToolCalls := make([]opencode.ToolPart, 0)- width := min(m.width, app.MAX_CONTAINER_WIDTH)- if m.app.Config.Layout == opencode.LayoutConfigStretch {- width = m.width- }+ width := m.width // always use full widthfor _, message := range m.app.Messages {var content string@@ -320,13 +317,6 @@ func (m *messagesComponent) renderView() tea.Cmd {continue}- width := width- if m.app.Config.Layout == opencode.LayoutConfigAuto &&- part.Tool == "edit" &&- part.State.Error == "" {- width = min(m.width, app.EDIT_DIFF_MAX_WIDTH)- }-if part.State.Status == opencode.ToolPartStateStatusCompleted || part.State.Status == opencode.ToolPartStateStatusError {key := m.cache.GenerateKey(casted.ID,part.ID,@@ -419,10 +409,7 @@ func (m *messagesComponent) renderHeader() string {return ""}- headerWidth := min(m.width, app.MAX_CONTAINER_WIDTH)- if m.app.Config.Layout == opencode.LayoutConfigStretch {- headerWidth = m.width- }+ headerWidth := m.widtht := theme.CurrentTheme()base := styles.NewStyle().Foreground(t.Text()).Background(t.Background()).Renderdiff --git a/packages/tui/internal/tui/tui.go b/packages/tui/internal/tui/tui.goindex b201a908698..a81c1a6ba72 100644--- a/packages/tui/internal/tui/tui.go+++ b/packages/tui/internal/tui/tui.go@@ -439,7 +439,7 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {case tea.WindowSizeMsg:msg.Height -= 2 // Make space for the status bara.width, a.height = msg.Width, msg.Height- container := min(a.width, app.MAX_CONTAINER_WIDTH)+ container := min(a.width, 86)layout.Current = &layout.LayoutInfo{Viewport: layout.Dimensions{Width: a.width,diff --git a/packages/tui/sdk/.stats.yml b/packages/tui/sdk/.stats.ymlindex 0f1eb3f1109..02591cbbbe8 100644--- a/packages/tui/sdk/.stats.yml+++ b/packages/tui/sdk/.stats.yml@@ -1,4 +1,4 @@configured_endpoints: 22-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-d34620b462127c45497743c97fd3569f9e629d9fbd97c0707087eeddbd4b3de1.yml-openapi_spec_hash: 23864c98d555350fe56f1d0e56f205c5-config_hash: a8441af7cb2db855d79fd372ee3b9fb1+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-a1da357fcefd3105736841fbf44018022fade78e67ffc81e178cf9196da723ee.yml+openapi_spec_hash: 9bd27afcc5b8f43d8e4223f7c984035f+config_hash: 62b73a3397120578a992bffd1e69386adiff --git a/packages/tui/sdk/api.md b/packages/tui/sdk/api.mdindex 68320cc04fd..15b177e92e5 100644--- a/packages/tui/sdk/api.md+++ b/packages/tui/sdk/api.md@@ -64,7 +64,6 @@ Response Types:- <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>- <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>-- <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>- <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>- <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>- <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>diff --git a/packages/tui/sdk/config.go b/packages/tui/sdk/config.goindex f54c6a75aa8..34788dacd46 100644--- a/packages/tui/sdk/config.go+++ b/packages/tui/sdk/config.go@@ -55,8 +55,8 @@ type Config struct {Instructions []string `json:"instructions"`// Custom keybind configurationsKeybinds KeybindsConfig `json:"keybinds"`- // Layout to use for the TUI- Layout LayoutConfig `json:"layout"`+ // @deprecated Always uses stretch layout.+ Layout ConfigLayout `json:"layout"`// Minimum log level to write to log filesLogLevel LogLevel `json:"log_level"`// MCP (Model Context Protocol) server configurations@@ -197,6 +197,22 @@ func (r configExperimentalHookSessionCompletedJSON) RawJSON() string {return r.raw}+// @deprecated Always uses stretch layout.+type ConfigLayout string++const (+ ConfigLayoutAuto ConfigLayout = "auto"+ ConfigLayoutStretch ConfigLayout = "stretch"+)++func (r ConfigLayout) IsKnown() bool {+ switch r {+ case ConfigLayoutAuto, ConfigLayoutStretch:+ return true+ }+ return false+}+type ConfigMcp struct {// Type of MCP server connectionType ConfigMcpType `json:"type,required"`@@ -574,21 +590,6 @@ func (r keybindsConfigJSON) RawJSON() string {return r.raw}-type LayoutConfig string--const (- LayoutConfigAuto LayoutConfig = "auto"- LayoutConfigStretch LayoutConfig = "stretch"-)--func (r LayoutConfig) IsKnown() bool {- switch r {- case LayoutConfigAuto, LayoutConfigStretch:- return true- }- return false-}-type McpLocalConfig struct {// Command and arguments to run the MCP serverCommand []string `json:"command,required"`diff --git a/stainless.yml b/stainless.ymlindex 1bfc0ef9965..42f42b4cdb3 100644--- a/stainless.yml+++ b/stainless.yml@@ -82,7 +82,6 @@ resources:mcpLocalConfig: McpLocalConfigmcpRemoteConfig: McpRemoteConfigmodeConfig: ModeConfig- layoutConfig: LayoutConfigmethods:get: get /config