modscode EN

modscode / 図鑑 / open-tray

open-tray

A pane of things to look at or listen to: what Claude made this session, things related to what you are working on, and local servers. Project rules in .claude/tray.json or ~/.claude/open-tray/rules/.

確かめやすいコードターミナル+デスクトップペイントーストBoxButtonText

何をするか

  • 欄・トーストを描く
  • /tray を足す
  • mcp__open-tray__offer の呼び出しを見張る(止めることがある)
  • prompt.submit・session.start・turn.completeにフックする
  • ターンをまたいで自分の状態を持つ

良いところ

  • ネットワークに出ない
  • TypeScript で書かれている
  • エラーを扱う

作り始めるためのコード

2 種類あります。上のデザインから modscode が書いた雛形と、その Mod 自身のコードのうち描いている部分です。

雛形(register.tsx)

register.tsx
import type { Register } from 'claude-code'

// Drawn like open-tray by Jake Rains (pane, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/jakerains-open-tray/
// 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: "Open Tray" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Button } = $.ui.resolve(e)
    const label = '…'
    const text = '…'
    const count = '…'
    const ICONS = '…'
    const meta = '…'
    const text2 = '…'
    const tag = '…'
    const url = '…'
    return (
      <Box flexDirection="column">
        <Box flexDirection="row" justifyContent="space-between">
          <Text bold>
            <Text color="#a78bfa">
              {"◆ "}
            </Text>
            Open Tray
          </Text>
          <Text backgroundColor="#a78bfa" color="#14121c" bold>
            {` ${label} `}
          </Text>
        </Box>
        <Box flexDirection="column" marginTop={1} paddingX={1}>
          <Text color="#b8b5c8">
            Nothing here yet.
          </Text>
          <Text color="#6e6a80" wrap="wrap">
            Films, audio, images and pages I make for you land here. As we work, things related to what we are on show up below.
          </Text>
        </Box>
        <Box flexDirection="row" marginTop={1}>
          <Text bold color="#a78bfa">
            {text}
          </Text>
          <Text color="#6e6a80">
            {` ${count} `}
          </Text>
          <Text color="#3a3750">
            ────────
          </Text>
        </Box>
        <Box flexDirection="row" justifyContent="space-between" backgroundColor="#26243a">
          <Box flexDirection="row" flexShrink={1}>
            <Text color="#a78bfa">
              ▌
            </Text>
            <Text>
              {` ${ICONS} `}
            </Text>
            <Button plain label={`${label}`} />
          </Box>
          <Text color="#6e6a80">
            {` ${meta} `}
          </Text>
        </Box>
        <Box flexDirection="row" justifyContent="space-between" backgroundColor="#26243a">
          <Box flexDirection="row" flexShrink={1}>
            <Text color="#a78bfa">
              ▌
            </Text>
            <Text>
              {` ${ICONS} `}
            </Text>
            <Button plain label={`${label}`} />
          </Box>
          <Text color="#6e6a80">
            {` ${meta} `}
          </Text>
        </Box>
        <Box flexDirection="row" justifyContent="space-between" backgroundColor="#26243a">
          <Box flexDirection="row" flexShrink={1}>
            <Text color="#a78bfa">
              ▌
            </Text>
            <Text>
              {` ${ICONS} `}
            </Text>
            <Button plain label={`${label}`} />
          </Box>
          <Text color="#6e6a80">
            {` ${meta} `}
          </Text>
        </Box>
        <Box flexDirection="row" marginTop={1}>
          <Text bold color="#a78bfa">
            {text2}
          </Text>
          <Text color="#6e6a80">
            {` ${count} `}
          </Text>
          <Text color="#3a3750">
            ────────
          </Text>
        </Box>
        <Box flexDirection="row" flexWrap="wrap" marginTop={1}>
          <Button plain hotkey="o" label="open   " />
          <Button plain hotkey="f" label="Finder   " />
          <Button plain hotkey="a" label="audio   " />
          <Button plain hotkey="p" label="keep   " />
          <Button plain hotkey="x" label="remove   " />
          <Button plain hotkey="j" label="down   " />
          <Button plain hotkey="k" label="up" />
        </Box>
        <Box flexDirection="column" borderStyle="round" borderColor="#3a3750" paddingX={1} marginTop={1}>
          <Text bold color="#b8b5c8">
            Local servers
          </Text>
          <Box flexDirection="row">
            <Text color="#4ade80">
              {"● "}
            </Text>
            <Button plain label={`${tag}  ${url}`} />
            <Text color="#f87171">
              {"  stopped"}
            </Text>
          </Box>
          <Box flexDirection="row">
            <Text color="#4ade80">
              {"● "}
            </Text>
            <Button plain label={`${tag}  ${url}`} />
            <Text color="#f87171">
              {"  stopped"}
            </Text>
          </Box>
          <Box flexDirection="row">
            <Text color="#4ade80">
              {"● "}
            </Text>
            <Button plain label={`${tag}  ${url}`} />
            <Text color="#f87171">
              {"  stopped"}
            </Text>
          </Box>
          <Button plain hotkey="r" label={`restart ${tag}`} />
        </Box>
      </Box>
    )
  })

  on('session.start', async ($, e, next) => {
    const baseName = '…'
    await $.ui.toast(`Not found: ${baseName}`)
    await $.ui.toast(`Shown in Finder: Open Tray opens only films, audio, images, pages and documents`)
    return next(e)
  })
}

