Skip to content

InkProof MVP — handwritten math notebook with CHECK MY WORK - #2

Open
Om280 wants to merge 29 commits into
mainfrom
arena/01a106de-inkproof
Open

Om280 wants to merge 29 commits into
mainfrom
arena/01a106de-inkproof

Conversation

@Om280

@Om280 Om280 commented Oct 4, 2026

Copy link
Copy Markdown
Owner

InkProof — Prove your work.

Complete MVP of the InkProof Android tablet app plus its backend.

What's inside

  • Low-latency ink engine (InkCanvasView): active stroke rendered immediately from MotionEvents (unbuffered dispatch + batched historical samples), committed strokes in a Picture display list rebuilt only on change, pressure-tapered vector ink, page-space geometry (sharp at any zoom).
  • Stylus-first input for OnePlus Pad + Stylo 2: tool-type routing, palm rejection, stylus-button eraser, hover cursor; fingers pan / pinch-zoom.
  • Hold-to-shape: geometric detection of line/circle/ellipse/rectangle/square/triangle/polygon with configurable ~400 ms hold.
  • Question as a first-class object: typed/handwritten/pasted content, dedicated solution region, version counters; multiple questions per page fully isolated.
  • CHECK MY WORK pipeline: question + ONLY that question's solution strokes → replaceable HandwritingRecognizer → structured JSON → backend/mock provider → strict validated CheckResponse → compact side panel (first mistake, dependent steps, progressive hints, optional solution). UNCLEAR instead of guessing — always.
  • Room persistence (folders/notebooks/pages/questions/strokes/check cache), undo/redo, lasso (check/solve/copy/move/delete/recolor), templates, PDF import/annotate/export, polished Compose library/editor/settings.
  • Zero-dependency Node backend: mock mode, AI (Anthropic/OpenAI) + Wolfram hooks, rate limiting, response sanitization, dedup cache. Secrets live only here — never in the app.

Test results (CI green ✅)

  • Android: 52/52 unit + Robolectric tests (shape detection, stroke codec, undo/redo, line segmentation, strict JSON parsing incl. malformed AI output, mock scenarios, notebook/page persistence, page & question isolation, cache invalidation).
  • Backend: 11/11 node:test tests.
  • Debug APK built and uploaded as the inkproof-debug-apk workflow artifact.

Notes

  • Physical validation on OnePlus Pad + Stylo 2 still required (documented in README).
  • .env.example provided; no secrets committed.

InkProof Agent and others added 29 commits October 4, 2026 12:52
- Low-latency InkCanvasView: active stroke rendered immediately from
  MotionEvents (unbuffered dispatch, historical samples), committed
  strokes in a Picture display list, pressure-tapered vector ink
- Stylus-first input: tool-type routing, palm rejection, stylus-button
  eraser, hover cursor; fingers pan/pinch-zoom
- Vector stroke model with Room persistence (folders/notebooks/pages/
  questions/strokes/check cache), full page & question isolation
- Hold-to-shape: geometric detector (line/circle/ellipse/rect/square/
  triangle/polygon), configurable hold delay
- Question as first-class object: typed/handwritten/pasted content,
  dedicated solution region, version counters, per-question checks
- CheckWorkEngine pipeline: strokes -> HandwritingRecognizer ->
  structured CheckRequest -> provider -> strict validated CheckResponse,
  cached by content+solution version; UNCLEAR instead of guessing
- Compose UI: library with real thumbnails, editor with toolbar/page
  rail/check side panel/lasso actions, polished settings
- Zero-dependency Node backend (mock mode, AI + Wolfram hooks, rate
  limiting, schema sanitization) with 11 passing node:test tests
- Android unit + Robolectric isolation tests, CI workflow, README,
  .env.example

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Rectangles/squares/triangles drawn starting at a corner lost that vertex
because corner detection only scanned interior indices; the seam angle is
now tested explicitly (fixes 3 failing geometry tests).

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
… settings

- ShapeDetector: hold-to-shape now recognizes arrows (straight shaft +
  V-head) and emits a clean 5-point arrow polyline; tested.
- Text tool: tap to place typed text boxes on the page, tap again to
  edit/delete; persisted per page and purged with page/notebook.
- Library folders: chip row (All / folders / + New), long-press to
  rename/delete (notebooks survive folder deletion), 'Move to folder…'
  in the notebook menu.
- Import image: gallery picker -> image becomes an annotatable page.
- Settings now live: continue-from-last-page (per-notebook last page
  remembered), full-screen canvas (system bars hidden + new toggle),
  auto-show first hint on INCORRECT/INCOMPLETE, recognition confidence
  threshold wired into CheckWorkEngine (below it -> UNCLEAR, provider
  never called, never cached).
- EditorViewModel refreshes re-read strokes from DB so freshly drawn
  ink is never wiped by question/text updates.
- New tests: engine confidence thresholds, folder move/rename/delete,
  text object persistence + cascade; arrow detection.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…tart

