Skip to content

Commit 7908fc8

Browse files
authored
feat(sideshow-term): support sidebar mouse selection (#29)
1 parent d3afe1a commit 7908fc8

3 files changed

Lines changed: 21 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ All notable user-visible changes to this project are documented in this file.
2020

2121
- `sideshow-term watch` now starts a local server in the background when needed,
2222
and bare `sideshow-term` opens the watcher. Terminal servers default to port
23-
4243, with `--port` for choosing another local port. `sideshow-term serve`
24-
remains for explicit server-only use.
23+
4243, with `--port` for choosing another local port. The watcher supports
24+
mouse input for clicking sidebar snippets and wheel-scrolling content.
25+
`sideshow-term serve` remains for explicit server-only use.
2526
- Snippets are now "surfaces" throughout the API: `/api/surfaces`, `surface-*`
2627
SSE events, and comments keyed by `surfaceId`. The old snippet endpoints and
2728
the `publish_snippet`/`update_snippet` tools remain as back-compat aliases, so

sideshow-term/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ the CLI shells out to Bun for `watch` and `render`.
6161

6262
```
6363
sideshow-term [--port N] open the live TUI viewer, starting a local server if needed
64-
sideshow-term watch [--port N] [--no-serve] open the live TUI viewer (Bun)
64+
sideshow-term watch [--port N] [--no-serve] open the live TUI viewer (Bun; keyboard + mouse)
6565
sideshow-term serve [--port N] start only the server (REST + SSE + MCP)
6666
sideshow-term render <file|-> [--width N] preview STML to plain text (Bun)
6767
sideshow-term publish <file|-> [--title …] publish an STML snippet

sideshow-term/src/watch.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ async function api<T>(path: string): Promise<T | null> {
4747
}
4848

4949
async function main() {
50-
const renderer = await createCliRenderer({ exitOnCtrlC: true, targetFps: 30 });
50+
const renderer = await createCliRenderer({ exitOnCtrlC: true, targetFps: 30, useMouse: true });
5151

5252
// --- static layout ---
5353
const rootCol = new BoxRenderable(renderer, {
@@ -93,7 +93,7 @@ async function main() {
9393
main.add(scroll);
9494

9595
const footer = new TextRenderable(renderer, {
96-
content: "↑/↓ select [ / ] scroll r refresh q quit",
96+
content: "↑/↓ select click sidebar [ / ] scroll wheel scroll r refresh q quit",
9797
paddingLeft: 1,
9898
height: 1,
9999
fg: muted,
@@ -134,6 +134,12 @@ async function main() {
134134
for (const child of node.getChildren().slice()) node.remove(child.id);
135135
}
136136

137+
function selectSnippet(id: string) {
138+
selectedId = id;
139+
renderSidebar();
140+
void showSelected();
141+
}
142+
137143
function renderSidebar() {
138144
clearChildren(sidebar);
139145
if (flat.length === 0) {
@@ -154,6 +160,14 @@ async function main() {
154160
content: label,
155161
fg: selected ? heading : undefined,
156162
bg: selected ? (resolveColor("subtle") ?? undefined) : undefined,
163+
height: 1,
164+
width: "100%",
165+
selectable: false,
166+
onMouseUp(event) {
167+
if (event.button !== 0) return;
168+
event.stopPropagation();
169+
selectSnippet(snip.id);
170+
},
157171
}),
158172
);
159173
}
@@ -195,9 +209,7 @@ async function main() {
195209
if (flat.length === 0) return;
196210
const cur = selectedIndex();
197211
const next = Math.max(0, Math.min(flat.length - 1, (cur < 0 ? 0 : cur) + delta));
198-
selectedId = flat[next].id;
199-
renderSidebar();
200-
void showSelected();
212+
selectSnippet(flat[next].id);
201213
}
202214

203215
renderer.keyInput.on("keypress", (key) => {

0 commit comments

Comments
 (0)