SLOPSHOPPER

session

Side pane with the session's model, cost and limits, subagents, loaded skills, MCP servers, changed files (+/- lines) and context usage

paneguardcommandpromptprocesstimer
v0.1.0no licenseupdated 2026-10-21djavrell/dotfile/claude/mods/session
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · session
│ ┃ session ✕ › fix the failing auth test and add an audit log call │ ┃ ╭──────────────────────────────────────────╮ │ ┃ │ view-main 💰 $0.4200 │ ⏺ Read(src/auth.ts) │ ┃ │ ⏱ 30m │ ⎿ Read 6 lines │ ┃ ╰──────────────────────────────────────────╯ ⏺ Update(src/auth.ts) │ ┃ ⎿ Added 2 lines, removed 1 line │ ┃ Skills ⏺ Bash(bun test) │ ┃ None. ⎿ 3 pass, 1 fail │ ┃ │ ┃ MCP ● Done. refresh now rejects expired claims and logs an audit event. │ ┃ None. │ ┃ ✻ Worked for 42s · done 4:20 PM │ ┃ Files │ ┃ None. › /session │ ┃ ⎿ session: Session pane closed. │ ┃ Context │ ┃ 49% 📊 97k/200k │ ┃ │ ┃ │ ┃ │ ┃ │ ┃ │ ┃ │ ┃ │ ┃ │ ┃ ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Pane · session
╭──────────────────────────────────────────────────────────╮ │ view-main 💰 $0.4200 │ │ ⏱ 30m │ ╰──────────────────────────────────────────────────────────╯ Skills None. MCP None. Files None. Context 49% 📊 97k/200k
README

session

A side pane that shows what the session is doing at a glance: the main agent card and its subagents, the skills used, the MCP servers' health (from mcp-status), the files changed in the repo, and the context window usage. It opens on session start, and /session toggles it.

Example

╭────────────────────────────────────────────────╮
│ * opus-5-5   🧠 ▰▰▰▱▱ high   💰 $1.2345        │
│ ⚡ 23%/41% ↺ 2h15m   󰃨 97%   ⏱ 42m             │
╰────────────────────────────────────────────────╯
├─ ✓ * Explore find the pane hooks
│  ▰▰▰▰▰▰ 6/6
└─ ● * general-purpose write the README
   ▰▰▰▱ 3/4

Skills
code-review, simplify

MCP
● cclsp
● plugin:playwright:playwright
● linear Needs authentication

Files
└─ * claude/mods/session/
   ├─ * README.md                          +72 ●
   └─ * register.tsx                    +4 -1 ●
2 edited · +76 -1

