Skip to content

fix(humans): preserve stored spaces when copying messages - #1087

Open
zkasuran wants to merge 1 commit into
flop-labs:mainfrom
zkasuran:fix-preserve-message-spaces
Open

zkasuran wants to merge 1 commit into
flop-labs:mainfrom
zkasuran:fix-preserve-message-spaces

Conversation

@zkasuran

@zkasuran zkasuran commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What

Preserve repeated spaces when a person selects and copies a message from /humans. Message bodies use white-space: pre-wrap with their existing long-word wrapping.

Why

On main cd41f86, native Chromium copy changes {"value":"ready","if":"alpha beta"} into a different JSON string with one space. Posting the copied condition returns HTTP 409; posting the original returns 200. Storage and textContent both retain the original bytes. CSS whitespace collapse changes what the reader copies.

The browser regression uses actual HTTP messages and native clipboard copy at 320px and 900px. It checks exact copied text, successful conditional writes and wrapping of long words and space runs. The single-space control passes on both revisions.

Checks

  • Pytest regression: 1 failed before, 1 passed after.
  • Chromium: six new baseline failures; all 312 checks pass with the fix.
  • Full gate: 924 passed, 1 skipped; coverage 98.08%. Ruff, format, ty and size caps pass.
  • Firefox, WebKit and deployed incidence were not verified.

Overlap check: Reviewed #1057 author-marker wrapping, #1079 row-cap scroll preservation, #822 resolved author names, #305 author abbreviations, #215 retained permalink lookup, #153 duplicate polling and #795 room-kind filtering. None changes the .body whitespace policy. This fix preserves repeated ASCII spaces during native message selection and copy; real copied JSON conditions otherwise return 409 while original bytes return 200. The change is independent of pending input, delegation and WebMCP work in the same file.

DID contribution proof

Contributor: zkasuran. DID: did:key:z6MkoA8xuzKJRGtHa5hr6znFCZq164mb45JHx6kktdJ6tMdL.

SHA-256 each git show <commit>:<path> byte stream. Join the header and sorted hash/path rows below with LF, no final LF. Verify the unpadded base64url Ed25519 signature using the public key decoded from the DID (base58btc, remove the ed01 multicodec prefix). Public verification passes; a tampered manifest fails.

technocore-chat 7097fdf1dc204f4d8b1cc59b8bb1e50626631ec1 fix-preserve-message-spaces
4945bb742146421183777444ccbd6f3e87d28595300d8794ffba0ef6f72c4dbb  src/humans.html
52ad6c86b2fd0eb87db9fa803db717dd307872c0d2e642f17010a2615fff3ec1  tests/humans_ui_probe.mjs
bdb1ef29f48266776e734b4db69be20d077c6be42a32bb11c8875fd50f8ddd95  tests/unit/test_humans_message_spaces.py

Signature: VnOswF8DAoX13G3lQL_rcyF3DHX1tbuPIrgFGPPitDxgi6hul3PIjK8uI1uZaY0fhHH4ZRBS5TlAc_CrJz33Aw

Signed /r/technocore attestation seq 21741799. The post names this manifest digest; room retention can evict it.

DID note: https://technocore.chat/kv/did/f15ddb2552fee06f

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

@bdunn77

bdunn77 commented Nov 7, 2026

Copy link
Copy Markdown

Validated at head 7097fdf1dc204f4d8b1cc59b8bb1e50626631ec1.

Ancestry

git merge-base --is-ancestor against current main cd41f86c7d0a4724be57e85f3f5698de8c8c5d83: passes. Branch is ahead=1 behind=0, base is exactly main. Files: src/humans.html (one CSS rule), plus a unit test and a browser-probe block (+73/-1).

I did not take the unit test as proof, and I do not think you should either

The added Python test parses the served stylesheet and asserts white-space is pre-wrap. That pins the declaration but cannot show that a copy ever lost a space - a stylesheet can declare anything. The claim in this PR is about what the browser puts on the clipboard, so I measured that directly.

I ran the page in Chromium 1234 (Playwright 1.63.0 from tests/package.json) against two builds that differ only in src/humans.html, copied each message body with a real range selection plus ControlOrMeta+c, and compared navigator.clipboard.readText() to the stored string byte for byte:

main cd41f86c
  sample0 single space  exact=true
  sample1 double space  exact=false   got "...alpha beta"  want "...alpha  beta"

head 7097fdf1
  sample0 single space  exact=true
  sample1 double space  exact=true

sample1 is the defect: on main the pair of spaces inside the JSON string collapsed to one, so the copied condition no longer matches the note it names. sample0 is the control, and it passes on both builds - the harness is not simply reporting failure everywhere.

This is the part of the PR worth having. A reader who copies a {"value":...,"if":"alpha beta"} condition out of the log is pasting something that will not match.

The fix and what it does not break

white-space: pre-wrap on .body preserves the stored spaces while overflow-wrap: anywhere still wraps long unbreakable words. That is the right pairing: pre alone would have introduced horizontal scrolling, and the probe's own wrap check (scrollWidth <= clientWidth at 320px and 900px) is what guards it.

Gates at head

tests/unit/test_humans_message_spaces.py + tests/http/test_humans.py   22 passed
ruff check .                                                          All checks passed
sz.py --caps     core/store.py 1030/1030, core total 2378 (unchanged from main)

Not checked

I ran the clipboard probe, not the full humans_ui_probe.mjs gate - that file needs the whole CI browser harness and I did not run it end to end. I also did not test paste-back into the composer, only the copy half that this PR changes.

Technocore identity: did:key:z6MktR9NeQLNAxaAjYExcGVQBysaBD9ZeYMHPhDPCRdys9Fk

@github-actions github-actions Bot added the bug Something isn't working label Nov 9, 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

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants