Skip to content

Commit 4401a7f

Browse files
committed
fix(tui): allow native text selection/copy by disabling mouse capture by default
Mouse reporting (tea.WithMouseCellMotion) captures terminal mouse events and prevents standard click-drag selection and copy. Keep mouse support off by default and add a --mouse flag for users who prefer wheel scrolling. - add --mouse CLI flag - only enable WithMouseCellMotion when --mouse is set - update README usage examples and key bindings
1 parent 4c54d13 commit 4401a7f

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ bodek --sandbox # run tool calls inside odek's
7676
bodek --url 'http://127.0.0.1:8080/?token=…' # attach with the token URL odek serve printed
7777
bodek --url http://127.0.0.1:8080 --token d3adb33f # attach with an explicit token
7878
bodek --odek-bin ./odek # use a specific odek binary
79+
bodek --mouse # enable mouse wheel scrolling (blocks text selection)
7980
bodek -- --prompt-caching # pass extra flags through to `odek serve`
8081
```
8182

@@ -103,7 +104,8 @@ by `odek serve` from its usual chain — `~/.odek/config.json` → `./odek.json`
103104
| `^J` | Insert a newline in the input |
104105
| `^L` | Clear the conversation |
105106
| `Esc` | Cancel the running turn |
106-
| `` / `` / `PgUp` / `PgDn` / wheel | Scroll the transcript |
107+
| `` / `` / `PgUp` / `PgDn` | Scroll the transcript |
108+
| `wheel` (with `--mouse`) | Scroll the transcript |
107109
| `^C` | Quit |
108110

109111
### Commands (`/`)

cmd/bodek/main.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func run() error {
3232
token = flag.String("token", "", "WS auth token for an attached odek serve (as printed at its startup)")
3333
sandbox = flag.Bool("sandbox", false, "run tool calls inside odek's Docker sandbox")
3434
bin = flag.String("odek-bin", "", "path to the odek binary to spawn (default: odek on PATH)")
35+
mouse = flag.Bool("mouse", false, "enable mouse wheel scrolling (disables native text selection/copy)")
3536
)
3637
flag.Usage = func() {
3738
fmt.Fprintf(os.Stderr, "Usage: bodek [options] [-- <odek serve flags>]\n\n")
@@ -113,11 +114,15 @@ func run() error {
113114
LogPath: logPath,
114115
})
115116

116-
// Mouse reporting enables wheel scrolling in the transcript. Click-drag text
117-
// selection is delegated to the terminal's shift+drag fallback where the
118-
// terminal supports it; otherwise users can rely on keyboard scrolling
119-
// (↑/↓, PgUp/PgDn, ^U/^D).
120-
p := tea.NewProgram(model, tea.WithAltScreen(), tea.WithMouseCellMotion())
117+
// Mouse reporting enables wheel scrolling in the transcript, but it also
118+
// captures the terminal mouse and blocks native click-drag text selection
119+
// and copy. Keep it off by default so users can copy freely; enable it only
120+
// when explicitly requested with --mouse.
121+
programOpts := []tea.ProgramOption{tea.WithAltScreen()}
122+
if *mouse {
123+
programOpts = append(programOpts, tea.WithMouseCellMotion())
124+
}
125+
p := tea.NewProgram(model, programOpts...)
121126
if _, err := p.Run(); err != nil {
122127
return fmt.Errorf("TUI exited: %w", err)
123128
}

0 commit comments

Comments
 (0)