You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by wy...@apache.org on 2026/09/19 17:47:18 UTC

(maka) branch feat/runtime-host-rust updated: refactor(workhub): move the conversation surface into its plugin package

This is an automated email from the ASF dual-hosted git repository.

M4n5ter pushed a commit to branch feat/runtime-host-rust
in repository https://gitbox.apache.org/repos/asf/maka.git


The following commit(s) were added to refs/heads/feat/runtime-host-rust by this push:
     new f6089d1399 refactor(workhub): move the conversation surface into its plugin package
f6089d1399 is described below

commit f6089d1399e61d59028164c54e51a0fcaecf5952
Author: Wang <m4...@gmail.com>
AuthorDate: Sun Sep 20 01:47:12 2026 +0800

    refactor(workhub): move the conversation surface into its plugin package
    
    Generated-by: OpenAI Codex
---
 .../features/workbar/ui/workbar-surface.tsx        |   2 +-
 .../features/workhub/ui/workhub-composer.tsx       | 105 ----
 .../features/workhub/ui/workhub-progress-card.tsx  |  71 ---
 .../renderer/features/workhub/ui/workhub-root.tsx  | 401 +-----------
 apps/desktop/src/shared/workhub-control.d.ts       |  21 +-
 apps/desktop/src/shared/workhub-presentation.d.ts  |  56 +-
 packages/ui/package.json                           |   1 +
 .../ui/src}/workbar-edge-toggle.tsx                |   2 +-
 packages/workhub/package.json                      |   2 +
 packages/workhub/src/locales/workhub-live-copy.ts  |   6 +
 .../workhub/src/native.ts                          |  27 +-
 .../workhub/src/surface.ts                         |  22 +-
 packages/workhub/src/ui/ports.ts                   |  61 ++
 packages/workhub/src/ui/workhub-composer.tsx       | 118 ++++
 packages/workhub/src/ui/workhub-progress-card.tsx  | 126 ++++
 packages/workhub/src/ui/workhub-root.tsx           | 700 +++++++++++++++++++++
 16 files changed, 1067 insertions(+), 654 deletions(-)

diff --git a/apps/desktop/src/renderer/features/workbar/ui/workbar-surface.tsx b/apps/desktop/src/renderer/features/workbar/ui/workbar-surface.tsx
index 46863f864c..73e01f4fed 100644
--- a/apps/desktop/src/renderer/features/workbar/ui/workbar-surface.tsx
+++ b/apps/desktop/src/renderer/features/workbar/ui/workbar-surface.tsx
@@ -60,7 +60,7 @@ import {
   workbarToolDefinition,
   type WorkbarToolDefinition,
 } from '../model/workbar-tool-definitions';
-import { WorkbarEdgeToggle } from '../../../application/contracts/workbar-edge-toggle.js';
+import { WorkbarEdgeToggle } from '@maka/ui/workbar-edge-toggle';
 import { WorkBoardPanel } from '../../../work-board-panel.js';
 import { getShellCopy } from '../../../locales/shell-copy.js';
 import { getDesktopConversationCopy } from '../../../locales/conversation-copy.js';
diff --git a/apps/desktop/src/renderer/features/workhub/ui/workhub-composer.tsx b/apps/desktop/src/renderer/features/workhub/ui/workhub-composer.tsx
deleted file mode 100644
index 47c208ae9f..0000000000
--- a/apps/desktop/src/renderer/features/workhub/ui/workhub-composer.tsx
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import { forwardRef, useRef, useState } from 'react';
-import { Composer, useToast, useUiLocale, type ComposerHandle, type ComposerProps } from '@maka/ui';
-import { useComposerAttachments } from '@maka/ui/use-composer-attachments';
-import { toComposerIngestItems } from '@maka/ui/composer-attachments';
-import { MAX_ATTACHMENT_BYTES, MAX_ATTACHMENT_COUNT } from '@maka/core/attachments';
-import type { AttachmentRef, FollowUpMode } from '@maka/core/events';
-import { getDesktopConversationCopy } from '../../../locales/conversation-copy.js';
-import { localizedShellErrorMessage } from '../../../locales/shell-copy.js';
-import { useWorkHubServices } from '../services.js';
-import { workHubLiveCopy } from '@maka/workhub/locales';
-
-export type WorkHubComposerProps = Omit<ComposerProps, 'onSend' | 'draftKey'> & {
-  sessionId?: string;
-  onSend(text: string, attachments: AttachmentRef[], followUpMode?: FollowUpMode): Promise<boolean>;
-};
-
-/** The shared Composer and attachment lifecycle belong to the persistent coordination Session. */
-export const WorkHubComposer = forwardRef<ComposerHandle, WorkHubComposerProps>(function WorkHubComposer(
-  { sessionId, onSend, ...composer }, ref,
-) {
-  const services = useWorkHubServices();
-  const locale = useUiLocale();
-  const t = workHubLiveCopy[locale];
-  const toast = useToast();
-  // First resolution adopts the already editable draft. Temporary Host
-  // unavailability keeps it; switching Hosts selects a separate draft.
-  const draftOwner = useRef({ first: sessionId, latest: sessionId });
-  if (sessionId) {
-    draftOwner.current.first ??= sessionId;
-    draftOwner.current.latest = sessionId;
-  }
-  const scope = `workhub:${draftOwner.current.latest === draftOwner.current.first ? 'initial' : draftOwner.current.latest}`;
-  const currentSessionId = useRef(sessionId); currentSessionId.current = sessionId;
-  const [submitting, setSubmitting] = useState(false);
-  const submittingRef = useRef(false);
-  const staged = useComposerAttachments({
-    draftKey: scope,
-    toastApi: toast,
-    service: services.attachments,
-    copy: getDesktopConversationCopy(locale).actions,
-    formatError: (error, fallback) => localizedShellErrorMessage(error, fallback, locale),
-  });
-  const uploaded = useRef(new Map<string, AttachmentRef>());
-  return <Composer {...composer}
-    ref={ref}
-    draftKey={scope}
-    sendBlocked={composer.sendBlocked || submitting || !sessionId}
-    allowAttachmentOnlySend
-    pendingAttachments={staged.pendingAttachments}
-    onPickAttachments={staged.pickAttachments}
-    onAttachFilePaths={staged.attachFilePaths}
-    onRemoveAttachment={staged.removeAttachment}
-    onSend={async (text, metadata) => {
-      if (!sessionId || submittingRef.current || composer.sendBlocked) return false;
-      const snapshot = [...staged.pendingAttachments];
-      submittingRef.current = true; setSubmitting(true);
-      try {
-        if (snapshot.length > MAX_ATTACHMENT_COUNT || snapshot.some((item) => item.size > MAX_ATTACHMENT_BYTES)) {
-          throw new Error(t.attachmentLimit);
-        }
-        const attachments: AttachmentRef[] = [];
-        for (const item of snapshot) {
-          const key = `${scope}:${item.stagingKey}`;
-          let attachment = uploaded.current.get(key);
-          if (!attachment) {
-            [attachment] = await services.prepareAttachments(sessionId, toComposerIngestItems([item]));
-            if (!attachment) throw new Error(t.attachmentUploadFailed);
-            uploaded.current.set(key, attachment);
-          }
-          attachments.push(attachment);
-        }
-        // A Host switch during an upload must never submit the old draft into its successor.
-        if (currentSessionId.current !== sessionId) return false;
-        const accepted = await onSend(text.trim() || t.reviewAttachments, attachments, metadata?.followUpMode);
-        if (accepted) {
-          staged.clearSubmittedAttachments(snapshot);
-          for (const item of snapshot) uploaded.current.delete(`${scope}:${item.stagingKey}`);
-        }
-        return accepted;
-      } catch (error) {
-        toast.error(t.sendFailed, localizedShellErrorMessage(error, t.retry, locale));
-        return false;
-      } finally { submittingRef.current = false; setSubmitting(false); }
-    }}
-  />;
-});
diff --git a/apps/desktop/src/renderer/features/workhub/ui/workhub-progress-card.tsx b/apps/desktop/src/renderer/features/workhub/ui/workhub-progress-card.tsx
deleted file mode 100644
index 1f0f3a3bd7..0000000000
--- a/apps/desktop/src/renderer/features/workhub/ui/workhub-progress-card.tsx
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import { useEffect, type Ref } from 'react';
-import { IconButton } from '@astryxdesign/core';
-import { MakaWordmark, useUiLocale, type LiveTurnProjection } from '@maka/ui';
-import { ArrowRight, X } from '@maka/ui/icons';
-import type { StoredMessage } from '@maka/core/session';
-import type { WorkHubControlSnapshot } from '../../../../shared/workhub-control.js';
-import { useWorkHubServices } from '../services.js';
-import { workHubLiveCopy } from '@maka/workhub/locales';
-
-function latestText(liveTurn: LiveTurnProjection | undefined, messages: readonly StoredMessage[]): string | undefined {
-  for (let index = (liveTurn?.steps.length ?? 0) - 1; index >= 0; index--) {
-    const text = liveTurn!.steps[index]?.text?.text;
-    if (text?.trim()) return text;
-  }
-  for (let index = messages.length - 1; index >= 0; index--) {
-    const message = messages[index]!;
-    if (message.type === 'assistant' && (!liveTurn || message.turnId === liveTurn.turnId) && message.text.trim()) return message.text;
-  }
-  return undefined;
-}
-
-export function WorkHubProgressCard({ ref, request, control, liveTurn, messages, busy, onOpen }: {
-  ref?: Ref<HTMLElement>;
-  request: number;
-  control?: WorkHubControlSnapshot;
-  liveTurn?: LiveTurnProjection;
-  messages: readonly StoredMessage[];
-  busy: boolean;
-  onOpen(): void;
-}) {
-  const { presentation } = useWorkHubServices();
-  const t = workHubLiveCopy[useUiLocale()];
-  const status = control?.phase === 'paused' ? t.progressPaused : control?.phase === 'error' ? t.progressError
-    : control?.status ?? (busy || control?.phase === 'acting' ? t.progressWorking : t.progressDone);
-  const spoken = latestText(liveTurn, messages)?.trim().split(/(?<=[。!?!?])\s*|(?<=\.)\s+|\n+/u).filter(Boolean).at(-1);
-  useEffect(() => {
-    let second = 0;
-    const first = requestAnimationFrame(() => {
-      second = requestAnimationFrame(() => { void presentation.progressReady(request).catch(console.error); });
-    });
-    return () => { cancelAnimationFrame(first); cancelAnimationFrame(second); };
-  }, [presentation, request]);
-  return <aside ref={ref} className="workHubProgressCard" aria-label={t.progressTitle}>
-    <div className="workHubProgressHeader">
-      <span className="workHubProgressBrand"><MakaWordmark width={42} /></span>
-      <span className="workHubProgressStatus" role="status"><i data-active={busy || control?.phase === 'acting'} />{status}</span>
-      <IconButton className="workHubProgressOpen" size="sm" variant="ghost" label={t.progressOpen} tooltip={t.progressOpen} icon={<ArrowRight size={12} />} onClick={onOpen} />
-      <IconButton className="workHubProgressClose" size="sm" variant="ghost" icon={<X size={12} />} label={t.progressClose} onClick={() => { void presentation.hide().catch(console.error); }} />
-    </div>
-    <p className="workHubProgressText">{spoken?.replace(/\s+/g, ' ').trim() || t.progressHint}</p>
-  </aside>;
-}
diff --git a/apps/desktop/src/renderer/features/workhub/ui/workhub-root.tsx b/apps/desktop/src/renderer/features/workhub/ui/workhub-root.tsx
index 8457199de2..fdcf55315c 100644
--- a/apps/desktop/src/renderer/features/workhub/ui/workhub-root.tsx
+++ b/apps/desktop/src/renderer/features/workhub/ui/workhub-root.tsx
@@ -17,390 +17,25 @@
  * under the License.
  */
 
