Skip to content

feat(row-editor): edit text stored in a BLOB as text - #1452

Merged
NewtTheWolf merged 1 commit into
TabularisDB:mainfrom
parthchilwerwar:feat/blob-text-editing
Nov 9, 2026
Merged

NewtTheWolf merged 1 commit into
TabularisDB:mainfrom
parthchilwerwar:feat/blob-text-editing

Conversation

@parthchilwerwar

@parthchilwerwar parthchilwerwar commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Closes #698

Since #696, the grid shows a BLOB that holds printable UTF-8, such as a SQLite path column, 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:

    • complete: not a truncated preview;
    • at most 10 KiB: the hex editor's limit;
    • generic: application/octet-stream;
    • printable: valid UTF-8 with no binary control characters.

    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:

  • CRLF line endings: a browser textarea turns \r\n into \n, so an edit would silently drop the \rs.
  • A UTF-8 byte order mark: TextDecoder drops a leading EF 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:
    • blobValueToEditableText returns the editable text, using the grid's text check plus the byte-for-byte round-trip check.
    • blobTextToWireFormat encodes text as UTF-8 in the wire format.
    • The wire-format encoding at the end of blobHexToWireFormat moved into a shared bytesToBlobWireFormat, so both use it.
  • BlobTextInput: the text editor. Like BlobHexInput, it saves on blur, and Ctrl/Cmd+Enter finishes editing.
  • BlobBytesInput: shows the Text/Hex switch, as role="tablist" buttons with aria-selected like the JSON input's mode switch, and picks the editor. FieldEditor now renders it where it rendered BlobHexInput.
  • Translations: blobInput.editAs, blobInput.text and blobInput.hex in all 13 locales.

Testing

  • tests/utils/blob.test.ts: five new tests.

    • text BLOBs, including multi-byte characters, tabs, newlines and an empty BLOB, become editable text;
    • UTF-8 encoding into the wire format, with the MIME type kept;
    • saving unchanged text writes the identical value;
    • binary, PDF, truncated and over-10 KiB BLOBs are not editable as text;
    • CRLF text and a BOM are not editable as text.
  • tests/components/ui/FieldEditor.test.tsx: four new tests.

    • a text BLOB opens in Text, and editing saves the UTF-8 wire value;
    • unchanged text is not saved;
    • switching Text → Hex → Text shows 61 62 and then ab;
    • a binary BLOB shows no switch, only hex.

    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, FieldEditor or RowEditorPanel passes (11 files, 171 tests). pnpm typecheck passed. ESLint and Prettier passed on the changed files, and so did node scripts/check-theme-tokens.mjs.

How to try it

  1. In SQLite, create a table with a text value stored as a BLOB:

    CREATE TABLE blob_text_demo (id INTEGER PRIMARY KEY, path BLOB);
    INSERT INTO blob_text_demo (path) VALUES (CAST('C:\data\report.txt' AS BLOB));
    INSERT INTO blob_text_demo (path) VALUES (X'00FF10');
  2. Open the table and double-click the first path cell. The row editor shows Text selected, with C:\data\report.txt.

  3. Change it to C:\data\report-2026.txt, click outside the field, and save the row. The grid shows the new path, and SELECT hex(path) FROM blob_text_demo WHERE id = 1 returns its UTF-8 bytes.

  4. Switch to Hex. The bytes are shown, and edits there work as before.

  5. Double-click the second path cell. There is no Text/Hex switch, only the hex editor with 00 FF 10.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

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
Copilot AI balanced review requested due to automatic review settings November 9, 2026 09:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@kilo-code-bot

kilo-code-bot Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/web-ui/src/components/ui/BlobTextInput.tsx 25 Eligibility for text mode is re-evaluated on the committed value. If an edit makes the BLOB exceed 10 KiB, or adds a control character or \r, the editor is swapped mid-edit for hex-only (or the download editor above 10 KiB) and the Text/Hex switch disappears.
Files Reviewed (19 files)
  • packages/web-ui/src/components/ui/BlobBytesInput.tsx
  • packages/web-ui/src/components/ui/BlobTextInput.tsx - 1 issue
  • packages/web-ui/src/components/ui/FieldEditor.tsx
  • packages/web-ui/src/utils/blob.ts
  • packages/web-ui/tests/components/ui/FieldEditor.test.tsx
  • packages/web-ui/tests/utils/blob.test.ts
  • packages/web-ui/src/i18n/locales/*.json (13 locales)

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 main

@NewtTheWolf NewtTheWolf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

@NewtTheWolf

Copy link
Copy Markdown
Collaborator

Tested 8cb2b9737a10759fe638c08b869fac61d83a3b4b in the real Linux GTK/WebKitGTK app against disposable SQLite data. Ready to merge.

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. pnpm lint && pnpm typecheck && pnpm test:all passed, including 8,518 frontend tests; GitHub checks are green.

Scripted focus changes produced WebKit permission messages that also reproduce on official main 391f7db3. Monaco cancellation messages were also captured during rapid panel/transpose changes, with no failed save or byte mismatch.

@NewtTheWolf
NewtTheWolf merged commit fc44cef into TabularisDB:main Nov 9, 2026
11 checks passed
@parthchilwerwar

Copy link
Copy Markdown
Contributor Author

Late thanks, @NewtTheWolf, for testing this in the real GTK app and checking the stored bytes. That covered more than my tests did.

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.

[Feat]: Allow editing SQLite string BLOBs

3 participants