Skip to content

Panel P5: "In short", one sentence for every line - #566

Merged
sf624 merged 3 commits into
mainfrom
panel-p5
Nov 1, 2026
Merged

sf624 merged 3 commits into
mainfrom
panel-p5

Conversation

@sf624

@sf624 sf624 commented Oct 31, 2026

Copy link
Copy Markdown
Owner

Step P5 of docs/design/panel-redesign.md ("In short" on every line).

What users see

The panel's Meaning view (VS Code and the web page) starts with one sentence that says what the line does, labelled "In short" / 「ひとことで」, above the problems. The Reading view has none. Examples (sample.sh):

  • set -euo pipefail → "Turns on errexit, nounset and pipefail, the usual strict mode."
  • workdir=$(mktemp -d) → "Sets workdir to output of $(mktemp -d)."
  • make build > build.log 2>&1 || exit 1 → "Runs make, with stdout (fd 1) to build.log, stderr (fd 2) to where stdout (fd 1) goes; if that fails, runs exit with status 1; under set -e, a command that fails before the last one does not stop the script."
  • while read -r line; do → "Reads input.txt one line at a time, running line 29 for each line."
  • done < input.txt → "done ends the while loop of line 28: reads input.txt …"
  • grep -i error app.log | sort | uniq -c | sort -rn | head -n 3 → 「grep の出力の各行の出現回数を数え、多い順に回数つきで並べる(上位 3 行)。終了ステータスは最後に失敗したコマンドのもの(なければ 0)。」

How

  • LineExplanation.sentence (marked text), when ExplainOptions.sentence asks for it; src/linesentence.ts composes it from the tree, CommandSaid (src/explain/commands.ts: the command's names, the summary Token.summary also comes from, the options given), P4's argvWords (values, targets, a loop's words, with placeholders), and the status model. Texts: src/messages-sentence.ts (ja, en).
  • Idioms with a sentence of their own: idiomSaid in src/idioms.ts (strict mode, EXIT trap, quiet command -v, while read … done < f, endless loop, sort | uniq -c | sort -rn [| head], echo … >&2).
  • Rules: a clause about the status model carries its manual section (3.2.3, 4.3.1) and is dropped when a problem of the line cites it (problemSections; host problems via ExplainOptions.hostProblems). Code spans name single words only. A variable whose attributes change what is stored (CHANGING, now exported from src/semantics/walk/temporaries.ts) gets "what x gives".
  • Plan changes (written into the plan): set -e is said only where it does other than stop the script (said on every line it was noise); variableFrom was not needed.
  • Fixed on the way: a bare coproc made statusModel.status throw.
  • Nit: the Japanese HEALTHCHECK note says 2 is reserved.

Explanation changes (test/snapshot.ts)

None: the corpus' explanations are byte-identical (keyed by input; only the 5 new snippets are added). The sentence is only built when asked for.

Tests

  • test/linesentence.test.ts: 145 shapes in en and ja; over sample.sh and the fixtures: every line with code has a sentence, none states set -e/a pipeline status where a problem cites it, no code span is a stretch of more than one word, none is a row's text, Japanese spacing; every snippet and lines cut while typed without failing; assignment values against bash on the argv capture's runs.
  • test/web-sentence.test.ts: the web panel at 390 and 1280 px, en and ja (closing word, a problem line, a long line), hidden in Reading.
  • Full npm test locally: 10524 passing.

🤖 Generated with Claude Code

sf624 and others added 2 commits November 1, 2026 08:43
The Meaning view of the panel starts with one sentence that says what the
line does (`LineExplanation.sentence`, when `ExplainOptions.sentence` asks
for it; src/linesentence.ts, texts in src/messages-sentence.ts). It is
composed from the tree (lists, pipelines, blocks, their heads and closing
words), what each command is (`CommandSaid`, the record `Token.summary`
is now made from too), the words P4 reads (`argvWords`: values, targets,
a loop's words), and the status model (a pipeline's status; `set -e` in a
list and where it stops other than the script). Idioms with a sentence of
their own live in src/idioms.ts (`idiomSaid`).

A clause is left out when a problem of the line cites its section (the
host's problems too); no code span is a stretch of the line. Tests: 145
shapes in both languages, the rules over the corpus, the values against
bash on the argv capture's runs, and the web page's panel at 390 and
1280 px. A bare `coproc` no longer makes the status model fail.

Also: the Japanese HEALTHCHECK note says that 2 is reserved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Web preview removed: the pull request is closed.

…a whole statement, facts from the models)

- A pipeline over several lines (`cat f | while read l; do`) is said whole on
  its first line: each stage named (a compound one by its kind, never by its
  first token), what a compound stage does and where it runs (the environment
  model: a subshell, or the shell itself with lastpipe), and the pipeline's
  status and set -e facts. A closing word says the stages it pipes into.
- A statement started with `&` is said in the background as a whole, read
  from the status model (`status(n).kind === 'background'`).
- Whether a statement can fail is the status model's `mayFail`, tested
  against bash.
- The redirection kinds come from the dictionary (`RedirectOp.kind`,
  `dupTarget` for `>&` and `<&`): one table. A closed or moved descriptor is
  said short ("file descriptor 3 closed" / 「ファイルディスクリプタ 3 を閉じて」).
- A declaration builtin's clause has a verb ("… and sets `PATH` to …").
- The panel reads code spans as CommonMark does (`` `date` ``).
- `for x in $e` with `e` empty, and `for x in;`, say the body does not run;
  a word that gives no field is left out of a list.
- No "then" before a branch of `case`, `elif` or `else`; the article before
  a placeholder that stands alone ("the output of"); `done < input.txt` names
  the file once.
- Docs: the follow-up of `problemSections` (fact ids once Token.facts
  exists, SB3), and sources.md row 27 corrected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sf624
sf624 merged commit 7cbfd4b into main Nov 1, 2026
21 checks passed
@sf624
sf624 deleted the panel-p5 branch November 1, 2026 00:40

This branch was successfully deployed

1 active deployment
github-pages — dac9b8cd Deployed Nov 1, 2026 by sf624 via Deploy to GitHub Pages #1979
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant