Repository navigation
feat(tui): lead the exit line with the report's needs-attention items #1352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
240f539
1e88768
869a8be
97dc164
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import { readNeedsAttention } from '@utils/needs-attention'; | ||
|
|
||
| const report = (block: string) => | ||
| `# Error tracking report\n\n${block}\n\n## What you still need to do\n\n1. Something\n`; | ||
|
|
||
| describe('readNeedsAttention', () => { | ||
| it('returns each bullet of the warning block', () => { | ||
| const markdown = report( | ||
| [ | ||
| '> ⚠️ **Needs your attention**', | ||
| '> - Load `.env` in the app, or set `POSTHOG_API_KEY` in its environment.', | ||
| '> * Add the `POSTHOG_CLI_API_KEY` CI secret.', | ||
| ].join('\n'), | ||
| ); | ||
| expect(readNeedsAttention(markdown)).toEqual([ | ||
| 'Load `.env` in the app, or set `POSTHOG_API_KEY` in its environment.', | ||
| 'Add the `POSTHOG_CLI_API_KEY` CI secret.', | ||
| ]); | ||
| }); | ||
|
|
||
| it('accepts the warning sign without its emoji variant selector', () => { | ||
| const markdown = report('> ⚠ **Needs your attention**\n> - One thing'); | ||
| expect(readNeedsAttention(markdown)).toEqual(['One thing']); | ||
| }); | ||
|
|
||
| it('ignores other quote blocks and reports without the block', () => { | ||
| expect(readNeedsAttention(report('> - Just a quote'))).toEqual([]); | ||
| expect(readNeedsAttention('# Report\n\nAll done.')).toEqual([]); | ||
| }); | ||
|
|
||
| it('strips terminal control characters from items', () => { | ||
| const markdown = report( | ||
| '> ⚠️ **Needs your attention**\n> - Do \x1b[31mthis\x1b]52;c;ZXZpbA==\x07 now\x9b2J', | ||
| ); | ||
| expect(readNeedsAttention(markdown)).toEqual([ | ||
| 'Do [31mthis]52;c;ZXZpbA== now2J', | ||
| ]); | ||
| }); | ||
|
|
||
| it('keeps the tail of a bullet wrapped onto the next quoted line', () => { | ||
| const markdown = report( | ||
| [ | ||
| '> ⚠️ **Needs your attention**', | ||
| '> - Set `POSTHOG_API_KEY` in your deploy', | ||
| '> environment before the next release.', | ||
| '> - Add the CI secret.', | ||
| '>', | ||
| '> A closing note, not part of any item.', | ||
| ].join('\n'), | ||
| ); | ||
| expect(readNeedsAttention(markdown)).toEqual([ | ||
| 'Set `POSTHOG_API_KEY` in your deploy environment before the next release.', | ||
| 'Add the CI secret.', | ||
| ]); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /** The heading of the warning block a handoff report opens with when work is left. */ | ||
| export const NEEDS_ATTENTION_HEADING = 'Needs your attention'; | ||
|
|
||
| const BLOCK_START = new RegExp(`^\\s*>\\s*⚠.*${NEEDS_ATTENTION_HEADING}`); | ||
|
|
||
| // eslint-disable-next-line no-control-regex | ||
| const CONTROL_CHARS = /[\u0000-\u001f\u007f-\u009f]/g; | ||
|
|
||
| /** The bullets of a report's `> ⚠️ **Needs your attention**` block, or none. */ | ||
| export function readNeedsAttention(markdown: string): string[] { | ||
| const lines = markdown.split('\n'); | ||
| const start = lines.findIndex((line) => BLOCK_START.test(line)); | ||
| if (start === -1) return []; | ||
| const items: string[] = []; | ||
| // Items are agent-written and printed raw to the terminal: drop escapes. | ||
| const clean = (text: string) => text.replace(CONTROL_CHARS, '').trim(); | ||
| let open = false; | ||
| for (const line of lines.slice(start + 1)) { | ||
| const quoted = /^\s*>\s?(.*)$/.exec(line); | ||
| if (!quoted) break; | ||
| const bullet = /^\s*(?:[-*]|\d+\.)\s+(.*\S)/.exec(quoted[1]); | ||
| const text = clean(bullet ? bullet[1] : quoted[1]); | ||
| if (bullet) { | ||
| open = text !== ''; | ||
| if (open) items.push(text); | ||
| } else if (!text) { | ||
| open = false; | ||
| } else if (open) { | ||
| // A bullet wrapped onto the next quoted line keeps its tail. | ||
| items[items.length - 1] += ` ${text}`; | ||
| } | ||
| } | ||
| return items; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,11 +19,19 @@ import { OutroKind } from '@shared/outro'; | |
| import { isRunFailure, MINT_FAILURE_CONTACT } from '@tui/mint-failure'; | ||
| import { formatTokenCount, formatCostUsd } from '@shared/token-pricing'; | ||
| import { getLogFilePath } from '@utils/debug'; | ||
| import { readFileHead } from '@utils/bounded-fs'; | ||
| import { | ||
| NEEDS_ATTENTION_HEADING, | ||
| readNeedsAttention, | ||
| } from '@utils/needs-attention'; | ||
| import { join } from 'path'; | ||
|
|
||
| const RESET_ATTRS = '\x1b[0m'; | ||
| const GREEN = '\x1b[32m'; | ||
| const BOLD = '\x1b[1m'; | ||
| const DIM = '\x1b[2m'; | ||
| const YELLOW = '\x1b[33m'; | ||
| const REPORT_HEAD_BYTES = 16 * 1024; | ||
|
|
||
| /** | ||
| * Mirrors the hidden Ctrl+T HUD's tally into post-exit scrollback — but only | ||
|
|
@@ -66,7 +74,35 @@ function mcpLoginBlock(store: WizardStore): string | null { | |
| ); | ||
| } | ||
|
|
||
| /** The report's warning items, from the published handoff or else the report file. */ | ||
| function needsAttentionBlock(store: WizardStore): string | null { | ||
| const reportFile = store.session.outroData?.reportFile; | ||
| const markdown = | ||
| store.handoffText ?? | ||
| (reportFile | ||
| ? readFileHead( | ||
| join(store.session.installDir, reportFile), | ||
| REPORT_HEAD_BYTES, | ||
| ) | ||
| : null); | ||
| const items = markdown ? readNeedsAttention(markdown) : []; | ||
| if (items.length === 0) return null; | ||
| return ( | ||
| `${YELLOW}${BOLD}⚠ ${NEEDS_ATTENTION_HEADING}:${RESET_ATTRS}\n` + | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note Automated review. Not written by a human. Bullet text comes from agent-written markdown (handoff or report file) and is printed raw to the terminal. Control sequences such as ESC in an item could recolor, move the cursor, or spoof output after exit. Strip C0/C1 control characters from each item before printing (or in
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, NotVincent here :disguise-emoji:, I will do the deeds
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's done, NotVincent will tell Vincent to double check. |
||
| items.map((item) => ` • ${item}`).join('\n') | ||
|
veria-ai[bot] marked this conversation as resolved.
Resolved
|
||
| ); | ||
| } | ||
|
|
||
| export function getExitLine(store: WizardStore): string { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note Automated review. Not written by a human. Nit: the warning block is also prefixed on run failure, above "The wizard is unavailable". Skip it when
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, NotVincent here :disguise-emoji:, I will do the deeds
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's done, NotVincent will tell Vincent to double check. |
||
| // A failed run prints its own unavailable notice; the report's warnings don't apply. | ||
| const attention = isRunFailure(store.session) | ||
| ? null | ||
| : needsAttentionBlock(store); | ||
| const body = exitSummary(store); | ||
| return attention ? `${attention}\n\n${body}` : body; | ||
| } | ||
|
|
||
| function exitSummary(store: WizardStore): string { | ||
| const outro = store.session.outroData; | ||
| const label = store.programLabel ?? 'Wizard'; | ||
| const costLine = tokenCostLine(store); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note
Automated review. Not written by a human.
Nit: a trailing slash in
CONTEXT_MILL_URLyields a double slash in${CONTEXT_MILL_LOCAL_URL}/skill-menu.json. Trim trailing slashes, e.g..replace(/\/+$/, '').