SLOPSHOPPER

copy-session-id

A button in the prompt footer that copies the session id

newspinnertoast
v0.1.0GPL-3.0updated 2026-10-09lehmacdj/.dotfiles/llm/mods/copy-session-id
A shopper browsing a rack in a slop shop
README

.dotfiles

My unix/linux configuration files.

Contains configuration for all of the following:

  • bash
  • vim
  • tmux
  • zsh

I really don't recommend you use this yourself as this is my configuration and I change it very frequently. Instead I recommend going to [this project][1] which attempts to be a cut down version of this repository intended for forking.

[1]: https://github.com/lehmacdj/dotfiles

Source 1 files
hooks/register.tsx 49 lines
1import type { Register, UiCopyResult } from 'claude-code'
2
3// Human-readable form of each reason a copy can fail; the raw code is kept
4// alongside it in the toast for diagnostics.
5const describeFailure = (
6  reason: Extract<UiCopyResult, { isCopied: false }>['reason'],
7): string => {
8  switch (reason) {
9    case 'no-surface':
10      return 'nothing is attached to draw on'
11    case 'no-clipboard':
12      return 'no clipboard tool is available here'
13    case 'refused':
14      return 'the copy was refused'
15  }
16}
17
18export const register: Register = on => {
19  // The status line's own row is not a site a mod can draw in; the mode labels
20  // at the right end of the prompt footer are the nearest one, so the button
21  // goes in front of them.
22  on('ui.render', { component: 'SessionMode' }, async ($, e) => {
23    const id = await $.session.id()
24    const { Box, Button, Text } = $.ui.resolve(e)
25
26    return (
27      <Box>
28        <Button
29          key="copy-id"
30          label="⧉ copy sid"
31          plain
32          onPress={async press => {
33            const copied = await $.ui.copy({ text: id, surface: press.surface })
34            $.ui.toast(
35              copied.isCopied
36                ? 'Copied session id'
37                : `Couldn't copy session id: ` +
38                    `${describeFailure(copied.reason)} (${copied.reason})`,
39            )
40          }}
41        />
42        {e.props.modes.length > 0 && (
43          <Text dimColor> {e.props.modes.join(' & ')}</Text>
44        )}
45      </Box>
46    )
47  })
48}
49