modscode EN

modscode / 図鑑 / timeline

timeline

A pane with one card per turn of the session: what you asked, what Claude did, what it touched. Click a card to jump to that turn.

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

何をするか

  • 欄を描く
  • /timeline を足す
  • session.measure・session.start・turn.complete・turn.start ほか 3 個にフックする
  • ターンをまたいで自分の状態を持つ

良いところ

  • ネットワークに出ない
  • プロセスを起こさない
  • TypeScript で書かれている
  • エラーを扱う

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like timeline by Yunjia Zheng (pane), as modscode read it from the mod's code:
// https://modscode.com/gallery/yunjiaz7-timeline/
// 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: "Timeline" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Input, Button } = $.ui.resolve(e)
    const text = '…'
    const text2 = '…'
    const text3 = '…'
    const text4 = '…'
    const text5 = '…'
    const text6 = '…'
    const status = '…'
    const mark = '…'
    const head = '…'
    const head2 = '…'
    const head3 = '…'
    const length = '…'
    const mark2 = '…'
    const head4 = '…'
    const head5 = '…'
    const head6 = '…'
    const length2 = '…'
    const mark3 = '…'
    const head7 = '…'
    const head8 = '…'
    const head9 = '…'
    const length3 = '…'
    return (
      <Box flexDirection="column" paddingRight={1}>
        <Box flexDirection="row" justifyContent="space-between" paddingX={2}>
          <Box flexDirection="row">
            <Text>
              {text}
            </Text>
            <Text>
              {text2}
            </Text>
            <Text>
              {text3}
            </Text>
          </Box>
          <Box flexDirection="row">
            <Text>
              {text4}
            </Text>
            <Text>
              {text5}
            </Text>
            <Text>
              {text6}
            </Text>
          </Box>
        </Box>
        <Text color="text" dimColor>
          Nothing yet.
        </Text>
        <Box flexDirection="column">
          <Box borderStyle="round" borderColor="claude" paddingX={1}>
            <Input label="Find" placeholder="describe the turn you are looking for" value="" submitLabel="search" autoFocus />
          </Box>
          <Box paddingX={2}>
            <Text color="inactive">
              {status}
            </Text>
          </Box>
          <Box flexDirection="row" paddingX={2} gap={1}>
            <Button variant="primary" label="back to timeline" />
            <Text color="inactive">
              ·
            </Text>
            <Text color="claude" bold>
              /timeline find
            </Text>
            <Text color="inactive">
              hides the search box
            </Text>
          </Box>
        </Box>
        <Box flexDirection="column" marginTop={1} paddingX={1} borderStyle="round" borderColor="claude" backgroundColor="inverseText">
          <Box flexDirection="row">
            <Box flexShrink={0}>
              <Text color="inactive" bold>
                {mark}
              </Text>
            </Box>
            <Button plain dimColor label={`${text}`} />
          </Box>
          <Button plain dimColor label={`${text}`} />
          <Button plain dimColor label={`${text}`} />
          <Button plain dimColor label={`${text}`} />
          <Button plain dimColor label={`${text}`} />
          <Button plain dimColor label={`${text}`} />
          <Button plain dimColor label={`${text}`} />
          <Text color="error" wrap="wrap">
            {"  ⚠ "}
            {head}
          </Text>
          <Text color="error" wrap="wrap">
            {"  ⚠ "}
            {head2}
          </Text>
          <Text color="error" wrap="wrap">
            {"  ⚠ "}
            {head3}
          </Text>
          <Text color="error">
            {"  ⚠ "}
            {"…and "}
            {length}
            {" more"}
          </Text>
        </Box>
        <Box flexDirection="column" marginTop={1} paddingX={1} borderStyle="round" borderColor="claude" backgroundColor="inverseText">
          <Box flexDirection="row">
            <Box flexShrink={0}>
              <Text color="inactive" bold>
                {mark2}
              </Text>
            </Box>
            <Button plain dimColor label={`${text}`} />
          </Box>
          <Button plain dimColor label={`${text}`} />
          <Button plain dimColor label={`${text}`} />
          <Button plain dimColor label={`${text}`} />
          <Button plain dimColor label={`${text}`} />
          <Button plain dimColor label={`${text}`} />
          <Button plain dimColor label={`${text}`} />
          <Text color="error" wrap="wrap">
            {"  ⚠ "}
            {head4}
          </Text>
          <Text color="error" wrap="wrap">
            {"  ⚠ "}
            {head5}
          </Text>
          <Text color="error" wrap="wrap">
            {"  ⚠ "}
            {head6}
          </Text>
          <Text color="error">
            {"  ⚠ "}
            {"…and "}
            {length2}
            {" more"}
          </Text>
        </Box>
        <Box flexDirection="column" marginTop={1} paddingX={1} borderStyle="round" borderColor="claude" backgroundColor="inverseText">
          <Box flexDirection="row">
            <Box flexShrink={0}>
              <Text color="inactive" bold>
                {mark3}
              </Text>
            </Box>
            <Button plain dimColor label={`${text}`} />
          </Box>
          <Button plain dimColor label={`${text}`} />
          <Button plain dimColor label={`${text}`} />
          <Button plain dimColor label={`${text}`} />
          <Button plain dimColor label={`${text}`} />
          <Button plain dimColor label={`${text}`} />
          <Button plain dimColor label={`${text}`} />
          <Text color="error" wrap="wrap">
            {"  ⚠ "}
            {head7}
          </Text>
          <Text color="error" wrap="wrap">
            {"  ⚠ "}
            {head8}
          </Text>
          <Text color="error" wrap="wrap">
            {"  ⚠ "}
            {head9}
          </Text>
          <Text color="error">
            {"  ⚠ "}
            {"…and "}
            {length3}
            {" more"}
          </Text>
        </Box>
      </Box>
    )
  })
}

