diff --git a/CHANGELOG.md b/CHANGELOG.md index 30ad96c..3328131 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog -## Unreleased +## 0.4.0 (not released yet) + +### Changed + +- The Timeline tab's summary offer says how to turn summary lines on (set `summaryModel` to `haiku`) and has a **Got it** button, instead of a **Turn on summaries** button that changed the setting: the plugin directory accepts no settings call from a mod that keeps its engine for later, as every button and timer in this one does. A change in `/config` reloads the mod with the new value. ### Added diff --git a/README.md b/README.md index bb28e2d..8a8cee1 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,15 @@ A Claude Code mod that gives every session a small notepad: a one-line headline > [!NOTE] > **Summary lines spend some of your Claude usage, so they are off until you turn them on.** With them on, the mod asks Claude Haiku for a one-line summary after each turn. A call sends about 500 tokens and gets about 20 back. At the API prices of October 2026 that is about $0.00006 a turn on Haiku 5.5 ($0.10 and $0.50 per million tokens in and out), or about 6 cents per 1,000 turns; if your Claude Code's `haiku` is Haiku 4.5 ($1 and $5), ten times that. On a Pro or Max plan it counts against your usage limits instead of costing money, and a single turn of your own conversation usually uses thousands of times as much. The Timeline tab's last line shows the running total. > -> To turn them on, press **Turn on summaries** in the Timeline tab, or set `summaryModel` to `haiku` in `/config` (or with `/plugin configure sessionpad@sessionpad`). To turn them off, set it back to `off`. Sessions already open in other windows may keep the old setting until they start again. While they are off, each turn's line in the Timeline is its prompt's first line, and the mod makes no model calls at all. +> To turn them on, set `summaryModel` to `haiku`: in a terminal session with `/config` or `/plugin configure sessionpad@sessionpad`, or from a shell (which serves the Desktop app's sessions too) with +> +> ```bash +> echo '{"summaryModel":"haiku"}' | claude plugin configure sessionpad@sessionpad --values-stdin +> ``` +> +> To turn them off, set it back to `off` the same way. Sessions already open in other windows may keep the old setting until they start again. While they are off, each turn's line in the Timeline is its prompt's first line, and the mod makes no model calls at all. -Status: alpha. Version 0.3.0, released 2026-10-29, with all four milestones built (notes, timeline, workspace, pruning). +Status: alpha. Version 0.4.0, not released yet; 0.3.0 was released 2026-10-29, with all four milestones built (notes, timeline, workspace, pruning). ## What it does @@ -128,8 +134,7 @@ That leaves your data. To delete it too, delete the mod's store file, the one na `claude plugin validate` reads the mod the way Claude Code will and lists every event it hooks and every API call it makes. For this version it reports, in part (the full report also lists the hooks that answer for themselves and the `$.state` values, and names the function behind each call): ``` -hooks: session.start, classic.SessionStart{source=clear|resume|fork}, - config.set{key="sessionpad.summaryModel"}, session.end, +hooks: session.start, classic.SessionStart{source=clear|resume|fork}, session.end, command.run{command=pad|sessionpad}, command.run{command=note|pad-note}, command.run{command=headline|pad-headline}, command.run{command=pad-export}, prompt.submit, turn.start, tool.call{tool=Edit|Write|NotebookEdit|Bash}, @@ -137,7 +142,7 @@ hooks: session.start, classic.SessionStart{source=clear|resume|fork}, tool.call{tool=mcp__sessionpad__notes_read}, ui.render{component=Pane, requestId=sessionpad}, ui.render{component=AbovePrompt} calls: $.clock.after, $.clock.every, $.clock.now, $.command.list, - $.command.register, $.config.set, $.env.get, $.fs.exists, $.fs.list, + $.command.register, $.env.get, $.fs.exists, $.fs.list, $.fs.read, $.fs.stat, $.fs.write, $.model.complete, $.process.run, $.session.cwd, $.session.id, $.session.repo, $.state.get, $.state.set, $.store.delete, $.store.get, $.store.keys, $.store.set, $.tool.register, @@ -146,7 +151,7 @@ env reads: CLAUDE_CONFIG_DIR, HOME, USERPROFILE env writes: nothing ``` -There is no `$.http`: the only thing that leaves your machine is the summary line's model call, described above. `$.process.run` runs `git` (read-only commands), `du -sk` and `rm` on the mod's own files. `$.config.set` changes only the mod's own `summaryModel`, when you press **Turn on summaries**, and the `config.set` hook only watches that one setting change. The hooks on `prompt.submit`, `turn.start` and the `tool.call` for Edit, Write, NotebookEdit and Bash only watch: each passes the event on and hands back what came back, untouched. Run `claude plugin validate sessionpad` in a clone to see the full report. +There is no `$.http`: the only thing that leaves your machine is the summary line's model call, described above. `$.process.run` runs `git` (read-only commands), `du -sk` and `rm` on the mod's own files. The mod changes no settings: the plugin directory accepts no settings call from a mod that, as this one does in its buttons and timers, keeps the engine for later, so the Timeline tab says how to turn summary lines on instead of doing it. The hooks on `prompt.submit`, `turn.start` and the `tool.call` for Edit, Write, NotebookEdit and Bash only watch: each passes the event on and hands back what came back, untouched. Run `claude plugin validate sessionpad` in a clone to see the full report. ## Development @@ -177,11 +182,11 @@ Decisions made while building, and places where this build of Claude Code (2.1.3 - **The input field sits under the headline**, above the notes, so it stays in view however many notes there are. - **The tools wait behind tool search**, as MCP tools do, so they cost nothing on requests that don't use them. Their names (`mcp__sessionpad__note`, `mcp__sessionpad__notes_read`) are enough for Claude to find them. - **Bold text uses `bold`**, which every surface draws; the Desktop app's table turns it into its own weight. -- **How it looks.** The pane follows the Cards design, `mockups/pane_as_drawn/02-cards.html` (the choice is recorded in `DECISION.md` beside it), drawn only with what a design test page (`/pad-demo`, removed once the look was settled) showed each surface can draw, as `mockups/sessionpad_pane/RENDERING.md` records. On Desktop the headline, each note, each day of the timeline and the current worktree sit on soft filled cards: a faint round border around a see-through grey fill (`rgba(128, 128, 128, 0.12)`), which reads as a light grey on the light pane and a dark grey on the dark one, so it follows the mode where an opaque raw color would turn unreadable in one of them; the Undo card is tinted red the same way. The cards were first filled with the theme's `promptBorder` shade, which drew too dark for the dim text and the buttons on them. A terminal would fill those with a mid grey block, so there a card is a grey frame, and the headline and the note being edited take the accent frame. The open tab is the app's primary pill on Desktop; a colored or bold label inside a Button draws only in a terminal, which shows the open tab that way. Hover can't reveal anything on Desktop and a terminal has none, so every button says what it does in its own label. An edited note's Save is its field's own submit button, since Desktop draws that button whatever else is beside it. Both fields, the note field and an edited note's, ask for three rows; 2.1.299, the oldest release the mod supports, has no `rows` for a field and draws them as one line. Times sit in a fixed-width column, since runs of spaces collapse on both surfaces. Text in the timeline wraps rather than being cut, and the pane is sized to `100%` of its body rather than a count of cells, since the Desktop app's proportional text doesn't keep to one. What the note field and an open note's field hold is kept as it is typed, so a redraw for any other reason (a note added from another window, say) puts it back; it is kept in the module rather than in `$.state`, because a `$.state` write draws the pane again and the Desktop app then draws the field afresh, which made its border flash at every keystroke. Emptying the note field after a note is added takes two draws, since the app sets a field's text only when the value it is drawn with changes and typing drew nothing: one with what the field holds, then, a quarter of a second later, one empty. A reload of the mod starts them over: it comes with an update of the mod and with a change to its settings (**Turn on summaries** is one), and then the note field empties, and a note open for editing stays open but shows its own text again, losing what was typed in it and not saved. +- **How it looks.** The pane follows the Cards design, `mockups/pane_as_drawn/02-cards.html` (the choice is recorded in `DECISION.md` beside it), drawn only with what a design test page (`/pad-demo`, removed once the look was settled) showed each surface can draw, as `mockups/sessionpad_pane/RENDERING.md` records. On Desktop the headline, each note, each day of the timeline and the current worktree sit on soft filled cards: a faint round border around a see-through grey fill (`rgba(128, 128, 128, 0.12)`), which reads as a light grey on the light pane and a dark grey on the dark one, so it follows the mode where an opaque raw color would turn unreadable in one of them; the Undo card is tinted red the same way. The cards were first filled with the theme's `promptBorder` shade, which drew too dark for the dim text and the buttons on them. A terminal would fill those with a mid grey block, so there a card is a grey frame, and the headline and the note being edited take the accent frame. The open tab is the app's primary pill on Desktop; a colored or bold label inside a Button draws only in a terminal, which shows the open tab that way. Hover can't reveal anything on Desktop and a terminal has none, so every button says what it does in its own label. An edited note's Save is its field's own submit button, since Desktop draws that button whatever else is beside it. Both fields, the note field and an edited note's, ask for three rows; 2.1.299, the oldest release the mod supports, has no `rows` for a field and draws them as one line. Times sit in a fixed-width column, since runs of spaces collapse on both surfaces. Text in the timeline wraps rather than being cut, and the pane is sized to `100%` of its body rather than a count of cells, since the Desktop app's proportional text doesn't keep to one. What the note field and an open note's field hold is kept as it is typed, so a redraw for any other reason (a note added from another window, say) puts it back; it is kept in the module rather than in `$.state`, because a `$.state` write draws the pane again and the Desktop app then draws the field afresh, which made its border flash at every keystroke. Emptying the note field after a note is added takes two draws, since the app sets a field's text only when the value it is drawn with changes and typing drew nothing: one with what the field holds, then, a quarter of a second later, one empty. A reload of the mod starts them over: it comes with an update of the mod and with a change to its settings (in `/config`, say), and then the note field empties, and a note open for editing stays open but shows its own text again, losing what was typed in it and not saved. - **The tab digits are the terminal's.** A digit presses a tab only while the pane holds the keyboard, which a terminal gives it with ctrl+x tab; elsewhere a digit goes to the prompt, so the Desktop app's tabs are drawn without them. - **The band's width.** The band refuses Claude Code's own row under a Box with a width, so the width is on the row that holds the headline and, on Desktop, the **Open pad** button. - **Open pad lives in the band.** A mod can't add a button to the app's toolbar or title bar: the places it can draw are the transcript's messages, the prompt's hints, the band above the prompt and panes. The band is the one always in view, so the button goes there, on every surface but the terminal. -- **Summaries are off by default.** `summaryModel` ships as `off`, since each call spends some of the person's usage and spending it should be their choice. The line Haiku writes is what makes the Timeline worth reading after a few days away, so the Timeline tab offers it once, with **Turn on summaries** and **Not now**; the answer is kept for every session under the store key `summary-offer`, which pruning leaves alone. Changing `summaryModel` in `/config` counts as an answer too, and the next turn follows it without a reload. +- **Summaries are off by default.** `summaryModel` ships as `off`, since each call spends some of the person's usage and spending it should be their choice. The line Haiku writes is what makes the Timeline worth reading after a few days away, so while it is off the Timeline tab says what it costs and how to turn it on, until **Got it** dismisses that for every session (the store key `summary-offer`, which pruning leaves alone). The tab can't turn it on itself: the plugin directory accepts no settings call from a mod that keeps its engine for later, as every button and timer here does. A change in `/config` reloads the mod with the new value. - **The pane opens only when asked:** with `/pad`, or with the band's **Open pad** button on Desktop. Opening it unasked at the start of a session with notes is still an open question. - `$.fs.write` creates missing directories, which the timeline file relies on. The home folder comes from `HOME`, else `USERPROFILE` on Windows, and `CLAUDE_CONFIG_DIR` wins over both. With none of them set, no timeline is kept and `/pad-export` asks for a path. - **A turn's prompt comes from `turn.start`**, not `prompt.submit` as the spec had it. `turn.start` carries the turn's id, the same one `turn.complete` carries, so the prompt and the end are paired exactly; `prompt.submit` also fires for prompts typed while a turn runs, which join that turn rather than starting one. diff --git a/justfile b/justfile index b70f3cc..49e6b44 100644 --- a/justfile +++ b/justfile @@ -8,7 +8,15 @@ clean: # Run every check: formatting, types, tests. CI runs this recipe on pull # requests into main, and you run it before pushing. -check: format_check validate type_check test +check: format_check validate type_check dollar_check test + +# Fail when a call on $ is split across lines or a property of $ is read: +# the plugin directory reads $ only as whole $.noun.method(...) calls +dollar_check: + #!/usr/bin/env bash + set -euo pipefail + found=$(grep -rnE '\$\.[a-z]+(\.[a-zA-Z]+)?\s*$|\$\.[a-z]+\.[a-zA-Z]+[^a-zA-Z(]' sessionpad/src sessionpad/hooks | grep -vE '^[^:]+:[0-9]+:\s*(//|\*|/\*)' || true) + if [ -n "$found" ]; then echo "$found"; echo "Write each call on \$ whole, on one line: \$.noun.method(...)"; exit 1; fi # Check formatting of the mod, the marketplace file and the docs format_check: diff --git a/sessionpad/.claude-plugin/plugin.json b/sessionpad/.claude-plugin/plugin.json index ec0dfa4..9f0062d 100644 --- a/sessionpad/.claude-plugin/plugin.json +++ b/sessionpad/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "sessionpad", "displayName": "Session Pad", - "version": "0.3.0", + "version": "0.4.0", "description": "A notepad for each Claude Code session: a headline and notes, a timeline of every turn, and the session's worktree and disk use, in a pane and above the prompt.", "author": { "name": "J" diff --git a/sessionpad/README.md b/sessionpad/README.md index b4e2562..c80d2cf 100644 --- a/sessionpad/README.md +++ b/sessionpad/README.md @@ -21,7 +21,7 @@ Session Pad is a Claude Code mod: it runs in Claude Code 2.1.299 or later, in th ## What it runs, sends and stores - **Nothing leaves your machine unless you turn on summary lines.** The mod makes no network calls of its own. -- **Summary lines are off until you turn them on**, with **Turn on summaries** in the Timeline tab or the `summaryModel` setting. With them on, after each turn the mod asks Claude Haiku, on your own plan or API key, for a one-line summary. It sends the prompt's first 200 characters, the start of Claude's final answer (1,500 characters at most), the names of the files written (not their paths or contents) and the number of commands run. A call is about 500 tokens in and 20 out, roughly 6 cents per 1,000 turns on Haiku 5.5 at the API prices of October 2026 (ten times that if your Claude Code's `haiku` is Haiku 4.5); the Timeline tab shows the running total. +- **Summary lines are off until you turn them on**, with the `summaryModel` setting (see [Settings](#settings)). With them on, after each turn the mod asks Claude Haiku, on your own plan or API key, for a one-line summary. It sends the prompt's first 200 characters, the start of Claude's final answer (1,500 characters at most), the names of the files written (not their paths or contents) and the number of commands run. A call is about 500 tokens in and 20 out, roughly 6 cents per 1,000 turns on Haiku 5.5 at the API prices of October 2026 (ten times that if your Claude Code's `haiku` is Haiku 4.5); the Timeline tab shows the running total. - **What it watches in the session:** it hooks each prompt you send, each turn's start and end, and each Edit, Write, NotebookEdit and Bash call, to write the timeline: the prompt's first 200 characters, the paths of the files written (up to 25 a turn) and how many commands ran. These hooks only observe: they pass every prompt and call on unchanged, and never block one. - **Programs it runs:** `git`, read-only, in the session's folder, for the branch and the worktrees; `du -sk` from your home folder (the root folder where there is none), in the background, to measure worktree sizes (the `measureDisk` setting turns this off); and `rm`, only on the mod's own timeline files, when old sessions are pruned (where there is no `rm`, as on Windows, those files are emptied instead). - **What it stores, all on your machine:** @@ -32,7 +32,10 @@ Session Pad is a Claude Code mod: it runs in Claude Code 2.1.299 or later, in th The two `~/.claude` folders are under `CLAUDE_CONFIG_DIR` instead when that is set. - **What it deletes:** a session nobody has opened for `retentionDays` (90 by default) loses its pad, its timeline file (and any copy of one put aside as unreadable) and its index row; sizes measured that long ago go too, and so do timeline files that old that no session in the index owns. Exports are never touched. -- **Settings it changes:** only its own `summaryModel`, when you press **Turn on summaries**. +- **Settings it changes:** none. It reads its own settings, and a change you make in `/config` reloads it. +- **The model call** goes through Claude Code's own model access, on the plan or API key the session already uses; the mod never reads a key, token or credential itself. +- **What its hooks change:** nothing that passes through them, with two exceptions that are the mod's own: its hooks on its two tools, `note` and `notes_read`, answer those tools, which is how they work, and its commands answer `/pad`, `/note`, `/headline` and `/pad-export`. +- **Files it writes outside its own folders:** only the `/pad-export` file you name. An export never replaces a file that isn't an earlier export: each one starts with the line ``, and a file without it is left alone. ## Settings @@ -44,6 +47,14 @@ Session Pad is a Claude Code mod: it runs in Claude Code 2.1.299 or later, in th | `summaryModel` | `off` | `off`, or `haiku` to have Haiku write each turn's summary line | | `timelineCap` | `500` | Entries a session's timeline file keeps, from 1 to 1000; the oldest go first | +To change a setting, run `/config` in a terminal session, or `/plugin configure `. From a shell, which also serves the Desktop app's sessions, this turns summary lines on: + +```bash +echo '{"summaryModel":"haiku"}' | claude plugin configure --values-stdin +``` + +`` is the name `claude plugin list` shows for Session Pad: `sessionpad@sessionpad` when it came from the author's marketplace. Set `summaryModel` back to `off` the same way to turn them off. A change reloads the mod with the new value. + ## Install, update, uninstall Added from the plugin directory on claude.ai, it reaches Claude Code through your account (as `sessionpad@synced`), and you update or remove it there. diff --git a/sessionpad/hooks/register.ts b/sessionpad/hooks/register.ts index a377a94..e8996aa 100644 --- a/sessionpad/hooks/register.ts +++ b/sessionpad/hooks/register.ts @@ -19,7 +19,7 @@ import { readThisPad, setThisHeadline, } from "../src/pad"; -import { OFFER_KEY, summaryModelNow, useSummaryModel } from "../src/settings"; +import { OFFER_KEY } from "../src/settings"; import { forgetPaneEdits, readHeadline, showOffer } from "../src/state"; import { PRUNE_DELAY_MS, pruneOld, retentionDays } from "../src/prune"; import { forgetRenewals, touchSeen } from "../src/store"; @@ -93,7 +93,9 @@ export function describePad(pad: Pad): string { /** Command names another plugin or Claude Code itself already uses. */ async function takenCommands($: EngineInterface): Promise> { try { - const own = $.plugin.name; + // The manifest's name, which never changes; the directory's check reads + // only $.noun.method(...) calls, not a property such as $.plugin.name. + const own = "sessionpad"; const commands = await $.command.list(); const others = commands.filter( (one) => !(one.source === "plugin" && one.plugin?.split("@")[0] === own) @@ -280,45 +282,6 @@ async function registerTools($: EngineInterface): Promise { } } -async function noteCommand( - $: EngineInterface, - command: string, - args: string, - signal: AbortSignal -): Promise<{ text: string }> { - try { - const added = await addThisNote($, args, "user", signal); - if (added.status === "blank") return { text: `Usage: /${command} ` }; - return { text: describeAdd(added) }; - } catch (error) { - return { text: `sessionpad: the note was not saved: ${String(error)}` }; - } -} - -async function headlineCommand( - $: EngineInterface, - args: string, - signal: AbortSignal -): Promise<{ text: string }> { - try { - return { text: describeHeadline(await setThisHeadline($, args, signal)) }; - } catch (error) { - return { text: `sessionpad: the headline was not saved: ${String(error)}` }; - } -} - -async function exportCommand( - $: EngineInterface, - args: string -): Promise<{ text: string }> { - try { - const path = await exportThisSession($, args); - return { text: await describeExport($, path) }; - } catch (error) { - return { text: `sessionpad: the export failed: ${String(error)}` }; - } -} - /** * The most prompts kept waiting for their turns. Past it the oldest goes, * and its turn, if it ever starts, is judged by its text. @@ -380,14 +343,19 @@ function keepSeen($: EngineInterface, days: number): void { }); } +// Whether summary lines are off in this module's settings; register sets it. +// Kept here so refreshOffer takes $ alone, the one shape the plugin directory +// reads for a function in a hook's file that passes $ on. +let isSummaryOff = true; + /** * Shows the Timeline tab's offer to turn summary lines on while they are off - * and nobody has answered it yet; never fails the caller. + * and nobody has dismissed it yet; never fails the caller. */ async function refreshOffer($: EngineInterface): Promise { try { const isAnswered = (await $.store.get(OFFER_KEY)) !== undefined; - await showOffer($, summaryModelNow() === null && !isAnswered); + await showOffer($, isSummaryOff && !isAnswered); } catch { // No offer this time: the store couldn't say whether it was answered. } @@ -409,14 +377,12 @@ export const register: Register = (on, options) => { const showBand = options.showBand !== false; setMeasureDisk(options.measureDisk !== false); const retention = retentionDays(options.retentionDays); - useSummaryModel(summaryModel(options.summaryModel)); + // A change to the setting in /config reloads the module with it. const timeline: TimelineSettings = { - // Read at each turn: the Timeline tab or /config may turn summaries on. - get summaryModel() { - return summaryModelNow(); - }, + summaryModel: summaryModel(options.summaryModel), cap: timelineCap(options.timelineCap), }; + isSummaryOff = timeline.summaryModel === null; // The session id whose pad is loaded, to carry the pad across /clear and // /branch, which give the conversation a new id without a session.start. let loadedId: string | undefined; @@ -523,23 +489,6 @@ export const register: Register = (on, options) => { } ).catch(($, e, next) => next(e)); - // The person set summaryModel in /config: the next turn follows it, and the - // Timeline tab stops offering, since they have chosen. The key is spelled - // out (SUMMARY_CONFIG_KEY's value) so validate can read the matcher. - on("config.set", { key: "sessionpad.summaryModel" }, async ($, e, next) => { - const result = await next(e); - if (result.deny === undefined) { - useSummaryModel(summaryModel(result.value)); - try { - await showOffer($, false); - await $.store.set(OFFER_KEY, { at: await $.clock.now() }); - } catch { - // The setting is written either way; only the offer's answer is lost. - } - } - return result; - }).catch(($, e, next) => next(e)); // replays the result next settled to - // Observe only, and instant: every session.end hook shares 1.5 seconds. on("session.end", ($, e, next) => { endedId = e.sessionId; @@ -554,27 +503,56 @@ export const register: Register = (on, options) => { : { text: "sessionpad: the pane could not be opened." } ); - on("command.run", { command: ["note", "pad-note"] }, ($, e, next) => - served.has(e.command) - ? noteCommand($, e.command, e.args, next.signal) - : next(e) - ).catch(($, e, next) => + // The commands do their work in the hook's own body: the plugin directory + // reads $ passed on to another file only from there, or from a function in + // this file that takes $ alone. + on("command.run", { command: ["note", "pad-note"] }, async ($, e, next) => { + if (!served.has(e.command)) return next(e); + try { + const added = await addThisNote($, e.args, "user", next.signal); + if (added.status === "blank") { + return { text: `Usage: /${e.command} ` }; + } + return { text: describeAdd(added) }; + } catch (error) { + return { text: `sessionpad: the note was not saved: ${String(error)}` }; + } + }).catch(($, e, next) => next.called || !served.has(e.command) ? next(e) : { text: "sessionpad: the note was not saved." } ); - on("command.run", { command: ["headline", "pad-headline"] }, ($, e, next) => - served.has(e.command) ? headlineCommand($, e.args, next.signal) : next(e) + on( + "command.run", + { command: ["headline", "pad-headline"] }, + async ($, e, next) => { + if (!served.has(e.command)) return next(e); + try { + const set = await setThisHeadline($, e.args, next.signal); + return { text: describeHeadline(set) }; + } catch (error) { + return { + text: `sessionpad: the headline was not saved: ${String(error)}`, + }; + } + } ).catch(($, e, next) => next.called || !served.has(e.command) ? next(e) : { text: "sessionpad: the headline was not saved." } ); - on("command.run", { command: "pad-export" }, ($, e, next) => - served.has(e.command) ? exportCommand($, e.args) : next(e) - ).catch(($, e, next) => + on("command.run", { command: "pad-export" }, async ($, e, next) => { + if (!served.has(e.command)) return next(e); + try { + const path = await exportThisSession($, e.args); + const text = await describeExport($, path); + return { text }; + } catch (error) { + return { text: `sessionpad: the export failed: ${String(error)}` }; + } + }).catch(($, e, next) => next.called || !served.has(e.command) ? next(e) : { text: "sessionpad: the export failed." } diff --git a/sessionpad/src/drafts.ts b/sessionpad/src/drafts.ts index f6df38c..f375122 100644 --- a/sessionpad/src/drafts.ts +++ b/sessionpad/src/drafts.ts @@ -5,7 +5,7 @@ // The pane reads these while drawing, so a redraw for any other reason (a // note added from another window, say) puts back what was typed. A reload // of the mod starts them over: it comes with an update of the mod, and with -// a change to its settings (Turn on summaries is one). The note field then +// a change to its settings in /config. The note field then // empties, and a note open for editing stays open but shows its own text // again, losing what was typed in it and not saved. diff --git a/sessionpad/src/prune.ts b/sessionpad/src/prune.ts index 410877f..f5deade 100644 --- a/sessionpad/src/prune.ts +++ b/sessionpad/src/prune.ts @@ -219,9 +219,9 @@ async function isStillUnseen( const row = parseIndex(await $.store.get(INDEX_KEY))[id]; if (row !== undefined && row.lastSeen >= before) return false; if (timelineDir === null) return true; - const file = await $.fs - .stat(`${timelineDir}/${fileName(id)}.json`) - .catch(() => undefined); + // Kept on one line: the directory's check reads $.noun.method(...) whole. + const path = `${timelineDir}/${fileName(id)}.json`; + const file = await $.fs.stat(path).catch(() => undefined); return file === undefined || file.mtimeMs < before; } diff --git a/sessionpad/src/settings.ts b/sessionpad/src/settings.ts index 88a8014..5dbd8f7 100644 --- a/sessionpad/src/settings.ts +++ b/sessionpad/src/settings.ts @@ -1,23 +1,12 @@ -// The summary setting as this module runs with it: read when the module -// loads, and changed when the person turns summaries on from the Timeline tab -// or changes the setting in /config, so the next turn follows it without a -// reload. - -/** The setting's key as `$.config` names it. */ -export const SUMMARY_CONFIG_KEY = "sessionpad.summaryModel"; +// The summary setting's offer. The mod never changes the setting itself (the +// plugin directory accepts no settings call from a mod that keeps its engine +// for later, as every button and timer here does): the Timeline tab says how +// to turn summary lines on, and a change in /config reloads the mod with the +// new value. /** - * The store key that records that the person answered the Timeline tab's - * offer, or changed the setting themselves: shared by every session, so the - * offer is made once, and never pruned. + * The store key that records that the person dismissed the Timeline tab's + * offer: shared by every session, so the offer is made once, and never + * pruned. */ export const OFFER_KEY = "summary-offer"; - -let model: string | null = null; - -/** The model that writes summary lines now, or null while they are off. */ -export const summaryModelNow = (): string | null => model; - -export function useSummaryModel(next: string | null): void { - model = next; -} diff --git a/sessionpad/src/ui.tsx b/sessionpad/src/ui.tsx index e9c454f..16533d3 100644 --- a/sessionpad/src/ui.tsx +++ b/sessionpad/src/ui.tsx @@ -74,8 +74,7 @@ import { showOffer, showTab, } from "./state"; -import { OFFER_KEY, SUMMARY_CONFIG_KEY, useSummaryModel } from "./settings"; -import { summaryModel } from "./summary"; +import { OFFER_KEY } from "./settings"; import { RECENT_COUNT } from "./timeline"; import { formatSize, isMeasureDisk, scheduleRefresh } from "./workspace"; @@ -576,36 +575,8 @@ export function turnMarks( .join(" ยท "); } -/** - * Turns summary lines on from the Timeline tab's offer, as the person would - * in /config, and records the answer so the offer isn't made again. - */ -async function pressSummariesOn($: EngineInterface): Promise { - await guarded($, "turning summary lines on", async () => { - const result = await $.config.set({ - key: SUMMARY_CONFIG_KEY, - value: "haiku", - }); - if (result.deny !== undefined) { - $.ui.toast(`sessionpad: summary lines stay off: ${result.deny}`); - return; - } - // This module's own change: its config.set hook doesn't see it. What - // was written counts, since another plugin's hook may have changed it. - const model = summaryModel(result.value); - useSummaryModel(model); - await showOffer($, false); - await rememberAnswer($); - $.ui.toast( - model === null - ? "sessionpad: summary lines stay off: the setting was written as off." - : `Summary lines are on: ${model} writes one after each turn. Set summaryModel to off in /config to stop.` - ); - }); -} - /** Hides the offer, here and in every other session. */ -async function pressNotNow($: EngineInterface): Promise { +async function pressGotIt($: EngineInterface): Promise { await guarded($, "hiding the offer", async () => { await showOffer($, false); await rememberAnswer($); @@ -662,7 +633,9 @@ async function renderTimelineTab( Turned on, Haiku writes one line after each turn: about 500 tokens in - and 20 out, from your plan's usage or your API key. + and 20 out, from your plan's usage or your API key. To turn them on, set + summaryModel to haiku: with /config in a terminal session, or from a + shell with the command under Settings in Session Pad's README.