Mod 自身のコード

Mod のライセンス(MIT)に従って載せています。全文は下にあります。写すときは著作権表示を残してください。

open-tray/hooks/register.tsx 236〜365 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    const { Box, Text, Button } = $.ui.resolve(e)
    const mine = await read($, items)
    const r = await read($, related)
    const away = new Set(await read($, hidden))
    const live = await read($, players)
    const now = await $.clock.now()
    const columns = e.props.bodyColumns
    const rows = flatten(mine, r, away)
    const pick = Math.min(await read($, selected), Math.max(0, rows.length - 1))
    const stopped = live.find(p => !p.isAlive)
    const mineCount = rows.filter(row => row.place === 'mine').length
    const areaCount = rows.length - mineCount

    const title = (text: string, count: number) => (
      <Box flexDirection="row" marginTop={1}>
        <Text bold color={THEME.accent}>{text.toUpperCase()}</Text>
        <Text color={THEME.faint}>{` ${count} `}</Text>
        <Text color={THEME.rule}>{'─'.repeat(Math.max(0, columns - text.length - String(count).length - 2))}</Text>
      </Box>
    )

    const line = (index: number) => {
      const row = rows[index]!
      const isPicked = index === pick
      const bar = <Text color={THEME.accent}>{isPicked ? '▌' : ' '}</Text>
      if (row.kind === 'action') {
        return (
          <Box flexDirection="row" backgroundColor={isPicked ? THEME.picked : undefined}>
            {bar}
            <Text color={THEME.go}>{' ⏵ '}</Text>
            <Button key={`row-${index}`} plain label={clip(row.action.label, columns - 5)} onPress={() => void runRow($, index)} />
          </Box>
        )
      }
      const meta = `${row.item.tag ? `${row.item.tag}  ` : ''}${ago(now - row.item.addedAt)}`
      return (
        <Box flexDirection="row" justifyContent="space-between" width={columns} backgroundColor={isPicked ? THEME.picked : undefined}>
          <Box flexDirection="row" flexShrink={1}>
            {bar}
            <Text color={KIND_COLORS[row.item.kind]}>{` ${ICONS[row.item.kind]} `}</Text>
            <Button
              key={`row-${index}`}
              plain
              label={clip(row.item.label, Math.max(8, columns - meta.length - 7))}
              onPress={() => void runRow($, index)}
            />
          </Box>
          <Text color={THEME.faint}>{` ${meta} `}</Text>
        </Box>
      )
    }

    // The area's rows, under a small heading per group.
    const areaLines: RenderChildren[] = []
    let lastGroup = ''
    rows.forEach((row, index) => {
      if (row.place !== 'area') return
      if (row.group !== lastGroup) {
        areaLines.push(<Text color={THEME.sub}>{`  ${row.group}`}</Text>)
        lastGroup = row.group
      }
      areaLines.push(line(index))
    })

    return (
      <Box flexDirection="column" width={columns}>
        <Box flexDirection="row" justifyContent="space-between" width={columns}>
          <Text bold>
            <Text color={THEME.accent}>{'◆ '}</Text>
            {'Open Tray'}
          </Text>
          {r.label ? (
            <Text backgroundColor={THEME.accent} color={THEME.onAccent} bold>{` ${r.label} `}</Text>
          ) : (
            <Text color={THEME.faint}>{'following your work'}</Text>
          )}
        </Box>

        {rows.length === 0 && (
          <Box flexDirection="column" marginTop={1} paddingX={1}>
            <Text color={THEME.sub}>{'Nothing here yet.'}</Text>
            <Text color={THEME.faint} wrap="wrap">
              {'Films, audio, images and pages I make for you land here. As we work, things related to what we are on show up below.'}
            </Text>
          </Box>
        )}

        {mineCount > 0 && title('Made this session', mineCount)}
        {rows.map((row, index) => (row.place === 'mine' ? line(index) : null))}

        {areaCount > 0 && title(r.label || 'Related', areaCount)}
        {areaLines}

        {rows.length > 0 && (
          <Box flexDirection="row" flexWrap="wrap" marginTop={1}>
            <Button key="open" plain hotkey="o" label="open   " onPress={() => void runRow($, pick)} />
            <Button key="finder" plain hotkey="f" label="Finder   " onPress={() => void act($, pick, 'finder')} />
            <Button key="audio" plain hotkey="a" label="audio   " onPress={() => void act($, pick, 'audio')} />
            <Button key="keep" plain hotkey="p" label="keep   " onPress={() => void keep($, pick)} />
            <Button key="remove" plain hotkey="x" label="remove   " onPress={() => void remove($, pick)} />
            <Button key="down" plain hotkey="j" label="down   " onPress={() => void move($, 1)} />
            <Button key="up" plain hotkey="k" label="up" onPress={() => void move($, -1)} />
          </Box>
        )}

        {live.length > 0 && (
          <Box flexDirection="column" borderStyle="round" borderColor={THEME.rule} paddingX={1} marginTop={1}>
            <Text bold color={THEME.sub}>{'Local servers'}</Text>
            {live.map((player, index) => (
              <Box flexDirection="row">
                <Text color={player.isAlive ? THEME.go : THEME.stop}>{player.isAlive ? '● ' : '○ '}</Text>
                <Button
                  key={`player-${index}`}
                  plain
                  dimColor={!player.isAlive}
                  label={`${player.tag ?? 'player'}  ${player.url}`}
                  onPress={() => void $.process.run(['open', player.url])}
                />
                {!player.isAlive && <Text color={THEME.stop}>{'  stopped'}</Text>}
              </Box>
            ))}
            {stopped && (
              <Button key="restart" plain hotkey="r" label={`restart ${stopped.tag ?? stopped.url}`} onPress={() => void restart($, stopped)} />
            )}
          </Box>
        )}
      </Box>
    )
  })
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 Jake Rains

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.

