# dsh-remote bundle patch: inserts this plugin into a profile's layer stack.
# Applied when a profile lists this bundle; rows reference the package by name so
# Node resolution finds the installed code.
#
# Since v0.7.2 dsh-remote ships dsh-better-sidebar as a hard dependency and
# mounts it here, so `dsh plugin add dsh-remote` brings up the sidebar with
# zero extra steps. The sidebar row uses a DEDICATED id (`dsh-remote-sidebar`)
# and a guard so it backs off when another entry already mounts
# `dsh-better-sidebar` (e.g. the user installed the sidebar bundle on its own,
# or an aggregate bundle owns it) — two enabled mounts would both register
# /sidebar/api and fail the whole plugin tree at boot.
#
# The guard checks EXISTENCE only (id + name), never the `disabled` property of
# other rows: reading another row's disabled inside this row's disabled
# expression would recursively re-enter the loader and overflow the stack
# (dsh-better-sidebar's own row carries a disabled expression too, so the two
# would ping-pong). Existence is sufficient — the standalone row is only ever
# created when the user (or an aggregate bundle) explicitly mounts the sidebar.
- insert:
    - id: dsh-remote
      name: 'dsh-remote'
    - id: dsh-remote-sidebar
      name: 'dsh-better-sidebar'
      disabled: !!js "[...ctx.loader.entries()].some((e) => e.options.name === 'dsh-better-sidebar' && e.options.id !== 'dsh-remote-sidebar')"
