Skip to content

Test the preview overlay's view and edit modes instead of the old read-only copy - #1486

Merged
dylanplayer merged 1 commit into
mainfrom
codevisor/ackee
Nov 26, 2026
Merged

dylanplayer merged 1 commit into
mainfrom
codevisor/ackee

Conversation

@dylanplayer

Copy link
Copy Markdown
Member

Main's Build has been red since #1477 on every merge (#1479, #1480, #1483). Each run had exactly one failure, in ci / checks-swift: "The lightbox shows a file read-only even when the machine would let it be edited" (FileOpenerTests.swift:134, !page.document.isEditable). Nothing else in those Builds failed. The #1482 run was cancelled because #1483 superseded it.

What was wrong

The test still assumed the old design. Before #1477, the overlay opened a separate read-only copy of the document, so document.isEditable was false. Since #1477, the overlay opens the same document tabs use, so the document reports what the machine allows. Whether the overlay can edit is now decided by the pane's mode (editor.isEditable, which is viewing/editing combined with the machine's permission).

I checked #1477 for a real bug and found none. The overlay opens its pages with access: .viewing. The text view (macOS and iOS) and the find bar's Replace both gate on editor.isEditable. The pencil only appears when the machine allows editing.

What changed

The stale test is replaced by two tests that describe #1477's intended behavior:

  • Writable file: the overlay opens read-only. The pencil makes it editable, and the eye makes it read-only again.
  • File the machine won't let you edit: the overlay shows no pencil and the file never becomes editable.

Each fixture now uses its own machine ID, because FileDocumentStore.shared caches documents by machine and path, and parallel tests would otherwise get each other's document.

Verification

  • swift test --filter "FileOpenerTests|FileEditorSessionTests": 18/18 passed, three times in a row.
  • Mutation check: making the overlay open pages as .editing fails both new tests.
  • The CI lane run locally (node scripts/check.mjs --base=e513cc016 --lanes=swift-style,swift): format, lint and all Swift suites passed.
  • Tophat in the macOS dev app:
    • A writable notes.md link opened on the rendered preview with a pencil. Its text could be selected but not edited.
    • The pencil switched to the editable source, and the eye switched back.
    • After chmod 444 on the file, the overlay showed no pencil.

🤖 Generated with Claude Code

…d-only copy

#1477 made the overlay open the same document tabs use, in a viewing mode,
so the document reports the machine's writability and the pane decides
whether it can be edited. The lightbox test still expected the document
itself to be read-only, which failed every Build on main since.

The overlay now has two tests: a writable file opens read-only, the pencil
makes it editable and the eye turns it back; a file the machine won't let
you edit gets no pencil. Each fixture uses its own machine id so the shared
document store doesn't hand one test another's document.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@dylanplayer
dylanplayer merged commit d593f98 into main Nov 26, 2026
@dylanplayer
dylanplayer deleted the codevisor/ackee branch November 26, 2026 02:11
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.

1 participant