Personal Telegram developer console for GitHub

docs: lock Workspace Mini App editor design

davoodmehraban89 committed Oct 4, 2026 at 11:09 UTC 55f4489bd2754014fe10e93891ae7086c64481ab
1 file changed +33
docs/superpowers/specs/2026-10-04-workspace-mini-app-editor.md new
+33
@@ -0,0 +1,33 @@
1 +# Workspace Mini App Editor — Design Lock
2 +
3 +## Goal
4 +Replace the primary Telegram chat/ForceReply whole-file paste flow with a real, owner-only Mini App editor while preserving the existing branch-first Workspace, Diff, immutable Ready intent, Safe Approval, replay protection and provider-write invariants.
5 +
6 +## Confirmed root causes
7 +- `README.md` is not rejected because it is Markdown. The current generic editable-text policy rejects it because the Phase 1 ceiling is 3,000 Unicode code points; the repository README is larger than that ceiling.
8 +- Telegram Bot API reply/inline keyboards do not provide an arbitrary multiline textarea. A Telegram Mini App/Web App is the supported mechanism for a custom HTML5 input UI.
9 +- The persistent bottom keyboard can appear to disappear when the old ForceReply input takes over the composer. Removing ForceReply from the primary Draft edit path avoids that UX conflict.
10 +
11 +## Locked behavior
12 +1. Workspace view exposes `🧑‍💻 Editor` as an `InlineKeyboardButton.web_app` URL scoped only by the opaque 10-character Workspace ID.
13 +2. Source/Draft content is never placed in the Web App URL, Telegram callback data, logs or audit metadata.
14 +3. The editor shell is served by the same Cloudflare Worker at `/workspace/editor`.
15 +4. Editor API is same-origin at `/workspace/api/editor`.
16 +5. Every editor API request must carry `Telegram.WebApp.initData` and backend validation must:
17 + - verify Telegram HMAC-SHA-256 integrity using the bot token and `WebAppData` derivation;
18 + - reject stale `auth_date` values;
19 + - parse the Telegram user and require the configured owner ID.
20 +6. GET loads only the durable Workspace metadata/current Draft needed by the editor.
21 +7. PUT updates only the durable Draft after the same editable-file safety policy and digest calculation. It never calls GitHub and never creates a branch/commit.
22 +8. GitHub mutation remains exclusively `Ready -> Safe Approval -> branch-only commit` in the existing Telegram flow.
23 +9. New bounded editor ceiling: 20,000 Unicode code points and 65,536 UTF-8 bytes. Sensitive paths, binary-like content and Git LFS pointers remain rejected.
24 +10. File upload remains a secondary Draft input and uses the same expanded byte ceiling. Legacy `wtext:*` callbacks may remain compatible for old Telegram messages but are no longer exposed as the primary Workspace action.
25 +
26 +## Acceptance criteria
27 +- Repository `README.md` preview exposes Edit and can create a Workspace.
28 +- Workspace shows a Web App editor button, not the old primary Paste button.
29 +- Mini App displays current Draft in a multiline monospace textarea with character/byte counters.
30 +- Save persists exact Draft bytes/text to `WORKSPACE_STORE`; no GitHub provider write occurs.
31 +- Missing/tampered/stale/non-owner Mini App init data is rejected.
32 +- Existing Diff, Commit Message, Ready, Safe Approval, replay protection and branch-only commit tests remain green.
33 +- Production deploy keeps both Durable Object bindings active and owner-device smoke confirms Editor -> Save Draft -> Diff -> Commit behavior.