Repository navigation
Show thread titles and project names in bb thread list - #1798
SawyerHood merged 1 commit into
Conversation
bb thread list printed only ID, Project, and Status, so users had to fall back to --json to see which thread was which. Add a Title column (title -> titleFallback -> "-", one line, cut at 60 chars) and resolve project IDs to project names. ID stays first for scripts. Fixes #1648 Co-Authored-By: Claude <[email protected]>
|
🚨 SLOP COP 🚨 · I am SlopCop. I am reviewing this pull request for security, code quality, performance, architecture, and test coverage. |
| thread.id, | ||
| thread.projectId === PERSONAL_PROJECT_ID ? "-" : thread.projectId, | ||
| truncateCell(formatThreadListTitle(thread), MAX_TITLE_WIDTH), | ||
| formatThreadListProject(thread, projectNames), |
There was a problem hiding this comment.
🚨 slopcop/review — Bound the project cell before table layout. Project names only require a nonempty string, so their length and line count have no limit. projectWidth then uses the longest name for every row. A 10,000-character name across 1,000 thread rows produced about 20 MB of output in a local check. Apply the same single-line, maximum-width formatter to project names before this row is built.
| } | ||
|
|
||
| function truncateCell(value: string, maxWidth: number): string { | ||
| const singleLine = value.replace(/\s+/g, " "); |
There was a problem hiding this comment.
🚨 slopcop/review — Sanitize terminal control sequences before this value reaches cli-table3. This replacement removes whitespace only. I reproduced both ESC[2J and an OSC 8 link in the rendered output. A stored title, first-prompt fallback, or project name can therefore clear or reposition the terminal, create a misleading link, or trigger other terminal actions. Add a shared terminal-cell sanitizer that removes complete escape sequences and remaining C0/C1 controls. Apply it to both title and project cells before width calculation.
| function truncateCell(value: string, maxWidth: number): string { | ||
| const singleLine = value.replace(/\s+/g, " "); | ||
| if (singleLine.length <= maxWidth) return singleLine; | ||
| return `${singleLine.slice(0, maxWidth - 1)}…`; |
There was a problem hiding this comment.
🚨 slopcop/review — Do not truncate a Unicode title with UTF-16 code units. For example, 58 ASCII characters followed by an emoji cross this slice boundary. The result contains only the emoji's high surrogate before the ellipsis, so terminals show a replacement character. CJK and combining text also have display widths that differ from .length. Truncate by grapheme and terminal display width, then calculate titleWidth with the same width rule. Add emoji, CJK, and combining-mark cases.
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
Plain English summary: This change makes bb thread list easier to read. It adds titles and replaces project IDs with project names. JSON output stays unchanged.
I found three issues:
- Medium security: The new text cells keep terminal control sequences. I reproduced a screen-clear sequence and an OSC link in the table output.
- Medium performance: A project name has no length limit and sets the width for every row. One test produced approximately 20 MB.
- Medium correctness: The title limit uses UTF-16 units. It can split an emoji and print a damaged character.
The title selection rule now exists in several app and CLI helpers. A small domain helper could return the title or its fallback. Each caller could select its own empty value.
The project lookup also adds one serial request. That request returns all projects and their sources. A small name lookup would reduce this work.
Validation passed. Turbo completed six tasks, 452 CLI tests, and 44 template tests. The source CLI showed the expected columns against the live server. All current GitHub checks pass.
I did not use a browser test because this pull request changes only the CLI and its guide.
What was wrong
bb thread listprinted exactly three columns:ID,Project, andStatus. The server response forGET /api/v1/threads(andbb thread list --json) carriestitleandtitleFallbackfor every thread, and the desktop sidebar andbb thread showdisplay them. The table rendererprintThreadTableinapps/cli/src/commands/thread/list.tsnever put the title in the table, so a user had to shell out to--jsonto learn which thread was which. Root cause and repro: https://get-bb.github.io/reports/issues/1648.htmlWhat changed
apps/cli/src/commands/thread/list.ts: add aTitlecolumn resolved astitle->titleFallback->-, collapsed to one line and cut at 60 characters with an ellipsis. Column order isID,Title,Project,Status;IDstays first for scripts.Projectcolumn now shows the project name. The command fetchesprojects.listonce for the table view only (--jsonoutput does not fetch projects). Unknown project IDs fall back to the raw ID; the personal project still shows-.apps/cli/src/__tests__/command-output/thread-list.test.ts: new test that asserts theTitleheader, the title, the fallback title, single-line collapse, 60-char truncation, project name resolution, and the unknown-project fallback; a test that--jsonskips the project fetch; the two exact-string layout tests updated for the new columns.packages/templates/src/templates/bb-guide-threads.md(+ regeneratedtemplates.generated.ts): document the table columns forbb thread list.Deviation from the report
The report proposed only the
Titlecolumn. Per the scope note (and #1760), this PR also resolvesprojectIdto the project name in the same change.Verification
bb thread list prints the thread title, fallback, and project name (#1648)fails on the base commit (3 failed / 7 passed with the oldlist.ts) and passes after the change.pnpm exec turbo run typecheck test --filter=@bb/templates --filter=@bb/cli: 6 tasks successful,@bb/cli452 tests passed,@bb/templates44 tests passed.Fixes #1648