-import { useEffect, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from 'react';
-import type { FeedbackInput } from '@maka/workhub/slots';
-import { ChatSurfaceLayout, UserQuestionPrompt, MakaWordmark, useUiLocale, type ComposerHandle } from '@maka/ui';
-import { Button, IconButton } from '@astryxdesign/core';
-import { ChevronDown, PictureInPicture2, Undo2, X } from '@maka/ui/icons';
-import { useLiveContextUsage } from '@maka/ui/context-usage';
-import { selectLatestRequestUsage } from '@maka/ui/context-usage';
-import { WorkHubProgressCard } from './workhub-progress-card.js';
-import { WorkHubComposer } from './workhub-composer.js';
-import { WorkHubConversation } from '@maka/workhub/conversation';
-import { FormInteractionPrompt } from '@maka/ui';
-import { getShellCopy } from '../../../locales/shell-copy.js';
-import { WorkbarEdgeToggle } from '../../../application/contracts/workbar-edge-toggle.js';
-import { WorkHubNavigationRail } from '@maka/workhub/conversation';
-import { useWorkHubHighlightState, WorkHubHighlightContext, WorkHubHueProvider } from '@maka/workhub/conversation';
-import { getWorkHubRailCopy } from '@maka/workhub/locales';
-import { useWorkHubController } from '@maka/workhub/controller';
+import { useMemo, type ComponentProps } from 'react';
+import { WorkHubRoot as Conversation, type WorkHubAttachmentServices, type WorkHubWindowServices } from '@maka/workhub/surface';
+import { getDesktopConversationCopy } from '../../../locales/conversation-copy.js';
+import { localizedShellErrorMessage } from '../../../locales/shell-copy.js';
 import { useWorkHubServices } from '../services.js';
-import type { WorkHubControlSnapshot } from '../../../../shared/workhub-control.js';
-import type { WorkHubPresentationSnapshot } from '../../../../shared/workhub-presentation.js';
-import { workHubLiveCopy } from '@maka/workhub/locales';
-import { applyWorkHubDelegationFeedback, workHubLinkedWork } from '@maka/workhub/model';
-import type { WorkHubDelegationFeedback } from '@maka/workhub/model';
 
-function cancelReveal(element: HTMLDivElement | null, content: HTMLDivElement | null) {
-  for (const target of [element, content]) for (const animation of target?.getAnimations() ?? []) animation.cancel();
-  content?.style.removeProperty('pointer-events');
-}
-
-function revealWordmark(element: HTMLDivElement | null, content: HTMLDivElement | null) {
-  cancelReveal(element, content);
-  if (!element || window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
-  element.animate([
-    { opacity: 0, transform: 'translateY(6px) scale(0.98)', offset: 0 },
-    { opacity: 0.9, transform: 'translateY(0) scale(1)', offset: 0.3 },
-    { opacity: 0.9, transform: 'translateY(0) scale(1)', offset: 0.5 },
-    { opacity: 0, transform: 'translateY(-3px) scale(1)', offset: 0.85 },
-    { opacity: 0, transform: 'translateY(-3px) scale(1)', offset: 1 },
-  ], { duration: 1200, easing: 'ease-out' });
-  if (content) {
-    // Non-compositable properties in the same effect force opacity onto the
-    // renderer thread. Keep the interaction gate outside the visual keyframes.
-    content.style.pointerEvents = 'none';
-    const reveal = content.animate([
-      { opacity: 0, offset: 0 },
-      { opacity: 0, offset: 0.65 },
-      { opacity: 1, offset: 1 },
-    ], { duration: 1200, easing: 'ease-in-out' });
-    reveal.id = 'workhub-reveal';
-    reveal.onfinish = () => {
-      if (!content.getAnimations().some((animation) => animation.id === 'workhub-reveal' && animation.playState === 'running')) content.style.removeProperty('pointer-events');
-    };
-  }
-}
-
-export function WorkHubRoot({ sessionId, feedback }: {
-  sessionId: string | undefined;
-  feedback?: (input: FeedbackInput) => ReactNode;
-}) {
-  const highlight = useWorkHubHighlightState();
-  const locale = useUiLocale();
+export function WorkHubRoot(props: Pick<ComponentProps<typeof Conversation>, 'sessionId' | 'feedback'>) {
   const services = useWorkHubServices();
-  const controller = useWorkHubController(sessionId, services, () => highlight.selectWork(undefined));
-  const { session, transcript, busy } = controller;
-  useEffect(() => {
-    services.bindBrowserSession(controller.sessionId ?? null);
-    return () => services.bindBrowserSession(null);
-  }, [services, controller.sessionId]);
-  const modelChoice = controller.choices.find((choice) =>
-    choice.connectionId === session?.llmConnectionId && choice.connectionSlug === session?.llmConnectionSlug && choice.model === session?.model,
-  );
-  const thinkingLevels = modelChoice?.thinkingLevels ?? [];
-  const liveContextUsage = useLiveContextUsage({ inspector: services.inspector, sessionId: controller.sessionId, model: session?.model, providerType: modelChoice?.providerType });
-  const thinkingLevel = session?.thinkingLevel && thinkingLevels.includes(session.thinkingLevel) ? session.thinkingLevel : undefined;
-  const t = workHubLiveCopy[locale];
-  const shortcutLabel = navigator.platform.toLowerCase().includes('mac') ? '⌘⇧K' : 'Ctrl+Shift+K';
-  const composer = useRef<ComposerHandle>(null);
-  const composerSurface = useRef<HTMLDivElement>(null);
-  const revealMark = useRef<HTMLDivElement>(null);
-  const history = useRef<HTMLDivElement>(null);
-  const hasPresented = useRef(false);
-  const progressHeader = useRef<HTMLElement>(null);
-  const surface = useRef<HTMLElement>(null);
-  const [editingProgressRequest, setEditingProgressRequest] = useState<number>();
-  const [expandedOverride, setConversationExpanded] = useState<boolean>();
-  const promptStates = new Map<string, import('@maka/workhub/model').WorkHubDelegationState>();
-  for (const message of transcript.messages) if (message.type === 'turn_state') promptStates.set(message.turnId, message.status);
-  for (const [turnId, state] of Object.entries(controller.turnStates)) promptStates.set(turnId, state);
-  if (controller.liveTurn && !controller.liveTurn.terminal) promptStates.set(controller.liveTurn.turnId, 'running');
-  if (controller.pendingTurnId && controller.sending) promptStates.set(controller.pendingTurnId, 'running');
-  if (controller.activeInteraction) promptStates.set(controller.activeInteraction.turnId, 'waiting_for_user');
-  const hasConversation = transcript.messages.length > 0 || busy || Boolean(controller.liveTurn);
-  const conversationExpanded = expandedOverride ?? hasConversation;
-  const hasConversationRef = useRef(hasConversation);
-  hasConversationRef.current = hasConversation;
-  const [expandedLayoutHeight, setExpandedLayoutHeight] = useState(720);
-  const [control, setControl] = useState<WorkHubControlSnapshot>();
-  const [presentation, setPresentation] = useState<WorkHubPresentationSnapshot>();
-  const progress = presentation?.progressRequest !== undefined;
-  const editingProgress = progress && editingProgressRequest === presentation.progressRequest;
-  const floating = presentation?.placement === 'floating';
-  useEffect(() => {
-    if (controller.activeQuestion || controller.activeForm) {
-      setConversationExpanded(true);
-
-    }
-  }, [controller.activeQuestion, controller.activeForm, presentation?.progressRequest]);
-  const showConversation = !progress && (!floating || conversationExpanded);
-  useLayoutEffect(() => {
-    const element = surface.current;
-    const unsubscribe = services.presentation.onViewportInset((inset) => {
-      element?.style.setProperty('--workhub-viewport-inset', `${inset}px`);
-    });
-    return () => {
-      unsubscribe();
-      element?.style.removeProperty('--workhub-viewport-inset');
-    };
-  }, [services]);
-  const dockMotion = useRef<{ floating: boolean; progress: boolean; expanded: boolean; padding: Keyframe; animation?: Animation }>(undefined);
-  useLayoutEffect(() => {
-    const dock = composerSurface.current?.parentElement?.parentElement;
-    if (!dock) return;
-    const readPadding = (): Keyframe => {
-      const style = getComputedStyle(dock);
-      return { paddingInlineStart: style.paddingInlineStart, paddingInlineEnd: style.paddingInlineEnd, paddingBottom: style.paddingBottom };
-    };
-    const previous = dockMotion.current;
-    const from = previous?.animation?.playState === 'running' ? readPadding() : previous?.padding;
-    previous?.animation?.cancel();
-    const padding = readPadding();
-    // Animate only a live expand/collapse. Summoning a parked renderer must
-    // paint its final gutter immediately; interrupted motion resumes in place.
-    const animation = floating && previous?.floating && !progress && !previous.progress && previous.expanded !== showConversation && from && !window.matchMedia('(prefers-reduced-motion: reduce)').matches
-      ? dock.animate([from, padding], { duration: 420, easing: 'cubic-bezier(0.22, 1, 0.36, 1)' })
-      : undefined;
-    dockMotion.current = { floating, progress, expanded: showConversation, padding, animation };
-  }, [floating, progress, showConversation]);
-  useEffect(() => () => dockMotion.current?.animation?.cancel(), []);
-  const editProgress = () => {
-    if (progress) setEditingProgressRequest(presentation.progressRequest);
-  };
-  const compactHeight = () => Math.ceil(composerSurface.current?.getBoundingClientRect().height ?? 96);
-  useLayoutEffect(() => {
-    if (!composerSurface.current) return;
-    const resize = () => {
-      surface.current?.style.setProperty('--workhub-composer-height', `${compactHeight()}px`);
-      void services.presentation.setConversationLayout({ expanded: conversationExpanded, compactHeight: compactHeight(), interactionPending: Boolean(controller.activeInteraction) }).catch(controller.report);
-      if (progress) {
-        const height = Math.ceil(progressHeader.current?.getBoundingClientRect().height ?? 80) + compactHeight() + 2;
-        void services.presentation.resizeProgress(presentation.progressRequest!, height).catch(controller.report);
-        return;
-      }
-    };
-    const observer = new ResizeObserver(resize);
-    observer.observe(composerSurface.current);
-    if (progressHeader.current) observer.observe(progressHeader.current);
-    resize();
-    return () => observer.disconnect();
-  }, [services, floating, conversationExpanded, presentation?.progressRequest, editingProgress, controller.activeInteraction]);
-  const previousInteraction = useRef<string | undefined>(undefined);
-  useLayoutEffect(() => {
-    const id = controller.activeInteraction?.requestId;
-    if (previousInteraction.current && !id && document.hasFocus() &&
-      (document.activeElement === document.body || composerSurface.current?.contains(document.activeElement))) {
-      composer.current?.focus();
-    }
-    previousInteraction.current = id;
-  }, [controller.activeInteraction?.requestId]);
-  const toggleConversation = () => {
-    if (conversationExpanded) {
-      cancelReveal(revealMark.current, history.current);
-      setExpandedLayoutHeight(surface.current?.querySelector('.maka-chat-layout')?.getBoundingClientRect().height ?? 0);
-      setConversationExpanded(false);
-    } else {
-      setConversationExpanded(true);
-    }
-    composer.current?.focus();
-  };
-  useEffect(() => {
-    let active = true;
-    const acceptPresentation = (next: WorkHubPresentationSnapshot) => {
-      if (!active) return;
-      if (next.progressRequest !== undefined) hasPresented.current = true;
-      if (next.progressRequest !== undefined || next.placement !== 'floating' || !next.floatingVisible) {
-        cancelReveal(revealMark.current, history.current);
-        for (const animation of composerSurface.current?.getAnimations() ?? []) animation.cancel();
-      }
-      if (!hasConversationRef.current && (next.placement === 'docked' || !next.floatingVisible)) setConversationExpanded(undefined);
-      setPresentation(next);
-    };
-    const unsubscribe = services.presentation.subscribe(acceptPresentation);
-    void services.presentation
-      .getSnapshot()
-      .then(acceptPresentation)
-      .catch(controller.report);
-    const acceptControl = (next: WorkHubControlSnapshot) => {
-      if (active)
-        setControl((previous) =>
-          !previous || next.revision >= previous.revision ? next : previous,
-        );
-    };
-    const unsubscribeControl = services.control.subscribe(acceptControl);
-    void services.control.getSnapshot().then(acceptControl).catch(controller.report);
-    const focus = services.presentation.onFocusComposer((expand) => {
-      if (expand) setConversationExpanded(true);
-      const choice = surface.current?.querySelector<HTMLElement>('.maka-choice-panel');
-      if (choice) {
-        if (!choice.contains(document.activeElement)) choice.focus();
-      } else composer.current?.focus();
-      // A warm summon must not fade the last painted frame back out.
-      if (hasPresented.current) return;
-      hasPresented.current = true;
-      if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
-      for (const element of [composerSurface.current]) {
-        for (const animation of element?.getAnimations() ?? []) animation.cancel();
-      }
-      composerSurface.current?.animate([
-        { opacity: 0.45, transform: 'translateY(8px)' },
-        { opacity: 1, transform: 'translateY(0)' },
-      ], { duration: 360, easing: 'cubic-bezier(0.16, 1, 0.3, 1)' });
-      revealWordmark(revealMark.current, history.current);
-    });
-    return () => {
-      active = false;
-      unsubscribe();
-      unsubscribeControl();
-      focus();
-    };
-  }, [services]);
-  const tasks = controller.sessions.filter((candidate) => candidate.id !== controller.sessionId && !candidate.labels.includes('mode:side_conversation') && !candidate.subagent).map((task) => ({
-    target: { sessionId: task.id }, projectName: task.cwd?.replace(/[/\\]+$/, '').split(/[/\\]/).at(-1) ?? '',
-    sessionName: task.name, archived: task.isArchived, state: task.status,
-    updatedAt: task.lastMessageAt ?? task.statusUpdatedAt ?? 0,
-  }));
-  const links = useMemo(() => workHubLinkedWork(transcript.messages, controller.sessions, getWorkHubRailCopy(locale).work), [transcript.messages, controller.sessions, locale]);
-  const [delegationFeedback, setDelegationFeedback] = useState<readonly WorkHubDelegationFeedback[]>([]);
-  const references = useMemo(() => links.flatMap((link) =>
-      link.targetMessageId ? [{
-        id: link.id,
-        targetSessionId: link.targetSessionId,
-        targetMessageId: link.targetMessageId,
-      }] : [],
-    ), [links]);
-  const linksWithFeedback = useMemo(
-    () => applyWorkHubDelegationFeedback(links, delegationFeedback),
-    [links, delegationFeedback],
-  );
-  const delegatedSessionIds = linksWithFeedback.map((link) => link.targetSessionId);
-  const call = (task: Promise<unknown>) => {
-    void task.catch(controller.report);
-  };
-  return (
-    <WorkHubHighlightContext.Provider value={highlight}>
-    {feedback?.({ locale, references, onFeedback: setDelegationFeedback, onError: controller.report })}
-    <WorkHubHueProvider sessionIds={[...tasks.map((task) => task.target.sessionId), ...delegatedSessionIds]}>
-    <section ref={surface} data-progress={progress} data-progress-editing={editingProgress} className="workHubLive workhub-surface" data-placement={presentation?.placement ?? 'docked'} data-conversation-expanded={showConversation} aria-label={t.title}>
-      {!floating && presentation?.workbar && <WorkbarEdgeToggle label={getShellCopy(locale).chrome[presentation.workbar.collapsed ? 'expandWorkbar' : 'collapseWorkbar']} {...presentation.workbar} onToggle={() => call(services.presentation.toggleWorkbar())} />}
-      {progress && <WorkHubProgressCard ref={progressHeader} request={presentation.progressRequest!} control={control} liveTurn={controller.liveTurn} messages={transcript.messages} busy={Boolean(controller.activeTurn) || controller.sending} onOpen={() => {
-        setConversationExpanded(true);
-        if (presentation.progressRequest !== undefined) call(services.presentation.expandProgress(presentation.progressRequest));
-      }} />}
-      {!progress && floating && conversationExpanded && <div className="workHubWindowControls">
-        <IconButton className="workHubCloseButton" type="button" size="sm" variant="ghost" icon={<X size={12} />} label={t.hide} onClick={() => call(services.presentation.hide())} />
-        <div className="workHubWindowActions">
-          <IconButton type="button" size="sm" variant="ghost" icon={<PictureInPicture2 size={14}><path d="m8 11-4-4m0 4V7h4" /></PictureInPicture2>} label={t.dock} onClick={() => call(services.presentation.dock())} />
-          <IconButton type="button" size="sm" variant="ghost" icon={<ChevronDown size={14} style={{ rotate: conversationExpanded ? '0deg' : '180deg' }} />} label={conversationExpanded ? t.collapseConversation : t.expandConversation} aria-expanded={conversationExpanded} onClick={toggleConversation} />
-        </div>
-      </div>}
-      <div className="workHubRevealMark" ref={revealMark} aria-hidden="true"><MakaWordmark width={192} /></div>
-      <div className="workHubWorkspace"><div className="mainColumn">
-      <ChatSurfaceLayout
-        scrollButton={showConversation ? undefined : null}
-        style={!showConversation ? { height: expandedLayoutHeight, flex: 'none', position: 'absolute', bottom: 0, width: '100%' } : undefined}
-        composer={
-          <div className="workHubComposerSurface" ref={composerSurface} onFocusCapture={editProgress} onPointerUpCapture={editProgress}>
-            {(controller.error || control?.error) && (
-              <div className="workHubLiveError" role="alert">
-                {controller.error ?? t.controlFailed}
-                {controller.canRetry && (
-                  <Button label={t.retry} variant="ghost" onClick={controller.retry} />
-                )}
-              </div>
-            )}
-            {controller.activeForm && <FormInteractionPrompt request={controller.activeForm} onRespond={controller.respondToUserForm} onStop={controller.stop} stopPending={controller.stopPending} />}
-            {controller.activeQuestion && <UserQuestionPrompt key={controller.activeQuestion.requestId}
-              request={controller.activeQuestion} onRespond={controller.respondToUserQuestion}
-              onStop={controller.stop} stopPending={controller.stopPending} />}
-            <div className="workHubComposerContent" hidden={Boolean(controller.activeQuestion || controller.activeForm)}>
-            <WorkHubComposer
-              pendingMessages={controller.transientMessages}
-              queuedMessages={controller.messageQueue.entries}
-              queuedMessageRevision={controller.messageQueue.revision}
-              onUpdateQueuedEntry={controller.updateQueuedEntry}
-              onDeleteQueuedEntry={controller.deleteQueuedEntry}
-              onPromoteQueuedEntry={controller.promoteQueuedEntry}
-              onReorderQueuedEntries={controller.reorderQueuedEntries}
-              placeholder={progress ? t.progressInput : t.welcome}
-              ref={composer}
-              sessionId={controller.sessionId}
-              streaming={busy}
-              sendBlocked={!controller.sessionId || controller.sending || !session?.model}
-              allowAttachmentImportWhileStreaming
-              stopPending={controller.stopPending}
-              onSend={async (text, attachments, followUpMode) => {
-                const accepted = await controller.send(text, attachments, followUpMode);
-                if (accepted) {
-                  setConversationExpanded(true);
-                  if (progress) call(services.presentation.expandProgress(presentation.progressRequest));
-                }
-                return accepted;
-              }}
-              onStop={controller.stop}
-              activeSession={session}
-              activeModel={session?.model}
-              activeModelLabel={modelChoice?.label}
-              activeProviderType={modelChoice?.providerType}
-              activeModelConnectionId={session?.llmConnectionId}
-              activeModelConnectionSlug={session?.llmConnectionSlug}
-              modelChoices={controller.choices}
-              pickerPresentation={showConversation ? 'popover' : 'wheel'}
-              pickersReadOnly={Boolean(controller.activeQuestion || controller.activeForm)}
-              maxInputRows={progress && !editingProgress ? 1 : showConversation ? undefined : 6}
-              onModelChange={controller.changeModel}
-              modelSwitchAvailability={controller.configuringModel ? { available: false, pending: true, reason: 'pending' } : undefined}
-              contextUsage={session ? {
-                usageTokens: liveContextUsage?.usageTokens ?? selectLatestRequestUsage(transcript.messages, session.model, session),
-                declaredContextWindow: modelChoice?.declaredContextWindow,
-                meteredContextWindow: liveContextUsage?.contextWindow,
-                metadataContextWindow: modelChoice?.contextWindow,
-                onOpen: () => call(services.presentation.openUsage()),
-              } : undefined}
-              activeThinkingLevels={thinkingLevels}
-              activeThinkingLevel={thinkingLevel}
-              onThinkingLevelChange={controller.changeThinkingLevel}
-              modelSwitchHasHistory={transcript.messages.length > 0}
-              footerAccessory={
-                <div className="workHubComposerActions">
-                  {control?.canUndo && <IconButton type="button" size="sm" variant="ghost" icon={<Undo2 size={16} />} label={t.undo} isDisabled={busy} onClick={() => call(services.control.undo())} />}
-                  {!floating && <IconButton type="button" size="sm" variant="ghost" icon={<PictureInPicture2 size={16} />} label={t.float} tooltip={`${t.float} · ${shortcutLabel}`} onClick={() => call(services.presentation.detach())} />}
-                </div>
-              }
-            />
-            {!progress && floating && !conversationExpanded && (
-              <IconButton className="workHubExpandButton" type="button" size="sm" variant="ghost" icon={<ChevronDown size={14} style={{ rotate: '180deg' }} />} label={t.expandConversation} aria-expanded={false} onClick={toggleConversation} />
-            )}
-            </div>
-          </div>
-        }
-      >
-        <div ref={history} className="workHubHistory" aria-hidden={!showConversation} inert={!showConversation}>
-        <div className="workhub-body">
-        <WorkHubNavigationRail locale={locale} sessions={tasks} delegatedSessionIds={delegatedSessionIds} copy={getWorkHubRailCopy(locale)} />
-        <div className="workhub-conversation-shell">
-        <WorkHubConversation
-          promptStates={promptStates}
-          workLinks={linksWithFeedback}
-          onReadAttachmentBytes={services.readAttachmentBytes}
-          onOpenWork={(id) => call(services.presentation.openSession(id))}
-          scrollBehavior="auto"
-          onNew={() => composer.current?.focus()}
-          messages={[...transcript.messages]}
-          hasEarlierHistory={transcript.hasOlder}
-          onLoadEarlierHistory={controller.loadEarlier}
-          transientMessages={controller.transientMessages}
-          viewportNavigation={controller.viewportNavigation}
-          liveTurns={controller.liveTurns}
-          onStreamingSettled={controller.streamingSettled}
-          activeTurn={controller.activeTurn}
-          messageLoading={!transcript.ready}
-          activeSession={session}
-          activeModel={session?.model}
-          emptyOverride={
-            <div className="workHubLiveWelcome">
-              <MakaWordmark width={112} />
-              <p>{t.hint}</p>
-            </div>
-          }
-        />
-        </div></div>
-        </div>
-      </ChatSurfaceLayout>
-      </div></div>
-    </section>
-    </WorkHubHueProvider>
-    </WorkHubHighlightContext.Provider>
-  );
+  const native = useMemo<WorkHubWindowServices>(() => ({
+    presentation: services.presentation,
+    control: services.control,
+    bindBrowserSession: services.bindBrowserSession,
+  }), [services]);
+  const attachments = useMemo<WorkHubAttachmentServices>(() => ({
+    staging: services.attachments,
+    read: services.readAttachmentBytes,
+    prepare: services.prepareAttachments,
+    copy: (locale) => getDesktopConversationCopy(locale).actions,
+    formatError: localizedShellErrorMessage,
+  }), [services]);
+  return <Conversation {...props} sessions={services} native={native} attachments={attachments} contextUsage={services.inspector} />;
 }
diff --git a/apps/desktop/src/shared/workhub-control.d.ts b/apps/desktop/src/shared/workhub-control.d.ts
index 638c5109b4..2c29829a3e 100644
--- a/apps/desktop/src/shared/workhub-control.d.ts
+++ b/apps/desktop/src/shared/workhub-control.d.ts
@@ -17,23 +17,4 @@
  * under the License.
  */
 
-export interface WorkHubControlSnapshot {
-  readonly revision: number;
-  readonly phase: 'idle' | 'acting' | 'paused' | 'error';
-  readonly canUndo: boolean;
-  readonly status?: string;
-  readonly error?: string;
-  readonly cursor?: {
-    readonly x: number;
-    readonly y: number;
-    readonly clicking: boolean;
-    readonly durationMs?: number;
-  };
-}
-
-export interface WorkHubControlBridge {
-  getSnapshot(): Promise<WorkHubControlSnapshot>;
-  stop(): Promise<void>;
-  undo(): Promise<void>;
-  subscribe(handler: (snapshot: WorkHubControlSnapshot) => void): () => void;
-}
+export type { WorkHubControlSnapshot, WorkHubControlBridge } from '@maka/workhub/native';
diff --git a/apps/desktop/src/shared/workhub-presentation.d.ts b/apps/desktop/src/shared/workhub-presentation.d.ts
index 4c5f2df215..1c5fe9ac52 100644
--- a/apps/desktop/src/shared/workhub-presentation.d.ts
+++ b/apps/desktop/src/shared/workhub-presentation.d.ts
@@ -17,55 +17,7 @@
  * under the License.
  */
 
-export interface WorkHubHostRect {
-  readonly x: number;
-  readonly y: number;
-  readonly width: number;
-  readonly height: number;
-}
-
-export interface WorkHubWorkbarState {
-  readonly collapsed: boolean;
-  readonly placement: 'right' | 'bottom';
-}
-
-export interface WorkHubHost {
-  readonly visible: boolean;
-  readonly occluded?: boolean;
-  readonly workbar?: WorkHubWorkbarState;
-  readonly rect: WorkHubHostRect;
-}
-
-export interface WorkHubPresentationSnapshot {
-  readonly placement: 'docked' | 'floating';
-  readonly floatingVisible: boolean;
-  readonly shortcutRegistered: boolean;
-  readonly rendererCrashed: boolean;
-  readonly progressRequest?: number;
-  readonly workbar?: WorkHubWorkbarState;
-}
-
-export type WorkHubMainNavigation =
-  | { readonly kind: 'workhub'; readonly panelAction?: 'usage' | 'toggle' }
-  | { readonly kind: 'session'; readonly sessionKey: string };
-
-export interface WorkHubPresentationBridge {
-  ready(): Promise<void>;
-  getSnapshot(): Promise<WorkHubPresentationSnapshot>;
-  setHost(host: WorkHubHost): Promise<string | void>;
-  setConversationLayout(layout: { expanded: boolean; compactHeight: number; interactionPending?: boolean }): Promise<void>;
-  progressReady(request: number): Promise<void>;
-  resizeProgress(request: number, height: number): Promise<void>;
-  expandProgress(progressRequest: number): Promise<void>;
-  detach(): Promise<void>;
-  dock(): Promise<void>;
-  hide(): Promise<void>;
-  openUsage(): Promise<void>;
-  toggleWorkbar(): Promise<void>;
-  openSession(sessionKey: string): Promise<void>;
-  subscribe(handler: (snapshot: WorkHubPresentationSnapshot) => void): () => void;
-  /** Visible top edge inside the animation canvas, in CSS pixels. */
-  onViewportInset(handler: (inset: number) => void): () => void;
-  onFocusComposer(handler: (expand?: boolean) => void): () => void;
-  onOpenMain(handler: (navigation: WorkHubMainNavigation) => void): () => void;
-}
+export type {
+  WorkHubHost, WorkHubPresentationSnapshot,
+  WorkHubMainNavigation, WorkHubPresentationBridge,
+} from '@maka/workhub/native';
diff --git a/packages/ui/package.json b/packages/ui/package.json
index 0fef37dfba..7507e75e09 100644
--- a/packages/ui/package.json
+++ b/packages/ui/package.json
@@ -7,6 +7,7 @@
   "main": "./dist/index.js",
   "types": "./dist/index.d.ts",
   "exports": {
+    "./workbar-edge-toggle": "./dist/workbar-edge-toggle.js",
     "./context-usage": "./dist/context-usage.js",
     "./session-execution": "./dist/session-execution.js",
     "./plugin": "./dist/plugin.js",
diff --git a/apps/desktop/src/renderer/application/contracts/workbar-edge-toggle.tsx b/packages/ui/src/workbar-edge-toggle.tsx
similarity index 96%
rename from apps/desktop/src/renderer/application/contracts/workbar-edge-toggle.tsx
rename to packages/ui/src/workbar-edge-toggle.tsx
index ebcc486399..528ff5d4cf 100644
--- a/apps/desktop/src/renderer/application/contracts/workbar-edge-toggle.tsx
+++ b/packages/ui/src/workbar-edge-toggle.tsx
@@ -18,7 +18,7 @@
  */
 
 import { Button } from '@astryxdesign/core/Button';
-import { ChevronLeft, ChevronRight } from '@maka/ui/icons';
+import { ChevronLeft, ChevronRight } from './icons.js';
 
 /** An edge affordance shared by the collapsed and expanded workspace. */
 export function WorkbarEdgeToggle(props: { collapsed: boolean; label: string; placement?: 'right' | 'bottom'; onToggle(): void }) {
diff --git a/packages/workhub/package.json b/packages/workhub/package.json
index d508dfbdcc..17da946c6a 100644
--- a/packages/workhub/package.json
+++ b/packages/workhub/package.json
@@ -5,6 +5,8 @@
   "private": true,
   "type": "module",
   "exports": {
+    "./surface": "./dist/surface.js",
+    "./native": "./dist/native.js",
     "./controller": "./dist/controller.js",
     "./conversation": "./dist/conversation.js",
     "./model": "./dist/model.js",
diff --git a/packages/workhub/src/locales/workhub-live-copy.ts b/packages/workhub/src/locales/workhub-live-copy.ts
index 667dc74076..d888d65c22 100644
--- a/packages/workhub/src/locales/workhub-live-copy.ts
+++ b/packages/workhub/src/locales/workhub-live-copy.ts
@@ -20,6 +20,8 @@
 import type { UiCatalog } from '@maka/core/ui-locale';
 export const workHubLiveCopy = {
   en: {
+    expandWorkbar: 'Expand task workbar',
+    collapseWorkbar: 'Collapse task workbar',
     filterConversation: 'Filter conversation by Work',
     clearConversationFilter: 'Show all conversations',
     noWorkConversation: 'No conversations for this Work in this part of history.',
@@ -70,6 +72,8 @@ export const workHubLiveCopy = {
     openResult: 'Open result',
   },
   'zh-CN': {
+    expandWorkbar: '展开任务工作栏',
+    collapseWorkbar: '收起任务工作栏',
     filterConversation: '筛选此 Work 的对话',
     clearConversationFilter: '显示全部对话',
     noWorkConversation: '这段历史中没有此 Work 的对话。',
@@ -117,6 +121,8 @@ export const workHubLiveCopy = {
     openResult: '打开结果',
   },
   'zh-TW': {
+    expandWorkbar: '展開任務工作欄',
+    collapseWorkbar: '收起任務工作欄',
     filterConversation: '篩選此 Work 的對話',
     clearConversationFilter: '顯示全部對話',
     noWorkConversation: '這段歷史中沒有此 Work 的對話。',
diff --git a/apps/desktop/src/shared/workhub-presentation.d.ts b/packages/workhub/src/native.ts
similarity index 78%
copy from apps/desktop/src/shared/workhub-presentation.d.ts
copy to packages/workhub/src/native.ts
index 4c5f2df215..4cd21f85ec 100644
--- a/apps/desktop/src/shared/workhub-presentation.d.ts
+++ b/packages/workhub/src/native.ts
@@ -53,7 +53,11 @@ export interface WorkHubPresentationBridge {
   ready(): Promise<void>;
   getSnapshot(): Promise<WorkHubPresentationSnapshot>;
   setHost(host: WorkHubHost): Promise<string | void>;
-  setConversationLayout(layout: { expanded: boolean; compactHeight: number; interactionPending?: boolean }): Promise<void>;
+  setConversationLayout(layout: {
+    expanded: boolean;
+    compactHeight: number;
+    interactionPending?: boolean;
+  }): Promise<void>;
   progressReady(request: number): Promise<void>;
   resizeProgress(request: number, height: number): Promise<void>;
   expandProgress(progressRequest: number): Promise<void>;
@@ -69,3 +73,24 @@ export interface WorkHubPresentationBridge {
   onFocusComposer(handler: (expand?: boolean) => void): () => void;
   onOpenMain(handler: (navigation: WorkHubMainNavigation) => void): () => void;
 }
+
+export interface WorkHubControlSnapshot {
+  readonly revision: number;
+  readonly phase: 'idle' | 'acting' | 'paused' | 'error';
+  readonly canUndo: boolean;
+  readonly status?: string;
+  readonly error?: string;
+  readonly cursor?: {
+    readonly x: number;
+    readonly y: number;
+    readonly clicking: boolean;
+    readonly durationMs?: number;
+  };
+}
+
+export interface WorkHubControlBridge {
+  getSnapshot(): Promise<WorkHubControlSnapshot>;
+  stop(): Promise<void>;
+  undo(): Promise<void>;
+  subscribe(handler: (snapshot: WorkHubControlSnapshot) => void): () => void;
+}
diff --git a/apps/desktop/src/shared/workhub-control.d.ts b/packages/workhub/src/surface.ts
similarity index 58%
copy from apps/desktop/src/shared/workhub-control.d.ts
copy to packages/workhub/src/surface.ts
index 638c5109b4..3905fe935e 100644
--- a/apps/desktop/src/shared/workhub-control.d.ts
+++ b/packages/workhub/src/surface.ts
@@ -17,23 +17,5 @@
  * under the License.
  */
 
-export interface WorkHubControlSnapshot {
-  readonly revision: number;
-  readonly phase: 'idle' | 'acting' | 'paused' | 'error';
-  readonly canUndo: boolean;
-  readonly status?: string;
-  readonly error?: string;
-  readonly cursor?: {
-    readonly x: number;
-    readonly y: number;
-    readonly clicking: boolean;
-    readonly durationMs?: number;
-  };
-}
-
-export interface WorkHubControlBridge {
-  getSnapshot(): Promise<WorkHubControlSnapshot>;
-  stop(): Promise<void>;
-  undo(): Promise<void>;
-  subscribe(handler: (snapshot: WorkHubControlSnapshot) => void): () => void;
-}
+export { WorkHubRoot, type WorkHubRootProps } from './ui/workhub-root.js';
+export type { WorkHubAttachmentServices, WorkHubWindowServices } from './ui/ports.js';
diff --git a/packages/workhub/src/ui/ports.ts b/packages/workhub/src/ui/ports.ts
new file mode 100644
index 0000000000..6ad7ed524e
--- /dev/null
+++ b/packages/workhub/src/ui/ports.ts
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import type { AttachmentRef } from '@maka/core/events';
+import type { ArtifactBinaryReadResult } from '@maka/core/artifacts';
+import type { UiLocale } from '@maka/core/ui-locale';
+import type {
+  ComposerAttachmentService,
+  ComposerAttachmentCopy,
+} from '@maka/ui/use-composer-attachments';
+import type { WorkHubControlBridge, WorkHubPresentationBridge } from '../native.js';
+
+/** Window operations used by the conversation, not window ownership or creation. */
+export interface WorkHubWindowServices {
+  presentation: Pick<
+    WorkHubPresentationBridge,
+    | 'getSnapshot'
+    | 'setConversationLayout'
+    | 'progressReady'
+    | 'resizeProgress'
+    | 'expandProgress'
+    | 'detach'
+    | 'dock'
+    | 'hide'
+    | 'openUsage'
+    | 'toggleWorkbar'
+    | 'openSession'
+    | 'subscribe'
+    | 'onViewportInset'
+    | 'onFocusComposer'
+  >;
+  control: WorkHubControlBridge;
+  bindBrowserSession(sessionId: string | null): void;
+}
+
+export interface WorkHubAttachmentServices {
+  staging: ComposerAttachmentService;
+  read(sessionId: string, artifactId: string): Promise<ArtifactBinaryReadResult>;
+  prepare(
+    sessionId: string,
+    items: Array<{ approvalId: string; name: string; mimeType?: string } | { file: File }>,
+  ): Promise<AttachmentRef[]>;
+  copy(locale: UiLocale): ComposerAttachmentCopy;
+  formatError(error: unknown, fallback: string, locale: UiLocale): string;
+}
diff --git a/packages/workhub/src/ui/workhub-composer.tsx b/packages/workhub/src/ui/workhub-composer.tsx
new file mode 100644
index 0000000000..3b212f99c9
--- /dev/null
+++ b/packages/workhub/src/ui/workhub-composer.tsx
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { forwardRef, useRef, useState } from 'react';
+import { Composer, useToast, useUiLocale, type ComposerHandle, type ComposerProps } from '@maka/ui';
+import { useComposerAttachments } from '@maka/ui/use-composer-attachments';
+import { toComposerIngestItems } from '@maka/ui/composer-attachments';
+import { MAX_ATTACHMENT_BYTES, MAX_ATTACHMENT_COUNT } from '@maka/core/attachments';
+import type { AttachmentRef, FollowUpMode } from '@maka/core/events';
+import type { WorkHubAttachmentServices } from './ports.js';
+import { workHubLiveCopy } from '../locales.js';
+
+export type WorkHubComposerProps = Omit<ComposerProps, 'onSend' | 'draftKey'> & {
+  sessionId?: string;
+  attachments: WorkHubAttachmentServices;
+  onSend(text: string, attachments: AttachmentRef[], followUpMode?: FollowUpMode): Promise<boolean>;
+};
+
+/** The shared Composer and attachment lifecycle belong to the persistent coordination Session. */
+export const WorkHubComposer = forwardRef<ComposerHandle, WorkHubComposerProps>(
+  function WorkHubComposer({ sessionId, attachments: service, onSend, ...composer }, ref) {
+    const locale = useUiLocale();
+    const t = workHubLiveCopy[locale];
+    const toast = useToast();
+    // First resolution adopts the already editable draft. Temporary Host
+    // unavailability keeps it; switching Hosts selects a separate draft.
+    const draftOwner = useRef({ first: sessionId, latest: sessionId });
+    if (sessionId) {
+      draftOwner.current.first ??= sessionId;
+      draftOwner.current.latest = sessionId;
+    }
+    const scope = `workhub:${draftOwner.current.latest === draftOwner.current.first ? 'initial' : draftOwner.current.latest}`;
+    const currentSessionId = useRef(sessionId);
+    currentSessionId.current = sessionId;
+    const [submitting, setSubmitting] = useState(false);
+    const submittingRef = useRef(false);
+    const staged = useComposerAttachments({
+      draftKey: scope,
+      toastApi: toast,
+      service: service.staging,
+      copy: service.copy(locale),
+      formatError: (error, fallback) => service.formatError(error, fallback, locale),
+    });
+    const uploaded = useRef(new Map<string, AttachmentRef>());
+    return (
+      <Composer
+        {...composer}
+        ref={ref}
+        draftKey={scope}
+        sendBlocked={composer.sendBlocked || submitting || !sessionId}
+        allowAttachmentOnlySend
+        pendingAttachments={staged.pendingAttachments}
+        onPickAttachments={staged.pickAttachments}
+        onAttachFilePaths={staged.attachFilePaths}
+        onRemoveAttachment={staged.removeAttachment}
+        onSend={async (text, metadata) => {
+          if (!sessionId || submittingRef.current || composer.sendBlocked) return false;
+          const snapshot = [...staged.pendingAttachments];
+          submittingRef.current = true;
+          setSubmitting(true);
+          try {
+            if (
+              snapshot.length > MAX_ATTACHMENT_COUNT ||
+              snapshot.some((item) => item.size > MAX_ATTACHMENT_BYTES)
+            ) {
+              throw new Error(t.attachmentLimit);
+            }
+            const attachments: AttachmentRef[] = [];
+            for (const item of snapshot) {
+              const key = `${scope}:${item.stagingKey}`;
+              let attachment = uploaded.current.get(key);
+              if (!attachment) {
+                [attachment] = await service.prepare(sessionId, toComposerIngestItems([item]));
+                if (!attachment) throw new Error(t.attachmentUploadFailed);
+                uploaded.current.set(key, attachment);
+              }
+              attachments.push(attachment);
+            }
+            // A Host switch during an upload must never submit the old draft into its successor.
+            if (currentSessionId.current !== sessionId) return false;
+            const accepted = await onSend(
+              text.trim() || t.reviewAttachments,
+              attachments,
+              metadata?.followUpMode,
+            );
+            if (accepted) {
+              staged.clearSubmittedAttachments(snapshot);
+              for (const item of snapshot) uploaded.current.delete(`${scope}:${item.stagingKey}`);
+            }
+            return accepted;
+          } catch (error) {
+            toast.error(t.sendFailed, service.formatError(error, t.retry, locale));
+            return false;
+          } finally {
+            submittingRef.current = false;
+            setSubmitting(false);
+          }
+        }}
+      />
+    );
+  },
+);
diff --git a/packages/workhub/src/ui/workhub-progress-card.tsx b/packages/workhub/src/ui/workhub-progress-card.tsx
new file mode 100644
index 0000000000..fa22dee03e
--- /dev/null
+++ b/packages/workhub/src/ui/workhub-progress-card.tsx
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { useEffect, type Ref } from 'react';
+import { IconButton } from '@astryxdesign/core';
+import { MakaWordmark, useUiLocale, type LiveTurnProjection } from '@maka/ui';
+import { ArrowRight, X } from '@maka/ui/icons';
+import type { StoredMessage } from '@maka/core/session';
+import type { WorkHubControlSnapshot } from '../native.js';
+import type { WorkHubWindowServices } from './ports.js';
+import { workHubLiveCopy } from '../locales.js';
+
+function latestText(
+  liveTurn: LiveTurnProjection | undefined,
+  messages: readonly StoredMessage[],
+): string | undefined {
+  for (let index = (liveTurn?.steps.length ?? 0) - 1; index >= 0; index--) {
+    const text = liveTurn!.steps[index]?.text?.text;
+    if (text?.trim()) return text;
+  }
+  for (let index = messages.length - 1; index >= 0; index--) {
+    const message = messages[index]!;
+    if (
+      message.type === 'assistant' &&
+      (!liveTurn || message.turnId === liveTurn.turnId) &&
+      message.text.trim()
+    )
+      return message.text;
+  }
+  return undefined;
+}
+
+export function WorkHubProgressCard({
+  ref,
+  request,
+  presentation,
+  control,
+  liveTurn,
+  messages,
+  busy,
+  onOpen,
+}: {
+  ref?: Ref<HTMLElement>;
+  request: number;
+  presentation: Pick<WorkHubWindowServices['presentation'], 'progressReady' | 'hide'>;
+  control?: WorkHubControlSnapshot;
+  liveTurn?: LiveTurnProjection;
+  messages: readonly StoredMessage[];
+  busy: boolean;
+  onOpen(): void;
+}) {
+  const t = workHubLiveCopy[useUiLocale()];
+  const status =
+    control?.phase === 'paused'
+      ? t.progressPaused
+      : control?.phase === 'error'
+        ? t.progressError
+        : (control?.status ??
+          (busy || control?.phase === 'acting' ? t.progressWorking : t.progressDone));
+  const spoken = latestText(liveTurn, messages)
+    ?.trim()
+    .split(/(?<=[。!?!?])\s*|(?<=\.)\s+|\n+/u)
+    .filter(Boolean)
+    .at(-1);
+  useEffect(() => {
+    let second = 0;
+    const first = requestAnimationFrame(() => {
+      second = requestAnimationFrame(() => {
+        void presentation.progressReady(request).catch(console.error);
+      });
+    });
+    return () => {
+      cancelAnimationFrame(first);
+      cancelAnimationFrame(second);
+    };
+  }, [presentation, request]);
+  return (
+    <aside ref={ref} className="workHubProgressCard" aria-label={t.progressTitle}>
+      <div className="workHubProgressHeader">
+        <span className="workHubProgressBrand">
+          <MakaWordmark width={42} />
+        </span>
+        <span className="workHubProgressStatus" role="status">
+          <i data-active={busy || control?.phase === 'acting'} />
+          {status}
+        </span>
+        <IconButton
+          className="workHubProgressOpen"
+          size="sm"
+          variant="ghost"
+          label={t.progressOpen}
+          tooltip={t.progressOpen}
+          icon={<ArrowRight size={12} />}
+          onClick={onOpen}
+        />
+        <IconButton
+          className="workHubProgressClose"
+          size="sm"
+          variant="ghost"
+          icon={<X size={12} />}
+          label={t.progressClose}
+          onClick={() => {
+            void presentation.hide().catch(console.error);
+          }}
+        />
+      </div>
+      <p className="workHubProgressText">{spoken?.replace(/\s+/g, ' ').trim() || t.progressHint}</p>
+    </aside>
+  );
+}
diff --git a/packages/workhub/src/ui/workhub-root.tsx b/packages/workhub/src/ui/workhub-root.tsx
new file mode 100644
index 0000000000..2876d9807e
--- /dev/null
+++ b/packages/workhub/src/ui/workhub-root.tsx
@@ -0,0 +1,700 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { useEffect, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from 'react';
+import type { FeedbackInput } from '../slots.js';
+import {
+  ChatSurfaceLayout,
+  UserQuestionPrompt,
+  MakaWordmark,
+  useUiLocale,
+  type ComposerHandle,
+} from '@maka/ui';
+import { Button, IconButton } from '@astryxdesign/core';
+import { ChevronDown, PictureInPicture2, Undo2, X } from '@maka/ui/icons';
+import { useLiveContextUsage } from '@maka/ui/context-usage';
+import { selectLatestRequestUsage } from '@maka/ui/context-usage';
+import { WorkHubProgressCard } from './workhub-progress-card.js';
+import { WorkHubComposer } from './workhub-composer.js';
+import { WorkHubConversation } from '../conversation.js';
+import { FormInteractionPrompt } from '@maka/ui';
+import { WorkbarEdgeToggle } from '@maka/ui/workbar-edge-toggle';
+import { WorkHubNavigationRail } from '../conversation.js';
+import {
+  useWorkHubHighlightState,
+  WorkHubHighlightContext,
+  WorkHubHueProvider,
+} from '../conversation.js';
+import { getWorkHubRailCopy } from '../locales.js';
+import { useWorkHubController } from '../controller.js';
+import type { CoordinationSessionServices } from '../controller.js';
+import type { ContextUsageService } from '@maka/ui/context-usage';
+import type { WorkHubAttachmentServices, WorkHubWindowServices } from './ports.js';
+import type { WorkHubControlSnapshot } from '../native.js';
+import type { WorkHubPresentationSnapshot } from '../native.js';
+import { workHubLiveCopy } from '../locales.js';
+import { applyWorkHubDelegationFeedback, workHubLinkedWork } from '../model.js';
+import type { WorkHubDelegationFeedback } from '../model.js';
+
+function cancelReveal(element: HTMLDivElement | null, content: HTMLDivElement | null) {
+  for (const target of [element, content])
+    for (const animation of target?.getAnimations() ?? []) animation.cancel();
+  content?.style.removeProperty('pointer-events');
+}
+
+function revealWordmark(element: HTMLDivElement | null, content: HTMLDivElement | null) {
+  cancelReveal(element, content);
+  if (!element || window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
+  element.animate(
+    [
+      { opacity: 0, transform: 'translateY(6px) scale(0.98)', offset: 0 },
+      { opacity: 0.9, transform: 'translateY(0) scale(1)', offset: 0.3 },
+      { opacity: 0.9, transform: 'translateY(0) scale(1)', offset: 0.5 },
+      { opacity: 0, transform: 'translateY(-3px) scale(1)', offset: 0.85 },
+      { opacity: 0, transform: 'translateY(-3px) scale(1)', offset: 1 },
+    ],
+    { duration: 1200, easing: 'ease-out' },
+  );
+  if (content) {
+    // Non-compositable properties in the same effect force opacity onto the
+    // renderer thread. Keep the interaction gate outside the visual keyframes.
+    content.style.pointerEvents = 'none';
+    const reveal = content.animate(
+      [
+        { opacity: 0, offset: 0 },
+        { opacity: 0, offset: 0.65 },
+        { opacity: 1, offset: 1 },
+      ],
+      { duration: 1200, easing: 'ease-in-out' },
+    );
+    reveal.id = 'workhub-reveal';
+    reveal.onfinish = () => {
+      if (
+        !content
+          .getAnimations()
+          .some(
+            (animation) => animation.id === 'workhub-reveal' && animation.playState === 'running',
+          )
+      )
+        content.style.removeProperty('pointer-events');
+    };
+  }
+}
+
+export interface WorkHubRootProps {
+  sessionId: string | undefined;
+  sessions: CoordinationSessionServices;
+  native: WorkHubWindowServices;
+  attachments: WorkHubAttachmentServices;
+  contextUsage: ContextUsageService;
+  feedback?: (input: FeedbackInput) => ReactNode;
+}
+
+export function WorkHubRoot({
+  sessionId,
+  sessions,
+  native,
+  attachments,
+  contextUsage,
+  feedback,
+}: WorkHubRootProps) {
+  const highlight = useWorkHubHighlightState();
+  const locale = useUiLocale();
+  const controller = useWorkHubController(sessionId, sessions, () =>
+    highlight.selectWork(undefined),
+  );
+  const { session, transcript, busy } = controller;
+  useEffect(() => {
+    native.bindBrowserSession(controller.sessionId ?? null);
+    return () => native.bindBrowserSession(null);
+  }, [native, controller.sessionId]);
+  const modelChoice = controller.choices.find(
+    (choice) =>
+      choice.connectionId === session?.llmConnectionId &&
+      choice.connectionSlug === session?.llmConnectionSlug &&
+      choice.model === session?.model,
+  );
+  const thinkingLevels = modelChoice?.thinkingLevels ?? [];
+  const liveContextUsage = useLiveContextUsage({
+    inspector: contextUsage,
+    sessionId: controller.sessionId,
+    model: session?.model,
+    providerType: modelChoice?.providerType,
+  });
+  const thinkingLevel =
+    session?.thinkingLevel && thinkingLevels.includes(session.thinkingLevel)
+      ? session.thinkingLevel
+      : undefined;
+  const t = workHubLiveCopy[locale];
+  const shortcutLabel = navigator.platform.toLowerCase().includes('mac') ? '⌘⇧K' : 'Ctrl+Shift+K';
+  const composer = useRef<ComposerHandle>(null);
+  const composerSurface = useRef<HTMLDivElement>(null);
+  const revealMark = useRef<HTMLDivElement>(null);
+  const history = useRef<HTMLDivElement>(null);
+  const hasPresented = useRef(false);
+  const progressHeader = useRef<HTMLElement>(null);
+  const surface = useRef<HTMLElement>(null);
+  const [editingProgressRequest, setEditingProgressRequest] = useState<number>();
+  const [expandedOverride, setConversationExpanded] = useState<boolean>();
+  const promptStates = new Map<string, import('../model.js').WorkHubDelegationState>();
+  for (const message of transcript.messages)
+    if (message.type === 'turn_state') promptStates.set(message.turnId, message.status);
+  for (const [turnId, state] of Object.entries(controller.turnStates))
+    promptStates.set(turnId, state);
+  if (controller.liveTurn && !controller.liveTurn.terminal)
+    promptStates.set(controller.liveTurn.turnId, 'running');
+  if (controller.pendingTurnId && controller.sending)
+    promptStates.set(controller.pendingTurnId, 'running');
+  if (controller.activeInteraction)
+    promptStates.set(controller.activeInteraction.turnId, 'waiting_for_user');
+  const hasConversation = transcript.messages.length > 0 || busy || Boolean(controller.liveTurn);
+  const conversationExpanded = expandedOverride ?? hasConversation;
+  const hasConversationRef = useRef(hasConversation);
+  hasConversationRef.current = hasConversation;
+  const [expandedLayoutHeight, setExpandedLayoutHeight] = useState(720);
+  const [control, setControl] = useState<WorkHubControlSnapshot>();
+  const [presentation, setPresentation] = useState<WorkHubPresentationSnapshot>();
+  const progress = presentation?.progressRequest !== undefined;
+  const editingProgress = progress && editingProgressRequest === presentation.progressRequest;
+  const floating = presentation?.placement === 'floating';
+  useEffect(() => {
+    if (controller.activeQuestion || controller.activeForm) {
+      setConversationExpanded(true);
+    }
+  }, [controller.activeQuestion, controller.activeForm, presentation?.progressRequest]);
+  const showConversation = !progress && (!floating || conversationExpanded);
+  useLayoutEffect(() => {
+    const element = surface.current;
+    const unsubscribe = native.presentation.onViewportInset((inset) => {
+      element?.style.setProperty('--workhub-viewport-inset', `${inset}px`);
+    });
+    return () => {
+      unsubscribe();
+      element?.style.removeProperty('--workhub-viewport-inset');
+    };
+  }, [native]);
+  const dockMotion = useRef<{
+    floating: boolean;
+    progress: boolean;
+    expanded: boolean;
+    padding: Keyframe;
+    animation?: Animation;
+  }>(undefined);
+  useLayoutEffect(() => {
+    const dock = composerSurface.current?.parentElement?.parentElement;
+    if (!dock) return;
+    const readPadding = (): Keyframe => {
+      const style = getComputedStyle(dock);
+      return {
+        paddingInlineStart: style.paddingInlineStart,
+        paddingInlineEnd: style.paddingInlineEnd,
+        paddingBottom: style.paddingBottom,
+      };
+    };
+    const previous = dockMotion.current;
+    const from = previous?.animation?.playState === 'running' ? readPadding() : previous?.padding;
+    previous?.animation?.cancel();
+    const padding = readPadding();
+    // Animate only a live expand/collapse. Summoning a parked renderer must
+    // paint its final gutter immediately; interrupted motion resumes in place.
+    const animation =
+      floating &&
+      previous?.floating &&
+      !progress &&
+      !previous.progress &&
+      previous.expanded !== showConversation &&
+      from &&
+      !window.matchMedia('(prefers-reduced-motion: reduce)').matches
+        ? dock.animate([from, padding], { duration: 420, easing: 'cubic-bezier(0.22, 1, 0.36, 1)' })
+        : undefined;
+    dockMotion.current = { floating, progress, expanded: showConversation, padding, animation };
+  }, [floating, progress, showConversation]);
+  useEffect(() => () => dockMotion.current?.animation?.cancel(), []);
+  const editProgress = () => {
+    if (progress) setEditingProgressRequest(presentation.progressRequest);
+  };
+  const compactHeight = () =>
+    Math.ceil(composerSurface.current?.getBoundingClientRect().height ?? 96);
+  useLayoutEffect(() => {
+    if (!composerSurface.current) return;
+    const resize = () => {
+      surface.current?.style.setProperty('--workhub-composer-height', `${compactHeight()}px`);
+      void native.presentation
+        .setConversationLayout({
+          expanded: conversationExpanded,
+          compactHeight: compactHeight(),
+          interactionPending: Boolean(controller.activeInteraction),
+        })
+        .catch(controller.report);
+      if (progress) {
+        const height =
+          Math.ceil(progressHeader.current?.getBoundingClientRect().height ?? 80) +
+          compactHeight() +
+          2;
+        void native.presentation
+          .resizeProgress(presentation.progressRequest!, height)
+          .catch(controller.report);
+        return;
+      }
+    };
+    const observer = new ResizeObserver(resize);
+    observer.observe(composerSurface.current);
+    if (progressHeader.current) observer.observe(progressHeader.current);
+    resize();
+    return () => observer.disconnect();
+  }, [
+    native,
+    floating,
+    conversationExpanded,
+    presentation?.progressRequest,
+    editingProgress,
+    controller.activeInteraction,
+  ]);
+  const previousInteraction = useRef<string | undefined>(undefined);
+  useLayoutEffect(() => {
+    const id = controller.activeInteraction?.requestId;
+    if (
+      previousInteraction.current &&
+      !id &&
+      document.hasFocus() &&
+      (document.activeElement === document.body ||
+        composerSurface.current?.contains(document.activeElement))
+    ) {
+      composer.current?.focus();
+    }
+    previousInteraction.current = id;
+  }, [controller.activeInteraction?.requestId]);
+  const toggleConversation = () => {
+    if (conversationExpanded) {
+      cancelReveal(revealMark.current, history.current);
+      setExpandedLayoutHeight(
+        surface.current?.querySelector('.maka-chat-layout')?.getBoundingClientRect().height ?? 0,
+      );
+      setConversationExpanded(false);
+    } else {
+      setConversationExpanded(true);
+    }
+    composer.current?.focus();
+  };
+  useEffect(() => {
+    let active = true;
+    const acceptPresentation = (next: WorkHubPresentationSnapshot) => {
+      if (!active) return;
+      if (next.progressRequest !== undefined) hasPresented.current = true;
+      if (
+        next.progressRequest !== undefined ||
+        next.placement !== 'floating' ||
+        !next.floatingVisible
+      ) {
+        cancelReveal(revealMark.current, history.current);
+        for (const animation of composerSurface.current?.getAnimations() ?? []) animation.cancel();
+      }
+      if (!hasConversationRef.current && (next.placement === 'docked' || !next.floatingVisible))
+        setConversationExpanded(undefined);
+      setPresentation(next);
+    };
+    const unsubscribe = native.presentation.subscribe(acceptPresentation);
+    void native.presentation.getSnapshot().then(acceptPresentation).catch(controller.report);
+    const acceptControl = (next: WorkHubControlSnapshot) => {
+      if (active)
+        setControl((previous) =>
+          !previous || next.revision >= previous.revision ? next : previous,
+        );
+    };
+    const unsubscribeControl = native.control.subscribe(acceptControl);
+    void native.control.getSnapshot().then(acceptControl).catch(controller.report);
+    const focus = native.presentation.onFocusComposer((expand) => {
+      if (expand) setConversationExpanded(true);
+      const choice = surface.current?.querySelector<HTMLElement>('.maka-choice-panel');
+      if (choice) {
+        if (!choice.contains(document.activeElement)) choice.focus();
+      } else composer.current?.focus();
+      // A warm summon must not fade the last painted frame back out.
+      if (hasPresented.current) return;
+      hasPresented.current = true;
+      if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
+      for (const element of [composerSurface.current]) {
+        for (const animation of element?.getAnimations() ?? []) animation.cancel();
+      }
+      composerSurface.current?.animate(
+        [
+          { opacity: 0.45, transform: 'translateY(8px)' },
+          { opacity: 1, transform: 'translateY(0)' },
+        ],
+        { duration: 360, easing: 'cubic-bezier(0.16, 1, 0.3, 1)' },
+      );
+      revealWordmark(revealMark.current, history.current);
+    });
+    return () => {
+      active = false;
+      unsubscribe();
+      unsubscribeControl();
+      focus();
+    };
+  }, [native]);
+  const tasks = controller.sessions
+    .filter(
+      (candidate) =>
+        candidate.id !== controller.sessionId &&
+        !candidate.labels.includes('mode:side_conversation') &&
+        !candidate.subagent,
+    )
+    .map((task) => ({
+      target: { sessionId: task.id },
+      projectName:
+        task.cwd
+          ?.replace(/[/\\]+$/, '')
+          .split(/[/\\]/)
+          .at(-1) ?? '',
+      sessionName: task.name,
+      archived: task.isArchived,
+      state: task.status,
+      updatedAt: task.lastMessageAt ?? task.statusUpdatedAt ?? 0,
+    }));
+  const links = useMemo(
+    () =>
+      workHubLinkedWork(transcript.messages, controller.sessions, getWorkHubRailCopy(locale).work),
+    [transcript.messages, controller.sessions, locale],
+  );
+  const [delegationFeedback, setDelegationFeedback] = useState<
+    readonly WorkHubDelegationFeedback[]
+  >([]);
+  const references = useMemo(
+    () =>
+      links.flatMap((link) =>
+        link.targetMessageId
+          ? [
+              {
+                id: link.id,
+                targetSessionId: link.targetSessionId,
+                targetMessageId: link.targetMessageId,
+              },
+            ]
+          : [],
+      ),
+    [links],
+  );
+  const linksWithFeedback = useMemo(
+    () => applyWorkHubDelegationFeedback(links, delegationFeedback),
+    [links, delegationFeedback],
+  );
+  const delegatedSessionIds = linksWithFeedback.map((link) => link.targetSessionId);
+  const call = (task: Promise<unknown>) => {
+    void task.catch(controller.report);
+  };
+  return (
+    <WorkHubHighlightContext.Provider value={highlight}>
+      {feedback?.({
+        locale,
+        references,
+        onFeedback: setDelegationFeedback,
+        onError: controller.report,
+      })}
+      <WorkHubHueProvider
+        sessionIds={[...tasks.map((task) => task.target.sessionId), ...delegatedSessionIds]}
+      >
+        <section
+          ref={surface}
+          data-progress={progress}
+          data-progress-editing={editingProgress}
+          className="workHubLive workhub-surface"
+          data-placement={presentation?.placement ?? 'docked'}
+          data-conversation-expanded={showConversation}
+          aria-label={t.title}
+        >
+          {!floating && presentation?.workbar && (
+            <WorkbarEdgeToggle
+              label={t[presentation.workbar.collapsed ? 'expandWorkbar' : 'collapseWorkbar']}
+              {...presentation.workbar}
+              onToggle={() => call(native.presentation.toggleWorkbar())}
+            />
+          )}
+          {progress && (
+            <WorkHubProgressCard
+              presentation={native.presentation}
+              ref={progressHeader}
+              request={presentation.progressRequest!}
+              control={control}
+              liveTurn={controller.liveTurn}
+              messages={transcript.messages}
+              busy={Boolean(controller.activeTurn) || controller.sending}
+              onOpen={() => {
+                setConversationExpanded(true);
+                if (presentation.progressRequest !== undefined)
+                  call(native.presentation.expandProgress(presentation.progressRequest));
+              }}
+            />
+          )}
+          {!progress && floating && conversationExpanded && (
+            <div className="workHubWindowControls">
+              <IconButton
+                className="workHubCloseButton"
+                type="button"
+                size="sm"
+                variant="ghost"
+                icon={<X size={12} />}
+                label={t.hide}
+                onClick={() => call(native.presentation.hide())}
+              />
+              <div className="workHubWindowActions">
+                <IconButton
+                  type="button"
+                  size="sm"
+                  variant="ghost"
+                  icon={
+                    <PictureInPicture2 size={14}>
+                      <path d="m8 11-4-4m0 4V7h4" />
+                    </PictureInPicture2>
+                  }
+                  label={t.dock}
+                  onClick={() => call(native.presentation.dock())}
+                />
+                <IconButton
+                  type="button"
+                  size="sm"
+                  variant="ghost"
+                  icon={
+                    <ChevronDown
+                      size={14}
+                      style={{ rotate: conversationExpanded ? '0deg' : '180deg' }}
+                    />
+                  }
+                  label={conversationExpanded ? t.collapseConversation : t.expandConversation}
+                  aria-expanded={conversationExpanded}
+                  onClick={toggleConversation}
+                />
+              </div>
+            </div>
+          )}
+          <div className="workHubRevealMark" ref={revealMark} aria-hidden="true">
+            <MakaWordmark width={192} />
+          </div>
+          <div className="workHubWorkspace">
+            <div className="mainColumn">
+              <ChatSurfaceLayout
+                scrollButton={showConversation ? undefined : null}
+                style={
+                  !showConversation
+                    ? {
+                        height: expandedLayoutHeight,
+                        flex: 'none',
+                        position: 'absolute',
+                        bottom: 0,
+                        width: '100%',
+                      }
+                    : undefined
+                }
+                composer={
+                  <div
+                    className="workHubComposerSurface"
+                    ref={composerSurface}
+                    onFocusCapture={editProgress}
+                    onPointerUpCapture={editProgress}
+                  >
+                    {(controller.error || control?.error) && (
+                      <div className="workHubLiveError" role="alert">
+                        {controller.error ?? t.controlFailed}
+                        {controller.canRetry && (
+                          <Button label={t.retry} variant="ghost" onClick={controller.retry} />
+                        )}
+                      </div>
+                    )}
+                    {controller.activeForm && (
+                      <FormInteractionPrompt
+                        request={controller.activeForm}
+                        onRespond={controller.respondToUserForm}
+                        onStop={controller.stop}
+                        stopPending={controller.stopPending}
+                      />
+                    )}
+                    {controller.activeQuestion && (
+                      <UserQuestionPrompt
+                        key={controller.activeQuestion.requestId}
+                        request={controller.activeQuestion}
+                        onRespond={controller.respondToUserQuestion}
+                        onStop={controller.stop}
+                        stopPending={controller.stopPending}
+                      />
+                    )}
+                    <div
+                      className="workHubComposerContent"
+                      hidden={Boolean(controller.activeQuestion || controller.activeForm)}
+                    >
+                      <WorkHubComposer
+                        attachments={attachments}
+                        pendingMessages={controller.transientMessages}
+                        queuedMessages={controller.messageQueue.entries}
+                        queuedMessageRevision={controller.messageQueue.revision}
+                        onUpdateQueuedEntry={controller.updateQueuedEntry}
+                        onDeleteQueuedEntry={controller.deleteQueuedEntry}
+                        onPromoteQueuedEntry={controller.promoteQueuedEntry}
+                        onReorderQueuedEntries={controller.reorderQueuedEntries}
+                        placeholder={progress ? t.progressInput : t.welcome}
+                        ref={composer}
+                        sessionId={controller.sessionId}
+                        streaming={busy}
+                        sendBlocked={!controller.sessionId || controller.sending || !session?.model}
+                        allowAttachmentImportWhileStreaming
+                        stopPending={controller.stopPending}
+                        onSend={async (text, attachments, followUpMode) => {
+                          const accepted = await controller.send(text, attachments, followUpMode);
+                          if (accepted) {
+                            setConversationExpanded(true);
+                            if (progress)
+                              call(
+                                native.presentation.expandProgress(presentation.progressRequest),
+                              );
+                          }
+                          return accepted;
+                        }}
+                        onStop={controller.stop}
+                        activeSession={session}
+                        activeModel={session?.model}
+                        activeModelLabel={modelChoice?.label}
+                        activeProviderType={modelChoice?.providerType}
+                        activeModelConnectionId={session?.llmConnectionId}
+                        activeModelConnectionSlug={session?.llmConnectionSlug}
+                        modelChoices={controller.choices}
+                        pickerPresentation={showConversation ? 'popover' : 'wheel'}
+                        pickersReadOnly={Boolean(
+                          controller.activeQuestion || controller.activeForm,
+                        )}
+                        maxInputRows={
+                          progress && !editingProgress ? 1 : showConversation ? undefined : 6
+                        }
+                        onModelChange={controller.changeModel}
+                        modelSwitchAvailability={
+                          controller.configuringModel
+                            ? { available: false, pending: true, reason: 'pending' }
+                            : undefined
+                        }
+                        contextUsage={
+                          session
+                            ? {
+                                usageTokens:
+                                  liveContextUsage?.usageTokens ??
+                                  selectLatestRequestUsage(
+                                    transcript.messages,
+                                    session.model,
+                                    session,
+                                  ),
+                                declaredContextWindow: modelChoice?.declaredContextWindow,
+                                meteredContextWindow: liveContextUsage?.contextWindow,
+                                metadataContextWindow: modelChoice?.contextWindow,
+                                onOpen: () => call(native.presentation.openUsage()),
+                              }
+                            : undefined
+                        }
+                        activeThinkingLevels={thinkingLevels}
+                        activeThinkingLevel={thinkingLevel}
+                        onThinkingLevelChange={controller.changeThinkingLevel}
+                        modelSwitchHasHistory={transcript.messages.length > 0}
+                        footerAccessory={
+                          <div className="workHubComposerActions">
+                            {control?.canUndo && (
+                              <IconButton
+                                type="button"
+                                size="sm"
+                                variant="ghost"
+                                icon={<Undo2 size={16} />}
+                                label={t.undo}
+                                isDisabled={busy}
+                                onClick={() => call(native.control.undo())}
+                              />
+                            )}
+                            {!floating && (
+                              <IconButton
+                                type="button"
+                                size="sm"
+                                variant="ghost"
+                                icon={<PictureInPicture2 size={16} />}
+                                label={t.float}
+                                tooltip={`${t.float} · ${shortcutLabel}`}
+                                onClick={() => call(native.presentation.detach())}
+                              />
+                            )}
+                          </div>
+                        }
+                      />
+                      {!progress && floating && !conversationExpanded && (
+                        <IconButton
+                          className="workHubExpandButton"
+                          type="button"
+                          size="sm"
+                          variant="ghost"
+                          icon={<ChevronDown size={14} style={{ rotate: '180deg' }} />}
+                          label={t.expandConversation}
+                          aria-expanded={false}
+                          onClick={toggleConversation}
+                        />
+                      )}
+                    </div>
+                  </div>
+                }
+              >
+                <div
+                  ref={history}
+                  className="workHubHistory"
+                  aria-hidden={!showConversation}
+                  inert={!showConversation}
+                >
+                  <div className="workhub-body">
+                    <WorkHubNavigationRail
+                      locale={locale}
+                      sessions={tasks}
+                      delegatedSessionIds={delegatedSessionIds}
+                      copy={getWorkHubRailCopy(locale)}
+                    />
+                    <div className="workhub-conversation-shell">
+                      <WorkHubConversation
+                        promptStates={promptStates}
+                        workLinks={linksWithFeedback}
+                        onReadAttachmentBytes={attachments.read}
+                        onOpenWork={(id) => call(native.presentation.openSession(id))}
+                        scrollBehavior="auto"
+                        onNew={() => composer.current?.focus()}
+                        messages={[...transcript.messages]}
+                        hasEarlierHistory={transcript.hasOlder}
+                        onLoadEarlierHistory={controller.loadEarlier}
+                        transientMessages={controller.transientMessages}
+                        viewportNavigation={controller.viewportNavigation}
+                        liveTurns={controller.liveTurns}
+                        onStreamingSettled={controller.streamingSettled}
+                        activeTurn={controller.activeTurn}
+                        messageLoading={!transcript.ready}
+                        activeSession={session}
+                        activeModel={session?.model}
+                        emptyOverride={
+                          <div className="workHubLiveWelcome">
+                            <MakaWordmark width={112} />
+                            <p>{t.hint}</p>
+                          </div>
+                        }
+                      />
+                    </div>
+                  </div>
+                </div>
+              </ChatSurfaceLayout>
+            </div>
+          </div>
+        </section>
+      </WorkHubHueProvider>
+    </WorkHubHighlightContext.Provider>
+  );
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org