Context
▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱
* 3k  * 17k  * 2k  * 26k
24%  📊 48k/200k
/session         toggle the pane
/context-icons   list the Context legend's icons and grid cells
Source 20 files
hooks/register.tsx 269 lines
1// Wiring of the session pane: the small state left here (skills, model, tick), the hooks and the pane's assembly.
2// Each domain's atoms live in state/ with their read/update calls (the validator wants them in one file), reached
3// through function declarations that take $. Pure helpers sit in lib/, each section's drawing in sections/.
4import { atom, read, update } from "claude-code";
5import type { EngineInterface, Register, Timer } from "claude-code";
6
7import type { ModelInfo } from "../types";
8import { childCounts, visibleAgents } from "./lib/agentTree";
9import { AgentsSection } from "./sections/agents";
10import { BranchSection } from "./sections/branch";
11import { CONTEXT_LEGEND, ContextSection } from "./sections/context";
12import { FilesSection } from "./sections/files";
13import { McpSection } from "./sections/mcp";
14import { SkillsSection } from "./sections/skills";
15import { MainAgentCard } from "./sections/mainAgent";
16import { readContext, refreshContext } from "./state/context";
17import {
18  GIT_POLL_MS,
19  WRITERS,
20  pollGit,
21  readFiles,
22  refresh,
23  scheduleRefresh,
24  toggleFolder,
25} from "./state/files";
26import { PANE, isPaneOpen, openPane } from "./state/pane";
27
28// ── state ────────────────────────────────────────────────────────────────────
29
30// owned by the agents mod (the single source of the session's agents): read here, never written
31const agents = atom({ plugin: "agents", key: "list" } as const, []);
32// owned by git-provider (it polls gh): read here, never written
33const pullRequestState = atom({ plugin: "git-provider", key: "current" } as const, null);
34const branchState = atom({ plugin: "git-provider", key: "branch" } as const, null);
35// owned by mcp-status (it checks the servers and follows their calls): read here, never written
36const mcpServers = atom({ plugin: "mcp-status", key: "servers" } as const, []);
37const skills = atom({ plugin: "session", key: "skills" } as const, []);
38const info = atom({ plugin: "session", key: "info" } as const, null);
39// bumped on a timer and on each measure (turn, rate-limit move) so usage, countdown and elapsed time redraw
40const tick = atom({ plugin: "session", key: "tick" } as const, 0);
41
42const TICK_MS = 10_000;
43// the tick and git poll timers, cancelled when a new session.start starts others
44let tickTimer: Timer | undefined;
45let gitPollTimer: Timer | undefined;
46// a finished agent stays in the pane this long after it ended, then leaves on the next tick
47const FINISHED_AGENT_KEEP_MS = 30_000;
48
49// ── refreshes ────────────────────────────────────────────────────────────────
50
51async function addSkill($: EngineInterface, name: string) {
52  await update($, skills, (skillNames) =>
53    skillNames.includes(name) ? skillNames : [...skillNames, name],
54  );
55}
56
57async function bumpTick($: EngineInterface) {
58  await update($, tick, (tickCount) => tickCount + 1);
59}
60
61// $.palette is absent for a moment when this mod draws before palette has loaded: default colors then
62async function getTheme($: EngineInterface) {
63  try {
64    return await $.palette.get();
65  } catch {
66    return undefined;
67  }
68}
69
70// ── hooks ────────────────────────────────────────────────────────────────────
71
72export const register: Register = (on) => {
73  on("session.start", async ($, event, next) => {
74    await $.command.register({
75      name: "session",
76      description: "Toggle the session pane: agents, skills, changed files",
77    });
78    await $.command.register({
79      name: "context-icons",
80      description:
81        "What the icons of the session pane's Context legend stand for",
82    });
83    void refresh($).catch(() => {});
84    void refreshContext($).catch(() => {});
85    tickTimer?.cancel();
86    tickTimer = $.clock.every(
87      TICK_MS,
88      () => void bumpTick($).catch(() => {}),
89    );
90    gitPollTimer?.cancel();
91    gitPollTimer = $.clock.every(
92      GIT_POLL_MS,
93      () => void pollGit($).catch(() => {}),
94    );
95    void openPane($).catch(() => {});
96
97    return next(event);
98  });
99
100  on("command.run", { command: "session" }, async ($) => {
101    if (await isPaneOpen($)) {
102      await $.ui.close({ id: PANE });
103
104      return { text: "Session pane closed." };
105    }
106    await refresh($).catch(() => {});
107    await openPane($);
108
109    return { text: "Session pane opened." };
110  });
111
112  on("command.run", { command: "context-icons" }, async () => ({
113    text: CONTEXT_LEGEND,
114  }));
115
116  on("tool.call", async ($, event, next) => {
117    const result = await next(event);
118    if (event.tool === "Skill") void addSkill($, event.skill).catch(() => {});
119    if (WRITERS.has(event.tool)) void scheduleRefresh($).catch(() => {});
120
121    return result;
122  });
123
124  on("turn.step", async function* ($, event, next) {
125    if (!event.agentId) {
126      const stepModel: ModelInfo = {
127        model: event.model.replace(/^claude-/, ""),
128        effort: event.effort === undefined ? undefined : String(event.effort),
129      };
130      void update($, info, () => stepModel).catch(() => {});
131    }
132
133    return yield* next(event);
134  });
135
136  // after each main-thread turn and when a rate-limit window moves: usage, countdown and elapsed time redraw
137  on("session.measure", async ($, event, next) => {
138    void update($, tick, (tickCount) => tickCount + 1).catch(() => {});
139    // the messages grow each turn; the threshold moves with the model (/model) and the settings
140    if (event.changed.includes("context"))
141      void refreshContext($).catch(() => {});
142
143    return next(event);
144  });
145
146  // a compaction is no turn: re-read the shrunk context once it is done
147  on("session.compact", async ($, event, next) => {
148    const result = await next(event);
149    if (!event.agentId) void refreshContext($).catch(() => {});
150
151    return result;
152  });
153
154  // skill.prompt did not fire in a live session on 2.1.291: Skill tool calls and typed
155  // /name commands are caught above and here instead
156  on("skill.prompt", async ($, event, next) => {
157    void addSkill($, event.skill).catch(() => {});
158    return next(event);
159  });
160
161  // ponytail: any user/plugin command outside this mod counts as a skill, the engine does not tell them apart
162  on("command.run", async ($, event, next) => {
163    const result = await next(event);
164    const commandInfo = (await $.command.list()).find(
165      (command) => command.name === event.command,
166    );
167    if (
168      commandInfo &&
169      commandInfo.plugin !== "session" &&
170      (commandInfo.source === "user" || commandInfo.source === "plugin")
171    )
172      void addSkill($, event.command).catch(() => {});
173
174    return result;
175  });
176
177  // ── pane ───────────────────────────────────────────────────────────────────
178
179  on("ui.render", { component: "Pane", requestId: PANE }, async ($, event) => {
180    const ui = $.ui.resolve(event);
181    const { Box, Text } = ui;
182    await read($, tick);
183    const [
184      [changedFiles, foldedFolders],
185      agentList,
186      skillList,
187      modelInfo,
188      contextInfo,
189      usage,
190      nowMs,
191      theme,
192      pullRequest,
193      branchName,
194      serverList,
195    ] = await Promise.all([
196      readFiles($),
197      read($, agents),
198      read($, skills),
199      read($, info),
200      readContext($),
201      $.session.usage(),
202      $.clock.now(),
203      getTheme($),
204      read($, pullRequestState),
205      read($, branchState),
206      read($, mcpServers),
207    ]);
208    // docked, fill the pane's height so the grown top block pushes Context to the bottom
209    const minHeight =
210      event.props.placement === "dock"
211        ? event.props.scroll.bodyRows
212        : undefined;
213
214    return (
215      <Box
216        flexDirection="column"
217        minHeight={minHeight}
218        backgroundColor={theme?.background}
219      >
220        <Box flexDirection="column" flexGrow={1}>
221          {MainAgentCard({
222            ui,
223            theme,
224            modelInfo,
225            contextInfo,
226            usage,
227            nowMs,
228            // a refused switch ({ deny }) changes nothing: ignored
229            onViewMain: () => void $.ui.view({}).catch(() => {}),
230          })}
231          {AgentsSection({
232            ui,
233            theme,
234            agentList: visibleAgents(agentList, nowMs, FINISHED_AGENT_KEEP_MS),
235            subagentCounts: childCounts(agentList),
236            nowMs,
237            bodyColumns: event.props.bodyColumns,
238            viewedAgentId: event.props.view?.agentId,
239            onViewAgent: (agentId) =>
240              void $.ui.view({ agentId }).catch(() => {}),
241          })}
242          <Text> </Text>
243          {SkillsSection({ ui, skillList })}
244          <Text> </Text>
245          {McpSection({ ui, theme, serverList })}
246          <Text> </Text>
247          {FilesSection({
248            ui,
249            theme,
250            changedFiles,
251            collapsedFolders: new Set(foldedFolders),
252            onToggleFolder: (folderPath) =>
253              void toggleFolder($, folderPath).catch(() => {}),
254          })}
255          <Text> </Text>
256        </Box>
257        {BranchSection({ ui, theme, branchName, pullRequest })}
258        {ContextSection({
259          ui,
260          theme,
261          contextInfo,
262          usage,
263          bodyColumns: event.props.bodyColumns,
264        })}
265      </Box>
266    );
267  });
268};
269
hooks/lib/agentTree.ts 129 lines
1import type { AgentEntry } from "agents";
2
3// the agents one Workflow run spawned, in their run order (agentIndex)
4export type WorkflowRun = { runId: string; agents: AgentEntry[] };
5
6// one line of the tree, an agent or a Workflow run grouping its agents: `guide` is the "│  ├─ " in
7// front of it, `underGuide` what goes in front of a line drawn under it (an agent's steps), carrying
8// the tree's lines down to its siblings and children
9export type AgentRow = { guide: string; underGuide: string } & (
10  | { agent: AgentEntry; run?: undefined }
11  | { agent?: undefined; run: WorkflowRun }
12);
13
14export const FINISHED = new Set(["completed", "failed", "killed"]);
15
16// drops agents finished more than `keepMs` ago (no endedAt counts as long ago), but keeps a finished
17// agent while one of its descendants is still shown, so a running child stays nested under it
18export function visibleAgents(
19  agents: readonly AgentEntry[],
20  nowMs: number,
21  keepMs: number,
22): AgentEntry[] {
23  const isRecent = (agent: AgentEntry) =>
24    !FINISHED.has(agent.status) ||
25    (agent.endedAt !== undefined && nowMs - agent.endedAt < keepMs);
26  // ponytail: rescans the list per agent, fine for a session's few dozen agents
27  const isVisible = (agent: AgentEntry): boolean =>
28    isRecent(agent) ||
29    agents.some((child) => child.parentId === agent.id && isVisible(child));
30  return agents.filter(isVisible);
31}
32
33export type ChildCount = { running: number; finished: number };
34
35// the agents each agent spawned itself (not its subagents' own), split running / finished; give it
36// the whole list, not the visible one, so children finished long ago still count
37export function childCounts(
38  agents: readonly AgentEntry[],
39): Map<string, ChildCount> {
40  const counts = new Map<string, ChildCount>();
41  for (const agent of agents) {
42    if (!agent.parentId) continue;
43    const count = counts.get(agent.parentId) ?? { running: 0, finished: 0 };
44    if (FINISHED.has(agent.status)) count.finished++;
45    else count.running++;
46    counts.set(agent.parentId, count);
47  }
48  return counts;
49}
50
51// one level's agents, a Workflow run's agents folded into one run node where its first one started;
52// a run of a single agent still gets its node, so a run always reads the same
53function groupRuns(agents: AgentEntry[]): (AgentEntry | WorkflowRun)[] {
54  const runs = new Map<string, WorkflowRun>();
55  const nodes: (AgentEntry | WorkflowRun)[] = [];
56  for (const agent of agents) {
57    if (!agent.workflow) {
58      nodes.push(agent);
59      continue;
60    }
61    const run = runs.get(agent.workflow.runId);
62    if (run) run.agents.push(agent);
63    else {
64      const newRun = { runId: agent.workflow.runId, agents: [agent] };
65      runs.set(newRun.runId, newRun);
66      nodes.push(newRun);
67    }
68  }
69  for (const run of runs.values())
70    run.agents.sort(
71      (agentA, agentB) =>
72        (agentA.workflow?.agentIndex ?? 0) - (agentB.workflow?.agentIndex ?? 0),
73    );
74  return nodes;
75}
76
77// agents nested under the agent that spawned them, each level in start order, a Workflow run's
78// agents under one run node; an agent whose parent is unknown (the main conversation, or a parent
79// dropped from the list) is a root
80export function buildAgentTree(agents: readonly AgentEntry[]): AgentRow[] {
81  const knownIds = new Set(agents.map((agent) => agent.id));
82  const byStart = [...agents].sort(
83    (agentA, agentB) => (agentA.startedAt ?? 0) - (agentB.startedAt ?? 0),
84  );
85  // each parent's children in start order, in one pass; the roots under the undefined key
86  const childrenByParent = new Map<string | undefined, AgentEntry[]>();
87  for (const agent of byStart) {
88    const parentKey =
89      agent.parentId && knownIds.has(agent.parentId)
90        ? agent.parentId
91        : undefined;
92    const siblings = childrenByParent.get(parentKey) ?? [];
93    siblings.push(agent);
94    childrenByParent.set(parentKey, siblings);
95  }
96  const childrenOf = (parentId: string | undefined) =>
97    childrenByParent.get(parentId) ?? [];
98
99  const rows: AgentRow[] = [];
100  const pushAgent = (agent: AgentEntry, guide: string, isLast: boolean) => {
101    const childGuide = guide + (isLast ? "   " : "│  ");
102    const hasChildren = childrenByParent.has(agent.id);
103    rows.push({
104      guide: guide + (isLast ? "└─ " : "├─ "),
105      underGuide: childGuide + (hasChildren ? "│ " : "  "),
106      agent,
107    });
108    walk(agent.id, childGuide);
109  };
110  const walk = (parentId: string | undefined, guide: string) => {
111    const nodes = groupRuns(childrenOf(parentId));
112    nodes.forEach((node, nodeIndex) => {
113      const isLast = nodeIndex === nodes.length - 1;
114      if (!("runId" in node)) return pushAgent(node, guide, isLast);
115      const runGuide = guide + (isLast ? "   " : "│  ");
116      rows.push({
117        guide: guide + (isLast ? "└─ " : "├─ "),
118        underGuide: runGuide + "│ ",
119        run: node,
120      });
121      node.agents.forEach((agent, agentIndex) =>
122        pushAgent(agent, runGuide, agentIndex === node.agents.length - 1),
123      );
124    });
125  };
126  walk(undefined, "");
127  return rows;
128}
129
hooks/sections/agents.tsx 157 lines
1import type { AgentEntry } from "agents";
2import type { Elements } from "claude-code";
3import type { PaletteColorPath, PaletteTheme } from "palette";
4
5import { Meter } from "../components/meter";
6import { FINISHED, buildAgentTree } from "../lib/agentTree";
7import type { ChildCount } from "../lib/agentTree";
8import { fmtElapsed } from "../lib/format";
9import { modelIcon } from "../lib/icons";
10import { paint, unInverted } from "../lib/theme";
11import type { Ui } from "../lib/theme";
12
13const AGENT_STATUS: Record<string, { icon: string; color: PaletteColorPath }> = {
14  pending: { icon: "●", color: "ansi.yellow" },
15  running: { icon: "●", color: "ansi.yellow" },
16  waiting: { icon: "●", color: "ansi.yellow" },
17  idle: { icon: "○", color: "comment" },
18  completed: { icon: "✓", color: "ansi.green" },
19  failed: { icon: "✗", color: "ansi.red" },
20  killed: { icon: "✗", color: "ansi.red" },
21};
22const UNKNOWN_STATUS = { icon: "?", color: "comment" } as const;
23const NO_CHILDREN: ChildCount = { running: 0, finished: 0 };
24
25export function AgentsSection({
26  ui: { Box, Button, Text },
27  theme,
28  agentList,
29  subagentCounts,
30  nowMs,
31  bodyColumns,
32  viewedAgentId,
33  onViewAgent,
34}: {
35  // an agent's line is a button: this section needs Button on top of Box and Text
36  ui: Ui & Pick<Elements[keyof Elements], "Button">;
37  theme?: PaletteTheme;
38  agentList: readonly AgentEntry[];
39  // by agent id, from `childCounts` over the whole list
40  subagentCounts: ReadonlyMap<string, ChildCount>;
41  nowMs: number;
42  // the pane's inner width, which the step strips fill
43  bodyColumns: number;
44  // the agent whose transcript the main view shows (`e.props.view`), underlined
45  viewedAgentId?: string;
46  onViewAgent: (agentId: string) => void;
47}) {
48  return (
49    <Box flexDirection="column">
50      {buildAgentTree(agentList).map((row) => {
51        if (row.run) {
52          const runAgents = row.run.agents;
53          // running while one agent runs, then failed if one failed
54          const runStatusName = runAgents.some((agent) => !FINISHED.has(agent.status))
55            ? "running"
56            : runAgents.some((agent) => agent.status !== "completed")
57              ? "failed"
58              : "completed";
59          const runStatus = AGENT_STATUS[runStatusName] ?? UNKNOWN_STATUS;
60          return (
61            <Text key={row.run.runId} wrap="truncate-end">
62              <Text dimColor>{row.guide}</Text>
63              <Text color={paint(theme, runStatus.color)}>{runStatus.icon} </Text>
64              {/* nf-md-sitemap */}
65              <Text color={theme?.ansi.blue}>{"\u{f0491}"} workflow</Text>{" "}
66              <Text dimColor>
67                {row.run.runId.slice(-6)} · {runAgents.length} agent{runAgents.length > 1 ? "s" : ""}
68              </Text>
69            </Text>
70          );
71        }
72        const { guide, underGuide, agent } = row;
73        const agentStatus = AGENT_STATUS[agent.status] ?? UNKNOWN_STATUS;
74        const model = modelIcon(agent.model);
75        const counter = ` ${agent.stepsDone}/${agent.stepsStarted}`;
76        // still running: counts up to now, the pane's 10s redraw moves it
77        const elapsedSeconds =
78          agent.startedAt === undefined
79            ? undefined
80            : Math.floor(((agent.endedAt ?? nowMs) - agent.startedAt) / 1000);
81        const children = subagentCounts.get(agent.id) ?? NO_CHILDREN;
82        return (
83          <Box key={agent.id} flexDirection="column">
84            {/* a click shows this agent's transcript in the main view; `hover` keeps the line unchanged
85                under the pointer (see unInverted): every part, spaces included, carries its own colors,
86                gray rather than dimColor; the keyed Box is the area that hovers, this line alone */}
87            <Box key={`row-${agent.id}`} flexDirection="row">
88              <Button key={`view-${agent.id}`} plain onPress={() => onViewAgent(agent.id)}>
89                <Text wrap="truncate-end">
90                  <Text color={theme?.dimmed} hover={unInverted(theme, theme?.dimmed)}>{guide}</Text>
91                  <Text
92                    color={paint(theme, agentStatus.color)}
93                    hover={unInverted(theme, paint(theme, agentStatus.color))}
94                  >
95                    {agentStatus.icon}{" "}
96                  </Text>
97                  <Text
98                    color={paint(theme, model.color)}
99                    hover={unInverted(theme, paint(theme, model.color))}
100                  >
101                    {model.glyph}{" "}
102                  </Text>
103                  <Text
104                    color={theme?.ansi.cyan}
105                    hover={unInverted(theme, theme?.ansi.cyan)}
106                    underline={agent.id === viewedAgentId}
107                  >
108                    {agent.type}
109                  </Text>
110                  <Text color={theme?.dimmed} hover={unInverted(theme, theme?.dimmed)}>{" "}</Text>
111                  {elapsedSeconds !== undefined && (
112                    <Text color={theme?.ansi.magenta} hover={unInverted(theme, theme?.ansi.magenta)}>
113                      ⏱ {fmtElapsed(elapsedSeconds)}{" "}
114                    </Text>
115                  )}
116                  {/* running children stand out, finished ones gray: ⑂2 +3 */}
117                  {children.running > 0 && (
118                    <Text color={theme?.ansi.blue} hover={unInverted(theme, theme?.ansi.blue)}>
119                      ⑂{children.running}{" "}
120                    </Text>
121                  )}
122                  {children.finished > 0 && (
123                    <Text color={theme?.dimmed} hover={unInverted(theme, theme?.dimmed)}>
124                      {children.running > 0 ? "+" : "⑂"}
125                      {children.finished}{" "}
126                    </Text>
127                  )}
128                  <Text color={theme?.dimmed} hover={unInverted(theme, theme?.dimmed)}>
129                    {agent.description}
130                  </Text>
131                </Text>
132              </Button>
133            </Box>
134            {agent.stepsStarted > 0 && (
135              <Text wrap="truncate-end">
136                <Text dimColor>{underGuide}</Text>
137                {/* one cell per step; the empty one left is the step running */}
138                {Meter({
139                  ui: { Box, Text },
140                  filled: agent.stepsDone,
141                  total: agent.stepsStarted,
142                  maxWidth: bodyColumns - underGuide.length - counter.length,
143                  filledColor: FINISHED.has(agent.status)
144                    ? theme?.ansi.green
145                    : theme?.ansi.blue,
146                  emptyColor: theme?.ansi.yellow,
147                })}
148                <Text dimColor>{counter}</Text>
149              </Text>
150            )}
151          </Box>
152        );
153      })}
154    </Box>
155  );
156}
157
hooks/sections/branch.tsx 84 lines
1import type { Elements } from "claude-code";
2import type { PullRequest } from "git-provider";
3import type { PaletteColorPath, PaletteTheme } from "palette";
4
5import { paint } from "../lib/theme";
6
7const BRANCH_ICON = ""; // nf-dev-git_branch
8const PR_ICON = ""; // nf-oct-git_pull_request
9const MERGED_ICON = ""; // nf-oct-git_merge
10
11type Mark = { icon: string; role: PaletteColorPath };
12
13const STATE_ROLE: Record<PullRequest["state"], PaletteColorPath> = {
14  open: "ansi.green",
15  draft: "comment",
16  merged: "ansi.magenta",
17  closed: "ansi.red",
18};
19const CHECKS_MARK: Record<PullRequest["checks"], Mark | null> = {
20  pass: { icon: "", role: "ansi.green" }, // nf-fa-check_circle
21  fail: { icon: "", role: "ansi.red" }, // nf-fa-times_circle
22  pending: { icon: "", role: "ansi.yellow" }, // nf-fa-clock_o
23  none: null,
24};
25const REVIEW_MARK: Record<PullRequest["review"], Mark | null> = {
26  approved: { icon: "", role: "ansi.green" }, // nf-fa-thumbs_up
27  changes_requested: { icon: "", role: "ansi.red" }, // nf-fa-pencil
28  required: { icon: "", role: "ansi.yellow" }, // nf-fa-eye
29  none: null,
30};
31
32// one line from what git-provider publishes: the pull request (number linked to GitHub and colored by state, then its
33// title, cut when the pane is narrow) then its CI and review icons, always shown; without a pull request, the
34// branch name as a fallback. Nothing outside git or on a detached HEAD without a pull request
35export function BranchSection({
36  ui: { Box, Text, Link },
37  theme,
38  branchName,
39  pullRequest,
40}: {
41  ui: Pick<Elements[keyof Elements], "Box" | "Text" | "Link">;
42  theme?: PaletteTheme;
43  branchName: string | null;
44  pullRequest: PullRequest | null;
45}) {
46  if (!branchName && !pullRequest) return null;
47  const marks = pullRequest
48    ? [CHECKS_MARK[pullRequest.checks], REVIEW_MARK[pullRequest.review]].filter((mark) => mark !== null)
49    : [];
50
51  return (
52    <Box flexDirection="column">
53      <Text weight="semibold">Branch</Text>
54      <Box flexDirection="row" columnGap={2}>
55        <Box flexShrink={1}>
56          {pullRequest ? (
57            <Text wrap="truncate-end">
58              <Text color={paint(theme, STATE_ROLE[pullRequest.state])}>
59                {pullRequest.state === "merged" ? MERGED_ICON : PR_ICON}{" "}
60                <Link href={pullRequest.url}>#{pullRequest.number}</Link>
61              </Text>{" "}
62              {pullRequest.title}
63            </Text>
64          ) : (
65            <Text wrap="truncate-end" color={paint(theme, "ansi.blue")}>
66              {BRANCH_ICON} {branchName}
67            </Text>
68          )}
69        </Box>
70        {marks.length > 0 && (
71          <Box flexShrink={0} columnGap={1}>
72            {marks.map((mark) => (
73              <Text key={mark.icon} color={paint(theme, mark.role)}>
74                {mark.icon}
75              </Text>
76            ))}
77          </Box>
78        )}
79      </Box>
80      <Text> </Text>
81    </Box>
82  );
83}
84
hooks/sections/context.tsx 115 lines
1import type { SessionUsage } from "claude-code";
2import type { PaletteColorPath, PaletteTheme } from "palette";
3
4import type { ContextInfo, ContextSlice } from "../../types";
5import { contextCells, sliceRuns } from "../lib/contextGrid";
6import { fmtTokens } from "../lib/format";
7import { paint } from "../lib/theme";
8import type { Ui } from "../lib/theme";
9
10// share of the auto-compaction threshold past which the context line warns
11const COMPACT_WARN = 0.9;
12const GRID_ROWS = 4;
13// the grid's cells; the legend keeps the plain square for a category it has no icon for
14const USED_CELL = "▰";
15const FREE_CELL = "▱";
16const UNKNOWN_ICON = "■";
17// by /context's row names: the rows have no stable id, only a kind; a row not listed takes the next spare color
18// and the plain cell as its legend icon
19const SLICE_STYLE: Record<string, { role: PaletteColorPath; icon: string }> = {
20  "System prompt": { role: "ansi.blue", icon: "" }, // nf-fa-cog
21  "System tools": { role: "ansi.cyan", icon: "" }, // nf-fa-wrench
22  "MCP tools": { role: "ansi.magenta", icon: "" }, // nf-fa-plug
23  "MCP server instructions": { role: "ansi.magenta", icon: "" }, // nf-fa-info_circle
24  "Custom agents": { role: "ansi.white", icon: "" }, // nf-fa-users
25  "Memory files": { role: "ansi.yellow", icon: "" }, // nf-fa-database
26  Skills: { role: "brights.yellow", icon: "" }, // nf-fa-bolt
27  Messages: { role: "ansi.green", icon: "" }, // nf-fa-comments
28};
29const SPARE_COLORS: PaletteColorPath[] = ["ansi.cyan", "ansi.magenta", "ansi.yellow", "ansi.blue"];
30
31// what /context-icons prints: each icon of the legend and the grid's other cells, by name
32export const CONTEXT_LEGEND = [
33  ...Object.entries(SLICE_STYLE).map(([name, style]) => `${style.icon}  ${name}`),
34  `${UNKNOWN_ICON}  another category, its name beside it`,
35  `${FREE_CELL}  free space (grid)`,
36  `${USED_CELL}  autocompact buffer (grid, red)`,
37].join("\n");
38
39export function ContextSection({
40  ui: { Box, Text },
41  theme,
42  contextInfo,
43  usage,
44  bodyColumns,
45}: {
46  ui: Ui;
47  theme?: PaletteTheme;
48  contextInfo: ContextInfo | null;
49  usage: SessionUsage;
50  // the pane's inner width, which the grid fills
51  bodyColumns: number;
52}) {
53  const contextPercent = usage.context.percent ?? 0;
54  const contextTokens = usage.context.tokens;
55  const compactTokens = contextInfo?.compactAt;
56  // close to the auto-compaction threshold, which can sit well below the model's window
57  const nearCompact =
58    !!contextTokens &&
59    !!compactTokens &&
60    contextTokens >= compactTokens * COMPACT_WARN;
61  const usedSlices =
62    contextInfo?.slices.filter(
63      (slice) => slice.kind === "used" && slice.tokens > 0,
64    ) ?? [];
65  const sliceColor = (slice: ContextSlice) => {
66    if (slice.kind === "buffer") return theme?.ansi.red;
67    if (slice.kind !== "used") return theme?.comment;
68    const spareIndex = usedSlices.indexOf(slice) % SPARE_COLORS.length;
69    return paint(
70      theme,
71      SLICE_STYLE[slice.name]?.role ?? SPARE_COLORS[spareIndex] ?? "comment",
72    );
73  };
74  const cells = contextInfo
75    ? contextCells(contextInfo.slices, contextInfo.maxTokens, GRID_ROWS * bodyColumns)
76    : [];
77  const gridRows = Array.from({ length: cells.length ? GRID_ROWS : 0 }, (_, rowIndex) =>
78    sliceRuns(cells.slice(rowIndex * bodyColumns, (rowIndex + 1) * bodyColumns)),
79  );
80
81  return (
82    <Box flexDirection="column">
83      <Text weight="semibold">Context</Text>
84      {gridRows.map((runs, rowIndex) => (
85        <Text key={`row${rowIndex}`} wrap="truncate-end">
86          {runs.map((run, runIndex) => (
87            <Text
88              key={`run${runIndex}`}
89              color={sliceColor(run.slice)}
90              dimColor={run.slice.kind !== "used"}
91            >
92              {(run.slice.kind === "free" ? FREE_CELL : USED_CELL).repeat(run.length)}
93            </Text>
94          ))}
95        </Text>
96      ))}
97      <Box flexDirection="row" flexWrap="wrap" columnGap={2}>
98        {usedSlices.map((slice) => (
99          <Text key={slice.name} color={sliceColor(slice)}>
100            {SLICE_STYLE[slice.name]?.icon ?? `${UNKNOWN_ICON} ${slice.name}`}{" "}
101            {fmtTokens(slice.tokens)}
102          </Text>
103        ))}
104      </Box>
105      <Text color={nearCompact ? theme?.ansi.red : theme?.ansi.yellow} wrap="truncate-end">
106        {Math.round(contextPercent)}%  📊{" "}
107        {contextTokens
108          ? `${fmtTokens(contextTokens)}/${fmtTokens(usage.context.window)}`
109          : "--/--"}
110        {nearCompact ? " ⚠" : ""}
111      </Text>
112    </Box>
113  );
114}
115
hooks/sections/files.tsx 102 lines
1import type { Elements } from "claude-code";
2import type { PaletteTheme } from "palette";
3
4import type { Change } from "../../types";
5import { EDITED_MARK, FOLDER_CLOSED_ICON, FOLDER_ICON, fileIcon } from "../lib/icons";
6import { paint, unInverted as unInvertedIn } from "../lib/theme";
7import type { Ui } from "../lib/theme";
8import { buildTree } from "../lib/tree";
9
10export function FilesSection({
11  ui: { Box, Button, Text },
12  theme,
13  changedFiles,
14  collapsedFolders,
15  onToggleFolder,
16}: {
17  // the folder lines are buttons: this section needs Button on top of Box and Text
18  ui: Ui & Pick<Elements[keyof Elements], "Button">;
19  theme?: PaletteTheme;
20  changedFiles: readonly Change[];
21  collapsedFolders: ReadonlySet<string>;
22  onToggleFolder: (folderPath: string) => void;
23}) {
24  const addedTotal = changedFiles.reduce(
25    (total, file) => total + (file.added ?? 0),
26    0,
27  );
28  const deletedTotal = changedFiles.reduce(
29    (total, file) => total + (file.deleted ?? 0),
30    0,
31  );
32
33  return (
34    <Box flexDirection="column">
35      <Text weight="semibold">Files</Text>
36      {changedFiles.length === 0 && <Text dimColor>None.</Text>}
37      {buildTree(changedFiles, collapsedFolders).map((row, rowIndex) => {
38        const { folderPath } = row;
39        // a click on a folder's line folds and unfolds its children; `hover` keeps the line unchanged
40        // under the pointer (see unInverted)
41        if (folderPath !== undefined) {
42          const isCollapsed = row.hiddenCount !== undefined;
43          const unInverted = (shownColor?: string) => unInvertedIn(theme, shownColor);
44          return (
45            <Box key={`folder-${folderPath}`} flexDirection="row">
46              <Button
47                key={`fold-${folderPath}`}
48                plain
49                onPress={() => onToggleFolder(folderPath)}
50              >
51                <Text color={theme?.dimmed} hover={unInverted(theme?.dimmed)}>
52                  {row.branch}
53                </Text>
54                <Text color={theme?.ansi.yellow} hover={unInverted(theme?.ansi.yellow)}>
55                  {isCollapsed ? FOLDER_CLOSED_ICON : FOLDER_ICON}{" "}
56                </Text>
57                <Text color={theme?.ansi.blue} hover={unInverted(theme?.ansi.blue)}>
58                  {row.label}
59                </Text>
60                {isCollapsed && (
61                  <Text color={theme?.dimmed} hover={unInverted(theme?.dimmed)}>
62                    {" "}
63                    {row.hiddenCount}
64                  </Text>
65                )}
66              </Button>
67            </Box>
68          );
69        }
70        const change = row.item!;
71        const icon = fileIcon(row.label);
72        return (
73          <Box key={`file-${rowIndex}`} flexDirection="row" gap={1}>
74            <Text wrap="truncate-end">
75              <Text dimColor>{row.branch}</Text>
76              <Text color={paint(theme, icon.color)}>{icon.glyph} </Text>
77              {row.label}
78            </Text>
79            {change.added !== null && (
80              <Text color={theme?.ansi.green}>+{change.added}</Text>
81            )}
82            {change.deleted !== null && change.deleted > 0 && (
83              <Text color={theme?.ansi.red}>-{change.deleted}</Text>
84            )}
85            {change.added === null && !change.isNew && (
86              <Text dimColor>bin</Text>
87            )}
88            <Text color={change.isNew ? theme?.ansi.green : theme?.ansi.yellow}>
89              {EDITED_MARK}
90            </Text>
91          </Box>
92        );
93      })}
94      {changedFiles.length > 0 && (
95        <Text dimColor>
96          {changedFiles.length} edited · +{addedTotal} -{deletedTotal}
97        </Text>
98      )}
99    </Box>
100  );
101}
102
hooks/sections/mcp.tsx 48 lines
1import type { McpServer, McpStatus } from "mcp-status";
2import type { PaletteColorPath, PaletteTheme } from "palette";
3
4import { paint } from "../lib/theme";
5import type { Ui } from "../lib/theme";
6
7// gray: not called yet; green: answered; yellow: a call errored or it needs sign-in; red: down
8const STATUS_COLOR: Record<McpStatus, PaletteColorPath> = {
9  idle: "comment",
10  ok: "ansi.green",
11  warning: "ansi.yellow",
12  error: "ansi.red",
13};
14
15// one line per server, the dot in its status color; a server in trouble shows its latest issue (or the
16// health check's words) dimmed after its name, /mcp-health has the rest
17export function McpSection({
18  ui: { Box, Text },
19  theme,
20  serverList,
21}: {
22  ui: Ui;
23  theme: PaletteTheme | undefined;
24  serverList: readonly McpServer[];
25}) {
26  return (
27    <Box flexDirection="column">
28      <Text weight="semibold">MCP</Text>
29      {serverList.length === 0 ? (
30        <Text dimColor>None.</Text>
31      ) : (
32        serverList.map((server) => {
33          const isTroubled =
34            server.status === "warning" || server.status === "error";
35          const detail = server.issues.at(-1) ?? server.health;
36          return (
37            <Text key={server.key} wrap="truncate-end">
38              <Text color={paint(theme, STATUS_COLOR[server.status])}>● </Text>
39              {server.name}
40              {isTroubled && detail ? <Text dimColor> {detail}</Text> : null}
41            </Text>
42          );
43        })
44      )}
45    </Box>
46  );
47}
48
hooks/sections/skills.tsx 21 lines
1import type { Ui } from "../lib/theme";
2
3export function SkillsSection({
4  ui: { Box, Text },
5  skillList,
6}: {
7  ui: Ui;
8  skillList: readonly string[];
9}) {
10  return (
11    <Box flexDirection="column">
12      <Text weight="semibold">Skills</Text>
13      {skillList.length === 0 ? (
14        <Text dimColor>None.</Text>
15      ) : (
16        <Text wrap="wrap">{skillList.join(", ")}</Text>
17      )}
18    </Box>
19  );
20}
21
hooks/sections/mainAgent.tsx 148 lines
1import type { Elements, SessionUsage } from "claude-code";
2import type { PaletteColorPath, PaletteTheme } from "palette";
3
4import type { ContextInfo, ModelInfo } from "../../types";
5import { Meter } from "../components/meter";
6import { fmtElapsed, fmtLeft } from "../lib/format";
7import { modelIcon } from "../lib/icons";
8import { band, paint, unInverted } from "../lib/theme";
9import type { Ui } from "../lib/theme";
10
11// the effort scale, one meter cell per level; a level outside it (a number) shows as text only
12const EFFORT_LEVELS = ["low", "medium", "high", "xhigh", "max"];
13// low and medium are drawn gray
14const EFFORT_COLOR: Record<string, PaletteColorPath> = {
15  max: "ansi.magenta",
16  xhigh: "ansi.magenta",
17  high: "ansi.cyan",
18};
19
20// nf-md-cached, as an escape: Nerd Font glyphs vanish from Claude's own output
21const CACHE_GLYPH = "\u{F00E8}";
22
23// the main conversation's card, the root the subagents' tree hangs from: model, effort, cost, limits, cache, time
24export function MainAgentCard({
25  ui: { Box, Button, Text },
26  theme,
27  modelInfo,
28  contextInfo,
29  usage,
30  nowMs,
31  onViewMain,
32}: {
33  // the model's line is a button: this card needs Button on top of Box and Text
34  ui: Ui & Pick<Elements[keyof Elements], "Button">;
35  theme?: PaletteTheme;
36  modelInfo: ModelInfo | null;
37  contextInfo: ContextInfo | null;
38  usage: SessionUsage;
39  nowMs: number;
40  onViewMain: () => void;
41}) {
42  const fiveHourLimit = usage.rateLimits.find(
43    (rateLimit) => rateLimit.kind === "five_hour",
44  );
45  const sevenDayLimit = usage.rateLimits.find(
46    (rateLimit) => rateLimit.kind === "seven_day",
47  );
48  const spendLimit = usage.rateLimits.find(
49    (rateLimit) => rateLimit.kind === "spend_limit",
50  );
51  // one countdown, for the 7d window once it is under pressure, else the 5h one
52  const countdownLimit =
53    sevenDayLimit &&
54    fiveHourLimit &&
55    sevenDayLimit.percentUsed > fiveHourLimit.percentUsed &&
56    sevenDayLimit.percentUsed >= 50
57      ? sevenDayLimit
58      : fiveHourLimit;
59  const secondsUntilReset = countdownLimit?.resetsAt
60    ? Math.floor((Date.parse(countdownLimit.resetsAt) - nowMs) / 1000)
61    : 0;
62  const elapsedSeconds = Math.floor((nowMs - usage.startedAt) / 1000);
63  const effort = modelInfo?.effort;
64  const effortLevel = effort ? EFFORT_LEVELS.indexOf(effort) + 1 : 0;
65  const effortColor = paint(theme, (effort && EFFORT_COLOR[effort]) || "comment");
66  const model = modelIcon(modelInfo?.model);
67  const cacheRead = contextInfo?.cacheReadPercent ?? null;
68
69  return (
70    <Box
71      flexDirection="column"
72      borderStyle="round"
73      borderColor={theme?.comment}
74      paddingX={1}
75    >
76      <Box flexDirection="row" gap={2}>
77        {/* a click brings the main conversation back into the main view; `hover` keeps the line
78            unchanged under the pointer (see unInverted); the keyed Box is the area that hovers */}
79        <Box key="view-main-row" flexDirection="row">
80          <Button key="view-main" plain onPress={onViewMain}>
81            <Text weight="semibold">
82              <Text
83                color={paint(theme, model.color)}
84                hover={unInverted(theme, paint(theme, model.color))}
85              >
86                {model.glyph}{" "}
87              </Text>
88              <Text color={theme?.ansi.cyan} hover={unInverted(theme, theme?.ansi.cyan)}>
89                {modelInfo?.model ?? "Claude"}
90              </Text>
91            </Text>
92          </Button>
93        </Box>
94        {effort && (
95          <Text color={effortColor}>
96            🧠{" "}
97            {effortLevel > 0 && (
98              <Text>
99                {Meter({
100                  ui: { Box, Text },
101                  filled: effortLevel,
102                  total: EFFORT_LEVELS.length,
103                  filledColor: effortColor,
104                })}{" "}
105              </Text>
106            )}
107            {effort}
108          </Text>
109        )}
110        {usage.cost && usage.cost.usd > 0 && (
111          <Text color={theme?.ansi.red}>💰 ${usage.cost.usd.toFixed(4)}</Text>
112        )}
113      </Box>
114      <Box flexDirection="row" gap={2}>
115        {fiveHourLimit && sevenDayLimit && (
116          <Text>
117            <Text color={theme?.ansi.yellow}>⚡ </Text>
118            <Text color={paint(theme, band(fiveHourLimit.percentUsed))}>
119              {Math.round(fiveHourLimit.percentUsed)}%
120            </Text>
121            <Text dimColor>/</Text>
122            <Text color={paint(theme, band(sevenDayLimit.percentUsed))}>
123              {Math.round(sevenDayLimit.percentUsed)}%
124            </Text>
125            {secondsUntilReset > 0 && (
126              <Text color={theme?.ansi.blue}> ↺ {fmtLeft(secondsUntilReset)}</Text>
127            )}
128          </Text>
129        )}
130        {cacheRead !== null && (
131          // high is good: a drop means the cache lapsed and the prefix was billed again
132          <Text color={paint(theme, band(100 - cacheRead))}>
133            {CACHE_GLYPH} {Math.round(cacheRead)}%
134          </Text>
135        )}
136        {spendLimit && (
137          <Text color={paint(theme, band(spendLimit.percentUsed))}>
138            💳 {Math.round(spendLimit.percentUsed)}%
139          </Text>
140        )}
141        {elapsedSeconds > 0 && (
142          <Text color={theme?.ansi.magenta}>⏱ {fmtElapsed(elapsedSeconds)}</Text>
143        )}
144      </Box>
145    </Box>
146  );
147}
148
hooks/state/context.ts 34 lines
1// The Context section's state: the context window's breakdown, re-read after each turn and each compaction.
2// The atom stays here with its read/update calls, as the validator requires.
3import { atom, read, update } from "claude-code";
4import type { EngineInterface } from "claude-code";
5
6import type { ContextInfo } from "../../types";
7import { cacheReadPercent } from "../lib/format";
8
9const context = atom({ plugin: "session", key: "context" } as const, null);
10
11// the summary breakdown is estimated locally: no API call
12export async function refreshContext($: EngineInterface) {
13  const { breakdown } = (await $.session.usage({ breakdown: "summary" }))
14    .context;
15  if (!breakdown) return;
16  const contextInfo: ContextInfo = {
17    slices: breakdown.categories.map(({ name, tokens, kind }) => ({
18      name,
19      tokens,
20      kind,
21    })),
22    maxTokens: breakdown.maxTokens,
23    compactAt: breakdown.autoCompactThreshold ?? null,
24    cacheReadPercent: breakdown.apiUsage
25      ? cacheReadPercent(breakdown.apiUsage)
26      : null,
27  };
28  await update($, context, () => contextInfo);
29}
30
31export async function readContext($: EngineInterface) {
32  return read($, context);
33}
34
hooks/state/files.ts 75 lines
1// The Files section's state: the changed files (git, debounced after writes and polled while the pane is open)
2// and the folded folders. The atoms stay here with their read/update calls, as the validator requires.
3import { atom, read, update } from "claude-code";
4import type { EngineInterface } from "claude-code";
5
6import {
7  DIFF_ARGS,
8  UNTRACKED_ARGS,
9  parseNumstat,
10  parseUntracked,
11} from "../lib/git";
12import { isPaneOpen } from "./pane";
13
14const files = atom({ plugin: "session", key: "files" } as const, []);
15const collapsedFolders = atom(
16  { plugin: "session", key: "collapsedFolders" } as const,
17  [],
18);
19
20export const GIT_POLL_MS = 10_000;
21const DEBOUNCE_MS = 300;
22export const WRITERS = new Set([
23  "Edit",
24  "MultiEdit",
25  "Write",
26  "NotebookEdit",
27  "Bash",
28]);
29
30// bumped by every refresh request: a run that is no longer the latest drops its result
31let refreshGeneration = 0;
32
33export async function refresh($: EngineInterface) {
34  const thisGeneration = ++refreshGeneration;
35  // ponytail: HEAD fails in a repo without commits; untracked files still show there
36  const [diff, untracked] = await Promise.all([
37    $.process.run(DIFF_ARGS),
38    $.process.run(UNTRACKED_ARGS),
39  ]);
40  if (thisGeneration !== refreshGeneration) return;
41  const changes = diff.exitCode === 0 ? parseNumstat(diff.stdout) : [];
42  if (untracked.exitCode === 0)
43    changes.push(...parseUntracked(untracked.stdout));
44  await update($, files, () => changes);
45}
46
47// coalesces bursts of tool calls into one git run, and skips it while the pane is closed
48export async function scheduleRefresh($: EngineInterface) {
49  const thisGeneration = ++refreshGeneration;
50  await $.clock.sleep(DEBOUNCE_MS);
51  if (thisGeneration !== refreshGeneration || !(await isPaneOpen($))) return;
52  await refresh($);
53}
54
55// ponytail: a folded folder stays listed once its files are committed; harmless, the list stays tiny
56export async function toggleFolder($: EngineInterface, folderPath: string) {
57  await update($, collapsedFolders, (folderPaths) =>
58    folderPaths.includes(folderPath)
59      ? folderPaths.filter((path) => path !== folderPath)
60      : [...folderPaths, folderPath],
61  );
62}
63
64// git changes made outside Claude (a commit, a checkout in another terminal) raise no event:
65// re-read them on a timer (register's $.clock.every) while the pane is open
66// ponytail: polling; a file watcher if git ever gets slow on a big repo
67export async function pollGit($: EngineInterface) {
68  if (await isPaneOpen($)) await refresh($);
69}
70
71// the changed files and the folded folders, for the pane's render
72export async function readFiles($: EngineInterface) {
73  return Promise.all([read($, files), read($, collapsedFolders)]);
74}
75
hooks/state/pane.ts 14 lines
1// The session pane's id and width, and the $ calls that open it or ask whether it is open.
2import type { EngineInterface } from "claude-code";
3
4export const PANE = "session";
5export const PANE_COLUMNS = 70;
6
7export async function isPaneOpen($: EngineInterface) {
8  return (await $.ui.panes()).some((pane) => pane.id === PANE);
9}
10
11export async function openPane($: EngineInterface) {
12  await $.ui.open({ id: PANE, title: "Session", columns: PANE_COLUMNS });
13}
14