modscode / Gallery / session-switcher
session-switcher
A paged, filterable, taggable switcher over your recent Claude Code sessions, with a per-row activity strip showing when each one was busy. Resumes in the session's own directory.
What it does
- Draws a pane
- Hooks session.start, ui.close
- Keeps its own state between turns
- Starts processes
Good points
- No network calls
- Written in TypeScript
- Handles errors
- Writes no files
Code to start from
Two kinds: a starter modscode writes from the design above, and the lines of the mod's own code that draw it.
Starter (register.tsx)
import type { Register } from 'claude-code'
// Drawn like session-switcher by Michael Shatny (pane, status), as modscode read it from the mod's code:
// https://modscode.com/gallery/semanticintent-session-switcher/
// Written by modscode from that reading, not copied from the mod: use it as you like.
// Each value below stands for one the mod works out at run time; put in your own.
export const register: Register = on => {
// the pane: open it with $.ui.open({ id: 'my-pane', title: "Sessions" })
on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
const { Box, Text, Button } = $.ui.resolve(e)
const length = '…'
const page = '…'
const pages = '…'
const query = '…'
const spark = '…'
const hotkey = '…'
const title = '…'
const ago = '…'
const project = '…'
const branch = '…'
const prompts = '…'
const filesTouched = '…'
const t = '…'
const project2 = '…'
const project3 = '…'
return (
<Box flexDirection="column" paddingX={1}>
<Box justifyContent="space-between">
<Text bold>
Sessions — tag which?
</Text>
<Text dimColor>
{`${length} found page ${page}1/${pages} indexing…`}
</Text>
</Box>
<Box marginBottom={1}>
<Text dimColor>
{`filter: ${query}`}
</Text>
</Box>
<Box flexDirection="column" marginBottom={1}>
<Box>
<Text>
{`${spark} `}
</Text>
<Box flexGrow={1}>
<Button hotkey={`${hotkey}`} plain label={`${title}`} />
</Box>
<Text dimColor>
{` ${ago}`}
</Text>
</Box>
<Box>
<Box flexShrink={0}>
<Text>
{project}
</Text>
</Box>
<Text dimColor wrap="truncate-end">
{` on ${branch}`}
</Text>
<Text dimColor wrap="truncate-end">
{` · ${prompts} prompt, ${filesTouched} files · sampled`}
</Text>
<Box flexShrink={0}>
<Text color="magenta">
{` #${t}`}
</Text>
</Box>
<Box flexShrink={0}>
<Text color="magenta">
{` #${t}`}
</Text>
</Box>
<Box flexShrink={0}>
<Text color="magenta">
{` #${t}`}
</Text>
</Box>
</Box>
</Box>
<Box flexDirection="column" marginBottom={1}>
<Box>
<Text>
{`${spark} `}
</Text>
<Box flexGrow={1}>
<Button hotkey={`${hotkey}`} plain label={`${title}`} />
</Box>
<Text dimColor>
{` ${ago}`}
</Text>
</Box>
<Box>
<Box flexShrink={0}>
<Text>
{project2}
</Text>
</Box>
<Text dimColor wrap="truncate-end">
{` on ${branch}`}
</Text>
<Text dimColor wrap="truncate-end">
{` · ${prompts} prompt, ${filesTouched} files · sampled`}
</Text>
<Box flexShrink={0}>
<Text color="magenta">
{` #${t}`}
</Text>
</Box>
<Box flexShrink={0}>
<Text color="magenta">
{` #${t}`}
</Text>
</Box>
<Box flexShrink={0}>
<Text color="magenta">
{` #${t}`}
</Text>
</Box>
</Box>
</Box>
<Box flexDirection="column" marginBottom={1}>
<Box>
<Text>
{`${spark} `}
</Text>
<Box flexGrow={1}>
<Button hotkey={`${hotkey}`} plain label={`${title}`} />
</Box>
<Text dimColor>
{` ${ago}`}
</Text>
</Box>
<Box>
<Box flexShrink={0}>
<Text>
{project3}
</Text>
</Box>
<Text dimColor wrap="truncate-end">
{` on ${branch}`}
</Text>
<Text dimColor wrap="truncate-end">
{` · ${prompts} prompt, ${filesTouched} files · sampled`}
</Text>
<Box flexShrink={0}>
<Text color="magenta">
{` #${t}`}
</Text>
</Box>
<Box flexShrink={0}>
<Text color="magenta">
{` #${t}`}
</Text>
</Box>
<Box flexShrink={0}>
<Text color="magenta">
{` #${t}`}
</Text>
</Box>
</Box>
</Box>
<Box marginTop={1} columnGap={2} flexWrap="wrap">
<Button hotkey="t" plain dimColor label="resume mode" />
<Button hotkey="p" plain dimColor label="prev" />
<Button hotkey="n" plain dimColor label="next" />
<Box flexShrink={0}>
<Text dimColor>
Esc close
</Text>
</Box>
<Box flexShrink={0}>
<Text dimColor>
· /switcher #tag tags this session
</Text>
</Box>
</Box>
</Box>
)
})
}
The mod's own code
Shown under the mod's licence (MIT); its text is below. Keep the notice if you copy these lines.
hooks/register.ts lines 304–337 · Pane
on("ui.render", { component: "Pane" }, async ($, e, next) => {
if (e.requestId !== PANE_ID) return next(e);
const table = await $.ui.resolve(e);
// Element tables differ by surface — one without `Input` still gets rows.
const { Box, Text, Button } = table;
const Input = "Input" in table ? table.Input : undefined;
const actions: Actions = {
filter: (value) => { state.query = value; state.page = 0; $.ui.invalidate("ui.render"); },
turnPage: (by) => { state.page = Math.max(0, state.page + by); $.ui.invalidate("ui.render"); },
toggleMode: () => { state.mode = state.mode === "tag" ? "resume" : "tag"; $.ui.invalidate("ui.render"); },
pick: (id) => {
const s = state.sessions.find((x) => x.id === id);
if (!s) return;
if (state.mode === "tag") {
const m = metaFor(s, state.meta);
state.editing = { id, text: [m?.title, ...(m?.tags ?? []).map((t) => "#" + t)].filter(Boolean).join(" ") };
return $.ui.invalidate("ui.render");
}
void resume($, s);
},
editTags: (value) => {
const s = state.editing && state.sessions.find((x) => x.id === state.editing!.id);
if (s && state.store) { setMeta(s, state.meta, value); void saveMeta(state.store, state.meta); }
// Cheap when the edited row isn't this session: the same line re-pins.
void pinStatus($);
state.editing = null;
state.mode = "resume";
$.ui.invalidate("ui.render");
},
};
return view({ Box, Text, Button, Input }, model(), actions);
});hooks/view.ts lines 77–146 · Pane
export function view(ui: Elements, model: Model, actions: Actions): RenderElement {
const { Box, Text, Button, Input } = ui;
const rows = model.sessions.filter((s) => matches(s, model.meta, model.query));
const pages = Math.max(1, Math.ceil(rows.length / PAGE));
// Clamped: a filter that shrinks the list must not strand the view on a
// page that no longer exists.
const page = Math.min(Math.max(0, model.page), pages - 1);
const visible = rows.slice(page * PAGE, page * PAGE + PAGE);
const header = Box({
justifyContent: "space-between",
children: [
Text({ bold: true, children: model.mode === "tag" ? "Sessions — tag which?" : "Sessions" }),
Text({ dimColor: true, children: `${rows.length} found page ${page + 1}/${pages}${model.syncing ? " indexing…" : ""}` }),
],
});
const filter = Input ? Input({
key: "filter",
// No label: the surface draws its own separator after one, so "› " came
// out as "› :".
placeholder: "filter by title, project, branch or #tag",
value: model.query,
submitLabel: "filter",
autoFocus: true,
onInput: (value: string) => actions.filter(value),
onSubmit: (value: string) => actions.filter(value),
}) : Text({ dimColor: true, children: model.query ? `filter: ${model.query}` : "filter unavailable on this surface" });
const body = visible.length === 0
? [Text({ dimColor: true, children: `No sessions match “${model.query}”. Clear the filter to see them all.` })]
: visible.map((s, i) => row(ui, s, model, actions, HOTKEYS[i] ?? ""));
const editor = model.editing && Input
? Input({
key: "tags",
label: "Tag or rename",
placeholder: "#wip #mods or a new title or both",
value: model.editing.text,
submitLabel: "save",
autoFocus: true,
onInput: () => {},
onSubmit: (value: string) => actions.editTags(value),
})
// Same squeeze as the meta line: in a narrow pane "Esc close" drew as
// "Esc" / "clos" / "e". Controls wrap onto another line as whole items;
// columnGap, not gap, or the wrapped line lands two blank lines down.
: Box({
marginTop: 1,
columnGap: 2,
flexWrap: "wrap",
children: [
Button({ key: "mode", hotkey: "t", plain: true, dimColor: true,
label: model.mode === "tag" ? "resume mode" : "tag a session",
onPress: () => actions.toggleMode() }),
Button({ key: "prev", hotkey: "p", plain: true, dimColor: true, label: "prev",
onPress: () => actions.turnPage(-1) }),
Button({ key: "next", hotkey: "n", plain: true, dimColor: true, label: "next",
onPress: () => actions.turnPage(1) }),
Box({ flexShrink: 0, children: [Text({ dimColor: true, children: "Esc close" })] }),
Box({ flexShrink: 0, children: [Text({ dimColor: true, children: "· /switcher #tag tags this session" })] }),
],
});
return Box({
flexDirection: "column",
paddingX: 1,
children: [header, Box({ marginBottom: 1, children: [filter] }), ...body, editor],
});
}hooks/view.ts lines 148–198 · Pane
function row(ui: Elements, s: Session, model: Model, actions: Actions, hotkey: string): RenderElement {
const { Box, Text, Button } = ui;
const m = metaFor(s, model.meta);
const colour = hue(s.project);
const isEditing = model.editing?.id === s.id;
return Box({
key: s.id,
flexDirection: "column",
marginBottom: isEditing ? 1 : 0,
children: [
Box({
children: [
Text({ color: colour, children: spark(s.activity) + " " }),
Box({
flexGrow: 1,
children: [
Button({
key: `row:${s.id}`,
hotkey,
plain: true,
label: m?.title ?? s.title,
onPress: () => actions.pick(s.id),
}),
],
}),
Text({ dimColor: true, children: " " + ago(s.lastActive) }),
],
}),
// One meta line, not three. Ten rows have to fit the pane alongside the
// filter and the controls, and the opening prompt is still searchable
// whether or not it is drawn.
// When the line is wider than the pane, every child gets squeezed, and a
// squeezed Text wraps inside its own narrow column — "Projects" came out
// as "Project" over "s", and a long branch interleaved with the project.
// So the project and tags never shrink, and the branch truncates instead.
Box({
marginLeft: INDENT,
children: [
Box({ flexShrink: 0, children: [Text({ color: colour, children: s.project })] }),
...(s.branch ? [Text({ dimColor: true, wrap: "truncate-end", children: ` on ${s.branch}` })] : []),
Text({ dimColor: true, wrap: "truncate-end",
children: ` · ${s.prompts} ${s.prompts === 1 ? "prompt" : "prompts"}`
+ (s.filesTouched ? `, ${s.filesTouched} files` : "")
+ (s.partial ? " · sampled" : "") }),
...(m?.tags ?? []).map((t) => Box({ flexShrink: 0, children: [Text({ color: "magenta", children: ` #${t}` })] })),
],
}),
],
});
}Licence text (MIT)
MIT License Copyright (c) 2026 Michael Shatny Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
What its code calls
runs programsreads filesenv varsremembers
The design, read from code
Drawn from the mod's source at the commit read, not from a run: a list is drawn three times, a condition takes its first branch that draws in the desktop app, and a value only the run time knows is shown as a made-up sample (dotted underline) or left out. Colours and type are this site's.
What its code shows
Read from the source at commit f75d78ce6b43 on 2026-10-06. The first group decides whether a mod is listed; the rest is for you to weigh. A later commit is not read until the next crawl.
| Decides the listing: code you can check | |
|---|---|
| Entry read | Every module hooks/hooks.json names was read.hooks/register.ts |
| Parses | Every file parses as TypeScript or JavaScript.6 files parsed |
| All its code is in the mod | Every import is a file of the mod or the engine's own module; no packages, no require.all its code is in the mod |
| Readable | No minified lines, no eval or new Function, no import of a computed path, no encoded blobs.no minified code, no eval, no encoded blobs |
| Calls in the open | Network and programs are reached as $.http.fetch and $.process.run in place, never passed around.every call outside goes through $ in the open |
| For you to weigh before installing | |
| Where it draws | The terminal, the desktop app, both, or nothing (hooks only: a guard or a prompt rewriter), as its code says. Shown, never a reason to leave a mod out.draws in the terminal and the desktop app, the same in both |
| Install line | Whether its repository's own .claude-plugin/marketplace.json lists it, so it installs from that marketplace with the lines on its page.listed in its repository's .claude-plugin/marketplace.json: installs from there |
| Programs on Windows | Whether every program it starts through $.process exists on Windows (tail, date, open, osascript, /usr/… do not).runs no program a Windows PC lacks |
| Network | Whether every fetch names its https host in the code.no network |
| Programs | Whether every program it starts is named in the code and is not a shell, an interpreter or a network tool.hooks/register.ts:162 a program named at run time |
| Reads and sends | Whether it both reads files or environment variables and reaches the network.reaches no network |
| Keys in the source | Whether the source holds what looks like an API key or a private key.no keys in the source |
| Licence | An open licence (MIT, Apache-2.0, BSD, ISC, Unlicense, 0BSD, CC0) with its text lets modscode show its code; otherwise the code is linked.MIT |
This is a reading of the code text, not a security review: it does not run the mod, and it cannot see what a program the mod starts does. The check before installing is yours. How mods are chosen
Install it
Check it yourself before you install it. Mods run unsandboxed, with your permissions, and modscode does not vouch for what this code does. Read the code below (or run claude plugin validate . in its folder), weigh what it reaches, and install the commit you read.
Its repository is its marketplace. Add that marketplace (in the terminal with these commands, or in the desktop app's plugin settings) and install the mod from it:
/plugin marketplace add semanticintent/claude-session-switcher/plugin install session-switcher@semanticintentThis installs the marketplace's latest commit, which may not be the one read here (f75d78ce6b43). Compare them before you install.
Ask Claude about it
With the modscode connector added, Claude can read this design, what its code reaches and its code, and build on them. Ask it like this:
Read the modscode design "semanticintent-session-switcher" with its code and make me a pane like itSearch them from Claude: the MCP connector
Similar designs
-
Ask Claude…2h 10m · █████░░░✓ build ✓ build ✓ buildJavaKotlin3 Python■ ok 3 ■ ok 3 ■ ok 3 Razor proven 3 Razor proven 3 Razor proven 3Phases ──────── 3/3build Pythonbuild Pythonbuild Python… 3 more phasesLua ──────── 3/Kotlin■ the whole upgrade Ruby■ build build Ruby■ build build Ruby■ build build Ruby … 3 moreNext ──────── PythonRuby (by hand)Podsclick a button, or ctrl+x tab then Tab, EnterAttention ──────── 3! Scala ! Scala ! Scala … 3 moreSession ──────── okJava
-
Ask Claude…great_cto: 3 gate waiting — /gatesGatesmy-app · 3 waiting · checked Gates UTCGates — Fix logina1b2c3dExpensive to undo. To approve, type Gates and press Enter.approve: Gates approveGates — Fix logina1b2c3dExpensive to undo. To approve, type Gates and press Enter.approve: Gates approveGates — Fix logina1b2c3dExpensive to undo. To approve, type Gates and press Enter.approve: Gates approve
-
Ask Claude…agent-discoverbuildbuildbuildRefreshMCP Browse/3Tab / shift+Tab move · Enter presses · ↑↓ scroll · Esc back to the promptBrowse...Audit asks:DeclineAcceptDeclineCancelAudit asks:DeclineAcceptDeclineCancelAudit asks:DeclineAcceptDeclineCancel
-
What it does
- Adds /sage-memory
- Watches Bash calls and can refuse them
- Hooks agent.spawn, classic.PostToolBatch, classic.SessionStart, prompt.attachment and 9 more
- Keeps its own state between turns
-
Ask Claude…Context●context-keeper42% full · 3 left████████░░░░░░░░3 of 3 tokensWhat fills itNo breakdown yet. It fills in after the first turn.build3████████░░░░░░░░build3████████░░░░░░░░Largest memory file: Actions (0)build3████████░░░░░░░░Tips• Checkpoint• Checkpoint• CheckpointActions● Measure nowCheckpoint cCheckpoint + compact kRefresh rCompact, keeping: e.g. the auth refactor and failing tests CompactCheckpointsNone yet. A checkpoint is a handoff note (goal, decisions, files, TODOs) you can reload after /clear.✓2h 10m note at 42%load✓2h 10m note at 42%load✓2h 10m note at 42%load
-
Ask Claude…guard 3 rulesGuardrails●guardrailsokPresetsFix login 3Fix login 3Fix login 3Rules●Fix loginEdit●Fix loginEdit●Fix loginEditYour own block patterns (regex on shell commands)Read●/All off/remove●/All off/remove●/All off/removeregex, e.g. docker\s+system\s+prune AddRules are best-effort pattern checks, a seatbelt, not a sandbox. Saved for all your sessions.Blocked this session (3)Nothing blocked yet. When a rule stops a command, it shows up here with the rule that caught it.✗ Edit All off: Grep✗ Edit All off: Grep✗ Edit All off: Grep