feat: add scroll speed to config (#1968)

This commit is contained in:
Aiden Cline
2025-08-15 13:21:02 -05:00
committed by GitHub
parent 57b04d9eb7
commit dc01071498
10 changed files with 116 additions and 62 deletions

View File

@@ -274,6 +274,10 @@ export namespace Config {
ref: "KeybindsConfig", ref: "KeybindsConfig",
}) })
export const TUI = z.object({
scroll_speed: z.number().min(1).optional().default(2).describe("TUI scroll speed"),
})
export const Layout = z.enum(["auto", "stretch"]).openapi({ export const Layout = z.enum(["auto", "stretch"]).openapi({
ref: "LayoutConfig", ref: "LayoutConfig",
}) })
@@ -284,6 +288,7 @@ export namespace Config {
$schema: z.string().optional().describe("JSON schema reference for configuration validation"), $schema: z.string().optional().describe("JSON schema reference for configuration validation"),
theme: z.string().optional().describe("Theme name to use for the interface"), theme: z.string().optional().describe("Theme name to use for the interface"),
keybinds: Keybinds.optional().describe("Custom keybind configurations"), keybinds: Keybinds.optional().describe("Custom keybind configurations"),
tui: TUI.optional().describe("TUI specific settings"),
plugin: z.string().array().optional(), plugin: z.string().array().optional(),
snapshot: z.boolean().optional(), snapshot: z.boolean().optional(),
share: z share: z

View File

@@ -1,4 +1,4 @@
configured_endpoints: 39 configured_endpoints: 39
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-b751e5c3cd3ab7fc61b18fbbfd6092b7264ea2ee305858aa538b884e7c492090.yml openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-e4b6496e5f2c68fa8b3ea1b88e40041eaf5ce2652001344df80bf130675d1766.yml
openapi_spec_hash: a61f8b1d9b834cf321f0cb7805cc8522 openapi_spec_hash: df474311dc9e4a89cd483bd8b8d971d8
config_hash: eab3723c4c2232a6ba1821151259d6da config_hash: eab3723c4c2232a6ba1821151259d6da

View File

@@ -110,7 +110,7 @@ Response Types:
Methods: Methods:
- <code title="post /session">client.Session.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#SessionService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</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#Session">Session</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code> - <code title="post /session">client.Session.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#SessionService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <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#SessionNewParams">SessionNewParams</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#Session">Session</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="patch /session/{id}">client.Session.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#SessionService.Update">Update</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>, body <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#SessionUpdateParams">SessionUpdateParams</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#Session">Session</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code> - <code title="patch /session/{id}">client.Session.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#SessionService.Update">Update</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>, body <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#SessionUpdateParams">SessionUpdateParams</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#Session">Session</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /session">client.Session.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#SessionService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</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#Session">Session</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code> - <code title="get /session">client.Session.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#SessionService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</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#Session">Session</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="delete /session/{id}">client.Session.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#SessionService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/builtin#bool">bool</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code> - <code title="delete /session/{id}">client.Session.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#SessionService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/builtin#bool">bool</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

View File

@@ -80,6 +80,8 @@ type Config struct {
Snapshot bool `json:"snapshot"` Snapshot bool `json:"snapshot"`
// Theme name to use for the interface // Theme name to use for the interface
Theme string `json:"theme"` Theme string `json:"theme"`
// TUI specific settings
Tui ConfigTui `json:"tui"`
// Custom username to display in conversations instead of system username // Custom username to display in conversations instead of system username
Username string `json:"username"` Username string `json:"username"`
JSON configJSON `json:"-"` JSON configJSON `json:"-"`
@@ -108,6 +110,7 @@ type configJSON struct {
SmallModel apijson.Field SmallModel apijson.Field
Snapshot apijson.Field Snapshot apijson.Field
Theme apijson.Field Theme apijson.Field
Tui apijson.Field
Username apijson.Field Username apijson.Field
raw string raw string
ExtraFields map[string]apijson.Field ExtraFields map[string]apijson.Field
@@ -1654,6 +1657,28 @@ func (r ConfigShare) IsKnown() bool {
return false return false
} }
// TUI specific settings
type ConfigTui struct {
// TUI scroll speed
ScrollSpeed float64 `json:"scroll_speed,required"`
JSON configTuiJSON `json:"-"`
}
// configTuiJSON contains the JSON metadata for the struct [ConfigTui]
type configTuiJSON struct {
ScrollSpeed apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ConfigTui) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r configTuiJSON) RawJSON() string {
return r.raw
}
type KeybindsConfig struct { type KeybindsConfig struct {
// Next agent // Next agent
AgentCycle string `json:"agent_cycle,required"` AgentCycle string `json:"agent_cycle,required"`
@@ -1719,6 +1744,10 @@ type KeybindsConfig struct {
ModelList string `json:"model_list,required"` ModelList string `json:"model_list,required"`
// Create/update AGENTS.md // Create/update AGENTS.md
ProjectInit string `json:"project_init,required"` ProjectInit string `json:"project_init,required"`
// Cycle to next child session
SessionChildCycle string `json:"session_child_cycle,required"`
// Cycle to previous child session
SessionChildCycleReverse string `json:"session_child_cycle_reverse,required"`
// Compact the session // Compact the session
SessionCompact string `json:"session_compact,required"` SessionCompact string `json:"session_compact,required"`
// Export session to editor // Export session to editor
@@ -1752,54 +1781,56 @@ type KeybindsConfig struct {
// keybindsConfigJSON contains the JSON metadata for the struct [KeybindsConfig] // keybindsConfigJSON contains the JSON metadata for the struct [KeybindsConfig]
type keybindsConfigJSON struct { type keybindsConfigJSON struct {
AgentCycle apijson.Field AgentCycle apijson.Field
AgentCycleReverse apijson.Field AgentCycleReverse apijson.Field
AgentList apijson.Field AgentList apijson.Field
AppExit apijson.Field AppExit apijson.Field
AppHelp apijson.Field AppHelp apijson.Field
EditorOpen apijson.Field EditorOpen apijson.Field
FileClose apijson.Field FileClose apijson.Field
FileDiffToggle apijson.Field FileDiffToggle apijson.Field
FileList apijson.Field FileList apijson.Field
FileSearch apijson.Field FileSearch apijson.Field
InputClear apijson.Field InputClear apijson.Field
InputNewline apijson.Field InputNewline apijson.Field
InputPaste apijson.Field InputPaste apijson.Field
InputSubmit apijson.Field InputSubmit apijson.Field
Leader apijson.Field Leader apijson.Field
MessagesCopy apijson.Field MessagesCopy apijson.Field
MessagesFirst apijson.Field MessagesFirst apijson.Field
MessagesHalfPageDown apijson.Field MessagesHalfPageDown apijson.Field
MessagesHalfPageUp apijson.Field MessagesHalfPageUp apijson.Field
MessagesLast apijson.Field MessagesLast apijson.Field
MessagesLayoutToggle apijson.Field MessagesLayoutToggle apijson.Field
MessagesNext apijson.Field MessagesNext apijson.Field
MessagesPageDown apijson.Field MessagesPageDown apijson.Field
MessagesPageUp apijson.Field MessagesPageUp apijson.Field
MessagesPrevious apijson.Field MessagesPrevious apijson.Field
MessagesRedo apijson.Field MessagesRedo apijson.Field
MessagesRevert apijson.Field MessagesRevert apijson.Field
MessagesUndo apijson.Field MessagesUndo apijson.Field
ModelCycleRecent apijson.Field ModelCycleRecent apijson.Field
ModelCycleRecentReverse apijson.Field ModelCycleRecentReverse apijson.Field
ModelList apijson.Field ModelList apijson.Field
ProjectInit apijson.Field ProjectInit apijson.Field
SessionCompact apijson.Field SessionChildCycle apijson.Field
SessionExport apijson.Field SessionChildCycleReverse apijson.Field
SessionInterrupt apijson.Field SessionCompact apijson.Field
SessionList apijson.Field SessionExport apijson.Field
SessionNew apijson.Field SessionInterrupt apijson.Field
SessionShare apijson.Field SessionList apijson.Field
SessionUnshare apijson.Field SessionNew apijson.Field
SwitchAgent apijson.Field SessionShare apijson.Field
SwitchAgentReverse apijson.Field SessionUnshare apijson.Field
SwitchMode apijson.Field SwitchAgent apijson.Field
SwitchModeReverse apijson.Field SwitchAgentReverse apijson.Field
ThemeList apijson.Field SwitchMode apijson.Field
ThinkingBlocks apijson.Field SwitchModeReverse apijson.Field
ToolDetails apijson.Field ThemeList apijson.Field
raw string ThinkingBlocks apijson.Field
ExtraFields map[string]apijson.Field ToolDetails apijson.Field
raw string
ExtraFields map[string]apijson.Field
} }
func (r *KeybindsConfig) UnmarshalJSON(data []byte) (err error) { func (r *KeybindsConfig) UnmarshalJSON(data []byte) (err error) {

View File

@@ -39,10 +39,10 @@ func NewSessionService(opts ...option.RequestOption) (r *SessionService) {
} }
// Create a new session // Create a new session
func (r *SessionService) New(ctx context.Context, opts ...option.RequestOption) (res *Session, err error) { func (r *SessionService) New(ctx context.Context, body SessionNewParams, opts ...option.RequestOption) (res *Session, err error) {
opts = append(r.Options[:], opts...) opts = append(r.Options[:], opts...)
path := "session" path := "session"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return return
} }
@@ -2324,6 +2324,15 @@ func (r sessionMessagesResponseJSON) RawJSON() string {
return r.raw return r.raw
} }
type SessionNewParams struct {
ParentID param.Field[string] `json:"parentID"`
Title param.Field[string] `json:"title"`
}
func (r SessionNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type SessionUpdateParams struct { type SessionUpdateParams struct {
Title param.Field[string] `json:"title"` Title param.Field[string] `json:"title"`
} }

View File

@@ -13,7 +13,7 @@ import (
"github.com/sst/opencode-sdk-go/option" "github.com/sst/opencode-sdk-go/option"
) )
func TestSessionNew(t *testing.T) { func TestSessionNewWithOptionalParams(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being") t.Skip("skipped: tests are disabled for the time being")
baseURL := "http://localhost:4010" baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
@@ -25,7 +25,10 @@ func TestSessionNew(t *testing.T) {
client := opencode.NewClient( client := opencode.NewClient(
option.WithBaseURL(baseURL), option.WithBaseURL(baseURL),
) )
_, err := client.Session.New(context.TODO()) _, err := client.Session.New(context.TODO(), opencode.SessionNewParams{
ParentID: opencode.F("parentID"),
Title: opencode.F("title"),
})
if err != nil { if err != nil {
var apierr *opencode.Error var apierr *opencode.Error
if errors.As(err, &apierr) { if errors.As(err, &apierr) {

View File

@@ -576,6 +576,15 @@ export type Config = {
* Custom keybind configurations * Custom keybind configurations
*/ */
keybinds?: KeybindsConfig keybinds?: KeybindsConfig
/**
* TUI specific settings
*/
tui?: {
/**
* TUI scroll speed
*/
scroll_speed: number
}
plugin?: Array<string> plugin?: Array<string>
snapshot?: boolean snapshot?: boolean
/** /**

View File

@@ -50,6 +50,7 @@ type App struct {
compactCancel context.CancelFunc compactCancel context.CancelFunc
IsLeaderSequence bool IsLeaderSequence bool
IsBashMode bool IsBashMode bool
ScrollSpeed int
} }
func (a *App) Agent() *opencode.Agent { func (a *App) Agent() *opencode.Agent {
@@ -198,6 +199,7 @@ func New(
InitialPrompt: initialPrompt, InitialPrompt: initialPrompt,
InitialAgent: initialAgent, InitialAgent: initialAgent,
InitialSession: initialSession, InitialSession: initialSession,
ScrollSpeed: int(configInfo.Tui.ScrollSpeed),
} }
return app, nil return app, nil
@@ -725,7 +727,7 @@ func (a *App) MarkProjectInitialized(ctx context.Context) error {
} }
func (a *App) CreateSession(ctx context.Context) (*opencode.Session, error) { func (a *App) CreateSession(ctx context.Context) (*opencode.Session, error) {
session, err := a.Client.Session.New(ctx) session, err := a.Client.Session.New(ctx, opencode.SessionNewParams{})
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -28,7 +28,6 @@ type AgentModel struct {
type State struct { type State struct {
Theme string `toml:"theme"` Theme string `toml:"theme"`
ScrollSpeed *int `toml:"scroll_speed"`
AgentModel map[string]AgentModel `toml:"agent_model"` AgentModel map[string]AgentModel `toml:"agent_model"`
Provider string `toml:"provider"` Provider string `toml:"provider"`
Model string `toml:"model"` Model string `toml:"model"`

View File

@@ -1194,11 +1194,7 @@ func NewMessagesComponent(app *app.App) MessagesComponent {
vp := viewport.New() vp := viewport.New()
vp.KeyMap = viewport.KeyMap{} vp.KeyMap = viewport.KeyMap{}
if app.State.ScrollSpeed != nil && *app.State.ScrollSpeed > 0 { vp.MouseWheelDelta = app.ScrollSpeed
vp.MouseWheelDelta = *app.State.ScrollSpeed
} else {
vp.MouseWheelDelta = 2
}
// Default to showing tool details, hidden thinking blocks // Default to showing tool details, hidden thinking blocks
showToolDetails := true showToolDetails := true