Personal Telegram developer console for GitHub
feat/persistent-menu-code-input
audit/commit-drilldown
audit/finalize-workspace-menu-security
audit/ops-actionability
audit/pr-menu-consolidation
audit/status-menu-consolidation
audit/telegram-menu-e2e
audit/telegram-menu-e2e-wave2
chore/actions-node24-runtime
cleanup/remove-diag
design/cloudflare-ops-read
docs/control-plane-2-7-design
docs/guide-v2-1-sync
docs/menu-audit-final-sync
docs/phase2-acceptance-closeout
docs/phase2-multifile-design
feat/bootstrap-worker
feat/cloudflare-ops-read
feat/cp2-multifile-final
feat/cp2-multifile-workspace
feat/cp3-github-write-final
feat/cp4-cloudflare-ops-final
feat/cp5-cicd-control-plane
feat/cp6-incident-manager
feat/cp7-automation-engine
feat/deep-file-browser
feat/final-delivery-16-20
feat/github-advanced-read
feat/in-app-guide-v2
feat/navigation-recovery-ux-v2
feat/ops-console-v2-1
feat/persistent-menu-code-input
feat/phase2-multifile-workspace
feat/phase2-multifile-workspace-v2
feat/plugin-foundation-v1
feat/safe-github-ops
feat/self-register-webhook
feat/studio-g0-foundation
feat/telegram-main-inline-menu
feat/telegram-pr-merge
feat/ux-platform-8-12
feat/v3a-readonly-copilot
feat/workspace-file-upload
feature/mobile-repo-browser
feature/multi-file-change-set
fix/approval-expiry-feedback
fix/callback-resilience-and-docs
fix/ci-actions-pagination
fix/cloudflare-fetch-binding
fix/editor-request-body-cap
fix/editor-safe-file-options
fix/issues-permission-release-empty-ux
fix/main-menu-callback-fallback
fix/phase2-file-editor-selection
fix/phase2-final-ux
fix/phase2-workspace-ref-persistence
fix/production-auto-deploy
fix/provider-write-error-feedback
fix/repository-id-navigation-fallback
fix/repository-pr-navigation
fix/telegram-callback-updates
fix/telegram-runtime-diagnostics
fix/workspace-editor-flow-v2
fix/workspace-recovery-validation
hardening/ci-zero-test-telegram-token
hardening/pr1-destructive-totp
hardening/pr2-kill-switch
main
multifile-workspace
nexa/edit-BwJEIIY3PW
nexa/edit-IPHT8irO7b
nexa/edit-b4Od3BIMYd
p2-multifile
phase2-20261005
phase2-20261005-a
phase2-20261005-b
phase2-20261005-c
phase2-20261005-d
phase2-20261005-e
phase2-20261005-f
phase2-20261005-g
phase2-20261005-h
phase2-20261005-i
phase2-20261005-j
phase2-20261005-k
phase2-20261005-l
phase2-20261005-m
phase2-20261005-n
phase2-20261005-o
phase2-20261005-p
phase2-20261005-q
phase2-20261005-r
phase2-20261005-s
phase2-20261005-t
phase2-20261005-u
phase2-20261005-v
phase2-20261005-w
phase2-20261005-x
phase2-20261005-y
phase2-20261005-z
phase2-acceptance-closeout
phase2-add-file-hotfix
phase2-change-set
phase2-design-20261005
phase2-design-final
phase2-implementation
phase2-multifile-implementation
phase2-multifile-spec
phase2-spec-final
phase2-workspace
phase2/multifile-workspace
plan/nexa-studio-v2-reviewed
security/remove-telegram-setup
spec/repository-workspace-editor
v3a/multifile
work/multifile
| 1 | # Repository Workspace / Code Editor Design |
| 2 | |
| 3 | Date: 2026-10-03 |
| 4 | Status: Proposed for implementation after owner review |
| 5 | Owner intent: let the repository owner browse a repository from Telegram, open a text file, edit it safely, inspect the exact diff, and commit the change back to GitHub. The architecture must support multi-file workspaces later without weakening approval, audit, branch, or conflict-safety rules. |
| 6 | |
| 7 | ## 1. Goals |
| 8 | |
| 9 | The feature must let the owner: |
| 10 | |
| 11 | 1. Select any repository already visible through Nexa. |
| 12 | 2. Browse to a text file and open a bounded preview. |
| 13 | 3. Start an edit workspace without writing anything to GitHub. |
| 14 | 4. Change file content or a bounded line range. |
| 15 | 5. Review a source-backed before/after diff. |
| 16 | 6. Provide a commit message. |
| 17 | 7. Commit only after Safe Approval. |
| 18 | 8. Receive the resulting commit SHA and continue into CI / Actions monitoring. |
| 19 | 9. Later edit multiple files in one workspace and commit them atomically. |
| 20 | |
| 21 | The central product goal is to make Nexa a real mobile developer control plane, not only a repository viewer. |
| 22 | |
| 23 | ## 2. Delivery Strategy |
| 24 | |
| 25 | ### Phase 1 — Safe single-file workspace |
| 26 | |
| 27 | Ship one-file editing first, but build the data model and commit engine so multi-file workspaces do not require a redesign. |
| 28 | |
| 29 | Phase 1 supports: |
| 30 | - owner-only text-file editing; |
| 31 | - branch-first commits; |
| 32 | - bounded file preview and editing payloads; |
| 33 | - exact diff before approval; |
| 34 | - conflict detection against the original base HEAD; |
| 35 | - Safe Approval before the GitHub mutation; |
| 36 | - idempotent commit intent tracking; |
| 37 | - commit SHA feedback and CI handoff. |
| 38 | |
| 39 | Phase 1 does not support: |
| 40 | - binary files; |
| 41 | - Git LFS objects; |
| 42 | - automatic merge/conflict resolution; |
| 43 | - arbitrary shell execution; |
| 44 | - direct commits to `main`; |
| 45 | - editing likely-secret/private-key files; |
| 46 | - multi-user collaboration. |
| 47 | |
| 48 | ### Phase 2 — Multi-file workspace |
| 49 | |
| 50 | Reuse the same workspace and commit engine to stage several changed files and create one atomic tree/commit. |
| 51 | |
| 52 | ### Phase 3 — Rich editor surface |
| 53 | |
| 54 | A Telegram Mini App can later use the same workspace API for larger files, syntax-aware editing, multi-file tabs, search and richer diff presentation. The Telegram chat UI remains the safe control and approval surface. |
| 55 | |
| 56 | ## 3. User Flow |
| 57 | |
| 58 | ### Open and edit |
| 59 | |
| 60 | `/start -> Repositories -> <repo> -> Files -> <file> -> Edit` |
| 61 | |
| 62 | The file view shows: |
| 63 | - path; |
| 64 | - branch/ref; |
| 65 | - blob SHA; |
| 66 | - file size; |
| 67 | - bounded text preview; |
| 68 | - `Edit` only when the file passes editable-file policy. |
| 69 | |
| 70 | Pressing `Edit` creates a local Nexa workspace. This is not a GitHub WRITE. |
| 71 | |
| 72 | ### Draft |
| 73 | |
| 74 | The workspace records: |
| 75 | - owner id; |
| 76 | - repository id/full name; |
| 77 | - base branch; |
| 78 | - base HEAD SHA; |
| 79 | - source path; |
| 80 | - source blob SHA; |
| 81 | - original content digest; |
| 82 | - draft content/digest; |
| 83 | - commit message/digest when supplied; |
| 84 | - target branch when supplied/generated; |
| 85 | - created/updated timestamps; |
| 86 | - expiration time; |
| 87 | - workspace state. |
| 88 | |
| 89 | The owner submits replacement text or a bounded line-range edit. Nexa validates size, UTF-8 encoding, source path, workspace ownership and configured input bounds before accepting it. Commit messages and branch names are normalized and bounded; branch names must satisfy Git ref safety rules. |
| 90 | |
| 91 | ### Review |
| 92 | |
| 93 | Nexa renders a bounded unified diff and summary: |
| 94 | - repository; |
| 95 | - base branch; |
| 96 | - planned target branch; |
| 97 | - file path; |
| 98 | - additions/deletions; |
| 99 | - original blob/base HEAD; |
| 100 | - proposed content digest; |
| 101 | - commit message. |
| 102 | |
| 103 | No provider mutation happens during preview. |
| 104 | |
| 105 | ### Commit |
| 106 | |
| 107 | The default path is: |
| 108 | |
| 109 | `draft -> review diff -> Safe Approval -> Git Data commit flow -> target branch ref -> return SHA -> monitor CI` |
| 110 | |
| 111 | The approval target binds at least: |
| 112 | - repository; |
| 113 | - workspace id / commit-intent id; |
| 114 | - base HEAD SHA; |
| 115 | - target branch; |
| 116 | - changed path(s); |
| 117 | - proposed content/tree digest; |
| 118 | - commit message digest; |
| 119 | - action id; |
| 120 | - owner; |
| 121 | - expiry. |
| 122 | |
| 123 | If anything material changes after approval is issued, Nexa must require a new approval. |
| 124 | |
| 125 | ## 4. Branch Policy |
| 126 | |
| 127 | ### Default: branch-first |
| 128 | |
| 129 | Phase 1 never commits directly to `main`. |
| 130 | |
| 131 | Nexa generates or accepts a safe branch name such as: |
| 132 | |
| 133 | `nexa/edit-<short-workspace-id>` |
| 134 | |
| 135 | The final approved composite action creates Git objects and then the target branch ref. This keeps drafts local and avoids a visible provider branch write before final confirmation. |
| 136 | |
| 137 | ### Direct-main future mode |
| 138 | |
| 139 | Direct commits to the default branch are deferred. If added later they must be explicitly enabled, clearly marked high-risk, respect branch protection/rulesets, and use a stronger confirmation UX. Nexa must never bypass GitHub protection rules. |
| 140 | |
| 141 | ## 5. Commit Engine |
| 142 | |
| 143 | The implementation should use GitHub Git Data primitives rather than designing around one-file Contents API behavior: |
| 144 | |
| 145 | 1. Read and pin the base HEAD commit/tree. |
| 146 | 2. After approval is consumed, re-check staleness/conflicts. |
| 147 | 3. Create blob(s) for staged content. |
| 148 | 4. Create a new tree from the pinned base tree. |
| 149 | 5. Create one commit pointing to that tree. |
| 150 | 6. Create or fast-forward the approved target branch ref. |
| 151 | 7. Persist the provider result into the workspace before returning success to Telegram. |
| 152 | |
| 153 | All GitHub Git Data writes (blob/tree/commit/ref) occur only after Safe Approval has been successfully consumed. Provider object creation is considered part of the approved composite WRITE even if a later ref update fails. |
| 154 | |
| 155 | This is slightly more work for the first single-file version, but it gives the correct atomic file-set foundation for Phase 2 multi-file commits. |
| 156 | |
| 157 | No branch ref may be moved if the repository state no longer matches the conflict checks described below. |
| 158 | |
| 159 | ## 6. Conflict and Staleness Safety |
| 160 | |
| 161 | A workspace is optimistic-concurrency controlled. |
| 162 | |
| 163 | Before final mutation Nexa re-reads the relevant branch state. |
| 164 | |
| 165 | Rules: |
| 166 | - If the base branch HEAD no longer matches the workspace base HEAD, the commit is blocked as stale before GitHub object creation. |
| 167 | - Nexa does not silently rebase, merge or overwrite. |
| 168 | - The owner is shown the conflict/staleness reason and can refresh the workspace from the new base. |
| 169 | - If a target branch already exists unexpectedly or moved since approval, the action fails closed. |
| 170 | - A provider 409/422 or protection error is surfaced to Telegram and audited; success is never fabricated. |
| 171 | |
| 172 | ## 7. Idempotency and Ambiguous Provider Outcomes |
| 173 | |
| 174 | Approval replay protection alone is not enough. A provider call can succeed while the Telegram response fails, and the owner may then try again with a fresh approval. |
| 175 | |
| 176 | Each ready-to-commit workspace therefore gets a stable commit-intent digest derived from repository, base SHA, target branch, path(s), content/tree digest and commit-message digest. |
| 177 | |
| 178 | Workspace state transitions are monotonic, for example: |
| 179 | |
| 180 | `DRAFT -> READY -> COMMITTING -> COMMITTED | FAILED | STALE` |
| 181 | |
| 182 | Rules: |
| 183 | - once `COMMITTED`, the workspace returns the recorded commit SHA and must not create another commit for the same intent; |
| 184 | - the resulting commit SHA/target ref are persisted before Nexa reports success to Telegram; |
| 185 | - if the provider result is ambiguous (timeout/network failure after a possible ref update), Nexa reconciles the target branch/ref against the expected commit intent before permitting a retry; |
| 186 | - a fresh approval cannot bypass an already-committed workspace intent; |
| 187 | - changing draft content, branch or commit message creates a new intent and invalidates any prior pending approval. |
| 188 | |
| 189 | This protects against duplicate commits even when the first successful provider result was not visible to the owner. |
| 190 | |
| 191 | ## 8. Workspace Storage |
| 192 | |
| 193 | Draft content must not be stored in Telegram callback data or process memory. |
| 194 | |
| 195 | Use a dedicated owner-scoped durable workspace store, preferably a separate Durable Object namespace/class such as `WORKSPACE_STORE` / `WorkspaceStore`. |
| 196 | |
| 197 | Properties: |
| 198 | - workspace id is random and non-secret; |
| 199 | - every operation checks owner identity; |
| 200 | - data is scoped by owner + workspace id; |
| 201 | - TTL cleanup removes abandoned drafts; |
| 202 | - committed result metadata is retained long enough to support idempotent retry/reconciliation; |
| 203 | - no GitHub token, Telegram token or signing secret is stored in the workspace; |
| 204 | - audit logs store metadata/digests, not full sensitive file contents; |
| 205 | - draft state is never treated as a provider commit. |
| 206 | |
| 207 | The existing `APPROVAL_REPLAY_GUARD` remains dedicated to one-time approval consumption. |
| 208 | |
| 209 | ## 9. Editable File Policy |
| 210 | |
| 211 | Phase 1 accepts UTF-8 text only. |
| 212 | |
| 213 | Reject or disable edit for: |
| 214 | - binary/non-UTF-8 content; |
| 215 | - files above the configured edit-size ceiling; |
| 216 | - Git LFS pointers when unsafe to edit as normal text; |
| 217 | - probable private-key/credential files such as common `.pem`, `id_rsa`, and committed environment-secret patterns; |
| 218 | - generated files identified by explicit project policy when available. |
| 219 | |
| 220 | Reads may remain available where already allowed, but the editor should fail closed for risky write targets. |
| 221 | |
| 222 | All rendered file content and diff text must be HTML-escaped and bounded for Telegram. Editable input must never be silently truncated. |
| 223 | |
| 224 | ## 10. Telegram UX |
| 225 | |
| 226 | New controls should fit naturally into the existing GitHub plugin: |
| 227 | |
| 228 | File view: |
| 229 | - `✏️ Edit` |
| 230 | - existing navigation/back controls |
| 231 | |
| 232 | Workspace view: |
| 233 | - path + base ref |
| 234 | - draft status |
| 235 | - `📝 تغییر متن` |
| 236 | - `🔍 مشاهده Diff` |
| 237 | - `💬 پیام Commit` |
| 238 | - `✅ آماده Commit` |
| 239 | - `🗑 لغو Draft` |
| 240 | |
| 241 | Ready-to-commit view: |
| 242 | - exact change summary; |
| 243 | - bounded diff; |
| 244 | - target branch; |
| 245 | - commit message; |
| 246 | - `✅ تأیید و Commit` through Safe Approval; |
| 247 | - cancel/back. |
| 248 | |
| 249 | After commit: |
| 250 | - resulting SHA; |
| 251 | - branch; |
| 252 | - `🧪 CI / Actions`; |
| 253 | - optional later `Create PR` action, separately approval-gated. |
| 254 | |
| 255 | For content too large to edit comfortably in chat, Phase 1 explains the limit rather than truncating editable input silently. The richer Mini App editor is the planned expansion path. |
| 256 | |
| 257 | ## 11. Action Model and Risk |
| 258 | |
| 259 | New actions should be explicit in the GitHub plugin manifest. |
| 260 | |
| 261 | READ examples: |
| 262 | - `github.workspace.view` |
| 263 | - `github.workspace.diff` |
| 264 | |
| 265 | Local/draft actions do not call GitHub and remain owner-only. |
| 266 | |
| 267 | Provider WRITE examples: |
| 268 | - `github.workspace.commit_branch` |
| 269 | - later `github.pr.create_from_workspace` |
| 270 | |
| 271 | Every provider WRITE must pass through the existing Action Policy, HMAC approval, durable replay guard and audit lifecycle. |
| 272 | |
| 273 | The GitHub Git Data write sequence must not begin until approval is successfully consumed. |
| 274 | |
| 275 | ## 12. Audit Requirements |
| 276 | |
| 277 | Audit events must let us reconstruct the control-plane decision without leaking source contents. |
| 278 | |
| 279 | Record metadata such as: |
| 280 | - workspace id; |
| 281 | - commit-intent digest; |
| 282 | - repo id; |
| 283 | - base SHA; |
| 284 | - target branch; |
| 285 | - paths changed; |
| 286 | - count of files; |
| 287 | - additions/deletions when available; |
| 288 | - proposed tree/content digest; |
| 289 | - action/policy/approval outcome; |
| 290 | - resulting commit SHA on success; |
| 291 | - reconciliation outcome after ambiguous provider failures; |
| 292 | - provider error category on failure. |
| 293 | |
| 294 | Do not log: |
| 295 | - full file contents; |
| 296 | - tokens/secrets; |
| 297 | - signed approval callback tokens. |
| 298 | |
| 299 | ## 13. Testing Strategy |
| 300 | |
| 301 | Implementation must be TDD and include: |
| 302 | |
| 303 | ### Unit / provider |
| 304 | - editable-file validation; |
| 305 | - workspace owner isolation; |
| 306 | - TTL/stale workspace behavior; |
| 307 | - text/diff bounds and escaping; |
| 308 | - branch/commit-message validation and bounds; |
| 309 | - blob/tree/commit/ref request construction; |
| 310 | - multi-file-capable tree construction even if UI initially stages one file; |
| 311 | - GitHub error propagation. |
| 312 | |
| 313 | ### Policy / security |
| 314 | - no GitHub WRITE before approval; |
| 315 | - approval target binds repo/workspace/base/branch/path/content digest; |
| 316 | - replay rejected; |
| 317 | - expired approval rejected; |
| 318 | - stale base HEAD blocks mutation before object creation; |
| 319 | - unexpected target-branch movement blocks mutation; |
| 320 | - non-owner cannot read or mutate workspace; |
| 321 | - sensitive-file policy fails closed. |
| 322 | |
| 323 | ### Idempotency |
| 324 | - committed workspace returns recorded SHA on retry without another provider write; |
| 325 | - fresh approval cannot duplicate an already-committed intent; |
| 326 | - ambiguous provider timeout reconciles expected target ref before retry; |
| 327 | - content/branch/message change invalidates prior approval and produces a new intent. |
| 328 | |
| 329 | ### Integration |
| 330 | - create draft -> edit -> diff -> approve -> branch commit; |
| 331 | - provider failure visibly updates Telegram; |
| 332 | - successful commit persists exact SHA before Telegram success feedback; |
| 333 | - successful commit returns exact SHA and CI navigation. |
| 334 | |
| 335 | ### Production acceptance |
| 336 | CI alone is insufficient. Acceptance requires an owner-device smoke on a safe test file/branch proving: |
| 337 | 1. draft creation does not change GitHub; |
| 338 | 2. diff matches the proposed edit; |
| 339 | 3. no GitHub write occurs before approval; |
| 340 | 4. confirmation creates exactly one commit on the intended branch; |
| 341 | 5. replay does not create a second commit; |
| 342 | 6. re-opening/retrying a committed workspace returns the same SHA without a duplicate commit; |
| 343 | 7. GitHub and Cloudflare audit/runtime evidence agree on the same operation. |
| 344 | |
| 345 | ## 14. Acceptance Criteria |
| 346 | |
| 347 | Phase 1 is complete only when all are true: |
| 348 | |
| 349 | - owner can open an eligible text file from Telegram; |
| 350 | - owner can create/edit a durable draft; |
| 351 | - exact bounded diff is visible before commit; |
| 352 | - `main` is not directly mutated; |
| 353 | - stale-base conflicts fail closed; |
| 354 | - final GitHub mutation is Safe-Approval gated and one-time; |
| 355 | - a committed workspace is idempotent across Telegram/network retries; |
| 356 | - resulting commit SHA/branch are shown from provider evidence; |
| 357 | - CI handoff is available; |
| 358 | - audit does not expose full draft/source contents or secrets; |
| 359 | - automated tests pass; |
| 360 | - exact production deployment is verified; |
| 361 | - owner-device production smoke passes. |
| 362 | |
| 363 | ## 15. Roadmap Placement |
| 364 | |
| 365 | Updated order: |
| 366 | |
| 367 | 1. GitHub Advanced READ production acceptance — completed. |
| 368 | 2. Repository Workspace / Code Editor — this design. |
| 369 | 3. Remaining useful GitHub Advanced WRITE operations (for example workflow dispatch or specific-job rerun) through Safe Approval. |
| 370 | 4. Cloudflare Ops plugin. |
| 371 | 5. CI/CD Control Plane and release acceptance orchestration. |
| 372 | 6. Monitoring + Incident Manager. |
| 373 | 7. Automation Engine. |
| 374 | 8. AI Copilot with no direct production mutation. |
| 375 | 9. Browser QA. |
| 376 | 10. Telegram Mini App using the same workspace/control-plane APIs. |
| 377 | 11. Plugin ecosystem, multi-project control plane and final hardening. |
| 378 | |
| 379 | ## 16. Key Architecture Decision |
| 380 | |
| 381 | The editor is not a special bypass around GitHub controls. It is a first-class GitHub WRITE workflow built on the same policy, approval, replay-protection and audit boundary already proven in production. |
| 382 | |
| 383 | The initial UI is deliberately small, but the underlying durable workspace + idempotent Git Data commit model is designed for later multi-file atomic commits and a richer editor without changing the security contract. |