Repository navigation
feat(row-editor): edit text stored in a BLOB as text - #1452
Conversation
A BLOB the grid shows as text (complete, generic, printable UTF-8 since TabularisDB#696) still opened the row editor on hex. Open it in a Text editor with a Text/Hex switch, and save the text as UTF-8 in the same BLOB wire format the hex editor writes, keeping the MIME type. Text editing is only offered when saving the text unchanged writes back the same bytes, so CRLF text and a UTF-8 byte order mark stay in hex. Closes TabularisDB#698
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
|
||
| const commit = () => { | ||
| if (draft === text) return; | ||
| onChange(blobTextToWireFormat(draft, mimeType)); |
There was a problem hiding this comment.
WARNING: Committing an edit can eject the user from the text editor, and the edit then cannot be continued in text mode.
blobValueToEditableText / blobValueToEditableHex re-evaluate eligibility against the new value after every commit. If the edited text now (a) exceeds 10 KiB, (b) contains a control character (e.g. pasted \x01), or (c) contains \r (a pasted CRLF block can still reach draft in some browsers/clipboard paths), the new value is no longer editable as text. BlobBytesInput then silently swaps the Text/Hex tab bar and the text editor for the hex-only editor, and above 10 KiB FieldEditor swaps to the file-download BlobInput, so the user's text disappears from view mid-edit.
Consider keeping the editor mode sticky for the lifetime of the field (e.g. decide text-mode eligibility from the original/initial value only, or keep rendering BlobTextInput while the draft is valid UTF-8), or at least validate the draft on commit and surface an inline error instead of swapping editors.
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (19 files)
Notes: review was static only (no code or tests were run). The translations, wire-format encoding and the CRLF/BOM round-trip guard look correct. Fix these issues in Kilo Cloud Reviewed by claude-sonnet-5.5 · Input: 250 · Output: 3.5K · Cached: 390.1K Review guidance: REVIEW.md from base branch |
NewtTheWolf
left a comment
There was a problem hiding this comment.
Thanks for preserving UTF-8 bytes and MIME metadata, including the CRLF/BOM cases that stay in hex mode. I reviewed 8cb2b9737a10759fe638c08b869fac61d83a3b4b and found no evident issue in this pass. The 101 targeted BLOB, FieldEditor and row-editor tests passed, along with typecheck and targeted source ESLint.
I will verify text editing, raw-byte fallback, save/reload and both grid layouts in the real app, then run the full required checks before merging.
|
Tested Exercised Text/Hex switching, unchanged blur, UTF-8 and raw-hex edits, submit/reload and the transposed grid. Verified persisted SQLite BLOB types and exact bytes, plus binary/CRLF/BOM/large/empty fallbacks. Scripted focus changes produced WebKit permission messages that also reproduce on official main |
|
Late thanks, @NewtTheWolf, for testing this in the real GTK app and checking the stored bytes. That covered more than my tests did. |
Closes #698
Since #696, the grid shows a BLOB that holds printable UTF-8, such as a SQLite
pathcolumn, as text. Double-clicking it still opened the row editor on hex (43 3A 5C …), so changing one character in a path meant editing bytes by hand.The row editor now opens such a BLOB in a Text editor, with a Text / Hex switch above it:
Saving text: the text is encoded as UTF-8 and written in the same
BLOB:<size>:<mime>:<base64>format the hex editor already uses, with the BLOB's MIME type kept. The backend gets the same kind of value as before.Hex is still available: switch to Hex to edit the raw bytes, as before.
Which BLOBs get text mode: exactly those the grid shows as text, since both use the same check from fix(sqlite): display UTF-8 BLOB values as text #696:
application/octet-stream;Any other BLOB still opens in hex only, or in the file editor when it is larger.
Keeping the bytes intact
Text mode is only offered when saving the text unchanged would write back exactly the same bytes. Two cases fail that test and stay in hex:
textareaturns\r\ninto\n, so an edit would silently drop the\rs.TextDecoderdrops a leadingEF BB BF, so an edit would silently remove it.Text left unchanged is never written back, so blurring the field without typing anything doesn't create a change.
Changes
utils/blob.ts:blobValueToEditableTextreturns the editable text, using the grid's text check plus the byte-for-byte round-trip check.blobTextToWireFormatencodes text as UTF-8 in the wire format.blobHexToWireFormatmoved into a sharedbytesToBlobWireFormat, so both use it.BlobTextInput: the text editor. LikeBlobHexInput, it saves on blur, and Ctrl/Cmd+Enter finishes editing.BlobBytesInput: shows the Text/Hex switch, asrole="tablist"buttons witharia-selectedlike the JSON input's mode switch, and picks the editor.FieldEditornow renders it where it renderedBlobHexInput.blobInput.editAs,blobInput.textandblobInput.hexin all 13 locales.Testing
tests/utils/blob.test.ts: five new tests.tests/components/ui/FieldEditor.test.tsx: four new tests.61 62and thenab;The existing test "should edit a small generic BINARY value as hex" stores the bytes of
test, which are printable text. It now clicks Hex before checking its hex editing.Checks: every test file that imports the BLOB utilities,
FieldEditororRowEditorPanelpasses (11 files, 171 tests).pnpm typecheckpassed. ESLint and Prettier passed on the changed files, and so didnode scripts/check-theme-tokens.mjs.How to try it
In SQLite, create a table with a text value stored as a BLOB:
Open the table and double-click the first
pathcell. The row editor shows Text selected, withC:\data\report.txt.Change it to
C:\data\report-2026.txt, click outside the field, and save the row. The grid shows the new path, andSELECT hex(path) FROM blob_text_demo WHERE id = 1returns its UTF-8 bytes.Switch to Hex. The bytes are shown, and edits there work as before.
Double-click the second
pathcell. There is no Text/Hex switch, only the hex editor with00 FF 10.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.