Skip to content

Read-only files (ProjectFile.readOnly) - #41

Merged
cedricvogel-leo merged 1 commit into
mainfrom
feature/read-only-files
Oct 29, 2026
Merged

cedricvogel-leo merged 1 commit into
mainfrom
feature/read-only-files

Conversation

@cedricvogel-leo

Copy link
Copy Markdown
Collaborator

Decision 2 from the Etappe 4 check: parser.py is a black box, so it should be read-only in the IDE. This is step 1 of 3: editor → tag → IDE + macro.

Changes

  • ProjectFile.readOnly?: boolean: a file to read, not to change.
    • The editor shows it read-only. domReadOnly keeps an iPad's keyboard closed.
    • Its tab has a lock, with an accessible label.
    • Typing into it shows «Schreibgeschützt: Diese Datei kann gelesen, aber nicht geändert werden.» / «Read-only: this file can be read but not changed.» (new optional string readOnlyFile).
    • It runs, imports, tests and visualizes like any other file.
  • Project helpers: updateProjectFile, renameProjectFile and deleteProjectFile leave a read-only file unchanged. Every host is protected, including the IDE's file drawer, before its own UI change.
  • Fix found while testing (please review): updateCode now ignores Monaco's flush events (setValue).
    • The workspace uses one Monaco model for all files. For a read-only editor, @monaco-editor/react replaces the text with an unguarded setValue, before its onChange knows the new tab.
    • Opening parser.py therefore wrote parser.py's text into auswerter.py: «Tests» then reported 38 instead of 11 examples.
    • A learner's own edits (typing, paste, undo) are never flushes.
    • Noted in CLAUDE.md.

Checked

  • check-embed-protocol.mjs (in test:protocol) checks the helpers against the build:
    • a read-only file stays unchanged after update, rename and delete
    • an ordinary file still changes
    • the flag survives an update of another file
  • Locally in the IDE, with this build and a share link where parser.py has readOnly: true:
    • The lock shows on parser.py only.
    • Typing leaves parser.py unchanged and shows the message.
    • Tab switches leave both files intact (before the fix: auswerter.py was overwritten).
    • Typing, undo and redo in auswerter.py are saved.
    • «Tests» gives 11 von 11. The flag is kept in the IDE's stored project.
  • Lint (known warning only), both builds, test:protocol.

Next

After tag v0.1.19:

  • IDE: bump; the file drawer offers no rename or delete for read-only files; ZIP export/import keeps the flag.
  • Macro: libraries in «IDE-Link kopieren» links become read-only.

🤖 Generated with Claude Code

A file with readOnly: true is one to read, not to change, e.g. a course's
library that learners use as a black box (the evaluator's parser.py). The
editor shows it read-only (domReadOnly, so an iPad's keyboard doesn't
open), its tab has a lock, typing into it shows «Schreibgeschützt: Diese
Datei kann gelesen, aber nicht geändert werden.» (readOnlyFile, de/en), and
updateProjectFile, renameProjectFile and deleteProjectFile leave it as it
is. It runs, imports, tests and visualizes like any other file.

updateCode now ignores Monaco's flush events (setValue): @monaco-editor/
react shows a read-only file with setValue before its onChange knows the
new tab, which wrote parser.py's text into the previously open file. A
learner's own edits (typing, paste, undo) are never flushes.

check-embed-protocol.mjs checks the helpers against the build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cedricvogel-leo
cedricvogel-leo merged commit 5bd8a4f into main Oct 29, 2026
1 check passed
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