Skip to content

feat(ui): truncate and clean session titles in picker#248

Open
Mohamed-Fathy-Salah wants to merge 9 commits into
carlos-algms:mainfrom
Mohamed-Fathy-Salah:feature/truncate-session-titles
Open

feat(ui): truncate and clean session titles in picker#248
Mohamed-Fathy-Salah wants to merge 9 commits into
carlos-algms:mainfrom
Mohamed-Fathy-Salah:feature/truncate-session-titles

Conversation

@Mohamed-Fathy-Salah

Copy link
Copy Markdown

This PR improves the session picker UI by cleaning newlines and truncating long session titles to 80 characters.

@coderabbitai

coderabbitai Bot commented May 23, 2026

Copy link
Copy Markdown

Review Change Stack

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
📝 Walkthrough

Walkthrough

Session titles with embedded newlines are now sanitized for picker display. The show_picker method replaces \r\n, \r, and \n characters with spaces and truncates the result to 80 bytes, ensuring clean presentation in the UI picker. The underlying session state remains unaffected; only the display string is modified.

Poem

A rabbit tidies up the view,
Newlines become spaces, crisp and true.
Eighty bytes to show your way,
Pick a session—clean display. 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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
Title check ✅ Passed The title accurately describes the main change: adding truncation and cleaning of newlines in session titles for the UI picker component.
Description check ✅ Passed The description clearly relates to the changeset, explaining that it cleans newlines and truncates session titles to 80 characters to improve UI presentation.
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 unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@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

📥 Commits

Reviewing files that changed from the base of the PR and between e08304f and 6c68e36.

📒 Files selected for processing (1)
  • lua/agentic/session_restore.lua

Comment thread lua/agentic/session_restore.lua Outdated
- Replace newlines with spaces in session titles
- Truncate session titles to 80 characters for better UI display
@Mohamed-Fathy-Salah Mohamed-Fathy-Salah force-pushed the feature/truncate-session-titles branch from 6c68e36 to b3eedf9 Compare May 23, 2026 06:28

@carlos-algms carlos-algms left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@Mohamed-Fathy-Salah Thank you for the contribution!

Could you please check the failing step?

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@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

📥 Commits

Reviewing files that changed from the base of the PR and between b3eedf9 and 9192923.

📒 Files selected for processing (1)
  • lua/agentic/session_restore.lua

Comment thread 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>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@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

📥 Commits

Reviewing files that changed from the base of the PR and between 9192923 and e6051d2.

📒 Files selected for processing (2)
  • lua/agentic/session_restore.lua
  • lua/agentic/session_restore.test.lua

Comment thread lua/agentic/session_restore.lua Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@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

📥 Commits

Reviewing files that changed from the base of the PR and between e6051d2 and 2548ad7.

📒 Files selected for processing (1)
  • lua/agentic/session_restore.lua

Comment thread lua/agentic/session_restore.lua
Mohamed-Fathy-Salah and others added 3 commits June 5, 2026 20:37
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>
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