feat(ui): truncate and clean session titles in picker#248
feat(ui): truncate and clean session titles in picker#248Mohamed-Fathy-Salah wants to merge 9 commits into
Conversation
|
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:
📝 WalkthroughWalkthroughSession titles with embedded newlines are now sanitized for picker display. The Poem
🚥 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 unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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 `@lua/agentic/session_restore.lua`:
- Line 62: Normalize CRLF and CR line endings before replacing newlines in the
title: update the transformation on the title variable (the line that currently
does title = title:gsub("\n", " "):sub(1, 80)) to first normalize "\r\n" to "\n"
and "\r" to "\n", then replace "\n" with a space, and finally call sub(1, 80);
this ensures Windows/Mac line endings are removed consistently when generating
the picker title.
🪄 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: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: e01be131-dfc8-4605-abb8-6106e1f70206
📒 Files selected for processing (1)
lua/agentic/session_restore.lua
- Replace newlines with spaces in session titles - Truncate session titles to 80 characters for better UI display
6c68e36 to
b3eedf9
Compare
carlos-algms
left a comment
There was a problem hiding this comment.
@Mohamed-Fathy-Salah Thank you for the contribution!
Could you please check the failing step?
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 `@lua/agentic/session_restore.lua`:
- Line 66: The byte-based truncation using :sub(1, 80) can split multi-byte
UTF-8 characters; add a UTF-8-safe truncation helper (e.g., utf8_truncate) that
uses vim.str_utf_start (or vim.str_utf_end) to find the last valid UTF-8
boundary before the byte limit, then replace occurrences of title:sub(1, 80) (or
the exact :sub(1, 80) expression) with a call to utf8_truncate(title, 80) so
displayed strings remain valid UTF-8.
🪄 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: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 8bb7348b-b32d-4d04-87b4-09c1c7977b14
📒 Files selected for processing (1)
lua/agentic/session_restore.lua
Replace :sub(1, 80) with utf8_truncate() which uses vim.str_utf_start and vim.str_utf_end to find the last valid character boundary before the byte limit, preventing split multi-byte codepoints in the picker. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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 `@lua/agentic/session_restore.lua`:
- Around line 6-10: The `@return` annotation for the utf8_truncate function is not
in the required LuaCATS format; update the comment above the local function
utf8_truncate to use the form "`@return` {string} truncated_string Truncated UTF-8
string" (or similar name/description) so it follows "`@return` {type} return_name
description" and documents the returned value consistently with the repo
guideline.
🪄 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: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: e562fc08-2e06-4164-be71-1781ebaeab6a
📒 Files selected for processing (2)
lua/agentic/session_restore.lualua/agentic/session_restore.test.lua
This reverts commit e6051d2.
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 `@lua/agentic/session_restore.lua`:
- Around line 62-66: Add a test in lua/agentic/session_restore.test.lua that
exercises CR/LF sanitization for ACP session titles: create an ACP session entry
whose title contains "\r\n" and "\n", call the picker flow that uses the display
normalization (the code path where title = title :gsub("\r\n", " ") :gsub("\r",
" ") :gsub("\n", " ") :sub(1, 80)), assert the returned picker items' display
values contain spaces instead of newlines (no "\r" or "\n"), and also assert
that the load_acp_session call (or its stub) receives the original unsanitized
choice.title if that behavior is expected; after adding the test run make
validate to ensure it passes.
🪄 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: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 985b0f98-8efa-4660-a628-7881f598da07
📒 Files selected for processing (1)
lua/agentic/session_restore.lua
Assert that \r\n/\n in an ACP session title collapse to spaces in the picker display while load_acp_session still receives the original unsanitized title. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This PR improves the session picker UI by cleaning newlines and truncating long session titles to 80 characters.