Skip to content

Commit bab23be

Browse files
authored
feat(sideshow-term): add clear command (#31)
1 parent 7908fc8 commit bab23be

5 files changed

Lines changed: 44 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ All notable user-visible changes to this project are documented in this file.
2222
and bare `sideshow-term` opens the watcher. Terminal servers default to port
2323
4243, with `--port` for choosing another local port. The watcher supports
2424
mouse input for clicking sidebar snippets and wheel-scrolling content.
25+
Agents can run `sideshow-term clear` to remove stale visualizations from the
26+
current session, or `sideshow-term clear --all` to clear the whole surface.
2527
`sideshow-term serve` remains for explicit server-only use.
2628
- Snippets are now "surfaces" throughout the API: `/api/surfaces`, `surface-*`
2729
SSE events, and comments keyed by `surfaceId`. The old snippet endpoints and

sideshow-term/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ sideshow-term render <file|-> [--width N] preview STML to plain text (Bun)
6767
sideshow-term publish <file|-> [--title …] publish an STML snippet
6868
sideshow-term update <id> <file|-> revise a snippet (new version)
6969
sideshow-term list / sessions inspect what's published
70+
sideshow-term clear [--session id|--all] clear existing visualizations
7071
sideshow-term demo seed an example session
7172
sideshow-term guide / setup print the agent contract
7273
```

sideshow-term/bin/sideshow-term.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ usage:
4343
sideshow-term update <id> <file|-> revise a snippet (new version)
4444
--title <t> replace title
4545
sideshow-term list [--session <id>|--all] list snippets
46+
sideshow-term clear [--session <id>|--all] [--sessions]
47+
clear existing visualizations
4648
sideshow-term sessions list sessions
4749
sideshow-term comment <text> [opts] post a comment
4850
--snippet <id> | --session <id>
@@ -375,6 +377,37 @@ const commands = {
375377
out(await api(`/api/sessions/${session}/snippets`));
376378
},
377379

380+
async clear() {
381+
const { values: flags } = parse({
382+
options: {
383+
session: { type: "string" },
384+
all: { type: "boolean" },
385+
sessions: { type: "boolean" },
386+
},
387+
});
388+
if (flags.all && flags.session) fail("pass either --session or --all, not both");
389+
const sessionIds = flags.all
390+
? (await api("/api/sessions")).map((session) => session.id)
391+
: [flags.session ?? (await resolveSession(flags))].filter(Boolean);
392+
if (sessionIds.length === 0) fail("no active session — pass --session or --all");
393+
394+
let visualizations = 0;
395+
let deletedSessions = 0;
396+
for (const session of sessionIds) {
397+
const snippets = await api(`/api/sessions/${session}/snippets`);
398+
for (const snippet of snippets) {
399+
await api(`/api/snippets/${snippet.id}`, { method: "DELETE" });
400+
visualizations += 1;
401+
}
402+
if (flags.sessions) {
403+
await api(`/api/sessions/${session}`, { method: "DELETE" });
404+
deletedSessions += 1;
405+
}
406+
}
407+
408+
out({ ok: true, sessions: sessionIds.length, visualizations, deletedSessions });
409+
},
410+
378411
async sessions() {
379412
parse();
380413
out(await api("/api/sessions"));

sideshow-term/guide/AGENT_SETUP.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ sideshow-term update <id> revised.stml
1717

1818
# Preview in your own shell, no viewer needed:
1919
sideshow-term render sketch.stml
20+
21+
# Clear stale visuals before replacing a board:
22+
sideshow-term clear # current session
23+
sideshow-term clear --all # every session on this surface
2024
```
2125

2226
If `sideshow-term` is not on PATH but you are in this repo, use

sideshow-term/skills/sideshow-term/SKILL.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ Save the returned `sessionId` and snippet `id`. Iterate with
3838
publishing near-duplicates — versions are kept. Preview without the viewer:
3939
`sideshow-term render sketch.stml`.
4040

41+
To remove stale visuals before replacing a board, run `sideshow-term clear` for
42+
the current session or `sideshow-term clear --all` for every session on the
43+
surface.
44+
4145
Rules of thumb:
4246

4347
- On your first publish, set a session title that names the task ("Auth

0 commit comments

Comments
 (0)