Build

Displays and the fold

Duo has a 387 point cover and a 790 point inner display, both 850 tall. The inner display can hold one app full width or two side by side. Your app runs on whichever is lit, and while the phone folds the other display already runs a copy, so the handover has no remount and no flash.

The view

TypeScript
1os.view // { display, placement, width, height, visible, active, focused, angle }
2os.onView(cb) // one event per frame at most, only on change
3
4// React
5const view = useDisplay() // from @doan-labs/duo-uikit
FieldValuesUse it for
displaycover, innerBehaviour that differs per glass, such as a pocket layout.
placementfull, left, rightWhich half of the inner display a split view occupies.
width, heightpointsLayout. A split half is as narrow as the cover, so lay out by the box, not by display.
angle0 to 180The hinge, live. 0 is closed, 180 flat.
visibleWhether this view is on glass right now.
activeWhether this view is the one the person is using.
focusedWhether it has keyboard focus.

Design for the cover first

A layout that reads at 387 points has room to breathe unfolded: a list becomes a list beside its detail, a toolbar spreads out, a chart gets its axis labels back. The reverse never works. Never hide a feature on the cover; the person may never unfold the phone for it.

The kit's components collapse themselves at cover width. Yours should too.

Your app runs twice

Each display is its own document with its own React tree. Module state is not shared. What both copies must agree on lives in the shell:

  • os.storage: persistent, private to the app id, survives everything.
  • os.session: ephemeral, shared by every view of this open app, gone when the app closes.

Both are revisioned key-value spaces; see Storage.

One owner

The shell names one view the owner: the first to connect, sticky until that view closes, identified by an epoch.

TypeScript
1os.owner // { epoch } or null
2os.onOwner(cb) // handover when the owner closes
3
4os.commands.send('refresh', '') // any view; resolves when the owner acknowledged
5os.commands.onCommand(async (c) => …) // runs in the owner only
6os.widget.set('small', { lines: [{ text: 'Tide 1.2 m', role: 'value' }] }) // owner only

The mirror draws everything and starts nothing: no sound, no network request, no timer of its own. Intent that must happen once travels as a command; the owner runs it and acknowledges, and the sender's promise resolves. A command is retried until acknowledged and deduplicated by id, so an owner handover in the middle does not lose or double it. Owner-only calls from a view that lost ownership fail with E_STALE.

Test it: open your app, fold the phone all the way, unfold it. The same content, the same scroll position, once.

Widgets

Declare widgets in the manifest and publish a snapshot from the owner. The shell draws it and shows its age; no app code runs on the home screen.

TypeScript
1os.widget.set('medium', {
2 lines: [
3 { text: 'Next high tide', role: 'label' },
4 { text: '14:32', role: 'value' },
5 { text: 'in 2 h 10 min', role: 'caption' }
6 ],
7 tint: 'glass',
8 arg: 'tide=next' // handed to os.session.arg when the widget opens the app
9})

Up to eight lines of 64 characters. arg is at most 256 characters.

TypeScript
1os.open('labs.doan.ipduo.maps', 'q=tides') // by id, with an optional argument
2os.home()

The target receives the argument in os.session.arg. The shell owns the scheme; apps cannot register their own.

Edit this page on GitHub