Skip to content

The agent that grows with you

P17 (NS-1021): one window sizing call for the setup chat; Elite opens with its panes closed (#129202)

Siddharth Balyanc3665b2a0043
diff --git a/apps/desktop/electron/chat-onboarding-window.ts b/apps/desktop/electron/chat-onboarding-window.ts
deleted file mode 100644
index 0de64bbfc17..00000000000
--- a/apps/desktop/electron/chat-onboarding-window.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-import { type BrowserWindow, ipcMain, screen } from 'electron'
-
-import { centeredBounds, type GrowRequest, growWindowBounds } from './window-growth'
-
-interface ChatOnboardingWindowOptions {
- enabled: boolean
- mainWindow: () => BrowserWindow | null
-}
-
-export function registerChatOnboardingWindow({ enabled, mainWindow }: ChatOnboardingWindowOptions): void {
- ipcMain.on('hermes:chat-onboarding:grow', (event, request: GrowRequest) => {
- const win = mainWindow()
-
- if (!enabled || !win || win.isDestroyed() || event.sender !== win.webContents) {
- return
- }
-
- const bounds = win.getBounds()
-
- win.setBounds(
- growWindowBounds(request, {
- bounds,
- frameWidth: bounds.width - win.getContentBounds().width,
- workArea: screen.getDisplayMatching(bounds).workArea,
- zoom: event.sender.getZoomFactor() || 1
- }),
- true
- )
- })
-
- ipcMain.on('hermes:chat-onboarding:solo-boot', event => {
- const win = mainWindow()
-
- if (!enabled || !win || win.isDestroyed() || event.sender !== win.webContents) {
- return
- }
-
- const area = screen.getDisplayMatching(win.getBounds()).workArea
- const width = Math.min(600, area.width)
- const height = Math.min(640, area.height)
-
- win.setBounds(centeredBounds(area, width, height), true)
- })
-}
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index f9a065bf32c..964c7bca9e0 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -119,7 +119,6 @@ import {
} from './browser-windows'
import { createBundleSkewChecker } from './bundle-skew'
import { detectBundleSwap, readBundleSwapStamp } from './bundle-swap'
-import { registerChatOnboardingWindow } from './chat-onboarding-window'
import { provisionCliLinks } from './cli-provision'
import { closeStopFailureMessage, finishWindowsCloseStop, type RuntimeLock } from './close-stop-kill'
import { shouldAttemptCloudBootCascade } from './cloud-boot-cascade'
@@ -613,6 +612,7 @@ import {
} from './window-connection-route'
import { registerWindowControlIpc, windowControlState } from './window-controls'
import { revealAction, shouldFocusToTakeKeyboard } from './window-focus-policy'
+import { isAppSized, registerWindowSizing } from './window-growth'
import { createWindowOpenHandler } from './window-open-policy'
import { installWindowRendererLifecycle } from './window-renderer-lifecycle'
import { wireWindowReveal } from './window-reveal'
@@ -620,10 +620,10 @@ import {
bindGeometryPersistence,
computeWindowOptions,
debounce,
- firstLaunchSize,
sanitizeWindowState,
MIN_HEIGHT as WINDOW_MIN_HEIGHT,
- MIN_WIDTH as WINDOW_MIN_WIDTH
+ MIN_WIDTH as WINDOW_MIN_WIDTH,
+ windowSize
} from './window-state'
import { hiddenWindowsChildOptions, windowsShellCommand } from './windows-child-options'
import { buildPathExtCandidates, chooseUpdaterArgs, resolveVenvHermesCommand } from './windows-hermes-path'
@@ -3490,7 +3490,7 @@ function readWindowState() {
// getNormalBounds() keeps the pre-maximize size, so un-maximizing next session
// lands back where the user actually sized the window.
function persistWindowState() {
- if (!mainWindow || mainWindow.isDestroyed() || mainWindow.isMinimized()) {
+ if (!mainWindow || mainWindow.isDestroyed() || mainWindow.isMinimized() || isAppSized(mainWindow)) {
return
}
@@ -14131,7 +14131,7 @@ function nextInstanceBounds(source: BrowserWindow | null = BrowserWindow.getFocu
const displays = screen.getAllDisplays()
const fallback = computeWindowOptions(
- readWindowState() ?? firstLaunchSize(screen.getPrimaryDisplay().workArea),
+ readWindowState() ?? windowSize('normal', screen.getPrimaryDisplay().workArea),
displays
)
@@ -14238,7 +14238,7 @@ const wakeIndicatorController = createWakeIndicatorWindowController({
wireWindow: window => wireCommonWindowHandlers(window, zoomWiringForWindowKind('wakeIndicator'))
})
-registerChatOnboardingWindow({ enabled: GUEST_ONBOARDING, mainWindow: (): BrowserWindow | null => mainWindow })
+registerWindowSizing({ enabled: GUEST_ONBOARDING, mainWindow: (): BrowserWindow | null => mainWindow })
registerMachineProfile()
// The pet overlay: a single transparent, frameless, always-on-top window that
@@ -15229,7 +15229,7 @@ function createWindow() {
const savedWindowState = readWindowState()
mainWindow = new BrowserWindow({
...computeWindowOptions(
- savedWindowState ?? firstLaunchSize(screen.getPrimaryDisplay().workArea),
+ savedWindowState ?? windowSize('normal', screen.getPrimaryDisplay().workArea),
screen.getAllDisplays()
),
minWidth: WINDOW_MIN_WIDTH,
diff --git a/apps/desktop/electron/preload.ts b/apps/desktop/electron/preload.ts
index ecb076b4028..70858e128bf 100644
--- a/apps/desktop/electron/preload.ts
+++ b/apps/desktop/electron/preload.ts
@@ -76,8 +76,7 @@ contextBridge.exposeInMainWorld('hermesDesktop', {
}
},
chatOnboarding: {
- grow: request => ipcRenderer.send('hermes:chat-onboarding:grow', request),
- soloBoot: () => ipcRenderer.send('hermes:chat-onboarding:solo-boot')
+ size: mode => ipcRenderer.send('hermes:window:size', mode)
},
petOverlay: {
// Main renderer → main process: window lifecycle + drag. `request` is
diff --git a/apps/desktop/electron/window-growth.ts b/apps/desktop/electron/window-growth.ts
index a5ba6002b42..56524cd7b88 100644
--- a/apps/desktop/electron/window-growth.ts
+++ b/apps/desktop/electron/window-growth.ts
@@ -1,50 +1,68 @@
-import type { Rectangle } from 'electron'
-
-export interface GrowRequest {
- bottom?: number
- left?: number
- minWidth?: number
- right?: number
- top?: number
+import { type BrowserWindow, ipcMain, type Rectangle, screen } from 'electron'
+
+import type { WindowSizeMode } from './window-size-types'
+import { windowSize } from './window-state'
+
+interface WindowSizingOptions {
+ enabled: boolean
+ mainWindow: () => BrowserWindow | null
}
-export interface GrowInputs {
- bounds: { height: number; width: number }
- frameWidth?: number
- workArea: { height: number; width: number; x: number; y: number }
- zoom?: number
+// The size this module last gave each window. window-state.json skips a window
+// still at it: an app-chosen size is not where the user left the window, and a
+// saved onboarding size reopened the app as a 602x642 chat.
+const appSized = new WeakMap<BrowserWindow, { height: number; width: number }>()
+
+export function isAppSized(win: BrowserWindow): boolean {
+ const size = appSized.get(win)
+
+ if (!size || win.isMaximized()) {
+ return false
+ }
+
+ const { height, width } = win.getNormalBounds()
+
+ return Math.abs(width - size.width) <= 1 && Math.abs(height - size.height) <= 1
}
-const MAX_DELTA_PX = 4000
+// Onboarding sets the chat size outright. Normal grows each axis to the normal
+// size and never shrinks one the user already made bigger.
+function sizedBounds(mode: WindowSizeMode, bounds: Rectangle, workArea: Rectangle): Rectangle | null {
+ const target = windowSize(mode, workArea)
-const MAX_WORK_AREA = 0.92
+ if (mode === 'onboarding') {
+ return centeredBounds(workArea, target.width, target.height)
+ }
-export function growWindowBounds(
- request: GrowRequest | null | undefined,
- { bounds, frameWidth = 0, workArea, zoom = 1 }: GrowInputs
-) {
- const dip = (value: number | undefined, round: (n: number) => number) =>
- Math.max(0, Math.min(MAX_DELTA_PX, round((Number(value) || 0) * zoom)))
+ const width = Math.max(bounds.width, target.width)
+ const height = Math.max(bounds.height, target.height)
+
+ return width === bounds.width && height === bounds.height ? null : centeredBounds(workArea, width, height)
+}
- const toDip = (value?: number) => dip(value, Math.round)
+export function registerWindowSizing({ enabled, mainWindow }: WindowSizingOptions): void {
+ ipcMain.on('hermes:window:size', (event, mode: WindowSizeMode) => {
+ const win = mainWindow()
- const requestedMin = dip(request?.minWidth, Math.ceil)
- const grown = bounds.width + toDip(request?.left) + toDip(request?.right)
+ if (!enabled || !win || win.isDestroyed() || event.sender !== win.webContents) {
+ return
+ }
- const width = Math.min(
- Math.max(grown, requestedMin ? requestedMin + frameWidth : 0),
- Math.round(workArea.width * MAX_WORK_AREA)
- )
+ if ((mode !== 'normal' && mode !== 'onboarding') || win.isMaximized() || win.isFullScreen()) {
+ return
+ }
- const height = Math.min(
- bounds.height + toDip(request?.top) + toDip(request?.bottom),
- Math.round(workArea.height * MAX_WORK_AREA)
- )
+ const bounds = win.getBounds()
+ const next = sizedBounds(mode, bounds, screen.getDisplayMatching(bounds).workArea)
- return centeredBounds(workArea, width, height)
+ if (next) {
+ appSized.set(win, { height: next.height, width: next.width })
+ win.setBounds(next, true)
+ }
+ })
}
-export function centeredBounds(workArea: Rectangle, width: number, height: number): Rectangle {
+function centeredBounds(workArea: Rectangle, width: number, height: number): Rectangle {
return {
height,
width,
diff --git a/apps/desktop/electron/window-size-types.ts b/apps/desktop/electron/window-size-types.ts
new file mode 100644
index 00000000000..e75a5d916bf
--- /dev/null
+++ b/apps/desktop/electron/window-size-types.ts
@@ -0,0 +1 @@
+export type WindowSizeMode = 'normal' | 'onboarding'
diff --git a/apps/desktop/electron/window-state.ts b/apps/desktop/electron/window-state.ts
index 2ece182bd98..a9f73c7175d 100644
--- a/apps/desktop/electron/window-state.ts
+++ b/apps/desktop/electron/window-state.ts
@@ -6,6 +6,8 @@
* live `screen` displays.
*/
+import type { WindowSizeMode } from './window-size-types'
+
const MIN_WIDTH = 400
const MIN_HEIGHT = 620
@@ -92,10 +94,29 @@ interface WorkArea {
height: number
}
-function firstLaunchSize(workArea: WorkArea): WindowOptions {
+// Share of the display's work area, clamped. Normal is the working app — the
+// first window and a layout pick in the setup chat. Onboarding is the setup
+// chat alone, before a layout exists; its floor keeps the chat readable at the
+// 110% default zoom.
+const WINDOW_SIZES: Record<WindowSizeMode, { share: WorkArea; min: WorkArea; max: WorkArea }> = {
+ normal: {
+ share: { width: 0.85, height: 0.85 },
+ min: { width: 1220, height: 800 },
+ max: { width: 1600, height: 1000 }
+ },
+ onboarding: {
+ share: { width: 0.45, height: 0.8 },
+ min: { width: 660, height: 700 },
+ max: { width: 820, height: 900 }
+ }
+}
+
+function windowSize(mode: WindowSizeMode, workArea: WorkArea): WindowOptions {
+ const { share, min, max } = WINDOW_SIZES[mode]
+
return {
- width: Math.min(clamp(Math.round(workArea.width * 0.75), 1220, 1600), workArea.width),
- height: Math.min(clamp(Math.round(workArea.height * 0.8), 800, 1000), workArea.height)
+ width: Math.min(clamp(Math.round(workArea.width * share.width), min.width, max.width), workArea.width),
+ height: Math.min(clamp(Math.round(workArea.height * share.height), min.height, max.height), workArea.height)
}
}
@@ -175,11 +196,11 @@ export {
bindGeometryPersistence,
computeWindowOptions,
debounce,
- firstLaunchSize,
GEOMETRY_EVENTS,
matchingWorkArea,
MIN_HEIGHT,
MIN_VISIBLE,
MIN_WIDTH,
- sanitizeWindowState
+ sanitizeWindowState,
+ windowSize
}
diff --git a/apps/desktop/src/app/contrib/layout-presets.ts b/apps/desktop/src/app/contrib/layout-presets.ts
index 9b3ad9b8c5d..0ed3dafa14a 100644
--- a/apps/desktop/src/app/contrib/layout-presets.ts
+++ b/apps/desktop/src/app/contrib/layout-presets.ts
@@ -74,6 +74,13 @@ const TERMINAL_TREE = split(
[3, 1]
)
+// Terminal deck places the tooling without opening it: the terminal rests as
+// its bottom rail and files/review as a closed right column, so ⌃` and ⌘J open
+// each one in its deck slot. Review rests with files: closing the file tree
+// collapses their shared column, and an open review there would leave ⌘G
+// reading open while nothing shows.
+const TERMINAL_RESTING = ['terminal', 'files', 'review'] as const
+
const QUAD_TREE = split(
'column',
[
@@ -99,7 +106,14 @@ export function registerLayoutPresets() {
{ id: 'default', title: 'Default', order: 0, tree: DEFAULT_TREE, tier: 'advanced' },
{ id: 'basic', title: 'Basic', order: 5, tree: BASIC_TREE, resting: BASIC_RESTING, tier: 'advanced' },
{ id: 'focus', title: 'Focus', order: 10, tree: FOCUS_TREE, resting: ['terminal'], tier: 'advanced' },
- { id: 'terminal-deck', title: 'Terminal deck', order: 20, tree: TERMINAL_TREE, tier: 'advanced' },
+ {
+ id: 'terminal-deck',
+ title: 'Terminal deck',
+ order: 20,
+ tree: TERMINAL_TREE,
+ resting: TERMINAL_RESTING,
+ tier: 'advanced'
+ },
{ id: 'quad', title: 'Quad', order: 30, tree: QUAD_TREE, tier: 'advanced' }
])
}
diff --git a/apps/desktop/src/components/onboarding-chat/assembly.ts b/apps/desktop/src/components/onboarding-chat/assembly.ts
index bc7acdd8e21..15b918679ea 100644
--- a/apps/desktop/src/components/onboarding-chat/assembly.ts
+++ b/apps/desktop/src/components/onboarding-chat/assembly.ts
@@ -15,7 +15,6 @@ import {
undismissTreePanes
} from '@/components/pane-shell/tree/store'
import { registry } from '@/contrib/registry'
-import { DOCKED_SIDEBAR_MIN_PX } from '@/hooks/use-mobile'
import { runtimeTranslations } from '@/i18n/runtime'
import { isOnboardingEnabled } from '@/lib/onboarding-enabled'
import { $interfaceMode, type InterfaceMode, setInterfaceMode } from '@/store/interface-mode'
@@ -67,7 +66,7 @@ export function takeGuideShape(): void {
startChatOnboardingSolo()
if ($chatOnboardingSolo.get()) {
- window.hermesDesktop?.chatOnboarding?.soloBoot?.()
+ window.hermesDesktop?.chatOnboarding?.size('onboarding')
}
}
@@ -111,18 +110,6 @@ function restorePreviousLayout() {
}
}
-interface LayoutGrowth {
- bottom?: number
- left?: number
- right?: number
- top?: number
-}
-
-const LAYOUT_GROWTH = new Map<string, LayoutGrowth>([
- ['basic', { left: 220 }],
- ['terminal-deck', { bottom: 200, left: 220, right: 240 }]
-])
-
function reconcileLayout(id: string, tree: LayoutNode): void {
applyLayoutPreset(id, tree)
@@ -150,8 +137,6 @@ function reconcileLayout(id: string, tree: LayoutNode): void {
}
export function assembleChatOnboarding(id: string, tree: LayoutNode, mode?: InterfaceMode): void {
- const firstPick = $chatOnboardingSolo.get()
-
if (mode && mode !== $interfaceMode.get()) {
restorePreviousLayout()
setInterfaceMode(mode)
@@ -159,17 +144,7 @@ export function assembleChatOnboarding(id: string, tree: LayoutNode, mode?: Inte
previousLayout = null
- if (firstPick) {
- const growth = LAYOUT_GROWTH.get(id) ?? { left: 220 }
-
- window.hermesDesktop?.chatOnboarding?.grow({
- bottom: growth.bottom ?? 0,
- left: growth.left ?? 0,
- right: growth.right ?? 0,
- minWidth: DOCKED_SIDEBAR_MIN_PX,
- top: growth.top ?? 0
- })
- }
+ window.hermesDesktop?.chatOnboarding?.size('normal')
reconcileLayout(id, tree)
@@ -206,7 +181,7 @@ export function snapshotChatLayout(): () => void {
if (snapshot.solo && !$chatOnboardingSolo.get()) {
$chatOnboardingSolo.set(true)
- window.hermesDesktop?.chatOnboarding?.soloBoot?.()
+ window.hermesDesktop?.chatOnboarding?.size('onboarding')
}
}
}
diff --git a/apps/desktop/src/global.d.ts b/apps/desktop/src/global.d.ts
index 3f5f96c6c5c..103756aa18d 100644
--- a/apps/desktop/src/global.d.ts
+++ b/apps/desktop/src/global.d.ts
@@ -8,7 +8,7 @@ import type { MachineProfile } from '../electron/machine-profile'
import type { HermesNotification } from '../electron/notification-types'
import type { PoolLimits } from '../electron/pool-limits'
import type { UpdateRunReport } from '../electron/updater/update-metrics'
-import type { GrowRequest } from '../electron/window-growth'
+import type { WindowSizeMode } from '../electron/window-size-types'
import type { WakeIndicatorState } from './lib/wake-indicator'
import type {
@@ -114,8 +114,7 @@ declare global {
onState: (callback: (state: WakeIndicatorState) => void) => () => void
}
chatOnboarding?: {
- grow: (request: GrowRequest) => void
- soloBoot: () => void
+ size: (mode: WindowSizeMode) => void
}
// The pop-out pet overlay: a transparent always-on-top window hosting only
// the mascot. The main renderer drives it (open/close/drag + state push);
diff --git a/optional-skills/productivity/initiate-setup/MAPPING.md b/optional-skills/productivity/initiate-setup/MAPPING.md
index d773aa8542d..4143d4ed714 100644
--- a/optional-skills/productivity/initiate-setup/MAPPING.md
+++ b/optional-skills/productivity/initiate-setup/MAPPING.md
@@ -120,7 +120,7 @@ Unchanged, per Sid. The check-in guidance there ("when you check in, look at wha
## 3. Renderer-only plumbing, left out of the skill
-Directive parsing and `DATA_STEPS`/`STEP_CARDS`; `FUNNEL_STEPS` metrics (`recordOnboarding('guide_look'...)`, which need a new hook on `setup_choose` kinds); `$onboardingAnswers` localStorage and `committed` receipts; handoff receipts, `persisted-handoff.ts`, `requestSetupHandoff` guards; chat-solo layout, `LAYOUT_GROWTH` window growth, `restorePreviousLayout`; interface-mode switch on layout pick (`LAYOUTS[].mode`); `accentsFor()` swatches and `NOUS_ACCENT`; `CONNECTOR_LEAD_ORDER` ordering and `CONNECTOR_PICKER_HIDDEN` (discord, discordbot, microsoft_teams); the 12-minus-plugins cap and search field; card footnote "Nothing connects or installs yet"; FirstBuildCard dedupe, 60-char filter, 4-pill cap, fallback pill; `firstTaskTitle` 28-char truncation; `reasoning: minimal` on the free tier route; `SETUP_CHAT_TITLE` and session adoption; catalog prefetch; guide loading UI and gate; `skipChatOnboarding`.
+Directive parsing and `DATA_STEPS`/`STEP_CARDS`; `FUNNEL_STEPS` metrics (`recordOnboarding('guide_look'...)`, which need a new hook on `setup_choose` kinds); `$onboardingAnswers` localStorage and `committed` receipts; handoff receipts, `persisted-handoff.ts`, `requestSetupHandoff` guards; chat-solo layout, `hermes:window:size` window sizing (`electron/window-growth.ts`), `restorePreviousLayout`; interface-mode switch on layout pick (`LAYOUTS[].mode`); `accentsFor()` swatches and `NOUS_ACCENT`; `CONNECTOR_LEAD_ORDER` ordering and `CONNECTOR_PICKER_HIDDEN` (discord, discordbot, microsoft_teams); the 12-minus-plugins cap and search field; card footnote "Nothing connects or installs yet"; FirstBuildCard dedupe, 60-char filter, 4-pill cap, fallback pill; `firstTaskTitle` 28-char truncation; `reasoning: minimal` on the free tier route; `SETUP_CHAT_TITLE` and session adoption; catalog prefetch; guide loading UI and gate; `skipChatOnboarding`.
## 4. Behaviour changes versus today