The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(desktop): move the SDK viewport atom into sdk/viewport.ts
Teknium2855cc05fb42
diff --git a/apps/desktop/src/sdk/index.ts b/apps/desktop/src/sdk/index.tsindex 730700da4b0..1aa33b2313e 100644--- a/apps/desktop/src/sdk/index.ts+++ b/apps/desktop/src/sdk/index.ts@@ -18,7 +18,7 @@* - `ui.*` — the design language, so plugin UI looks native by default.*/-import { atom, computed, type ReadableAtom } from 'nanostores'+import { computed, type ReadableAtom } from 'nanostores'import type { ReactNode } from 'react'import { capabilityScoped, getApiRequestConnection } from '@/api/client'@@ -28,7 +28,6 @@ import { openSession, type OpenSessionIntent } from '@/app/open-session'import { syncWorkspaceRoute } from '@/app/routes'import type { ClientSessionState } from '@/app/types'import {- $narrowViewport,$newSessionTabAction,$paneVisible,adoptContributedPanes,@@ -120,11 +119,13 @@ import {} from './profile-request'import { sessionsHost } from './sessions'import { desktopSettings } from './settings'+import { $viewport, type ViewportRect } from './viewport'/** Pane, status bar and titlebar slots; see `./areas` for the mount rules. */export * from './areas'/** The plugin authoring contract (`HermesPlugin`, `PluginContext`, `ctx.*` door types). */export type * from './plugin-contract'+export type { PluginProfileRequestOptions, PluginProfileRoute } from './profile-request'// -- state: readonly views over the app's live atoms -------------------------@@ -218,20 +219,6 @@ const $focusedSessionProfile = computed(owner?.profile || rememberedSessionProfile(sessions, focused, activeProfile))-/** Window geometry + the app's responsive posture, one readonly rect. */-export interface ViewportRect {- width: number- height: number- /** Below the app's sidebar-collapse breakpoint (rails become overlays). */- narrow: boolean-}--const readViewport = (): ViewportRect => ({- width: typeof window === 'undefined' ? 0 : window.innerWidth,- height: typeof window === 'undefined' ? 0 : window.innerHeight,- narrow: $narrowViewport.get()-})-/** Runtime session id → mid-turn. Not gateway socket state. */const $busyBySession = computed($sessionStates, states => {const map: Record<string, boolean> = {}@@ -243,14 +230,6 @@ const $busyBySession = computed($sessionStates, states => {return map})-const $viewport = atom<ViewportRect>(readViewport())--if (typeof window !== 'undefined') {- const refresh = () => $viewport.set(readViewport())- window.addEventListener('resize', refresh)- $narrowViewport.listen(refresh)-}-/** Live usage of the FOCUSED session, projected out of the streamed session* state — the same readout the core statusbar's context chip paints. */const $focusedUsage = computed($focusedSessionState, state => state?.usage ?? null)@@ -1572,11 +1551,11 @@ export const host = {// -- react bridge --------------------------------------------------------------export type { PluginProfileRequestOptions, PluginProfileRoute } from './profile-request'+export type { DesktopSettingKey, DesktopSettingValues } from './settings'// -- ui: the design language ---------------------------------------------------export type { DesktopSettingKey, DesktopSettingValues } from './settings'+export type { ViewportRect } from './viewport'/** THE whole Capabilities surface (Skills / Tools / MCP tabs, installed* lists, full-skill detail pane, embedded hub picker with one-click* installs). For plugin dialogs pass `embedded` (tab state stays local —diff --git a/apps/desktop/src/sdk/viewport.ts b/apps/desktop/src/sdk/viewport.tsnew file mode 100644index 00000000000..75ca3b3369f--- /dev/null+++ b/apps/desktop/src/sdk/viewport.ts@@ -0,0 +1,27 @@+// `host.state.viewport`: window geometry + the app's responsive posture.++import { atom } from 'nanostores'++import { $narrowViewport } from '@/components/pane-shell/tree/store'++/** Window geometry + the app's responsive posture, one readonly rect. */+export interface ViewportRect {+ width: number+ height: number+ /** Below the app's sidebar-collapse breakpoint (rails become overlays). */+ narrow: boolean+}++const readViewport = (): ViewportRect => ({+ width: typeof window === 'undefined' ? 0 : window.innerWidth,+ height: typeof window === 'undefined' ? 0 : window.innerHeight,+ narrow: $narrowViewport.get()+})++export const $viewport = atom<ViewportRect>(readViewport())++if (typeof window !== 'undefined') {+ const refresh = () => $viewport.set(readViewport())+ window.addEventListener('resize', refresh)+ $narrowViewport.listen(refresh)+}