2026-03-12 14:31:20 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html lang="en">
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="utf-8">
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
|
<title>Notes</title>
|
|
|
|
|
<style>
|
|
|
|
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
|
|
|
body {
|
|
|
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
|
|
|
background: #0f0f0f;
|
|
|
|
|
color: #e8e8e8;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
height: 100vh;
|
|
|
|
|
padding: 24px;
|
|
|
|
|
gap: 16px;
|
|
|
|
|
}
|
|
|
|
|
header {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
}
|
|
|
|
|
h1 {
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
letter-spacing: 0.12em;
|
|
|
|
|
text-transform: uppercase;
|
|
|
|
|
color: #666;
|
|
|
|
|
}
|
|
|
|
|
.actions {
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: 8px;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
button {
|
|
|
|
|
height: 32px;
|
|
|
|
|
padding: 0 16px;
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
border: 1px solid #2a2a2a;
|
|
|
|
|
background: #1a1a1a;
|
|
|
|
|
color: #e8e8e8;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
transition: background 0.1s;
|
|
|
|
|
}
|
|
|
|
|
button:hover { background: #222; }
|
|
|
|
|
button:active { background: #2a2a2a; }
|
|
|
|
|
button.primary {
|
|
|
|
|
background: #2a2a2a;
|
|
|
|
|
border-color: #444;
|
|
|
|
|
}
|
|
|
|
|
button.primary:hover { background: #333; }
|
|
|
|
|
textarea {
|
|
|
|
|
flex: 1;
|
|
|
|
|
background: #1a1a1a;
|
|
|
|
|
border: 1px solid #2a2a2a;
|
|
|
|
|
border-radius: 12px;
|
|
|
|
|
color: #e8e8e8;
|
|
|
|
|
font-family: inherit;
|
|
|
|
|
font-size: 15px;
|
|
|
|
|
line-height: 1.6;
|
|
|
|
|
padding: 20px;
|
|
|
|
|
resize: none;
|
|
|
|
|
outline: none;
|
|
|
|
|
transition: border-color 0.15s;
|
|
|
|
|
}
|
|
|
|
|
textarea:focus { border-color: #444; }
|
|
|
|
|
textarea::placeholder { color: #444; }
|
|
|
|
|
footer {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
height: 20px;
|
|
|
|
|
}
|
|
|
|
|
#status {
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
color: #444;
|
|
|
|
|
}
|
|
|
|
|
#charcount {
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
color: #444;
|
|
|
|
|
font-variant-numeric: tabular-nums;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<header>
|
|
|
|
|
<h1>Notes</h1>
|
|
|
|
|
<div class="actions">
|
|
|
|
|
<button id="discard">Discard</button>
|
|
|
|
|
<button class="primary" id="save">Save</button>
|
|
|
|
|
</div>
|
|
|
|
|
</header>
|
|
|
|
|
<textarea id="editor" placeholder="Start typing…" spellcheck="false"></textarea>
|
|
|
|
|
<footer>
|
|
|
|
|
<span id="status">connecting…</span>
|
|
|
|
|
<span id="charcount">0 chars</span>
|
|
|
|
|
</footer>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
(function () {
|
fix(notes): store notes exactly and never overwrite newer text
The Notes demo exchanged hand-escaped strings: the page turned every
literal backslash-n into a line break on load and save, the component
escaped only some control characters, so other text produced invalid
replies, and every reply replaced the editor contents, discarding text
typed while a save was in flight. Saves wrote the file in place and
replaced whatever another Notes window had stored.
Requests and replies are now JSON objects. The component reports a
revision (a hash of the stored bytes) with each load; a save names the
revision it was edited from and is refused when the stored notes have
changed since, so a second window's text is never replaced silently. The
file is written beside notes.txt and renamed over it. A save
acknowledgement updates only the saved state, never the editor, and
Discard reloads the stored notes.
tests/frame/check_notes.py edits Notes with real keyboard input on the
nested desktop: text with a literal backslash sequence, quotes, a tab and
non-ASCII characters is stored byte for byte, text typed during a save
survives, and a save after another window changed the file is refused.
It fails against the previous package, which turned the seeded "\n"
into a line break. app.wasm is rebuilt and the package re-signed with the
demo key.
2026-10-09 08:47:01 +00:00
|
|
|
// The component stores the text exactly as typed. Messages are JSON; each
|
|
|
|
|
// save names the revision it was edited from and is acknowledged by its
|
|
|
|
|
// sequence number, so a reply never replaces text typed after it was sent.
|
2026-03-12 14:31:20 +00:00
|
|
|
var editor = document.getElementById('editor');
|
|
|
|
|
var statusEl = document.getElementById('status');
|
|
|
|
|
var charEl = document.getElementById('charcount');
|
fix(notes): store notes exactly and never overwrite newer text
The Notes demo exchanged hand-escaped strings: the page turned every
literal backslash-n into a line break on load and save, the component
escaped only some control characters, so other text produced invalid
replies, and every reply replaced the editor contents, discarding text
typed while a save was in flight. Saves wrote the file in place and
replaced whatever another Notes window had stored.
Requests and replies are now JSON objects. The component reports a
revision (a hash of the stored bytes) with each load; a save names the
revision it was edited from and is refused when the stored notes have
changed since, so a second window's text is never replaced silently. The
file is written beside notes.txt and renamed over it. A save
acknowledgement updates only the saved state, never the editor, and
Discard reloads the stored notes.
tests/frame/check_notes.py edits Notes with real keyboard input on the
nested desktop: text with a literal backslash sequence, quotes, a tab and
non-ASCII characters is stored byte for byte, text typed during a save
survives, and a save after another window changed the file is refused.
It fails against the previous package, which turned the seeded "\n"
into a line break. app.wasm is rebuilt and the package re-signed with the
demo key.
2026-10-09 08:47:01 +00:00
|
|
|
var saveButton = document.getElementById('save');
|
2026-03-12 14:31:20 +00:00
|
|
|
var saved = '';
|
fix(notes): store notes exactly and never overwrite newer text
The Notes demo exchanged hand-escaped strings: the page turned every
literal backslash-n into a line break on load and save, the component
escaped only some control characters, so other text produced invalid
replies, and every reply replaced the editor contents, discarding text
typed while a save was in flight. Saves wrote the file in place and
replaced whatever another Notes window had stored.
Requests and replies are now JSON objects. The component reports a
revision (a hash of the stored bytes) with each load; a save names the
revision it was edited from and is refused when the stored notes have
changed since, so a second window's text is never replaced silently. The
file is written beside notes.txt and renamed over it. A save
acknowledgement updates only the saved state, never the editor, and
Discard reloads the stored notes.
tests/frame/check_notes.py edits Notes with real keyboard input on the
nested desktop: text with a literal backslash sequence, quotes, a tab and
non-ASCII characters is stored byte for byte, text typed during a save
survives, and a save after another window changed the file is refused.
It fails against the previous package, which turned the seeded "\n"
into a line break. app.wasm is rebuilt and the package re-signed with the
demo key.
2026-10-09 08:47:01 +00:00
|
|
|
var rev = null;
|
|
|
|
|
var seq = 0;
|
|
|
|
|
var pending = null;
|
2026-03-12 14:31:20 +00:00
|
|
|
|
|
|
|
|
function setStatus(msg) { statusEl.textContent = msg; }
|
fix(notes): store notes exactly and never overwrite newer text
The Notes demo exchanged hand-escaped strings: the page turned every
literal backslash-n into a line break on load and save, the component
escaped only some control characters, so other text produced invalid
replies, and every reply replaced the editor contents, discarding text
typed while a save was in flight. Saves wrote the file in place and
replaced whatever another Notes window had stored.
Requests and replies are now JSON objects. The component reports a
revision (a hash of the stored bytes) with each load; a save names the
revision it was edited from and is refused when the stored notes have
changed since, so a second window's text is never replaced silently. The
file is written beside notes.txt and renamed over it. A save
acknowledgement updates only the saved state, never the editor, and
Discard reloads the stored notes.
tests/frame/check_notes.py edits Notes with real keyboard input on the
nested desktop: text with a literal backslash sequence, quotes, a tab and
non-ASCII characters is stored byte for byte, text typed during a save
survives, and a save after another window changed the file is refused.
It fails against the previous package, which turned the seeded "\n"
into a line break. app.wasm is rebuilt and the package re-signed with the
demo key.
2026-10-09 08:47:01 +00:00
|
|
|
function countChars() { charEl.textContent = editor.value.length + ' chars'; }
|
|
|
|
|
function send(message) { window.weftIpc.send(JSON.stringify(message)); }
|
2026-03-12 14:31:20 +00:00
|
|
|
|
fix(notes): store notes exactly and never overwrite newer text
The Notes demo exchanged hand-escaped strings: the page turned every
literal backslash-n into a line break on load and save, the component
escaped only some control characters, so other text produced invalid
replies, and every reply replaced the editor contents, discarding text
typed while a save was in flight. Saves wrote the file in place and
replaced whatever another Notes window had stored.
Requests and replies are now JSON objects. The component reports a
revision (a hash of the stored bytes) with each load; a save names the
revision it was edited from and is refused when the stored notes have
changed since, so a second window's text is never replaced silently. The
file is written beside notes.txt and renamed over it. A save
acknowledgement updates only the saved state, never the editor, and
Discard reloads the stored notes.
tests/frame/check_notes.py edits Notes with real keyboard input on the
nested desktop: text with a literal backslash sequence, quotes, a tab and
non-ASCII characters is stored byte for byte, text typed during a save
survives, and a save after another window changed the file is refused.
It fails against the previous package, which turned the seeded "\n"
into a line break. app.wasm is rebuilt and the package re-signed with the
demo key.
2026-10-09 08:47:01 +00:00
|
|
|
editor.addEventListener('input', countChars);
|
2026-03-12 14:31:20 +00:00
|
|
|
|
fix(notes): store notes exactly and never overwrite newer text
The Notes demo exchanged hand-escaped strings: the page turned every
literal backslash-n into a line break on load and save, the component
escaped only some control characters, so other text produced invalid
replies, and every reply replaced the editor contents, discarding text
typed while a save was in flight. Saves wrote the file in place and
replaced whatever another Notes window had stored.
Requests and replies are now JSON objects. The component reports a
revision (a hash of the stored bytes) with each load; a save names the
revision it was edited from and is refused when the stored notes have
changed since, so a second window's text is never replaced silently. The
file is written beside notes.txt and renamed over it. A save
acknowledgement updates only the saved state, never the editor, and
Discard reloads the stored notes.
tests/frame/check_notes.py edits Notes with real keyboard input on the
nested desktop: text with a literal backslash sequence, quotes, a tab and
non-ASCII characters is stored byte for byte, text typed during a save
survives, and a save after another window changed the file is refused.
It fails against the previous package, which turned the seeded "\n"
into a line break. app.wasm is rebuilt and the package re-signed with the
demo key.
2026-10-09 08:47:01 +00:00
|
|
|
saveButton.addEventListener('click', function () {
|
|
|
|
|
if (!window.weftIpc || rev === null || pending) return;
|
|
|
|
|
seq += 1;
|
|
|
|
|
pending = { seq: seq, text: editor.value };
|
|
|
|
|
send({ op: 'save', seq: seq, base: rev, text: pending.text });
|
|
|
|
|
saveButton.disabled = true;
|
2026-03-12 14:31:20 +00:00
|
|
|
setStatus('saving…');
|
|
|
|
|
});
|
|
|
|
|
|
fix(notes): store notes exactly and never overwrite newer text
The Notes demo exchanged hand-escaped strings: the page turned every
literal backslash-n into a line break on load and save, the component
escaped only some control characters, so other text produced invalid
replies, and every reply replaced the editor contents, discarding text
typed while a save was in flight. Saves wrote the file in place and
replaced whatever another Notes window had stored.
Requests and replies are now JSON objects. The component reports a
revision (a hash of the stored bytes) with each load; a save names the
revision it was edited from and is refused when the stored notes have
changed since, so a second window's text is never replaced silently. The
file is written beside notes.txt and renamed over it. A save
acknowledgement updates only the saved state, never the editor, and
Discard reloads the stored notes.
tests/frame/check_notes.py edits Notes with real keyboard input on the
nested desktop: text with a literal backslash sequence, quotes, a tab and
non-ASCII characters is stored byte for byte, text typed during a save
survives, and a save after another window changed the file is refused.
It fails against the previous package, which turned the seeded "\n"
into a line break. app.wasm is rebuilt and the package re-signed with the
demo key.
2026-10-09 08:47:01 +00:00
|
|
|
// Discard reloads the stored notes, replacing unsaved edits.
|
2026-03-12 14:31:20 +00:00
|
|
|
document.getElementById('discard').addEventListener('click', function () {
|
fix(notes): store notes exactly and never overwrite newer text
The Notes demo exchanged hand-escaped strings: the page turned every
literal backslash-n into a line break on load and save, the component
escaped only some control characters, so other text produced invalid
replies, and every reply replaced the editor contents, discarding text
typed while a save was in flight. Saves wrote the file in place and
replaced whatever another Notes window had stored.
Requests and replies are now JSON objects. The component reports a
revision (a hash of the stored bytes) with each load; a save names the
revision it was edited from and is refused when the stored notes have
changed since, so a second window's text is never replaced silently. The
file is written beside notes.txt and renamed over it. A save
acknowledgement updates only the saved state, never the editor, and
Discard reloads the stored notes.
tests/frame/check_notes.py edits Notes with real keyboard input on the
nested desktop: text with a literal backslash sequence, quotes, a tab and
non-ASCII characters is stored byte for byte, text typed during a save
survives, and a save after another window changed the file is refused.
It fails against the previous package, which turned the seeded "\n"
into a line break. app.wasm is rebuilt and the package re-signed with the
demo key.
2026-10-09 08:47:01 +00:00
|
|
|
if (!window.weftIpc || pending) return;
|
2026-03-12 14:31:20 +00:00
|
|
|
editor.value = saved;
|
fix(notes): store notes exactly and never overwrite newer text
The Notes demo exchanged hand-escaped strings: the page turned every
literal backslash-n into a line break on load and save, the component
escaped only some control characters, so other text produced invalid
replies, and every reply replaced the editor contents, discarding text
typed while a save was in flight. Saves wrote the file in place and
replaced whatever another Notes window had stored.
Requests and replies are now JSON objects. The component reports a
revision (a hash of the stored bytes) with each load; a save names the
revision it was edited from and is refused when the stored notes have
changed since, so a second window's text is never replaced silently. The
file is written beside notes.txt and renamed over it. A save
acknowledgement updates only the saved state, never the editor, and
Discard reloads the stored notes.
tests/frame/check_notes.py edits Notes with real keyboard input on the
nested desktop: text with a literal backslash sequence, quotes, a tab and
non-ASCII characters is stored byte for byte, text typed during a save
survives, and a save after another window changed the file is refused.
It fails against the previous package, which turned the seeded "\n"
into a line break. app.wasm is rebuilt and the package re-signed with the
demo key.
2026-10-09 08:47:01 +00:00
|
|
|
countChars();
|
|
|
|
|
rev = null;
|
|
|
|
|
send({ op: 'load' });
|
|
|
|
|
setStatus('reloading…');
|
2026-03-12 14:31:20 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
document.addEventListener('keydown', function (e) {
|
|
|
|
|
if ((e.ctrlKey || e.metaKey) && e.key === 's') {
|
|
|
|
|
e.preventDefault();
|
fix(notes): store notes exactly and never overwrite newer text
The Notes demo exchanged hand-escaped strings: the page turned every
literal backslash-n into a line break on load and save, the component
escaped only some control characters, so other text produced invalid
replies, and every reply replaced the editor contents, discarding text
typed while a save was in flight. Saves wrote the file in place and
replaced whatever another Notes window had stored.
Requests and replies are now JSON objects. The component reports a
revision (a hash of the stored bytes) with each load; a save names the
revision it was edited from and is refused when the stored notes have
changed since, so a second window's text is never replaced silently. The
file is written beside notes.txt and renamed over it. A save
acknowledgement updates only the saved state, never the editor, and
Discard reloads the stored notes.
tests/frame/check_notes.py edits Notes with real keyboard input on the
nested desktop: text with a literal backslash sequence, quotes, a tab and
non-ASCII characters is stored byte for byte, text typed during a save
survives, and a save after another window changed the file is refused.
It fails against the previous package, which turned the seeded "\n"
into a line break. app.wasm is rebuilt and the package re-signed with the
demo key.
2026-10-09 08:47:01 +00:00
|
|
|
saveButton.click();
|
2026-03-12 14:31:20 +00:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
fix(notes): store notes exactly and never overwrite newer text
The Notes demo exchanged hand-escaped strings: the page turned every
literal backslash-n into a line break on load and save, the component
escaped only some control characters, so other text produced invalid
replies, and every reply replaced the editor contents, discarding text
typed while a save was in flight. Saves wrote the file in place and
replaced whatever another Notes window had stored.
Requests and replies are now JSON objects. The component reports a
revision (a hash of the stored bytes) with each load; a save names the
revision it was edited from and is refused when the stored notes have
changed since, so a second window's text is never replaced silently. The
file is written beside notes.txt and renamed over it. A save
acknowledgement updates only the saved state, never the editor, and
Discard reloads the stored notes.
tests/frame/check_notes.py edits Notes with real keyboard input on the
nested desktop: text with a literal backslash sequence, quotes, a tab and
non-ASCII characters is stored byte for byte, text typed during a save
survives, and a save after another window changed the file is refused.
It fails against the previous package, which turned the seeded "\n"
into a line break. app.wasm is rebuilt and the package re-signed with the
demo key.
2026-10-09 08:47:01 +00:00
|
|
|
function onMessage(raw) {
|
|
|
|
|
var msg;
|
|
|
|
|
try { msg = JSON.parse(raw); } catch (_) { return; }
|
|
|
|
|
if (msg.op === 'loaded') {
|
|
|
|
|
// Edits made while the load was in flight are kept.
|
|
|
|
|
if (editor.value === saved) {
|
|
|
|
|
editor.value = msg.text;
|
|
|
|
|
countChars();
|
|
|
|
|
}
|
|
|
|
|
saved = msg.text;
|
|
|
|
|
rev = msg.rev;
|
|
|
|
|
setStatus('');
|
|
|
|
|
} else if (msg.op === 'saved' && pending && msg.seq === pending.seq) {
|
|
|
|
|
saved = pending.text;
|
|
|
|
|
rev = msg.rev;
|
|
|
|
|
pending = null;
|
|
|
|
|
saveButton.disabled = false;
|
|
|
|
|
setStatus('saved');
|
|
|
|
|
setTimeout(function () { if (!pending) setStatus(''); }, 1500);
|
|
|
|
|
} else if (msg.op === 'error') {
|
|
|
|
|
if (pending && msg.seq === pending.seq) {
|
|
|
|
|
pending = null;
|
|
|
|
|
saveButton.disabled = false;
|
|
|
|
|
}
|
|
|
|
|
setStatus(msg.conflict
|
|
|
|
|
? 'not saved: changed in another window. Copy your text, then Discard to reload.'
|
|
|
|
|
: 'error: ' + msg.message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-12 14:31:20 +00:00
|
|
|
function setupIpc() {
|
|
|
|
|
if (!window.weftIpc) { setTimeout(setupIpc, 50); return; }
|
fix(notes): store notes exactly and never overwrite newer text
The Notes demo exchanged hand-escaped strings: the page turned every
literal backslash-n into a line break on load and save, the component
escaped only some control characters, so other text produced invalid
replies, and every reply replaced the editor contents, discarding text
typed while a save was in flight. Saves wrote the file in place and
replaced whatever another Notes window had stored.
Requests and replies are now JSON objects. The component reports a
revision (a hash of the stored bytes) with each load; a save names the
revision it was edited from and is refused when the stored notes have
changed since, so a second window's text is never replaced silently. The
file is written beside notes.txt and renamed over it. A save
acknowledgement updates only the saved state, never the editor, and
Discard reloads the stored notes.
tests/frame/check_notes.py edits Notes with real keyboard input on the
nested desktop: text with a literal backslash sequence, quotes, a tab and
non-ASCII characters is stored byte for byte, text typed during a save
survives, and a save after another window changed the file is refused.
It fails against the previous package, which turned the seeded "\n"
into a line break. app.wasm is rebuilt and the package re-signed with the
demo key.
2026-10-09 08:47:01 +00:00
|
|
|
window.weftIpc.onmessage = onMessage;
|
|
|
|
|
send({ op: 'load' });
|
2026-03-12 14:31:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setupIpc();
|
|
|
|
|
})();
|
|
|
|
|
</script>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|