# Tool windows

Satellite palettes that dock and Chrome-like tabs that tear off, and the workspace model they share.

Nucleus ships two tool window archetypes, declared from `nucleusApplication` and included in
`nucleus-application`: satellite palettes that float beside a document or dock into it, and
Chrome-like tabs that tear off into windows of their own.

Every API in this section is `@ExperimentalNucleusApi` at level `ERROR`. Add
`@OptIn(ExperimentalNucleusApi::class)`, or opt the module in with
`optIn.add("dev.nucleusframework.window.ExperimentalNucleusApi")` in `kotlin.compilerOptions`.

## Pick an archetype

![Satellites: the floating Tools and Layers palettes follow the document as it moves; Dock puts Layers in the document, Float takes it back out](/assets/docs/tool-windows/satellites-follow-dock.gif)

![Tabs: reordering a tab, tearing one off into its own window, then dropping it back on the strip](/assets/docs/tool-windows/tab-tear-off-merge.gif)

| | Satellites | Tabs |
| --- | --- | --- |
| What the user sees | Tool palettes, inspectors, panes around a document | Documents as tabs in a strip at the top of each window |
| Who opens windows | You open the document windows; palettes follow the focused one | The workspace: one window per group of tabs |
| Moves | Float ↔ dock, dock ↔ dock, between document windows | Reorder, tear off, merge into another window |
| Declaration | `Satellite(workspace, id, title) { … }` | `Tab(workspace, id, title) { … }` |
| Page | [Satellites](/docs/tool-windows/satellites), [Docking](/docs/tool-windows/docking) | [Tabs](/docs/tool-windows/tabs) |

The two compose: a tab window can host its own `DockLayout`. See
[Compose tabs with satellites](/docs/tool-windows/tabs#compose-tabs-with-satellites).
`Satellite`, `SatelliteWindow`, `Tab` and `TabWindows` live in `dev.nucleusframework.application`,
the rest in `dev.nucleusframework.window.tao`.

## Shared ideas

- **The workspace owns placement.** Declare each satellite or tab once, at application scope. The
  workspace picks the host window and moves it on drag. `initialPlacement`, `initiallyOpen` and
  `group` apply on the first declaration of an `id` only.
- **Entries outlive composition.** A satellite or tab declared again resumes where it was.
  `snapshot()` and `restore()` persist the layout.
- **State follows the content.** `rememberSaveable` survives every move between windows. Plain
  `remember` does not: hoist it or make it saveable.
- **View models follow the content too.** `viewModel { }` inside a satellite or a tab belongs to
  it, not to the window showing it. Its view models survive moves, docking, undocking and hiding,
  and a `SavedStateHandle` keeps its values across a move. They are cleared when a tab is closed,
  or when the `Satellite` or `Tab` declaration leaves the composition. See
  [View models and lifecycle](/docs/windows#view-models-and-lifecycle).

### Two ways to carry a drag

`SatelliteWorkspace.dragKind` and `TabWorkspace.dragKind` hold the `WorkspaceDragKind` of the drag
in flight, or `null`.

| Value | When | What follows the pointer |
| --- | --- | --- |
| `Window` | Windows, macOS, X11, XWayland | A real window, or a ghost window |
| `Transfer` | `TaoWindow.canPlaceOnScreen == false` (native Wayland) | The compositor's drag icon; `dragGhost` stays `null` |

Branch Wayland-sensitive chrome on `TaoWindow.canPlaceOnScreen`, or
`SatelliteScope.isCompositorPlaced`, never on the compositor name.
`NUCLEUS_TAO_LINUX_RENDERER=x11` runs the app on XWayland and restores window-following drags.
A layout of your own carries its drags the same way with the transfer drag API. See
[Carry a cross-window drag on Wayland](/docs/input/drag-and-drop#carry-a-cross-window-drag-on-wayland).

## Try them in the Nucleus Lab

Each archetype has a probe in the [Nucleus Lab](/docs/concepts/testing#check-a-module-with-the-nucleus-lab).
Open one with `./gradlew :examples:lab:app:run -Dlab.probe=<id>`.

| Probe | What it shows |
| --- | --- |
| `workspace.satellites` | Shared palettes, owner follows focus or a pin, drag to dock, layout snapshots |
| `workspace.tabs` | Tear-off, merge, reorder, hover cards with thumbnails, the strip drawn with Jewel's `TabStrip` |
| `workspace.tab-satellites` | One `SatelliteWorkspace` per tab window |
| `workspace.reader-dock` | Right-to-left reader: layered sides, custom splitters and headers, fixed panes |

## What's next

- [Satellites](/docs/tool-windows/satellites): declare palettes and let them follow the focused document.
- [Docking](/docs/tool-windows/docking): lay docked panels out around your content.
- [Tabs](/docs/tool-windows/tabs): turn documents into tabs that tear off into windows.
- [Linux and Wayland](/docs/windows/linux-wayland): what a compositor-placed window changes.
