Repository navigation
feat(limrun): serve iOS alert get/wait/accept/dismiss from tree capture #3699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
3a26dc2
feat(limrun): serve iOS alert get/wait/accept/dismiss from tree capture
thymikee 12ffa00
fix(limrun): harden iOS alert detection against ambiguous sheets
thymikee 9cdbae7
refactor(alert): drive every tree-based alert backend through one sha…
thymikee 574f1bb
refactor(alert): ride main's deadline primitive with no sleep seam
thymikee b1d173d
test(limrun): pin the accept-once/second-get-none timeline and satisf…
thymikee 6dfccf9
fix(alerts): resolve multi-grant sheets by a declared preference table
thymikee 2860188
fix(alerts): type the undecided state and bound the seams each budget…
thymikee 11094e7
fix(alerts): close the window holes the review found and cap the budget
thymikee 2219000
fix(alerts): scope alert captures to the warm helper and split the un…
thymikee 257d51b
fix(alerts): let only the latest answered capture claim a visible dialog
thymikee 36fae55
fix(alerts): a deadline-straddling confirm capture cannot erase an an…
thymikee 9696a08
test(alerts): pin the press cutoff's dispatched disclosure; review nits
thymikee 6ac1fb6
fix(alerts): let started probes finish, rank Android grants by id
thymikee 3920f94
fix(alerts): keep the mechanics façade lazy, honor cancel at every po…
thymikee bb2fc48
docs(alerts): state the real lazy-load constraint, cancel truth, and …
thymikee 09ba2dd
fix(alerts): type the transport-death cancel as pre-press, and make t…
thymikee e3ac15c
docs(capture-kit): scope the transport-death cancel comment to the ro…
thymikee 18c1a29
fix(alerts): state each permissioncontroller grant's role and rank in…
thymikee ab7c9fc
fix(alerts): refuse every undeclared permission grant instead of pres…
thymikee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { classifyAlertButtonRole, selectRankedAlertButtonByRole } from './alert-contract.ts'; | ||
|
|
||
| type Button = { label: string; role: ReturnType<typeof classifyAlertButtonRole> }; | ||
| const button = (label: string): Button => ({ label, role: classifyAlertButtonRole(label) }); | ||
|
|
||
| describe('selectRankedAlertButtonByRole', () => { | ||
| it('resolves distinct grants by the declared preference order', () => { | ||
| const buttons = [button("Don't Allow"), button('Allow Once'), button('Allow While Using App')]; | ||
| expect(selectRankedAlertButtonByRole(buttons, 'accept')?.label).toBe('Allow While Using App'); | ||
| expect(selectRankedAlertButtonByRole(buttons, 'dismiss')?.label).toBe("Don't Allow"); | ||
| }); | ||
|
|
||
| it('resolves the Android grant pair by the same table', () => { | ||
| const buttons = [button('While using the app'), button('Only this time'), button('Deny')]; | ||
| expect(selectRankedAlertButtonByRole(buttons, 'accept')?.label).toBe('While using the app'); | ||
| }); | ||
|
|
||
| it('refuses on equal-rank duplicates: the capture names no single physical button', () => { | ||
| const buttons = [button('OK'), button('OK'), button('Cancel')]; | ||
| expect(selectRankedAlertButtonByRole(buttons, 'accept')).toBeNull(); | ||
| }); | ||
|
|
||
| it('refuses when multiple candidates share a role the vocabulary cannot rank', () => { | ||
| // Roles can arrive from a platform id classifier; labels outside the vocabulary then tie. | ||
| const buttons: Button[] = [ | ||
| { label: 'While on the go', role: 'accept' }, | ||
| { label: 'Just this run', role: 'accept' }, | ||
| ]; | ||
| expect(selectRankedAlertButtonByRole(buttons, 'accept')).toBeNull(); | ||
| }); | ||
|
|
||
| it('refuses a mix of ranked and unranked candidates rather than preferring the known label', () => { | ||
| // The unranked one's role came from a platform id classifier, so it is a real grant the | ||
| // table cannot order. Letting the one known English label win would press an arbitrary | ||
| // grant of an unordered pair. | ||
| const buttons: Button[] = [ | ||
| { label: 'OK', role: 'accept' }, | ||
| { label: 'Unrecognized grant', role: 'accept' }, | ||
| ]; | ||
| expect(selectRankedAlertButtonByRole(buttons, 'accept')).toBeNull(); | ||
| }); | ||
|
|
||
| it('keeps the declared order over mixed English variants of distinct grants', () => { | ||
| // The closest positive: both candidates are ranked, so this is a preference, not ambiguity. | ||
| const buttons = [button('Allow Once'), button('Allow')]; | ||
| expect(selectRankedAlertButtonByRole(buttons, 'accept')?.label).toBe('Allow'); | ||
| }); | ||
|
|
||
| it('returns null when no button carries the role', () => { | ||
| expect(selectRankedAlertButtonByRole([button('Settings')], 'accept')).toBeNull(); | ||
| }); | ||
|
|
||
| it('orders candidates the label table cannot read by the backend rank it supplies', () => { | ||
| // The localized-sheet shape at the shared boundary: both labels are outside the vocabulary, | ||
| // and the backend's own fact (here, a grant-id rank) is the only order the pair has. The | ||
| // boundary must use it instead of refusing a pair the owning backend can order. | ||
| type RankedButton = Button & { id: string }; | ||
| const idRanks: Record<string, number> = { 'id/fg': 0, 'id/once': 1 }; | ||
| const rankById = (button: RankedButton): number | null => idRanks[button.id] ?? null; | ||
| const buttons: RankedButton[] = [ | ||
| { label: 'Solo esta vez', role: 'accept', id: 'id/once' }, | ||
| { label: 'Mientras la app est\u00e1 en uso', role: 'accept', id: 'id/fg' }, | ||
| ]; | ||
| expect(selectRankedAlertButtonByRole(buttons, 'accept', rankById)?.id).toBe('id/fg'); | ||
| }); | ||
|
|
||
| it('still refuses when the backend rank reaches neither of a multi-candidate pair', () => { | ||
| // The closest negative: the ranker exists but names nothing for these buttons, so the | ||
| // label fallback leaves an unranked candidate and the refusal stands. | ||
| type RankedButton = Button & { id: string }; | ||
| const buttons: RankedButton[] = [ | ||
| { label: 'Mientras la app est\u00e1 en uso', role: 'accept', id: 'vendor/a' }, | ||
| { label: 'Solo esta vez', role: 'accept', id: 'vendor/b' }, | ||
| ]; | ||
| expect(selectRankedAlertButtonByRole(buttons, 'accept', () => null)).toBeNull(); | ||
| }); | ||
|
|
||
| it('lets the backend rank decide a pair the label table would order the other way', () => { | ||
| // Both sources know these labels, and they conflict: the label table prefers | ||
| // "While using the app" (position 1) over "Only this time" (position 15), while the | ||
| // backend ranks them 2 and 0. The owning backend's fact is the authority — the label | ||
| // table ranks only where the backend declares nothing. | ||
| type RankedButton = Button & { id: string }; | ||
| const idRanks: Record<string, number> = { 'id/once': 0, 'id/fg': 2 }; | ||
| const rankById = (button: RankedButton): number | null => idRanks[button.id] ?? null; | ||
| const buttons: RankedButton[] = [ | ||
| { label: 'While using the app', role: 'accept', id: 'id/fg' }, | ||
| { label: 'Only this time', role: 'accept', id: 'id/once' }, | ||
| ]; | ||
| expect(selectRankedAlertButtonByRole(buttons, 'accept', rankById)?.id).toBe('id/once'); | ||
| }); | ||
|
|
||
| it('refuses a pair whose ranks come from different sources rather than comparing scales', () => { | ||
| // A backend id-rank and a label-table position are numbers on unrelated scales: id-rank 2 | ||
| // (a one-time grant) says nothing against label position 3 ("Always allow"). The pair is | ||
| // not orderable by any table, so it is refused, never resolved by whichever number is | ||
| // smaller. | ||
| type RankedButton = Button & { id: string }; | ||
| const rankById = (button: RankedButton): number | null => (button.id === 'id/once' ? 2 : null); | ||
| const buttons: RankedButton[] = [ | ||
| { label: 'Only this time', role: 'accept', id: 'id/once' }, | ||
| { label: 'Always allow', role: 'accept', id: 'no/rank' }, | ||
| ]; | ||
| expect(selectRankedAlertButtonByRole(buttons, 'accept', rankById)).toBeNull(); | ||
| }); | ||
| }); | ||
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.