Skip to content

feat: fit inbox subjects to row width - #1750

Open
mvanhorn wants to merge 1 commit into
floatpane:masterfrom
mvanhorn:fix/1533-matcha-subject-row-width
Open

mvanhorn wants to merge 1 commit into
floatpane:masterfrom
mvanhorn:fix/1533-matcha-subject-row-width

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What?

The inbox row is now sized from the list width before anything is drawn, and a zero or negative width draws nothing.

  • The cursor and visual markers are chosen first and counted with the style frame, prefix, icon, and separator.
  • Sender and subject are shortened with an ellipsis by display width.
  • The date is kept only when two extra columns remain, and the styled line is clamped to the list width.
  • Tabs and line breaks are shown as spaces, and the stored title is left unchanged.
  • Row chrome, status icon, and subject text live in small helpers.

go test ./tui/... passed. The tests in tui/inbox_test.go fail without the fix (checked by reverting the source changes).

Fixes #1533

Why?

Long inbox subjects run past the row, so the date no longer sits on the right edge and rows of different lengths stop lining up. On a narrow width the date and the selection marker are carried out with the text, and a tab or line break in the subject or sender splits the row.

The painter kept a floor under every budget: the left side stayed at least 10 columns, the subject at least 4, and the padding at least 1. A narrow list therefore still received a string wider than the row.

The visual-selection marker was prepended after that string was measured, the date was always appended, and the list width was reduced by a hardcoded 2 columns. Truncation cut raw runes, and tabs and newlines in the sender and subject were copied onto the row.

AI was used for assistance.

The row is now sized from the list width before anything is drawn, and a
zero or negative width draws nothing. The cursor and visual markers are
chosen first and counted with the style frame, prefix, icon, and
separator. Sender and subject are shortened with an ellipsis by display
width, the date is kept only when two extra columns remain, and the
styled line is clamped to the list width. Tabs and line breaks are shown
as spaces, the stored title is left unchanged, and row chrome, status
icon, and subject text live in small helpers.

Fixes floatpane#1533
@mvanhorn
mvanhorn requested a review from a team as a code owner October 22, 2026 10:54

@floatpanebot floatpanebot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @mvanhorn! Please fix the following issues with your PR:

  • Title: Is too long (42 characters). The PR title must be strictly under 40 characters.

@floatpanebot floatpanebot added bug Something isn't working enhancement New feature or request area/tui Terminal UI / view layer size/L Diff: 201–800 lines and removed bug Something isn't working enhancement New feature or request labels Oct 22, 2026
@floatpanebot

Copy link
Copy Markdown
Member

Benchmark report — no significant change

Metrics worse: 0 · better: 0 (threshold: ±3%).

benchstat output
goos: linux
goarch: amd64
pkg: github.com/floatpane/matcha/backend
cpu: AMD EPYC 7763 64-Core Processor                
                           │    old.txt    │               new.txt                │
                           │    sec/op     │    sec/op      vs base               │
ParseSearchQuery_Simple-4    3.098µ ± 317%   3.711µ ± 194%        ~ (p=0.937 n=6)
ParseSearchQuery_Complex-4   8.455µ ±  33%   5.485µ ±  37%  -35.12% (p=0.009 n=6)
TokenizeSearchQuery-4        4.944µ ±  89%   4.808µ ± 109%        ~ (p=1.000 n=6)
geomean                      5.059µ          4.608µ          -8.92%

                           │  old.txt   │              new.txt               │
                           │    B/op    │    B/op     vs base                │
ParseSearchQuery_Simple-4    26.00 ± 0%   26.00 ± 0%       ~ (p=1.000 n=6) ¹
ParseSearchQuery_Complex-4   762.0 ± 0%   762.0 ± 0%       ~ (p=1.000 n=6) ¹
TokenizeSearchQuery-4        176.0 ± 0%   176.0 ± 0%       ~ (p=1.000 n=6) ¹
geomean                      151.6        151.6       +0.00%
¹ all samples are equal

                           │  old.txt   │              new.txt               │
                           │ allocs/op  │ allocs/op   vs base                │
ParseSearchQuery_Simple-4    2.000 ± 0%   2.000 ± 0%       ~ (p=1.000 n=6) ¹
ParseSearchQuery_Complex-4   23.00 ± 0%   23.00 ± 0%       ~ (p=1.000 n=6) ¹
TokenizeSearchQuery-4        9.000 ± 0%   9.000 ± 0%       ~ (p=1.000 n=6) ¹
geomean                      7.453        7.453       +0.00%
¹ all samples are equal

pkg: github.com/floatpane/matcha/tui
                    │   old.txt    │              new.txt               │
                    │    sec/op    │    sec/op     vs base              │
LogPanelView-4        160.4µ ±  5%   169.8µ ±  9%       ~ (p=0.394 n=6)
SearchOverlayView-4   186.8µ ±  3%   178.4µ ± 14%       ~ (p=0.394 n=6)
InboxConstruction-4   941.9µ ± 10%   948.3µ ± 21%       ~ (p=0.818 n=6)
geomean               304.5µ         306.2µ        +0.59%

                    │    old.txt    │               new.txt               │
                    │     B/op      │     B/op       vs base              │
LogPanelView-4        44.67Ki ±  0%   44.67Ki ± 51%       ~ (p=0.455 n=6)
SearchOverlayView-4   44.68Ki ± 26%   56.15Ki ± 41%       ~ (p=0.814 n=6)
InboxConstruction-4   874.5Ki ±  0%   874.5Ki ±  0%       ~ (p=0.816 n=6)
geomean               120.4Ki         129.9Ki        +7.91%

                    │   old.txt   │              new.txt              │
                    │  allocs/op  │  allocs/op   vs base              │
LogPanelView-4         714.0 ± 0%    714.0 ± 0%       ~ (p=0.455 n=6)
SearchOverlayView-4    925.0 ± 0%    926.0 ± 0%       ~ (p=0.697 n=6)
InboxConstruction-4   3.483k ± 0%   3.482k ± 0%       ~ (p=0.563 n=6)
geomean               1.320k        1.320k       +0.03%

auto-generated by benchmarks.yml

@mvanhorn mvanhorn changed the title feat: keep inbox subjects within row width feat: fit inbox subjects to row width Oct 22, 2026
@floatpanebot
floatpanebot dismissed their stale review October 22, 2026 15:28

Formatting issues have been resolved. Thank you!

@floatpanebot floatpanebot added bug Something isn't working enhancement New feature or request labels Oct 22, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/tui Terminal UI / view layer bug Something isn't working enhancement New feature or request size/L Diff: 201–800 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FEAT: Wrap/truncate long subject lines cleanly in list

2 participants