Skip to content

feat(datagrid): read binary columns holding UTF-8 as text - #2603

Merged
datlechin merged 1 commit into
mainfrom
fix/2599-binary-text-display
Sep 2, 2026
Merged

datlechin merged 1 commit into
mainfrom
fix/2599-binary-text-display

Conversation

@datlechin

Copy link
Copy Markdown
Member

Fixes #2599.

The bug

ValueDisplayFormat.applicableColumnTypes mapped binary columns to [.raw, .uuid], so the Display As submenu on a VARBINARY or BLOB header offered Raw Value and UUID and nothing else. A binary column holding UTF-8, which is where MySQL applications put JSON payloads, tokens and message bodies, had no readable form at all: every cell rendered 0x7b226576656e74….

Smart value detection could not help either. ValueDisplayDetector reads its samples through PluginCellValue.asText, which is nil for every .bytes cell, so a binary column was invisible to it.

The fix

A new ValueDisplayFormat.text, applicable to binary columns. Everything the grid renders funnels through CellDisplayFormatter.format, so one case reaches the grid, the per-column value filter, column-width measurement, VoiceOver and single-cell copy at once.

BinaryTextDecoder is the whole decision, kept pure and separate because both the format and the detector ask it the same question:

  • Trailing 0x00 is trimmed, but only on a column whose base type name is BINARY. That is the one type that right-pads, so without the trim a fixed-width column holding text could never read as text, and with the trim anywhere else 0x6100 in a BLOB would report as a.
  • The bytes decode as UTF-8 or the answer is no.
  • Anything carrying a C0 control character or DEL is refused, tab, newline and carriage return excepted. That is what separates a stored string from a PNG header, a gzip stream, a SHA-1 digest or a packed IPv4 address, all of which are in the test suite.
  • Capped before decoding: 40,000 bytes on the display path, which always covers the grid's 10,000 character cell limit, and 512 bytes on the detection probe. A LONGBLOB never builds a multi-gigabyte String on the main thread. A cut value carries a …, so Cmd+C cannot hand back a prefix as if it were the whole thing. A cut that splits a UTF-8 sequence gives up at most three bytes; a whole value never does, since dropping bytes there would accept binary that happens to open with readable characters.

A value the decoder refuses falls back to the hex it always showed, per cell. So an image sitting in a column set to Text still reads as 0x89504E… while its neighbours read as text.

Detection is per column and every sample has to agree: all sampled values decode, and at least one carries content. A .text sample opts the column out entirely, which keeps MongoDB's driver-decoded legacy UUIDs on the byte order their connection chose. UUID detection still runs first, so an id-like BINARY(16) is unaffected.

ValueDisplayFormatService.applyFormat(_ String:) now returns String?. "This format cannot render this value" had no spelling before, and the Data overload was already optional. .uuid and the timestamps are unchanged; only .text ever answers nil.

The cell length cap and line-break flattening moved into CellDisplayFormatter.fitToCell and now cover the binary branch too. Hex never needed it, since a blob cell was capped at 64 bytes. Decoded text does.

Find had to move with it

FindMatcher.isSearchable excluded every binary column outright, and runFind dropped any cell whose value was not already a string. Both were right while hex was the only thing a binary column could show, and both would have silently skipped a column now displaying readable text: the user searches for signup, sees it on screen, and Find reports nothing.

A binary column is now searchable when its display format turns bytes into characters, which ValueDisplayFormat.rendersBinaryAsText answers. That covers UUID as well as Text, so a BINARY(16) id column showing 550e8400-… is searchable too. It was not before.

The format is a column-level choice and the fallback to hex is per value, so the two gates are separate: the column passes on its format, and each cell passes only if the format actually rendered those bytes. Without the second one a term like 8950 would match a 0x89504E47 still sitting in a Text column.

Server-side escalation is deliberately unchanged: isServerSearchable gates what can go into a LIKE without a cast, and bytea LIKE '…' fails the whole query on PostgreSQL.

Scope

Display only. A binary cell keeps the hex editor and the hex popover, exactly as Display As > UUID behaves today, and nothing about what is written changes. No PluginKit change, so no ABI bump.

Tests

47 new cases across six suites. The thirteen suites that own the touched types run 145 cases, all passing.

  • BinaryTextDecoderTests (21 new): real byte sequences, including a PNG header, a gzip header, a UUID's 16 bytes, a packed IPv4 address, BINARY(N) padding against the same bytes in a BLOB and a VARBINARY, an all-padding value, an embedded NUL, a split multi-byte sequence at the cap, the truncation marker, and the byte-per-character carrier string a driver hands over.
  • ValueDisplayDetectorTests (12 new): the mixed column, the all-empty column, the driver-decoded column, the trailing NUL under both column widths, and UUID still winning on an id-like BINARY(16).
  • TableViewCoordinatorFindTests (3 new): Find over a Text column, over a cell that fell back to hex, and over a column left on Raw.
  • CellDisplayFormatterTests (8 new): the render path, the hex fallback, the padding policy, line-break flattening and the length cap.
  • FindMatcherTests and ValueDisplayFormatTests: searchability per format, and menu contents per column type with MongoDB included.

No TableProUITests coverage. The flow is the data grid's column header context menu, and the header is entirely custom-drawn chrome with no addressable element; menu item identifiers also differ on the CI runner. The behaviour is fully covered by the unit suites instead.

Docs

features/json-viewer.mdx owns the Display As table and gained the Text row plus the per-cell fallback. features/data-grid.mdx and customization/data-settings.mdx each carried a copy of the format list; both now point at the table rather than restating it. The Settings row also claimed smart value detection renders JSON and PHP serialized columns, which it never did: ValueDisplayDetector only ever returned UUID and Unix timestamps.

Before / After

Same SQLite fixture in both: events.payload is a BLOB holding UTF-8 JSON, events.digest is a BLOB holding 20 random bytes. Captured from 0.70.0 and from this branch, both against throwaway storage.

Before, every value in both columns reads as hex:

payload                                         digest
0x7B226576656E74223A227369676E6570222C22706…    0x93D1B113CBD3F461A9351A13A38AD9A8E9B55305
0x7B226576656E74223A226C6F67696E222C2272656…    0x9A04BFB1B2C84EC5DE73A74F45672816B90802BB

After, payload reads as text and digest correctly stays hex, with no user action:

payload                                         digest
{"event":"signup","plan":"pro"}                 0x93D1B113CBD3F461A9351A13A38AD9A8E9B55305
{"event":"login","region":"eu"}                 0x9A04BFB1B2C84EC5DE73A74F45672816B90802BB

Full-window PNGs are attached below.

Fixes #2599

https://claude.ai/code/session_01RuTox52znCzCJy8hHstiXU

@mintlify

mintlify Bot commented Sep 2, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
TablePro 🟡 Building – Sep 2, 2026, 4:02 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@datlechin
datlechin merged commit f295ffa into main Sep 2, 2026
9 checks passed
@datlechin
datlechin deleted the fix/2599-binary-text-display branch September 2, 2026 04:03
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.

Currently Display As on Binary columns only show UUID and raw as options

1 participant