bettergui
meng-xinxue/bettergui
Starts with the sidebar collapsed, hides the Windows title-bar menu strip, the sidebar New Session button and the More menu's Browse other plugins row, and moves three side panels into the More menu. Each tweak has its own switch on the plugin's page.
설치
dsh plugin --profile web add github:meng-xinxue/betterguiREADME
DSH BetterGUI · 界面优化
Displayed in Plugins → Installed as 界面优化 (English UI: UI polish);
the package is dsh-bettergui.
Five small, focused tweaks for the DSH UI: a cleaner first screen without giving up functionality. Every tweak is one entry in a feature table and has one switch on the plugin's own row page in Plugins. A tweak drives a public Client service, contributes a component through a declared Slot, or — when neither exists — declares one narrow stylesheet rule scoped to a host attribute or a shipped icon id. Nothing here replaces shipped components, reaches into another plugin's DOM, or touches a shadow root.
Install
Install it like any other bundle, from a shell:
dsh plugin add https://github.com/Meng-XinXue/bettergui
dsh plugin add dsh-bettergui # once it is published to npm
dsh plugin add /path/to/bettergui # a local checkout
Or open Plugins → Install in the app and paste one of these into the 「包名或地址 / Package name or address」 field:
| Source | What to paste |
|---|---|
| GitHub | https://github.com/Meng-XinXue/bettergui |
| npm (once published) | dsh-bettergui |
| A checkout on disk | the folder path, e.g. C:\Users\me\bettergui |
Then reload the page: the bundle's Client half is assembled at startup, so the
first-screen features only appear on the next load. A GitHub address or .tgz
link is fetched directly rather than through the npm registry, so the machine
must be able to reach it — the installer offers a mainland-China mirror when it
cannot.
Requires DSH 0.2.x, whose Client services and Slots this bundle uses, and Node.js 20 or newer to build or pack it yourself.
Architecture
dsh-bettergui/
package.json bundle manifest: dsh.bundle.patch + dsh.client (web, immediate)
cordis.patch.yml one row: dsh-bettergui -> dsh-bettergui
index.js Host half: reserved for host-scoped work (apply/Config)
client.js Client half: FEATURES table, settings store, settings card
locale/ meta.title / meta.description / meta.detail per locale
docs/ one-image detail document + preview.svg
icon.svg artwork
- One row, no services. The bundle inserts a single row. The Host half is a no-op today, so enabling or disabling the plugin starts and stops the Client module and nothing else.
- One feature per entry.
client.jsdeclaresFEATURES = [ ... ]. A feature is{ id, apply(ctx), boot? };idis stable,applyperforms exactly one tweak, and it returns a disposer when the tweak can be undone. Adding a tweak means adding one entry — the settings card lists it automatically. - A supervisor owns the lifecycle. One loop applies enabled features and
disposes disabled ones, and re-runs whenever the card writes the store, so a
switch takes effect without a reload (except
boot: truefeatures, which have already happened by then). - Public services first. Where a service exists, the feature uses it
(
sidebar-starts-collapsedcallsctx.layout.toggleSidebar()). Where a Slot declares the chrome, the feature contributes through that Slot (hide-new-session-buttonoccupiessidebar.session.action;sidebar-panels-into-moreoccupiessidebar.panellist.actions). Only where neither exists does a feature fall back to a single declared<style>rule keyed on adata-*attribute or an icon id the app itself ships — never a selector chain into a shipped component's internals. No shipped Client package is imported. - Contributions are kept, not just made. A slot is declared by an entry, and
the Slots core empties a child slot's entries when its declaring entry is
released, so a one-shot registration silently vanishes the next time the shell
rebuilds that part of the UI. Every occupant here is installed through
occupySlot, which wrapsctx.slots.inject(<the slot itself>, …)— one installation per declaration lifetime of exactly the slot being occupied. - Everything is owned by
ctx.effect. Styles, dictionaries and listeners are registered with their cleanup returned, so disabling the plugin removes them; styles are marked withdata-dsh-bettergui, so re-activation can never leave a duplicate behind. - The switches live in the browser, not in the profile config. The boot graph
hands a Client half its code but never its row config (
WebBootEntrycarries no config field), so a toggle has to be readable before the first paint. The map is onelocalStoragekey,dsh-bettergui:features:v1, every feature defaulting to on. On the desktop app the page origin is the stabledsh-app://app, so the map survives a restart; a browser tab served from another port starts from the defaults.
Settings card
The card is the same component registered in two declared slots, because the Plugins page asks a bundle for configuration in two places and neither is discoverable from the other:
| Slot | Key | Where it shows |
|---|---|---|
plugins.bundle.config | dsh-bettergui (package name) | Plugins → 界面优化 / UI polish: a section on the bundle's own page, right under its title and description |
plugins.row.config | dsh-bettergui#dsh-bettergui (<package name>#<row id>) | The row's own page, opened from the row title in the bundle page's 「包含的组件 / Components」 list |
There is no separate "configure" button in the shipped page: a row that registers
a page turns its own title into the control (aria-label="配置 <name>", with a
chevron), and a bundle that registers one gains the section on its page. view: 'summary' renders the one-liner a row shows while closed; view: 'page' renders
one row per feature: label, hint, switch. Labels come from props.t, which the
slot binds to the locale namespace passed at registration:
ctx.locale.register('dsh-bettergui', MESSAGES); // en + zh dictionaries
const CARD_SLOTS = [
{ name: 'plugins.bundle.config', key: 'dsh-bettergui' },
{ name: 'plugins.row.config', key: 'dsh-bettergui#dsh-bettergui' },
];
for (const card of CARD_SLOTS) {
ctx.effect(() => ctx.slots.inject(card.name, () =>
ctx.slots.register({ name: card.name, key: card.key, locale: 'dsh-bettergui' }, FeatureCard),
), `dsh-bettergui: settings card (${card.name})`);
}
The card draws its own markup and CSS on --dsw-alias-* tokens (the shipped
primitives are not a dependency of a bundle). The switch copies the shipped
geometry value for value — 36×20 track with a 16 px thumb, border-l3 off,
brand-primary on, switch-thumb for the resting thumb — and widens its pointer
target with a ::before overlay instead of growing the visual. Switches are real
button[role="switch"][aria-checked] elements labelled by their visible title and
grouped under the card's intro line, so keyboard and screen-reader behavior is the
platform's.
Features
sidebar-starts-collapsed
The shipped layout store initializes layoutInfo.sidebar to SIDEBAR_DEFAULT
(280 px) on every page load, so the app opens with the sidebar expanded.
The feature toggles it once at activation, leaving the toggle shortcut, drag,
session and panel behavior untouched. What a collapsed sidebar looks like is the
shipped frame's decision: a 56 px icon rail in a plain browser window, nothing at
all in a Windows desktop window (the reopen control sits in the caption row) or
on macOS (the reopen control sits in the frame's leading seat).
Guard: window.innerWidth >= 1024 + 32. Below the shipped SIDEBAR_AUTO_COLLAPSE
(1024 px) breakpoint the sidebar is already collapsed and the same toggle would
expand it over the squeezed center, so the narrow band is skipped. The 32 px
slack covers the difference between window.innerWidth and the measured frame
width that the store actually compares.
Known limits:
- The public
layoutservice exposestoggleSidebar()only, with no state read, so the feature is direction-blind: it relies on the shipped transient default (expanded) being in effect at activation. A second plugin that writes the sidebar preference before this one would be flipped the other way. - Windows in the 1024–1056 px band keep the shipped expanded sidebar.
- Every page load re-collapses, including one the user expanded earlier in the same session — the shipped store has no persistence to respect.
- It is a
boot: truefeature: the switch applies from the next launch, because flipping it back cannot unfold a sidebar that is already open (and re-running it later would fold the app under the user).
Restore: the sidebar's expand control, or Ctrl+B in the desktop app
(primary+alt+B in a browser window).
hide-caption-menu
The Windows desktop preload appends a plain host element div[data-windows-menu]
to the document body — the title bar's 「应用」/「编辑」 menu strip, whose internals
live in an open shadow root — and, only on Windows, sets data-windows-titlebar on
<html>. The feature adds one rule through ctx.effect:
html[data-windows-titlebar] [data-windows-menu] { display: none !important; }
Because the rule is keyed on the attribute the preload sets, it is platform-gated by itself: on macOS, Linux and in the browser nothing matches. No observer, no platform sniffing in JS, no shadow-root access, no layout recalculation — one declaration, idempotent, removed with the feature.
What it costs: those menu commands lose their on-screen entry point, so use their keyboard shortcuts (copy, paste, undo and so on). The window's minimize and close buttons are separate elements and keep working. Nothing in the conversation, sidebar or panels depends on that strip.
hide-new-session-button
The sidebar owns New Session, and it renders that row through the
sidebar.session.action HOC slot: the shell passes its own tooltip + button as
children and an occupant may omit children to replace what sits inside the
layer. The feature registers one occupant that renders nothing:
occupySlot(
ctx.slots,
{ name: 'sidebar.session.action', id: 'dsh-bettergui:hide-new-session' },
() => null,
);
That is the declared way to drop the button — no class-name selector, no DOM
surgery, and the occupant is removed with the feature. The row's own <div>
remains and collapses to zero height.
A registration alone is not enough. The row is a child slot of the shell's
sidebar entry, and the Slots core clears a child slot's entries whenever the
entry that declares it is released. A one-shot register therefore disappears
the first time the shell rebuilds its sidebar, and the button reappears; so does
an inject keyed on the parent sidebar slot, because it fires before the child
slot is declared again. occupySlot (client.js) keys the injection on
sidebar.session.action itself, so the occupant is installed once per
declaration lifetime of the very slot it sits in. Every Slot contribution in this
plugin goes through it.
Same button, two seats: expanded it is the "New Session" bar; with the sidebar
collapsed on Windows the shell re-anchors it into the caption row, so both
disappear. Starting a session still works from the session.new shortcut
(Ctrl+N, Ctrl+Alt+N in a browser window) and from the brand mark at the top
of the sidebar.
A second plugin that also occupies sidebar.session.action replaces this layer
(the slot is a HOC stack; the highest-priority occupant wins).
hide-browse-plugins-row
The More menu's 「浏览更多插件」/ "Browse other plugins" row belongs to
dsh-client-ui-entry-customization, which registers one component into three list
slots: the sidebar's panel-list actions, the session header view actions and the
right sidebar's guide tab. The Slots service has no API to mask another
registration, and a menu row carries no identity attribute — its class names are
build-time CSS-module hashes. What it does carry is the shipped icon: primitives
render every icon as svg[data-icon="dsw-icon-<name>-<weight>"], and the browse
row is the only menu item using the plugin pinwheel. One rule therefore hides it:
button[role="menuitem"]:has(svg[data-icon^="dsw-icon-plugin-pinwheel-outline"]) { display: none !important; }
The rule is scoped to menu items, so nothing else that happens to draw a pinwheel (a plugin card, a sidebar entry) is affected. If DSH ever renames the icon, the rule matches nothing and hides nothing — the menu stays intact instead of losing an unrelated row. The other failure mode — DSH reusing that icon in an unrelated menu — is louder: the feature counts its matches after injecting the rule and warns when more than three rows match, since the shipped component appears in at most three menus. Costs: the row disappears from all three menus at once, and the separator that used to sit above it stays behind as a plain hairline. The plugin list itself is still reachable from the Plugins page.
sidebar-panels-into-more
The sidebar's panel list is the sidebar.panellist list slot: every plugin adds
its own row and the shell renders all of them. A row leaves that list only by
being unpinned, and the pin store
(dsh-client-ui-sidebar/src/client/panel-pins.ts) is memory-only and reaches no
public Client service — setPinned is injected into the shell's own occupants
only — so a plugin cannot unpin another plugin's row.
What a plugin can read is the slot itself: entriesOfSlot('sidebar.panellist')
returns each row's id and the label it projects. So the feature hides a fixed
set of panels from the nav, one rule per installed panel, matched on the row
button's accessible name:
const PANEL_IDS_IN_MORE = ['schedules', 'dsh-context', 'skill-explorer'];
// rebuilt per locale, one block per installed id (`<label>` falls back to the id,
// as the shell's own label fallback does):
nav div:has(> button[aria-label="<label>"]:not([role="menuitem"])),
nav div:has(> * > button[aria-label="<label>"]:not([role="menuitem"])),
nav button[aria-label="<label>"]:not([role="menuitem"]) { display: none !important; }
Why aria-label: a panel row stamps no per-entry attribute, and its class names
are build-time CSS-module hashes; the accessible name is the only handle the shell
projects for it (the row is a button[aria-label={label}], and the label comes
from the registration's thunk). That name is localized, so the rules are rebuilt
whenever the panel list or the locale changes — the same two signals the shell
itself re-renders on — and each thunk is called the way the shell calls it. The
rules are scoped to nav and exclude role="menuitem", so the More menu keeps
every row even if a future build stops portalling it outside the nav.
Hiding a row is only half the move. The shipped More menu lists unpinned panels
only — entry-customization renders entries.filter(entry => !entry.pinned) —
and these panels are pinned, so a hidden row would be stranded: gone from the nav,
absent from More. The same feature therefore also occupies
sidebar.panellist.actions, whose owner props hand a row everything it needs
(entries, onOpen, onDismiss), and draws one menu row per hidden panel:
slots.inject('sidebar.panellist.actions', () =>
slots.register(
{ name: 'sidebar.panellist.actions', id: 'dsh-bettergui:more-panels', order: -10, locale: 'dsh-bettergui' },
MorePanelRows,
));
Those rows list only targets that are still pinned (an unpinned panel already has
a shipped row, so ours steps aside instead of duplicating it), draw the panel's own
sidebar.panel.icon through renderFactorySlot, and sit above the menu's own rows
(order -10). Their chrome is .dbg-more-row, sized after the shipped menu rows
but naming no shipped class.
Costs, all deliberate:
- Panels installed later stay in the list. The set is explicit rather than "everything except Plugins", so a newly installed plugin never disappears on its own.
- The nav row is hidden, but the shell still holds the panel as pinned, so More offers our row instead of the shipped one. Our row has no pin switch, and the shipped pin toggle only appears on rows the shell already treats as unpinned. To get a hidden panel back into the list, turn this feature off.
- Our rows are drawn from scratch rather than reusing the shipped menu-item component, because a plugin bundle may not import a Harness Client package. If DSH retunes that menu, the rows can drift by a pixel or two.
- The shell renders the More launcher only while
sidebar.panellist.actionshas registrations, and our occupant now counts as one. With this feature on, the launcher therefore stays visible even if the shipped menu plugin (entry-customization) is disabled, where it would be hidden. - A panel that is not installed, or one whose label is empty, contributes no rule and no row; a missing label logs one warning per refresh instead of hiding an unrelated row.
Adding a feature
-
Add an object to
FEATURESinclient.js— the card picks it up:const example = { id: 'example', // stable; also the settings key and the locale suffix apply(ctx) { // one tweak: a public Client service, or one declared stylesheet rule return () => {}; // a disposer when the tweak can be undone }, }; -
Add its label and hint to
MESSAGES.en/MESSAGES.zhasfeature.<id>andhint.<id>. -
Inject the service it needs in the module's
injectlist, and add the owning package todsh.client.injectinpackage.jsonwhen activation order matters. -
Register styles and listeners inside
ctx.effect, or return a disposer, so the supervisor can undo the tweak. -
Keep user-visible text in the Client locale service; keep container styling on
--dsw-alias-*theme tokens.
Change the defaults
Per-user defaults are the switches on the plugin's row page. The build-time
default is "on" for every feature, set in the createStore default loop in
client.js; the numeric tunables (breakpoint, slack, selectors, and the panel ids
in PANEL_IDS_IN_MORE) are the constants
above each feature. Edit the file, then reload the page — the bundle is linked
from this directory, so no reinstall is needed — or reinstall from Plugins if
the manifest changed.
Notes
- Client-side only: no model requests, no data leaves the machine, no session events are written.
- Settings are per browser profile and per page origin. They are not part of the profile config, so they do not travel to another machine.
- Disabling the plugin restores the shipped default: the sidebar opens expanded, the Windows title-bar menu strip comes back, the New Session button and the Browse other plugins row return, and the three side panels sit in the panel list again.
License
MIT — see LICENSE. Version history in CHANGELOG.md.