NewLogic now takes (FileSystem, path, openfunc); update the e2e harness
and editor tests accordingly. The harness uses a no-op openfunc, matching
impl_other.go (the real app's OpenFile is a platform bridge, no-op off
Android).
Also adds doc/development_plan.md (draft, with corrections note re: the
live repo state).
`editorState.Replace`; `widget.Editor` pushes `key.SnippetCmd` every frame.
Our current custom UI never receives IME input at all.
2.**The IME snippet is selection-scoped** (`updateSnippet` reads only the
selected range; empty selection → empty snippet at caret). Consequence:
windowing the editor's backing text does *not* break IME behavior.
3.**`widget.Editor` is not virtualized.** `textView.layoutText` shapes the
*entire* document on every invalidation (each keystroke, IME commit, wrap
toggle, width change — *not* on scroll; scroll only moves a clip) and builds
an in-memory `glyphIndex` of **~200 bytes per rune** (`combinedPos` +
`text.Glyph` per rune).
4. **Measured on this desktop (shaper.Layout + full glyph iteration, = the
per-keystroke cost of `widget.Editor`):**
| text size | time/keystroke | peak RAM |
|---|---|---|
| 1 MB | 17 ms | ~0.32 GB |
| 2 MB | ~35 ms (extrapolated) | ~0.9 GB |
| 3 MB | — | ~1.7 GB (measured, incl. GC churn) |
| 4 MB | — | OOM-killed the benchmark host |
Planning figure: **~0.5 GB of RAM per 1 MB of text** (editor index +
shaper store + buffer + undo copies, with reallocation churn). Android app
memory ceilings (lmkd) are typically ~1.5–2 GB on 8 GB phones.
Therefore: comfortable editing up to **~2 MB**, a hard guard at **5 MB**
(≈ 2.5 GB — survivable on most phones, heavy), 10 MB ≈ 5 GB (OOM), 50 MB is
not deliverable with stock `widget.Editor`. 10 MB editing requires windowed
shaping (fork-level work on Gio). See §6.
## 3. What gets deleted
| Item | Where | Why |
|---|---|---|
| Whole custom toolkit | `internal/ui/` (element.go, render.go, layout.go, unit.go, icons/) ~1,500 L | replaced by Gio widgets |
| Worker pool + mock FS service | `internal/io/pool/worker_pool.go`, `mock/` (429 L) | replaced by plain background goroutines |
| 10 of 11 task types | `internal/io/pool/task.go` | only Read/Write are ever used, as plain functions |
| On-disk JSON index cache | `internal/browser/index.go``.pad/indices/` machinery | cache-in-indexed-dir is the fragile design behind the failing mtime test; a sync directory needs no cache (re-scan is ms) |
| Dead browser state | `state.go`: `VisibleCount` (never set → list rendered 0 rows), `RowFilenames`, `Pages`, `Page`, `SortIndex`, `SortMode` (duplicate of browser's), `PaginationState`, `PageSize` | replaced by `widget.List` + real filenames |
| Untyped handlers | `browser/handlers.go`, `editor/logic.go``func(any)` closures + globals | replaced by direct calls on the main goroutine |
| e2e harness | `internal/test/e2e/` | written against the dead architecture; replaced by widget-level tests after Phase 1 |
| Stale docs | `element_model.md`, `layout_rendering.md`, `touch.md`, `conflict_resolution.md`, `browser_implementation_plan.md` | describe deleted systems; `architecture.md` rewritten last |
**Kept (ported, not rewritten):**`browser/types.go` (Entry), `sort.go` + tests,
`search.go` + tests, directory scan from `index.go` (minus cache), the wrap /
autosave / per-file-offset concepts from `editor/state.go`.
## 4. Target architecture (single diagram, no channels except I/O)
```
main goroutine (Gio frame loop, owns ALL state)
app.State {
page: browser | editor
dir: string // current browser directory
entries: []browser.Entry // sorted+filtered, rebuilt on demand
4. IME verification on device: swipe typing, autocorrect, multi-line commits,
caret jump after commit.
**Done when:** edit + close + reopen restores file and caret; kill app,
reopen, same; external modification handled per §4; `-race` clean.
### Phase 3 — the 50 MB decision (see §6)
Either (A) document the limit and ship, or (C) build and integrate the
windowed editor. (B, full chunked streaming, is out of scope — it implies a
custom editor and forfeits the IME advantage.)
### Phase 4 — hardening
1. Rewrite `doc/architecture.md` to match reality; amend `spec.md` per §7.
2.`README.md`: what it is, how to build/install (Go 1.24, gioui.org, NDK).
3. Device test checklist in-repo.
## 6. The 50 MB decision (explicit fork)
| Option | What | IME | Effort | Outcome |
|---|---|---|---|---|
| **A. Accept a documented limit** (2 MB soft warn, 5 MB hard guard — §2.4) | nothing more than Phase 2 | full | done | the large majority of real text files in a sync dir; honest limit in UI |
| **C. Windowed editor** | isolated project: shape only viewport ± window; `glyphIndex` covers the window; offset map rune→window; scroll triggers re-window; undo history kept as per-operation edits, not full copies | full (snippet is selection-scoped, verified) | large — touches Gio internals (`textView`, `Editor`), upstreamable but expect divergence | 10 MB+ editing at 60 fps, *if* the PoC holds |
| B. Chunked streaming editor (spec's original) | build our own editor on raw ops | **lost** (no InputConnection) | largest | rejected: forfeits the core reason for moving to native |
**Recommendation: A now, C later as its own branch.** Reasoning: A delivers a
usable app; the Phase 0–2 work is identical under either choice, so nothing is
locked in. C is only worth starting if, after real usage, the 5 MB guard bites
(i.e. we genuinely need to *edit* larger files). If C is started, gate it
behind a PoC first: windowed shaping of a 10 MB file must sustain 60 fps
scroll + sub-100 ms keystroke on the target phone before any integration work.
## 7. Spec deltas (to write into spec.md after Phase 2)
1. "No practical limits / file never fully in memory" → "files up to N MB
(measured); larger files openable in browser, not editable."
2. Undo across sessions → dropped (in-session undo/redo is provided by the
editor widget).
3. Add: IME/swipe/autocorrect support (was an implicit requirement, now
explicit and delivered).
4. Add: external-change detection behavior (§4) as the conflict policy,
replacing `conflict_resolution.md`.
## 8. Non-goals (v1)
- File-system watcher / live browser refresh (re-scan on return to browser).
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.