-
Notifications
You must be signed in to change notification settings - Fork 3.8k
fix: terminal links broken on line breaks in CLI output #8607
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
Conversation
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>
Testing InstructionsThis 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 LinkSince the CLI is part of a monorepo with dependencies on cd extensions/cli
npm run build:local-deps # Builds all required monorepo packages
npm run build
npm link # Links the CLI for local testing2. 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.tsx3. 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 CLIIf you just want to verify the fix without building from source: npm i -g @continuedev/cli
cnKey Changes Verified
The fix conditionally uses Box layout only when URLs are detected, otherwise falls back to the simple Text component for backward compatibility. |
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.
No issues found across 2 files
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>
|
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>
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.
No issues found across 1 file
|
I've tried testing this local but the build won't pass preventing me from running
|
|
this is a problem on ink. Saw this in Claude Code this morning. |
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:
Expected output:
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
Testing
Added unit tests in
MarkdownRenderer.url.test.tsxto verify: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.
Written for commit be5070b. Summary will update automatically on new commits.