[fix/MAT-542] handwriting dataJson 전환 — base64 wrapping 제거#313
Open
b0nsu wants to merge 2 commits intofix/mat-524-autosave-data-lossfrom
Open
[fix/MAT-542] handwriting dataJson 전환 — base64 wrapping 제거#313b0nsu wants to merge 2 commits intofix/mat-524-autosave-data-lossfrom
b0nsu wants to merge 2 commits intofix/mat-524-autosave-data-lossfrom
Conversation
ScrapHandwritingUpdateRequest / ScrapHandwritingResp 양쪽에 dataJson?: string 추가, data 가 optional 로 완화. 그 외 도메인의 schema 변경분 동시 반영 (서버 develop OpenAPI 기준 누적분). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5초 autosave 메인 스레드 4단계 직렬화(stringify → encodeURIComponent
→ unescape → btoa)를 1단계(JSON.stringify)로 축소.
handwritingEncoder
- canonicalize: Stroke / Point / TextItem 의 키 순서를 명시 재구성하여
byte-stable JSON 출력 보장 (동일 입력 → 동일 출력).
- decodeHandwritingData: 응답 객체만 받는 단일 시그니처. dataJson 우선,
없으면 data(base64) fallback, 둘 다 없으면 빈값. 옛 strokes-only
배열 형식 호환 유지.
useHandwritingManager
- PUT body 를 { dataJson } 으로 (data 미포함) — 자연 마이그레이션.
- 응답 분기를 decodeHandwritingData(handwritingData) 로 단순화.
Stacked on PR #312 — base: fix/mat-524-autosave-data-loss.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the native scrap handwriting autosave/load pipeline to stop base64-wrapping handwriting payloads and instead persist/load plain JSON via the newly introduced dataJson field (with legacy data base64 fallback for reads). It also updates the generated OpenAPI TypeScript schema to reflect dataJson support and other upstream schema drift.
Changes:
- Replace handwriting save encoding from
stringify → encodeURIComponent → unescape → btoato a single deterministicJSON.stringify(canonicalize(...)). - Simplify handwriting decode to accept the full API response object and prefer
dataJson, falling back to legacy base64dataand older “strokes-only array” format. - Update API schema typings to add
dataJson?: stringand makedataoptional for handwriting request/response types (plus additional OpenAPI sync changes).
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| apps/native/src/types/api/schema.d.ts | Sync OpenAPI typings; adds dataJson/optional data for handwriting types and introduces additional schema drift updates. |
| apps/native/src/features/student/scrap/utils/handwritingEncoder.ts | Implement deterministic JSON encoding + unified decoder (dataJson preferred, data base64 fallback, strokes-only compatibility). |
| apps/native/src/features/student/scrap/hooks/useHandwritingManager.ts | Switch PUT body to { dataJson } and simplify load path to decodeHandwritingData(handwritingData). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
5초 autosave 메인 스레드 4단계 직렬화(stringify → encodeURIComponent → unescape → btoa) 를 1단계
JSON.stringify로 축소. dev 서버에 추가된dataJson: string필드 사용.Linear
Changes
handwritingEncoder.tscanonicalize—Stroke/Point/TextItem키 순서를 명시 재구성하여 byte-stable JSON 출력 보장 (동일 입력 → 동일 출력).encodeHandwritingData— 4단계 → 1단계 (JSON.stringify(canonicalize(...))).decodeHandwritingData— 응답 객체만 받는 단일 시그니처.dataJson우선 →data(base64) fallback → 둘 다 없으면 빈값. 옛 strokes-only 배열 형식 호환 유지.parseHandwriting내부 helper 분리.useHandwritingManager.ts{ dataJson }으로 (data 미포함) — 자연 마이그레이션.decodeHandwritingData(handwritingData)로 단순화 (호출부에서 dataJson/data 분기 흡수).schema.d.tspnpm openapi로 develop dev OpenAPI 동기화.ScrapHandwritingUpdateRequest/ScrapHandwritingResp양쪽에dataJson?: string추가,dataoptional 화. 그 외 누적 schema drift 동시 반영.Testing
pnpm typecheck통과pnpm lint변경 파일 0 errors{ dataJson: "..." }확인Risk / Impact
Follow-ups
Screenshots / Video
(필요 시 디바이스 캡처 첨부)