コードが呼ぶもの

プログラム起動ファイル書き込み環境変数Claude を動かすツール呼び出し保存

コードから読み取ったデザイン

読み取ったコミットのソースから描いたもので、動かした結果ではありません。一覧は 3 回描き、条件はデスクトップアプリで描く最初の分岐を取り、動かしたときにだけ決まる値は仮の例(点線の下線)にするか省きます。色と書体はこのサイトのものです。

コードから読めること

2026-10-06 に読んだコミット 814b7ca1ba85 のソースから。最初のまとまりが載せる条件で、残りは自分で判断するための材料です。後のコミットは、次に読むまで見ていません。

載せる条件: 確かめやすいコード
入口を読んだhooks/hooks.json が名指すモジュールをすべて読んだ。open-tray/hooks/register.tsx
解析できるすべてのファイルが TypeScript か JavaScript として解析できる。2 ファイルを解析
コードが Mod の中で完結import は Mod 自身のファイルかエンジンのモジュールだけ。パッケージも require もない。コードはすべて Mod の中
読める圧縮した行・eval・new Function・計算した道の import()・符号化した塊がない。圧縮・eval・符号化した塊なし
呼び出しが見える通信とプログラム起動はその場で $.http.fetch・$.process.run と書き、他へ渡さない。外への呼び出しはすべてその場の $ で
入れる前に自分で判断する材料
描く場所コードから読んだ、描く先。ターミナル・デスクトップアプリ・両方・何も描かない(フックだけ: 見張りやプロンプトの書き換え)のどれか。出すだけで、外す理由にはしない。ターミナルとデスクトップアプリに同じように描く
入れる手順リポジトリ自身の .claude-plugin/marketplace.json にこの Mod が載っていて、ページに書いた手順でそのマーケットプレイスから入れられるか。リポジトリの .claude-plugin/marketplace.json に載っており、そこから入れられる
Windows のプログラム$.process で起動するプログラムが Windows にあるか(tail・date・open・osascript・/usr/… などは無い)。open-tray/hooks/register.tsx:353 open(Windows にない); open-tray/hooks/register.tsx:408 open(Windows にない); open-tray/hooks/register.tsx:421 open(Windows にない); open-tray/hooks/register.tsx:424 open(Windows にない); open-tray/hooks/register.tsx:437 open(Windows にない)
通信fetch の送り先(https のホスト)がコードに書いてあるか。通信なし
プログラム起動するプログラムの名前がコードに書いてあり、シェル・インタプリタ・通信用の道具でないか。open-tray/hooks/register.tsx:542 /bin/sh(シェル・インタプリタ); open-tray/hooks/register.tsx:561 /bin/sh(シェル・インタプリタ); open-tray/hooks/register.tsx:643 curl(通信する)
読んで送るファイルや環境変数を読み、かつ通信するか。reads environment variables and files and reaches the network
ソースの鍵ソースに API キーや秘密鍵らしきものがあるか。ソースに鍵なし
ライセンスオープンなライセンス(MIT・Apache-2.0・BSD・ISC・Unlicense・0BSD・CC0)で全文があれば、modscode にコードを載せる。違えばリンクだけ。MIT

コードの文面を読んだだけで、安全の審査ではありません。動かしてはおらず、起動するプログラムの中で何が起きるかも見えません。入れる前の確認はあなたの役目です。 載せる条件

入れる

入れる前に、必ず自分で確かめてください。Mod はサンドボックスなしで、あなたの権限で動きます。modscode はこのコードの安全を保証しません。下のコードを読み(またはフォルダーで claude plugin validate .)、触るものを見て、読んだコミットを入れてください。

リポジトリがそのままマーケットプレイスです。このマーケットプレイスを足し(ターミナルでは次のコマンド、デスクトップアプリではプラグインの設定)、そこから Mod を入れます。

/plugin marketplace add jakerains/claudemods
/plugin install open-tray@claudemods

入るのはマーケットプレイスの最新のコミットで、ここで読んだもの(814b7ca1ba85)と違うことがあります。入れる前に見比べてください。

Claude に聞く

modscode のコネクタを入れると、Claude がこのデザイン・コードが触るもの・コードを読んで、それをもとに作れます。たとえば:

modscode のデザイン「jakerains-open-tray」をコードごと読んで、同じようなペインを作って

Claude から探す: MCP コネクタ

似たデザイン