fix(mastracode): align /update changelog trimming to dialog width#16550
fix(mastracode): align /update changelog trimming to dialog width#16550devin-ai-integration[bot] wants to merge 5 commits into
Conversation
Each changelog entry was truncated at a fixed 117 characters, leaving visible empty space on the right side of the update prompt on wider terminals. parseChangelog and fetchChangelog now accept an optional maxEntryWidth, and both call sites compute it from the current terminal width (mirroring the modal overlay sizing) so entries only show '…' when they truly don't fit. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
🦋 Changeset detectedLatest commit: 5e2dd86 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughAdds terminal-width-aware changelog truncation: new computeChangelogEntryWidth utility, expanded fetchChangelog/parseChangelog signatures to accept width options, TUI calls now compute and pass maxEntryWidth from terminal columns, and tests + changeset updated to exercise and document the behavior. ChangesResponsive Changelog Width Adaptation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
Thank you for your contribution! Your PR needs to fix an existing issue. You are required to link issues (e.g. with Mastra uses CodeRabbit for automated code reviews. Please address all feedback from CodeRabbit by either making changes to your PR or leaving a comment explaining why you disagree with the feedback. Since CodeRabbit is an AI, it may occasionally provide incorrect feedback. Addressing CodeRabbit's feedback will greatly increase the chances of your PR being merged. We appreciate your understanding and cooperation in helping us maintain high code quality standards. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@mastracode/src/utils/update-check.ts`:
- Around line 250-257: The first-sentence extraction (using sentenceEnd and
entry) can produce a string longer than maxEntryWidth because the truncation
branch is skipped; after you set entry = entry.slice(0, sentenceEnd + 1) in the
first-sentence branch, immediately apply the same length cap logic used in the
else branch: if entry.length > maxEntryWidth + 3 then set entry = entry.slice(0,
maxEntryWidth).trimEnd() + '…' (preserving the +3 grace behavior), so the
first-sentence path cannot overflow the dialog width.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 5a34fe25-6f52-469c-8bfc-9c80a4c2c396
📒 Files selected for processing (5)
.changeset/little-carpets-brush.mdmastracode/src/tui/commands/update.tsmastracode/src/tui/mastra-tui.tsmastracode/src/utils/__tests__/update-check.test.tsmastracode/src/utils/update-check.ts
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Remove the 160-column dialog cap for the update prompt so the changelog fills the available space on wide terminals. The modal now uses 90% of terminal width without a hard ceiling. At 202 cols the dialog is now 181 cols with 173-char entries instead of being capped at 160 cols (152-char entries). Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Revert the per-call maxWidth override for the update prompt and align computeChangelogEntryWidth() to the shared modal width capped at 160 cols, matching modalOverlayOptions() in tui/overlay.ts (introduced in PR #16274 to standardize modal sizing across /setup, /models, /sandbox, /api-keys, etc.). The update prompt now scales identically to every other modal: dialog = min(floor(cols * 0.9), 160), entry cap = 152 on wide terminals. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
CodeRabbit pointed out that the first-sentence branch (sentenceEnd < 100) short-circuits the width truncation, so a 95-char first sentence on a narrow terminal where maxEntryWidth is 64 could still overflow the dialog. Split the if/else into two independent ifs so the width cap is enforced even after the first-sentence slice. Added a regression test. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Description
Fixes the fixed-length truncation of changelog entries in the mastracode update prompt so trimming aligns with the dialog's actual width instead of cutting at a hardcoded 117 characters.
Reported in Slack: https://kepler-bej6556.slack.com/archives/C0ACHFXNK7T/p1778662829859489
Root cause
mastracode/src/utils/update-check.tstruncated every changelog entry at a fixed 117 chars regardless of terminal width — wasting space on wide terminals and showing unnecessary…suffixes.What changed
computeChangelogEntryWidth(terminalColumns)derives the per-entry char cap from the shared modal overlay sizing intui/overlay.ts:min(floor(cols * 0.9), 160)minus 8 cols (2 cols box padding each side + 4 cols•bullet prefix).parseChangelog()/fetchChangelog()now accept an optional{ maxEntryWidth }. Default stays at 117 for back-compat so existing callers/tests don't break.state.ui.terminal.columnsbefore fetching:/updateslash command (mastracode/src/tui/commands/update.ts)mastracode/src/tui/mastra-tui.ts)The 160-col modal cap from PR #16274 (standardize setup and config overlays) is preserved —
/updatescales identically to/setup,/models,/sandbox,/api-keys, etc.Per-width truncation
…only appears when an entry genuinely doesn't fit.Related issue(s)
Slack report only — no GitHub issue.
Type of change
Checklist
Verification
pnpm --filter mastracode exec vitest run src/utils/__tests__/update-check.test.ts— 19 passedpnpm --filter mastracode lint— cleanpnpm prettier --checkon changed files — cleanNotes
Filed
.changeset/little-carpets-brush.mdas a patch bump per.mastracode/commands/changeset.md.Link to Devin session: https://app.devin.ai/sessions/2d6fbe092b374429acba8d785fdaa42e
ELI5
This PR fixes how the update changelog is displayed in the terminal. Instead of always cutting text at a fixed 117 characters (which might be too short for wide screens or too long for narrow ones), the code now calculates the right width based on your actual terminal size—so the changelog always fits nicely in the dialog box.
Changes
Core Logic
computeChangelogEntryWidth(terminalColumns)to dynamically calculate the maximum entry width based on terminal dimensions, aligned with the modal overlay sizing (90% of terminal width, capped at 160 characters, minus 8 columns for box padding and bullet prefix).fetchChangelog()andparseChangelog()to accept an optionalChangelogOptionsparameter withmaxEntryWidthfield (defaults to 117 for backward compatibility).maxEntryWidthcap even after first-sentence slicing, fixing a regression where long first sentences could bypass width constraints.Integration Points
handleUpdateCommand(in/updateslash command) now computesmaxEntryWidthfrom terminal columns and passes it tofetchChangelog().mastra-tui.ts(passive update-available banner) similarly computes the width cap and passes it through.Test Coverage
computeChangelogEntryWidthcovering edge cases: unknown/zero terminal widths, scaling across terminal widths, and clamping to minimum entry width.parseChangelogtests to verifymaxEntryWidtheffects, sentence-based truncation, and width enforcement post-sentence slicing.Backward Compatibility
/updatenow scales proportionally like other modals.maxEntryWidthspecifications defaults to 117 characters.Example Behavior
Ellipsis appears only when an entry truly overflows its available width.