The corner finder reports the shaft->head turn a few samples inside the
curve, which dragged the snapped arrow tip short of the drawn tip. The
tip is now refined to the farthest point from the stroke start within
the head region (barbs double back, so they are always closer).

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…download

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…builds

- Settings -> AI -> Backend URL is now an editable dialog (with reset to
  the built-in default); the provider is re-created on the next check,
  no app restart or rebuild needed.
- Debug-only manifest overlay allows http:// backends so a local dev
  server on the same Wi-Fi works out of the box. Release still
  requires HTTPS.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Eraser: hit-testing only stroke POINTS meant snapped shapes (a line is
2 points) couldn't be erased mid-segment. StrokeHitTester now measures
distance to every rendered segment; small/medium/large sizes added.

Shapes: the SHAPE tool now draws the picked shape (line/arrow/rect/
square/circle/ellipse/triangle) with a live drag preview; results are
real vector strokes — movable, resizable (new corner handle), width-
adjustable, recolorable, erasable, lasso-able, undoable.

Clipboard: Cut + Duplicate; paste cloning extracted to ClipboardOps
(new IDs, offset, zero shared references) with tests.

Pages: long-press a thumbnail to reorder (persisted); bottom page pill
with prev / 'i of N' / next. Hold-to-shape stays PEN-only.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…icker

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…TML/CSV)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…model discovery

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
… isolation test

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…n in stripHtml test

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…ation (off/low/med/high)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…nd DB migration

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
… handoff

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…tion test in settings

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…st matrix

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
- raise min snap size 24->90 page units (letter-sized glyphs like o/0/x
  and parentheses can never be mistaken for shapes)
- remove the generic POLYGON fallback: only line/arrow/rect/square/
  circle/ellipse/triangle snap; 5+ corner scribbles stay ink
- tighten line deviation (5.5%), ellipse fit (0.19) and closure gates
- add a global 0.72 confidence gate: uncertain geometry does nothing
- regression tests: letter-o loop, parenthesis, sqrt stroke, sine curve,
  lumpy quad and 5-corner scribble all stay handwriting

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
- Notewise-style second row under the toolbar: pen/highlighter show
  color swatches + width dots, eraser shows S/M/L chips, shapes shows
  the 7 shape chips; scrolls horizontally when width-constrained
- no DropdownMenu ever covers the notebook for tool options anymore
- color indicator opens the custom HSV picker directly
- palette gains LIGHT_GREY and CYAN (now 15 pen colors)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
- ensure the ML Kit model is downloaded INSIDE recognize(): previously
  a missing model made clean handwriting come back 'unclear'
- pass RecognitionContext per line: WritingArea from the line's actual
  ink bounds + previous line as preContext (documented accuracy levers)
- new MathNormalizer post-processing (normalize-only, never guesses):
  x2->x^2 (word-safe: sin2x/log2 untouched), unicode superscripts,
  minus/arrow/multiplication variants, O-as-zero between digits
- 8 MathNormalizerTest cases covering the baseline equations
  (2x+6=14, x^2-5x+6=0, dy/dx, integral, lim x->0 sin(x)/x)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
- backend: POST /api/recognize — Gemini multimodal transcription of a
  PNG render of the SELECTED strokes; strict JSON out, never guesses
  (uncertain=true over invented readings); mock mode deterministic;
  rate-limited, validated (size/mime), 3 new backend tests (16 total)
- app: BackendInkRecognizer renders selected strokes black-on-white
  (never a screen screenshot, never a whole page) and parses the
  structured response through MathNormalizer
- HybridRecognizer: on-device first; cloud contacted ONLY when local is
  uncertain and only during explicit RECOGNIZE/CHECK actions; confident
  cloud reading wins, otherwise the honest uncertain result remains
- wired through InkProofApp.recognizer(mock, backendUrl) + CheckWorkEngine
- 5 HybridRecognizerTest cases (incl. cloud-never-contacted-when-confident)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…tool

- real hardware events ONLY: BUTTON_STYLUS_PRIMARY/SECONDARY state
  transitions on touch AND hover; never faked from screen taps
- StylusDoubleTapDetector (600ms window, consumed pairs don't chain) +
  StylusEraserToggle pure state machine (restores highlighter/lasso/
  shape/text, remembered-eraser edge falls back to pen)
- Settings > Writing > Stylus double-tap: Toggle eraser (default) / Off
- honest OnePlus Stylo note in Settings + code: the OEM air double-tap
  gesture is not exposed to third-party apps; if OnePlus maps it to a
  stylus button event this picks it up automatically
- 8 StylusDoubleTapTest cases (timing, OFF via reset, tool restoration)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…rt PDF

- composer chips row (horizontally scrollable): Write by hand, Type,
  Paste (clipboard), Import image, Import PDF
- imported image or first PDF page becomes the question statement:
  copied into app storage, question band sized to the media's aspect
  ratio, rendered on the page; the solution band below stays normal
  handwriting (imported regions are first-class Question objects)
- InkCanvasView draws question media from a per-path bitmap cache

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…ition, stylus double-press, question imports

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
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