Skip to content

fix(mastracode): align /update changelog trimming to dialog width#16550

Closed
devin-ai-integration[bot] wants to merge 5 commits into
mainfrom
devin/1778684172-mastracode-changelog-trimming
Closed

fix(mastracode): align /update changelog trimming to dialog width#16550
devin-ai-integration[bot] wants to merge 5 commits into
mainfrom
devin/1778684172-mastracode-changelog-trimming

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

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.ts truncated every changelog entry at a fixed 117 chars regardless of terminal width — wasting space on wide terminals and showing unnecessary suffixes.

What changed

  • New computeChangelogEntryWidth(terminalColumns) derives the per-entry char cap from the shared modal overlay sizing in tui/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.
  • Both call sites compute the cap from state.ui.terminal.columns before fetching:
    • /update slash command (mastracode/src/tui/commands/update.ts)
    • Passive update-available banner (mastracode/src/tui/mastra-tui.ts)

The 160-col modal cap from PR #16274 (standardize setup and config overlays) is preserved — /update scales identically to /setup, /models, /sandbox, /api-keys, etc.

Per-width truncation

 80 cols → dialog  72 cols → 64-char entries
120 cols → dialog 108 cols → 100-char entries
160 cols → dialog 144 cols → 136-char entries
200+ cols → dialog 160 cols → 152-char entries (modal cap)

only appears when an entry genuinely doesn't fit.

Related issue(s)

Slack report only — no GitHub issue.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Test update

Checklist

  • I have linked the related issue(s) in the description above
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works
  • I have addressed all Coderabbit comments on this PR

Verification

  • pnpm --filter mastracode exec vitest run src/utils/__tests__/update-check.test.ts — 19 passed
  • pnpm --filter mastracode lint — clean
  • pnpm prettier --check on changed files — clean
  • Manually verified truncation math at widths 80/120/160/200/300

Notes

Filed .changeset/little-carpets-brush.md as 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

  • Introduced 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).
  • Updated fetchChangelog() and parseChangelog() to accept an optional ChangelogOptions parameter with maxEntryWidth field (defaults to 117 for backward compatibility).
  • Modified truncation logic to enforce the maxEntryWidth cap even after first-sentence slicing, fixing a regression where long first sentences could bypass width constraints.

Integration Points

  • handleUpdateCommand (in /update slash command) now computes maxEntryWidth from terminal columns and passes it to fetchChangelog().
  • mastra-tui.ts (passive update-available banner) similarly computes the width cap and passes it through.

Test Coverage

  • Added dedicated tests for computeChangelogEntryWidth covering edge cases: unknown/zero terminal widths, scaling across terminal widths, and clamping to minimum entry width.
  • Extended parseChangelog tests to verify maxEntryWidth effects, sentence-based truncation, and width enforcement post-sentence slicing.

Backward Compatibility

Example Behavior

  • 80 cols → 72-col dialog → 64-char entries
  • 120 cols → 108-col dialog → 100-char entries
  • 160 cols → 144-col dialog → 136-char entries
  • 200+ cols → 160-col modal cap → 152-char entries

Ellipsis appears only when an entry truly overflows its available width.

Review Change Stack

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-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@changeset-bot

changeset-bot Bot commented May 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5e2dd86

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
mastracode Patch

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

@vercel

vercel Bot commented May 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
mastra-docs-1.x Skipped Skipped May 13, 2026 4:49pm
mastra-playground-ui Skipped Skipped May 13, 2026 4:49pm

Request Review

@coderabbitai

coderabbitai Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c827452f-232f-4366-bdfd-c9466bd2bf5b

📥 Commits

Reviewing files that changed from the base of the PR and between cb5e394 and 5e2dd86.

📒 Files selected for processing (2)
  • mastracode/src/utils/__tests__/update-check.test.ts
  • mastracode/src/utils/update-check.ts

Walkthrough

Adds 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.

Changes

Responsive Changelog Width Adaptation

Layer / File(s) Summary
Core changelog width utilities and types
mastracode/src/utils/update-check.ts
Adds ChangelogOptions, DEFAULT_MAX_ENTRY_WIDTH, and computeChangelogEntryWidth. Updates fetchChangelog/parseChangelog to accept options and applies width-driven truncation using maxEntryWidth + 3 with ellipsis.
TUI update command integration
mastracode/src/tui/commands/update.ts, mastracode/src/tui/mastra-tui.ts
Imports computeChangelogEntryWidth, computes maxEntryWidth from ctx.state.ui?.terminal?.columns / terminal columns in checkForUpdate, and passes { maxEntryWidth } into fetchChangelog.
Test coverage for width-aware truncation
mastracode/src/utils/__tests__/update-check.test.ts
Imports computeChangelogEntryWidth; revises parseChangelog truncation tests to use default cap and adds tests for wider/narrower maxEntryWidth, first-sentence truncation, and computeChangelogEntryWidth defaults/scaling/clamping.
Release documentation
.changeset/little-carpets-brush.md
Marks a patch release and documents that /update changelog entries now adapt to dialog width instead of truncating at a fixed length.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: fixing changelog trimming alignment to dialog width instead of hardcoded character limits.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch devin/1778684172-mastracode-changelog-trimming

Comment @coderabbitai help to get the list of available commands and usage tips.

@dane-ai-mastra

Copy link
Copy Markdown
Contributor

Thank you for your contribution!

Your PR needs to fix an existing issue. You are required to link issues (e.g. with Fixes #1234, Closes #1234) in your PR description. PRs without a linked issue may be closed.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 05e3395 and 986288c.

📒 Files selected for processing (5)
  • .changeset/little-carpets-brush.md
  • mastracode/src/tui/commands/update.ts
  • mastracode/src/tui/mastra-tui.ts
  • mastracode/src/utils/__tests__/update-check.test.ts
  • mastracode/src/utils/update-check.ts

Comment thread mastracode/src/utils/update-check.ts
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@vercel vercel Bot temporarily deployed to Preview – mastra-playground-ui May 13, 2026 15:02 Inactive
@vercel vercel Bot temporarily deployed to Preview – mastra-docs-1.x May 13, 2026 15:02 Inactive
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>
@vercel vercel Bot temporarily deployed to Preview – mastra-playground-ui May 13, 2026 15:41 Inactive
@vercel vercel Bot temporarily deployed to Preview – mastra-docs-1.x May 13, 2026 15:41 Inactive
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>
@vercel vercel Bot temporarily deployed to Preview – mastra-playground-ui May 13, 2026 16:28 Inactive
@vercel vercel Bot temporarily deployed to Preview – mastra-docs-1.x May 13, 2026 16:28 Inactive
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>
@vercel vercel Bot temporarily deployed to Preview – mastra-playground-ui May 13, 2026 16:49 Inactive
@vercel vercel Bot temporarily deployed to Preview – mastra-docs-1.x May 13, 2026 16:49 Inactive
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.

2 participants