Skip to content

The agent that grows with you

fix(bot-mode): Routines rows fit the 250px pane and a closed Scheduled jobs pane comes back

teknium18717a0bd3975
diff --git a/apps/desktop/e2e/bot-routines-pane-narrow.spec.ts b/apps/desktop/e2e/bot-routines-pane-narrow.spec.ts
new file mode 100644
index 00000000000..4bb0d517452
--- /dev/null
+++ b/apps/desktop/e2e/bot-routines-pane-narrow.spec.ts
@@ -0,0 +1,276 @@
+import { execFileSync } from 'node:child_process'
+import fs from 'node:fs'
+import path from 'node:path'
+
+import { startMockServer } from '../../../tests-js/scripts/mock-server'
+
+import {
+ buildAppEnv,
+ createSandbox,
+ launchDesktop,
+ type MockBackendFixture,
+ waitForAppReady,
+ writeEnvFile,
+ writeMockProviderConfig
+} from './fixtures'
+import { RealSessionBuilder } from './real-session-builder'
+import { expect, test } from './test'
+
+// The Scheduled jobs (Routines) pane docks at 250px beside a bot chat. A job
+// row is a grid item, and grid items default to `min-width: auto`, so a long
+// nowrap title pinned the row wider than the pane: the enable/disable Switch
+// and the delete control were clipped off the right edge and the next-run
+// label was cut mid-word (#91623, #89534). Closing the pane with its ✕ also
+// remembered the dismissal forever — re-entering Bot Mode never brought the
+// pane back (#102224).
+
+type Page = MockBackendFixture['page']
+
+const LONG_TITLE = '[bot:alpha] Weekly research digest with a deliberately long routine title that overflows'
+const SHOT_DIR = '/tmp/batchbots/panes-layout-cron-tile/shots'
+
+let fixture: MockBackendFixture | null = null
+let alphaHome = ''
+
+async function openBots(page: Page): Promise<void> {
+ const tab = page
+ .getByRole('button', { name: 'Bots', exact: true })
+ .or(page.getByRole('tab', { name: 'Bots', exact: true }))
+ .first()
+
+ await tab.click()
+ await expect(page.getByRole('button', { name: 'New bot or group chat' })).toBeVisible()
+}
+
+async function openSessions(page: Page): Promise<void> {
+ const tab = page
+ .getByRole('button', { name: /^sessions$/i })
+ .or(page.getByRole('tab', { name: /^sessions$/i }))
+ .first()
+
+ await tab.click()
+}
+
+async function openUntil(action: () => Promise<void>, expected: () => Promise<void>, attempts = 3): Promise<void> {
+ for (let attempt = 1; ; attempt += 1) {
+ await action()
+
+ try {
+ await expected()
+
+ return
+ } catch (error) {
+ if (attempt >= attempts) {
+ throw error
+ }
+ }
+ }
+}
+
+async function seedBot(hermesHome: string, mockUrl: string, name: string): Promise<string> {
+ const dir = path.join(hermesHome, 'profiles', name)
+ fs.mkdirSync(dir, { recursive: true })
+ writeMockProviderConfig(dir, mockUrl)
+ writeEnvFile(dir)
+
+ const builder = await RealSessionBuilder.start(dir)
+
+ try {
+ await builder.createSession({ title: 'Bot Chat', turns: [`Hello ${name}`] })
+ } finally {
+ await builder.close()
+ }
+
+ return dir
+}
+
+/** A real cron job in the profile's own cron store, written by the real store code. */
+function seedRoutine(profileHome: string, title: string): void {
+ const python = path.resolve(process.cwd(), '../../venv/bin/python')
+ const repoRoot = path.resolve(process.cwd(), '../..')
+
+ const script = [
+ 'from cron.jobs import create_job',
+ `create_job(name=${JSON.stringify(title)}, schedule='every 4 days', prompt='say hello')`
+ ].join('\n')
+
+ execFileSync(python, ['-c', script], {
+ cwd: repoRoot,
+ env: { ...process.env, HERMES_HOME: profileHome },
+ stdio: 'pipe'
+ })
+}
+
+function readJobs(profileHome: string): Array<{ enabled?: boolean; name?: string; state?: string }> {
+ const raw = JSON.parse(fs.readFileSync(path.join(profileHome, 'cron', 'jobs.json'), 'utf8'))
+
+ return Array.isArray(raw) ? raw : (raw.jobs ?? [])
+}
+
+async function openAlphaChat(page: Page): Promise<void> {
+ await openBots(page)
+
+ const alphaRow = page
+ .getByRole('button', { name: /^alpha\b/i })
+ .filter({ visible: true })
+ .first()
+
+ await expect(alphaRow).toBeVisible({ timeout: 30_000 })
+ await openUntil(
+ () => alphaRow.click(),
+ () =>
+ expect(page.getByText('Hello alpha', { exact: true }).filter({ visible: true }).first()).toBeVisible({
+ timeout: 45_000
+ })
+ )
+}
+
+function routinesTab(page: Page) {
+ return page.locator('[data-tree-tab="hermes-bots:routines"]').filter({ visible: true }).first()
+}
+
+/** Which left-dock tab is selected, and whether the bot chat is still the workspace. */
+async function workspaceState(page: Page) {
+ return page.evaluate(() => ({
+ selectedDockTab: document.querySelector('[role="tab"][aria-selected="true"]')?.textContent?.trim() ?? null,
+ treeTabs: [...document.querySelectorAll<HTMLElement>('[data-tree-tab]')].map(el => ({
+ id: el.getAttribute('data-tree-tab'),
+ visible: el.getClientRects().length > 0,
+ text: el.textContent?.trim()
+ })),
+ dismissed: localStorage.getItem('hermes.desktop.dismissedPanes.v1')
+ }))
+}
+
+/** Expand the collapsed right-edge Scheduled jobs tab (a no-op when the pane is already open); resolve the row. */
+async function expandRoutines(page: Page) {
+ const row = page
+ .getByRole('button', { name: /Weekly research digest/ })
+ .filter({ visible: true })
+ .first()
+
+ if (!(await row.isVisible())) {
+ const tab = routinesTab(page)
+ await expect(tab).toBeVisible({ timeout: 30_000 })
+ await tab.click()
+ }
+
+ await expect(row).toBeVisible({ timeout: 30_000 })
+ await page.waitForTimeout(2_500)
+ console.log('AFTER EXPAND', JSON.stringify(await workspaceState(page)))
+ await expect(row).toBeVisible()
+
+ return row
+}
+
+test.beforeAll(async () => {
+ const mock = await startMockServer()
+ const sandbox = createSandbox('bots-routines')
+ writeMockProviderConfig(sandbox.hermesHome, mock.url)
+ writeEnvFile(sandbox.hermesHome)
+ alphaHome = await seedBot(sandbox.hermesHome, mock.url, 'alpha')
+ seedRoutine(alphaHome, LONG_TITLE)
+ fs.mkdirSync(SHOT_DIR, { recursive: true })
+
+ const { app, page } = await launchDesktop(buildAppEnv(sandbox))
+
+ fixture = {
+ app,
+ page,
+ mock,
+ mockUrl: mock.url,
+ sandbox,
+ cleanup: async () => {
+ await app.close().catch(() => undefined)
+ await mock.close()
+ sandbox.cleanup()
+ }
+ }
+ await waitForAppReady(fixture, 120_000)
+})
+
+test.afterAll(async () => {
+ await fixture?.cleanup()
+ fixture = null
+})
+
+test('a long routine title never pushes the Switch, delete control or next-run label out of the 250px pane', async () => {
+ test.setTimeout(300_000)
+ const page = fixture!.page
+
+ await openAlphaChat(page)
+ const row = await expandRoutines(page)
+ await page.screenshot({ path: path.join(SHOT_DIR, 'routines-pane.png') })
+
+ // Geometry against the pane's own scroll container, not body text: the row
+ // is a grid item, so its intrinsic width is what pins the controls off-edge.
+ const geometry = await row.evaluate(button => {
+ const card = button.parentElement!.parentElement as HTMLElement
+ const scroller = card.closest<HTMLElement>('.overflow-y-auto')!
+ const paneRect = scroller.getBoundingClientRect()
+
+ const rect = (el: Element | null) => {
+ const r = el!.getBoundingClientRect()
+
+ return { left: r.left, right: r.right, width: r.width }
+ }
+
+ const nextRun = [...card.querySelectorAll<HTMLElement>('span')].find(s => /^next/i.test(s.textContent ?? ''))!
+ const title = button.querySelector<HTMLElement>('span.truncate')!
+
+ return {
+ card: rect(card),
+ pane: rect(scroller),
+ switch: rect(card.querySelector('[role="switch"]')),
+ trash: rect(card.querySelector('button[aria-label]')),
+ nextRun: { ...rect(nextRun), clipped: nextRun.scrollWidth > nextRun.clientWidth + 1, text: nextRun.textContent },
+ titleEllipsized: title.scrollWidth > title.clientWidth,
+ paneRight: paneRect.right
+ }
+ })
+
+ console.log('ROUTINE ROW GEOMETRY', JSON.stringify(geometry))
+
+ expect.soft(geometry.card.right).toBeLessThanOrEqual(geometry.pane.right + 1)
+ expect.soft(geometry.switch.right).toBeLessThanOrEqual(geometry.pane.right + 1)
+ expect.soft(geometry.trash.right).toBeLessThanOrEqual(geometry.pane.right + 1)
+ expect.soft(geometry.nextRun.right).toBeLessThanOrEqual(geometry.pane.right + 1)
+ expect.soft(geometry.nextRun.clipped).toBe(false)
+ expect.soft(geometry.nextRun.text).toMatch(/next: in \d+ days?/i)
+ // The title is the one thing that MAY be cut, and it must be cut with an ellipsis.
+ expect.soft(geometry.titleEllipsized).toBe(true)
+
+ await test.step("clicking the row's Switch toggles the job in place — the pane stays, jobs.json flips (#95031)", async () => {
+ const toggle = row.locator('xpath=..').getByRole('switch')
+ await expect(toggle).toBeVisible()
+ expect(readJobs(alphaHome)[0]?.enabled).not.toBe(false)
+
+ await toggle.click()
+
+ await expect.poll(() => readJobs(alphaHome)[0]?.enabled, { timeout: 30_000 }).toBe(false)
+ await expect(row).toBeVisible()
+ await expect(page.getByText(/Open this bot's continuous chat/i)).toHaveCount(0)
+ await page.screenshot({ path: path.join(SHOT_DIR, 'routines-pane-toggled.png') })
+ })
+
+ await test.step('closing Scheduled jobs with ✕ is recoverable — leaving and re-entering Bot Mode brings the pane back (#102224)', async () => {
+ const tab = page.locator('[data-tree-tab="hermes-bots:routines"]').first()
+ await expect(tab).toBeVisible({ timeout: 30_000 })
+ await tab.hover()
+ const closer = tab.getByRole('button', { name: /^close$/i }).first()
+ await closer.click({ force: true })
+ await page.waitForTimeout(1_500)
+ console.log('AFTER CLOSE', JSON.stringify(await workspaceState(page)))
+ await expect(page.getByRole('button', { name: /Weekly research digest/ })).toHaveCount(0, { timeout: 15_000 })
+ await page.screenshot({ path: path.join(SHOT_DIR, 'routines-closed.png') })
+
+ await openSessions(page)
+ await page.waitForTimeout(1_000)
+ await openAlphaChat(page)
+ await page.waitForTimeout(2_000)
+ console.log('AFTER RE-ENTER', JSON.stringify(await workspaceState(page)))
+ await page.screenshot({ path: path.join(SHOT_DIR, 'routines-restored.png') })
+
+ await expect(page.locator('[data-tree-tab="hermes-bots:routines"]').first()).toBeVisible({ timeout: 30_000 })
+ })
+})
diff --git a/apps/desktop/src/plugins/hermes-bots/cron.tsx b/apps/desktop/src/plugins/hermes-bots/cron.tsx
index 931bd069ac6..99f9ebee78d 100644
--- a/apps/desktop/src/plugins/hermes-bots/cron.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/cron.tsx
@@ -525,12 +525,18 @@ export function RoutineRow({ job, onOpen, owner }: RoutineRowProps) {
return (
<div
+ // `min-w-0` on the card AND on each line: a grid item's min-width defaults
+ // to `auto`, so a long nowrap title made the row as wide as its text (~530px
+ // in the 250px pane) and the pane's overflow clipped the Switch and delete
+ // control clean off the right edge, with the title hard-cut instead of
+ // ellipsized (#91623). The chain has to be unbroken — one `auto` in it
+ // re-pins the whole row.
className={cn(
- 'group grid gap-1.5 rounded-lg border border-(--ui-stroke-secondary) p-2.5 transition-colors',
+ 'group grid min-w-0 gap-1.5 rounded-lg border border-(--ui-stroke-secondary) p-2.5 transition-colors',
'hover:border-(--ui-stroke-primary, var(--ui-stroke-secondary))'
)}
>
- <div className="flex items-center gap-2">
+ <div className="flex min-w-0 items-center gap-2">
{/* The row's own button, not a click handler on the card: the switch */
/* and delete control are siblings, so opening the details can never */
/* swallow a toggle (and a nested button would be invalid markup). */}
@@ -568,12 +574,15 @@ export function RoutineRow({ job, onOpen, owner }: RoutineRowProps) {
</Button>
</Tip>
</div>
- <div className="flex items-center justify-between gap-2 pl-3.5">
- <span className="inline-flex items-center gap-1 rounded-full border border-(--ui-stroke-secondary) px-1.5 py-0.5 text-[0.65rem] text-(--ui-text-tertiary)">
+ {/* The schedule pill and the next-run label keep their words: when the
+ pane can't fit both on one line the next-run label wraps to a second
+ line instead of being cut to "next in 4" (#89534). */}
+ <div className="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 pl-3.5">
+ <span className="inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-full border border-(--ui-stroke-secondary) px-1.5 py-0.5 text-[0.65rem] text-(--ui-text-tertiary)">
<Codicon className="text-[0.7rem]" name="calendar" />
{scheduleLabel(job.schedule)}
</span>
- <span className="truncate text-[0.65rem] text-(--ui-text-quaternary)">
+ <span className="ml-auto shrink-0 whitespace-nowrap text-[0.65rem] text-(--ui-text-quaternary)">
{active && job.next_run_at
? `${c.next} ${relativeTime(new Date(job.next_run_at).getTime())}`
: c.states.paused}
diff --git a/apps/desktop/src/plugins/hermes-bots/plugin.tsx b/apps/desktop/src/plugins/hermes-bots/plugin.tsx
index 4e57c285f98..271134cc27c 100644
--- a/apps/desktop/src/plugins/hermes-bots/plugin.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/plugin.tsx
@@ -416,8 +416,8 @@ export default {
// keeps the pane's spot, so re-registering re-adopts it where it was.
// host.paneVisibility is feature-detected: older desktops without the SDK
// export keep the always-registered behavior.
- const registerRoutinesPane = () =>
- ctx.register({
+ const registerRoutinesPane = () => {
+ const dispose = ctx.register({
id: 'routines',
area: 'panes',
// The app's noun for these, so the tab agrees with the pane header and
@@ -441,6 +441,18 @@ export default {
render: () => <RoutinesPane />
})
+ // The pane's ✕ remembers a Close across launches, and nothing else ever
+ // shows this pane again — it only comes back by being registered here.
+ // Entering Bot Mode is the user asking for their bot's chrome, so a
+ // remembered Close is dropped and the pane returns the way it first
+ // arrived: as the collapsed right-edge tab (#102224).
+ if (typeof host.undismissPane === 'function') {
+ host.undismissPane(`${ID}:routines`)
+ }
+
+ return dispose
+ }
+
if (typeof host.paneVisibility === 'function') {
// The contribution-scoped pane id (`register` prefixes `${ID}:`).
const $sidebarVisible = host.paneVisibility(`${ID}:pane`)
diff --git a/apps/desktop/src/sdk/index.ts b/apps/desktop/src/sdk/index.ts
index bb9b39c4900..e7ec8c99e2e 100644
--- a/apps/desktop/src/sdk/index.ts
+++ b/apps/desktop/src/sdk/index.ts
@@ -30,9 +30,11 @@ import {
$narrowViewport,
$newSessionTabAction,
$paneVisible,
+ adoptContributedPanes,
registerPaneCloser,
removeTreePane,
- revealTreePane
+ revealTreePane,
+ undismissTreePanes
} from '@/components/pane-shell/tree/store'
import {
$workspaceMode,
@@ -1332,6 +1334,24 @@ export const host = {
* (`typeof host.paneVisibility === 'function'`). */
paneVisibility: (paneId: string): ReadableAtom<boolean> => $paneVisible(paneId),
+ /** Forget a persisted Close for a contributed pane so adoption puts it back
+ * where its dock hint says — WITHOUT fronting it or un-collapsing its zone
+ * (that is `revealPane`, for an explicit user action). For a pane a plugin
+ * registers conditionally (Bot Mode's Scheduled jobs pane exists only while
+ * Bot Mode is on screen), its re-registration is the only "show" the user
+ * ever performs, so a remembered Close would otherwise strand the pane until
+ * a full layout reset (#102224). Feature-detect on older desktops. */
+ undismissPane: (paneId: string): void => {
+ const id = (paneId ?? '').trim()
+
+ if (!id) {
+ return
+ }
+
+ undismissTreePanes([id])
+ adoptContributedPanes()
+ },
+
/** Reveal a contributed pane and its zone from an explicit user action. */
revealPane: (paneId: string): void => {
const id = (paneId ?? '').trim()
diff --git a/website/docs/user-guide/bot-mode.md b/website/docs/user-guide/bot-mode.md
index e3fb2920044..6f0ee24f643 100644
--- a/website/docs/user-guide/bot-mode.md
+++ b/website/docs/user-guide/bot-mode.md
@@ -86,7 +86,7 @@ A Bot's look, title, and description are stored in the profile's metadata on the
## Routines
-The **Routines** pane attaches recurring tasks to the Bot that does them — "summarize my inbox every morning" lives next to the Bot responsible for it. The pane docks beside the chat only while the Bots tab is active and steps aside when you switch back to Sessions (older desktop builds keep it always visible). A structured schedule picker builds the schedule (frequency first, then only the detail that matters), with an Advanced field exposing the raw Hermes schedule string.
+The **Routines** pane attaches recurring tasks to the Bot that does them — "summarize my inbox every morning" lives next to the Bot responsible for it. The pane docks beside the chat only while the Bots tab is active and steps aside when you switch back to Sessions (older desktop builds keep it always visible). Closing it with its ✕ hides it until you next leave and re-enter the Bots tab, when it comes back as the collapsed right-edge tab. A structured schedule picker builds the schedule (frequency first, then only the detail that matters), with an Advanced field exposing the raw Hermes schedule string.
Routines are plain [Hermes cron jobs](./features/cron.md) namespaced `[bot:<name>] <routine>` — they also show up in `hermes cron list` and the core Cron page. Runs land in the Bot's own chat history, so the result is right where you would talk to that Bot anyway.