The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): host.sessions.pin takes a drop index; reorder([]) resets the manual order
teknium19d8ae3885008
diff --git a/apps/desktop/src/app/chat/sidebar/session-row.test.tsx b/apps/desktop/src/app/chat/sidebar/session-row.test.tsxindex c45a57aa422..c8146ffe8b2 100644--- a/apps/desktop/src/app/chat/sidebar/session-row.test.tsx+++ b/apps/desktop/src/app/chat/sidebar/session-row.test.tsx@@ -349,23 +349,12 @@ describe('SidebarSessionRow decoration slots', () => {}))- it('mounts leading and trailing decorations with the row session id', () => {+ it('mounts leading and trailing decorations, each handed the DURABLE row id', () => {act(() => {decorate(SESSION_ROW_AREAS.leading, 'deco-lead', 'lead-deco')decorate(SESSION_ROW_AREAS.trailing, 'deco-tail', 'tail-deco')})- renderRow(makeSession({ id: 'row-42', title: 'Decorated' }))-- expect(screen.getByTestId('lead-deco').textContent).toBe('row-42')- expect(screen.getByTestId('tail-deco').textContent).toBe('row-42')- })-- it('hands the slot the DURABLE id when it differs from the live one', () => {- act(() => {- decorate(SESSION_ROW_AREAS.leading, 'deco-lead', 'lead-deco')- })-// Auto-compression rotates the live id. A plugin that remembered the live// one decorates this row until the next compaction and then silently stops// matching — so the slot hands the lineage root, the id core's own@@ -373,6 +362,7 @@ describe('SidebarSessionRow decoration slots', () => {renderRow(makeSession({ _lineage_root_id: 'root-9', id: 'live-9', title: 'Compressed' }))expect(screen.getByTestId('lead-deco').textContent).toBe('root-9')+ expect(screen.getByTestId('tail-deco').textContent).toBe('root-9')})it('renders nothing for an area with no registrations and survives an unmount', () => {diff --git a/apps/desktop/src/sdk/index.test.ts b/apps/desktop/src/sdk/index.test.tsindex 4de8d61872e..cd166960512 100644--- a/apps/desktop/src/sdk/index.test.ts+++ b/apps/desktop/src/sdk/index.test.ts@@ -383,6 +383,11 @@ describe('host.sessions session-list mutations', () => {host.sessions.pin('row-1', false)expect($pinnedSessionIds.get()).toEqual(['row-2'])++ // Drop-target pinning (drag-to-pin) slots the pin at an index instead of+ // appending — the same `pinSession(id, index)` the sidebar's drop uses.+ host.sessions.pin('row-0', true, 0)+ expect($pinnedSessionIds.get()).toEqual(['row-0', 'row-2'])})it('resolves a live id to its durable lineage root before pinning', async () => {@@ -404,6 +409,12 @@ describe('host.sessions session-list mutations', () => {expect($sidebarSessionOrderManual.get()).toBe(true)expect($sidebarSessionOrderIds.get()).toEqual(['c', 'a', 'b'])++ // Empty list = clear the manual order, back to the default sort.+ host.sessions.reorder([])++ expect($sidebarSessionOrderManual.get()).toBe(false)+ expect($sidebarSessionOrderIds.get()).toEqual([])})it('setColor writes the durable-keyed colour override and clears with null', async () => {diff --git a/apps/desktop/src/sdk/index.ts b/apps/desktop/src/sdk/index.tsindex 23d1c8d5fed..e2c5e06f990 100644--- a/apps/desktop/src/sdk/index.ts+++ b/apps/desktop/src/sdk/index.ts@@ -945,12 +945,14 @@ export const host = {* resolved to its durable lineage root before writing. */sessions: {/** Pin or unpin a session — the row's ⇧-click / context-menu action. A- * pinned session moves into the Pinned section on the next render. */- pin: (storedSessionId: string, pinned = true): void => {+ * pinned session moves into the Pinned section on the next render.+ * `index` slots the pin at that position in the Pinned list (a drop+ * target between two pins); omitted = append, like the ⇧-click. */+ pin: (storedSessionId: string, pinned = true, index?: number): void => {const id = durableSessionPinId(storedSessionId)if (pinned) {- pinSession(id)+ pinSession(id, index)} else {unpinSession(id)}@@ -958,9 +960,13 @@ export const host = {/** Replace the manual session order with `ids` (what a drag persists).* Ids the window hasn't loaded reconcile on the next render, exactly- * like the app's own reorder. */+ * like the app's own reorder. An EMPTY list clears the manual order and+ * returns Recents to the default sort — the sidebar's own reconcile+ * effect reaches that state one render after a drag empties the list;+ * the verb states it directly so a plugin reset never depends on a+ * mounted effect. */reorder: (ids: string[]): void => {- setSidebarSessionOrderManual(true)+ setSidebarSessionOrderManual(ids.length > 0)setSidebarSessionOrderIds(ids)},diff --git a/website/docs/developer-guide/desktop-plugin-sdk.md b/website/docs/developer-guide/desktop-plugin-sdk.mdindex 7b8b392bc18..188b5e89f65 100644--- a/website/docs/developer-guide/desktop-plugin-sdk.md+++ b/website/docs/developer-guide/desktop-plugin-sdk.md@@ -516,13 +516,49 @@ ctx.register({})```-Pair it with the session list API — `host.sessions.pin(id, pinned?)`,-`host.sessions.reorder(ids)`, `host.sessions.setColor(id, color | null)` — which-write the same stores the app's own controls write (so a plugin action and a-hand click can never disagree). Ids are STORED session ids: a live id is-resolved to its durable lineage root, so pins and colours survive compression's-id rotation — and the row-decoration slots hand your render that same durable id-(`_lineage_root_id ?? id`), never the live one.+Pair it with the session list API, which writes the same stores the app's own+controls write (so a plugin action and a hand click can never disagree):++```ts+host.sessions.pin(storedSessionId: string, pinned?: boolean, index?: number): void+host.sessions.reorder(storedSessionIds: string[]): void // [] = clear manual order → default sort+host.sessions.setColor(storedSessionId: string, color: string | null): void+```++Ids are STORED session ids: a live id is resolved to its durable lineage root,+so pins and colours survive compression's id rotation — and the row-decoration+slots hand your render that same durable id (`_lineage_root_id ?? id`), never+the live one. `pin(id, true, index)` slots the pin at that position in the+Pinned list (a drop target between two pins); without `index` it appends, like+the row's ⇧-click.++**Arbitration.** The verbs are discrete user-triggered edits of user data —+last write wins, exactly as if the user had clicked, and no plugin owns the+result afterwards. Slot contributions are ALL mounted (registration order, not+first-wins), each inside its own error boundary: a plugin that throws or+returns `null` for a row cannot suppress another plugin's decoration on it, and+two decorations on one row render side by side. Core keeps the row's layout,+gestures and title — slots augment, never replace.++**Teardown.** The verbs need none. Slot contributions are removed by the+`ctx.register` disposer (disable/reload drops them and the row re-renders+without the decoration).++Migration for the held catalog plugins:++- **drag-to-pin-session** — replace the `__reactFiber$*` walk for `onTogglePin`+ / `onReorderSessions` / `session._lineage_root_id` with the row's slot id+ (`render: ({ sessionId }) => …` under `SESSION_ROW_AREAS.leading` gives you+ the durable id per row), then `host.sessions.pin(sessionId, true, dropIndex)`+ for a drop into the Pinned section, `host.sessions.pin(sessionId, false)` for+ a drop back into Recents, and `host.sessions.reorder([])` for its+ "reset manual order" path.+- **better-session-appearance** — replace the `localStorage`+ `hermes.desktop.sessionColors` write and the fiber-harvested `onChange` with+ `host.sessions.setColor(sessionId, hex)` (`null` clears), and render its+ per-row glyph through `SESSION_ROW_AREAS.leading` instead of mutating the+ row's status dot (the durable id it needed from `_lineage_root_id` is the+ slot's `sessionId`).### Transcript directives — inline components the model addresses@@ -654,9 +690,9 @@ host.profileRoutes() // [{ profile, targetProfile, connecthost.requestProfile<T>(route, method, params?, timeoutMs?, { spawnPriority? }) // registry-routed RPC; no foreground swaphost.requestProfile<T>(profile, method, params?) // legacy v1/local overloadhost.request<T>(method, params?) // active-gateway JSON-RPC — the real power-host.sessions.pin(storedSessionId, pinned?) // pin/unpin a session (default pinned=true);- // same store the row's ⇧-click writes-host.sessions.reorder(ids) // replace the manual session order (what a drag persists)+host.sessions.pin(storedSessionId, pinned?, index?) // pin/unpin (default pinned=true); index = slot in Pinned;+ // same store the row's ⇧-click / drop writes+host.sessions.reorder(ids) // replace the manual session order (what a drag persists); [] resetshost.sessions.setColor(storedSessionId, color | null) // per-session colour override; null clears```@@ -1157,7 +1193,7 @@ pipeline as a trust boundary.| Category | Exports ||----------|---------|-| Host | `host` (`.state.*`, `.settings`, `.notify`, `.notifyError`, `.navigate`, `.onEvent`, `.logs`, `.status`, `.restartGateway`, `.request`, `.composer`) |+| Host | `host` (`.state.*`, `.settings`, `.notify`, `.notifyError`, `.navigate`, `.onEvent`, `.logs`, `.status`, `.restartGateway`, `.request`, `.composer`, `.sessions`) || Plugin contract | `HermesPlugin`, `PluginContext`, `PluginContribution`, `PluginStorage`, `PluginOs`, `PluginRestOptions`, `PluginNativeNotificationInput`, `PluginNotificationAction`, `HermesOpenTarget`, `Contribution` || Area constants | `PANES_AREA`, `ROUTES_AREA`, `SIDEBAR_NAV_AREA`, `STATUSBAR_AREAS`, `TITLEBAR_AREAS`, `WORKSPACE_PAGE_HEADER_AREA`, `PALETTE_AREA`, `KEYBINDS_AREA`, `THEMES_AREA`, `COMPOSER_AREAS` || Area payloads | `RouteContribution`, `SidebarNavContribution`, `StatusbarItem`, `TitlebarTool`, `PaletteContribution`, `KeybindContribution`, `ComposerMiddleware`, `ComposerAttachmentProvider` |