Mod 自身のコード

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

hooks/register.tsx 1937〜2096 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    const { Box, Button, Text } = $.ui.resolve(e)
    // A reload empties the module's own variables while the store keeps its
    // summaries, and a draw can be the first thing to run after one — so the
    // drawing loads them itself rather than trusting a command to have run.
    const storeKey = await loadStore($, language)
    await readMeter($)
    // The transcript is fetched only when a turn has changed it. A
    // redraw because the marker moved reuses the rows it already has, so
    // scrolling does not pull the whole session across on every step.
    let rows: Row[]
    let size: string
    if (cache === null) {
      const messages = await $.session.messages()
      if ('deny' in messages) {
        return <Text color="text" dimColor>cannot read this session</Text>
      }
      rows = rowsCached(messages)
      size = tailOf(messages)
    } else {
      rows = cache.rows
      size = cache.tail
    }
    // Read so that bumping it redraws this pane alone.
    await read($, drawAtom)
    isOpen = true
    // The maps may just have caught up with rows that reported before them.
    recompute()
    loop($)
    const nowAt = markedN
    drawnMark = nowAt
    // The pane's own body, not `e.viewport`: that is the conversation's width,
    // and sizing by it cut every line for a column twice as wide as the pane.
    // Less the pane's right pad, the card's border and its padding.
    const width = Math.max(20, (e.props.bodyColumns ?? 60) - 5)
    // What is left to write, counting a row that has only its ask: the trigger
    // below and the footer both read this, and counting only rows with nothing
    // at all meant a half-written row never asked for its other half.
    const unsummarised = rows.filter(
      r => summaries[r.key] === undefined
        || (doReplies && summaries[r.key]?.did === '' && r.body.trim() !== ''),
    ).length

    // Drawing the pane is the signal that someone is reading it, and the only
    // one that holds across a reload, a reopen and a new turn alike. The fill
    // is not awaited: the tree goes back now with the asks as written, and the
    // summaries land on the redraw its own invalidate causes. `filling` and
    // the missing count bound it — once nothing is missing, no call runs.
    if (unsummarised > 0 && !filling) {
      void runFill($, rows, storeKey, language, size, doReplies).catch(() => undefined)
    }

    // For each row, the last tool call of the rows before it: one pass.
    let lastTool: string | undefined
    const above = rows.map(r => {
      const before = lastTool
      lastTool = r.toolIds.at(-1) ?? lastTool

      return before
    })

    // Not every surface has a text field; where there is none the box is not
    // drawn and `/timeline find <words>` still searches.
    const table = $.ui.resolve(e)
    const Input = 'Input' in table ? table.Input : undefined
    const shown = isFinding && matches !== null
      ? matches.map(n => rows[n - 1]).filter((r): r is Row => r !== undefined)
      : rows
    shownOrder = shown.map(r => r.n)
    isPaneFocused = e.props.isFocused === true
    // The window is meant to stay at the head while the box is up. If the
    // engine moved it all the same (to show the ring), it is put back.
    if (isFinding && (e.props.scroll?.offset ?? 0) !== 0 && !isResetting) {
      isResetting = true
      $.clock.after(0, () => {
        void $.ui.scroll({ in: PANE, to: 'start' }).catch(() => undefined).then(() => {
          isResetting = false
        })
      })
    }
    paneRows = e.props.scroll?.bodyRows ?? paneRows
    // A card's rows: its border, the gap above it, its title and what is
    // drawn under that. The same lines the card draws below.
    heights = !isFinding ? [] : shown.map(row => {
      const summary = summaries[row.key]
      const did = !doReplies
        ? null
        : summary?.did || (summary !== undefined ? pendingOf(row, isRunning && row.n === rows.length, filling) : null)
      const errors = doReplies ? Math.min(2, row.errors.length) + (row.errors.length > 2 ? 1 : 0) : 0

      return 4
        + (did === null ? 0 : wrapCells(`  → ${did}`, width).length)
        + (doReplies && row.facts.length > 0 ? wrapCells(`  ${row.facts.join(' · ')}`, width).length : 0)
        + errors
    })
    if (isFinding) {
      // A window that grew, or cards that got shorter, can leave the first
      // card past where the last one would sit at the bottom.
      findTop = Math.min(findTop, lastTop(heights, paneRows - HEAD_ROWS))
      drawnCount = fitCount(heights, findTop, paneRows - HEAD_ROWS)
    }
    const status = isSearching
      ? 'searching…'
      : matches === null
        ? 'Enter searches by meaning'
        : matches.length === 0
          ? `nothing matches "${head(query, 24)}"`
          : `${matches.length} match${matches.length > 1 ? 'es' : ''}, best first — click one to jump to it`

    const { left, right } = meterParts(meter)
    const run = (parts: Part[], at: string) => parts.map((part, i) => (
      <Text key={`${at}${i}`} color={part.color} bold={part.bold}>{part.text}</Text>
    ))

    return (
      <Box flexDirection="column" paddingRight={1}>
        {/* How much of the context window and of the rate windows is used:
            figures only, coloured as they near the edge. */}
        {(left.length > 0 || right.length > 0) && (
          <Box flexDirection="row" justifyContent="space-between" paddingX={2}>
            <Box flexDirection="row">{run(left, 'ml')}</Box>
            <Box flexDirection="row">{run(right, 'mr')}</Box>
          </Box>
        )}
        {rows.length === 0 && <Text color="text" dimColor>Nothing yet.</Text>}
        {isFinding && Input !== undefined && (
          <Box flexDirection="column">
            <Box borderStyle="round" borderColor="claude" paddingX={1}>
              <Input
                key="find"
                label="Find"
                placeholder="describe the turn you are looking for"
                value={query}
                submitLabel="search"
                autoFocus
                onSubmit={(value: string) => {
                  void runFind($, rows, value)
                }}
              />
            </Box>
            {/* The command that closes it is the one thing here to act on, so
                it is the one thing in the accent. */}
            <Box paddingX={2}>
              <Text color="inactive">{status}</Text>
            </Box>
            {/* The way out of the results that needs no typing: back to every
                card, the box left open. A primary Button is drawn in the
                accent, `[ so ]`. The box itself shuts with the command. */}
            <Box flexDirection="row" paddingX={2} gap={1}>
              {matches !== null && (
                <Button
                  key="find-back"
                  variant="primary"
                  label="back to timeline"
                  onPress={() => {
                    void runFind($, rows, '')
                  }}
                />
              )}
              {matches !== null && <Text color="inactive">·</Text>}
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 Yunjia Zheng

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 に読んだコミット 1b932317e7aa のソースから。最初のまとまりが載せる条件で、残りは自分で判断するための材料です。後のコミットは、次に読むまで見ていません。

載せる条件: 確かめやすいコード
入口を読んだhooks/hooks.json が名指すモジュールをすべて読んだ。hooks/register.tsx
解析できるすべてのファイルが TypeScript か JavaScript として解析できる。1 ファイルを解析
コードが 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/… などは無い)。Windows にないプログラムを使わない
通信fetch の送り先(https のホスト)がコードに書いてあるか。通信なし
プログラム起動するプログラムの名前がコードに書いてあり、シェル・インタプリタ・通信用の道具でないか。プログラムを起動しない
読んで送るファイルや環境変数を読み、かつ通信するか。通信しない
ソースの鍵ソースに API キーや秘密鍵らしきものがあるか。ソースに鍵なし
ライセンスオープンなライセンス(MIT・Apache-2.0・BSD・ISC・Unlicense・0BSD・CC0)で全文があれば、modscode にコードを載せる。違えばリンクだけ。MIT

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

入れる

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

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

/plugin marketplace add yunjiaz7/claude-timeline-mod
/plugin install timeline@claude-timeline-mod

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

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン