refactor: split capture flow into focused modules and harden mask failures#155
Merged
Conversation
…lures
Extract the screenshot/redaction pipeline from src/widget/index.ts into
four focused modules: screenshot-options, capture-loading, annotation-flow,
and capture-flow. Adds new public/test fixture and unit coverage.
Type design:
- ScreenshotChoice is now a discriminated union with consistent `kind`
tags and an exhaustiveness check at the call site.
- CaptureWithLoadingResult is { kind: 'ok' | 'skipped' | 'cancelled' }
so callers stop overloading `null`.
- Internal ChosenCaptureResult is { captured | empty | returnToForm },
removing illegal-state combinations (e.g. screenshot + returnToForm).
Mask failure safety:
- New MaskApplicationError class is thrown from canvas/image failures
inside applyMaskToImage so callers can distinguish them from raw
capture errors.
- capture-loading shows a distinct "Privacy masking failed" modal that
refuses to retry and only offers Skip / Cancel — previously a mask
failure was indistinguishable from a generic capture failure and a
"Skip Screenshot" click could silently submit with no image while
the user thought capture had failed.
UI helper:
- redactionNoteHtml in ui.ts replaces four near-identical inline-styled
HTML strings across screenshot-options and annotation-flow.
9ab2ace to
aa0eef5
Compare
|
🎉 This PR is included in version 1.33.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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
src/widget/index.tsinto four focused modules (screenshot-options,capture-loading,annotation-flow,capture-flow);index.tsloses ~450 lines of capture/annotation flow.ScreenshotChoice,CaptureWithLoadingResult, internalChosenCaptureResult) with exhaustiveness checks, eliminating overloadednullsemantics and illegal{screenshot, returnToForm: true}states.MaskApplicationErrorclass and a distinct "Privacy masking failed" modal so a mask failure no longer masquerades as a generic capture failure where the user might click "Skip Screenshot" and silently submit without an image.redactionNoteHtmlhelper inui.tscollapses four near-identical inline-styled HTML strings across two modules.returnToForm: truecancel paths (screenshot-options cancel, capture-loading cancel, annotation cancel) and the native-viewportredactionUnavailableflag — previously these branches were only exercised by E2E.public/test/masking-layout-edge.htmlfixture + E2E tests asserting transformed / sticky / fixed redaction targets stay masked after scrolling.Pre-PR review gate run: code-reviewer, pr-test-analyzer, code-simplifier, silent-failure-hunter, and type-design-analyzer dispatched in parallel against the staged diff; critical and type-design findings have been addressed.
Test plan
npm run lint— 0 errors (24 pre-existing warnings)npm run build(tsc + widget tsconfig) — cleannpm run build:widget— 82.7 kB bundlenpm test— 204/204 unit tests pass (was 200; +4 cancel-path and viewport tests)