connect.windows
The single-window surface — read window state, open URLs, and change focus/state.
The shell is single-window, so this is an honest, thin surface — enough for
Chrome-shaped code to work, without pretending Connect+ is multi-window. Read with
tabs.read; change with tabs.write.
- Capabilities:
tabs.read(read),tabs.write(change) - Namespace:
connect.windows
Walkthrough
Read the window and its tabs.
- Declare
tabs.read(andtabs.writeif you'll change window state). - Read the window, populating its tabs:
const win = await connect.windows.getCurrent({ populate: true }); - Change focus/state with
updatewhen needed.
Methods
windows.get(options?) · getCurrent · getLastFocused · getAll
Read the window (they all resolve the same single window).
How to use it
- Call any of them — they're interchangeable here.
- Pass
{ populate: true }to include the window's tabs.
Signature — connect.windows.get(options?) (and getCurrent, getLastFocused,
getAll) · Capability: tabs.read
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
options.populate | boolean | no | Include the window's tabs in the result. |
Returns — Promise<Window> (or Window[] for getAll).
const win = await connect.windows.getCurrent({ populate: true });
console.log(win.tabs.length);windows.create(options)
Open URL(s) as tab(s).
How to use it
- Pass
url(a string or array) to open as tab(s). - Set
focused: trueto bring the app forward.
Signature — connect.windows.create({ url?, focused? }) · Capability: tabs.write
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | string[] | no | The URL(s) to open as tab(s). |
focused | boolean | no | Focus the app after opening. |
Returns — Promise<Window>.
windows.update(options)
Change window state.
How to use it
- Pass the fields you want to change (
focused,state,drawAttention). - Note bounds are read-only — the shell owns geometry.
Signature — connect.windows.update({ focused?, state?, drawAttention? }) ·
Capability: tabs.write
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
focused | boolean | no | Focus / blur the app. |
state | 'normal' | 'minimized' | 'maximized' | no | Window state. |
drawAttention | boolean | no | Flash for attention. |
Returns — Promise<Window>. Bounds are read-only.
Events
Each needs tabs.read and returns an unsubscribe function.
windows.onFocusChanged(cb)
App focus / blur.
How to use it
- Subscribe to pause/resume work when the app loses/gains focus.
- A payload of
-1means the app lost focus.
Payload — the window id, or -1 when the app loses focus.
windows.onCreated(cb) · windows.onRemoved(cb)
Window lifecycle.
How to use it
- Subscribe for parity with Chrome-shaped code; here it's the single window.
Payload — the window id.
Notes
- Because there's exactly one window,
get/getCurrent/getLastFocusedare interchangeable — the variants exist for Chrome-code parity.