You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(hub): support functional/boolean when on dock entries
Widen dock-entry `when` to `string | boolean | (() => string | boolean | undefined)`,
resolved to the existing `string | undefined` wire contract once per
`DevframeDocksHost.values()`/`projectView` serialization pass.
This lets a host give a dock registered via `docks.register(...)` or
mounted via `mountDevframe(ctx, def, { dock })` the same dynamic
visibility the built-in `~terminals`/`~messages` entries get from an
object-literal getter — a function survives `mountDevframe`'s
`...options.dock` spread by reference, where a getter would only run
once. Clients and `whenexpr` are unaffected; the resolved value is
still a plain string expression or `undefined`.
Copy file name to clipboardExpand all lines: docs/guide/when-clauses.md
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,23 @@ ctx.docks.register({
40
40
41
41
`when: 'false'` hides an entry unconditionally.
42
42
43
+
### Dynamic `when` on registered/mounted docks
44
+
45
+
A dock entry's `when` also accepts a boolean or a function, resolved to the string form above once per serialization (`ctx.docks.values()`) — a server-side authoring convenience for docks whose visibility depends on live state:
The function is re-invoked on every serialization pass, so it reflects the current state each time a client reads `devframe:docks` — the same pattern the hub's built-in `~terminals` dock uses to hide itself while no terminal session is open. `false` resolves to `'false'`; `true` resolves to `undefined` (unconditionally visible); a returned string is passed through unchanged and still evaluated client-side. This is what makes a function `when` useful specifically for a dock registered via `mountDevframe`'s `dock` option — that object is spread once, so a getter would only run once, but a function value survives the spread by reference.
0 commit comments