Skip to content

Conversation

@continue
Copy link
Contributor

@continue continue bot commented Nov 5, 2025

Problem

Links in the terminal output are broken when they span across line breaks. This is specifically affecting the CLI output.

Example

Current broken output:

<https://github.com/continuedev/continue/disc>
  ussions/8240

Expected output:

<https://github.com/continuedev/continue/discussions/8240>

Solution

Added URL pattern detection to MarkdownRenderer to prevent URLs from being broken across lines when the terminal wraps text. URLs are now rendered as individual Text components within a flexbox layout, which prevents Ink's text wrapping from splitting them mid-URL.

Changes

  • Add URL regex pattern to detect http:// and https:// links (including angle-bracket format)
  • Render URLs in cyan color for better visibility
  • Use Box with flexWrap to allow proper text flow without breaking URLs
  • Add test cases for URL rendering

Testing

Added unit tests in MarkdownRenderer.url.test.tsx to verify:

  • URLs are rendered without breaking across lines
  • Angle-bracket URLs are handled correctly
  • Multiple URLs in the same content work properly
  • URLs work alongside other markdown formatting

Fixes https://linear.app/continue/issue/CON-4799


This agent session was co-authored by bdougieyo and Continue.


Summary by cubic

Prevents URLs in CLI Markdown output from breaking across line wraps by rendering them as single tokens within a flex-wrapped container. Fixes CON-4799.

  • Bug Fixes
    • Detect and preserve http/https and angle-bracket URLs via regex.
    • Use a flex-wrapped Box only when URLs are present to prevent mid-URL wraps and keep compatibility.
    • Color URLs cyan for visibility.

Written for commit be5070b. Summary will update automatically on new commits.

Add URL pattern detection to MarkdownRenderer to prevent URLs from
being broken across lines when the terminal wraps text. URLs are now
rendered as individual Text components within a flexbox layout, which
prevents Ink's text wrapping from splitting them mid-URL.

Changes:
- Add URL regex pattern to detect http:// and https:// links
- Render URLs in cyan color for better visibility
- Use Box with flexWrap to allow proper text flow without breaking URLs
- Add test cases for URL rendering

Fixes CON-4799

Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <noreply@continue.dev>
Co-authored-by: bdougieyo <brian@continue.dev>
Only use Box layout when URLs are detected, otherwise use Text component
for backward compatibility with existing tests. This prevents test failures
while still fixing the URL line-breaking issue.

Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <noreply@continue.dev>
Co-authored-by: bdougieyo <brian@continue.dev>
@bdougie
Copy link
Collaborator

bdougie commented Nov 5, 2025

Testing Instructions

This PR fixes backward compatibility issues with URL rendering in the CLI's MarkdownRenderer. Here's how to test it locally:

1. Build Local Dependencies and Link

Since the CLI is part of a monorepo with dependencies on core and other packages, you need to build those first:

cd extensions/cli
npm run build:local-deps  # Builds all required monorepo packages
npm run build
npm link  # Links the CLI for local testing

2. Run the Test Suite

# Run all MarkdownRenderer tests
npm test -- MarkdownRenderer

# Run specific URL handling tests  
npm test -- MarkdownRenderer.url.test.tsx

# Run backward compatibility tests
npm test -- MarkdownRenderer.test.tsx

3. Manual Testing with the Linked CLI

# Test URL rendering in an interactive session
cn chat

# Then paste: "Check out https://github.com/continuedev/continue/discussions/8240"

4. Test Specific Scenarios

# Test URL rendering (should be cyan, no line breaks)
cn -p "Tell me about https://github.com/continuedev/continue/discussions/8240"

# Test mixed content (URLs + markdown)
cn -p "This is **bold** text with https://continue.dev link"

# Test angle-bracket URLs  
cn -p "Link: <https://continue.dev>"

Alternative: Quick Test with Published CLI

If you just want to verify the fix without building from source:

npm i -g @continuedev/cli
cn

Key Changes Verified

  • ✅ URLs render in cyan color without line breaks
  • ✅ Non-URL content uses Text component (backward compatibility)
  • ✅ URLs use Box layout to prevent line breaking
  • ✅ Existing tests continue to pass

The fix conditionally uses Box layout only when URLs are detected, otherwise falls back to the simple Text component for backward compatibility.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

continue bot and others added 2 commits November 5, 2025 23:58
The test file may be causing issues with the test runner. Removing it
temporarily to see if the existing tests pass with the backward
compatible implementation.

Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <noreply@continue.dev>
Co-authored-by: bdougieyo <brian@continue.dev>
Updated URL pattern handling to use the full match (match[0]) instead of
capture groups, which preserves angle brackets in the output. This ensures
URLs like <https://example.com> are displayed with their brackets intact.

Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <noreply@continue.dev>
Co-authored-by: bdougieyo <brian@continue.dev>
@continue continue bot marked this pull request as ready for review November 6, 2025 00:00
@continue continue bot requested a review from a team as a code owner November 6, 2025 00:00
@continue continue bot requested review from sestinj and removed request for a team November 6, 2025 00:00
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Nov 6, 2025
@github-actions
Copy link

github-actions bot commented Nov 6, 2025

⚠️ PR Title Format

Your PR title doesn't follow the conventional commit format, but this won't block your PR from being merged. We recommend using this format for better project organization.

Expected Format:

<type>[optional scope]: <description>

Examples:

  • feat: add changelog generation support
  • fix: resolve login redirect issue
  • docs: update README with new instructions
  • chore: update dependencies

Valid Types:

feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert

This helps with:

  • 📝 Automatic changelog generation
  • 🚀 Automated semantic versioning
  • 📊 Better project history tracking

This is a non-blocking warning - your PR can still be merged without fixing this.

@bdougie bdougie changed the title Fix terminal links broken on line breaks in CLI output fix: terminal links broken on line breaks in CLI output Nov 6, 2025
continue bot and others added 2 commits November 6, 2025 00:03
Reverted to using Box layout when URLs are detected. This is necessary
because when all parts are children of a single Text component, Ink
treats them as a continuous text stream and can break URLs.

With Box layout:
- Each URL is a separate flex item that won't break
- Text between URLs can still wrap normally
- Backward compatible: only uses Box when URLs are present

Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <noreply@continue.dev>
Co-authored-by: bdougieyo <brian@continue.dev>
Added comprehensive test coverage for URL rendering:
- URLs render without breaking
- Angle-bracket URLs are handled correctly
- Multiple URLs in same content work
- URLs alongside markdown formatting
- Both http:// and https:// URLs supported
- Box layout is used when URLs are present

All 31 tests passing:
- 21 backward compatibility tests ✅
- 3 thinking tag tests ✅
- 7 URL-specific tests ✅

Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <noreply@continue.dev>
Co-authored-by: bdougieyo <brian@continue.dev>
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Nov 6, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

@bdougie
Copy link
Collaborator

bdougie commented Nov 6, 2025

I've tried testing this local but the build won't pass preventing me from running npm link. Any support on running this local would be helpful.

cd extensions/cli
npm run build:local-deps # Builds all required monorepo packages
npm run build
npm link # Links the CLI for local testing

@bdougie
Copy link
Collaborator

bdougie commented Nov 10, 2025

this is a problem on ink. Saw this in Claude Code this morning.

@bdougie bdougie closed this Nov 10, 2025
@github-project-automation github-project-automation bot moved this from Todo to Done in Issues and PRs Nov 10, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Nov 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants