diff --git a/design-system/packages/ui/src/components/Icon/Icon.tsx b/design-system/packages/ui/src/components/Icon/Icon.tsx index 18d67f8fc0..0769568425 100644 --- a/design-system/packages/ui/src/components/Icon/Icon.tsx +++ b/design-system/packages/ui/src/components/Icon/Icon.tsx @@ -93,6 +93,7 @@ import { type LucideIcon, } from "lucide-react"; import { classNames } from "../../internal/classNames"; +import { CloudGit } from './cloudGit'; import { Galaxy } from './galaxy'; import { LayersPlus } from './layersPlus'; import { PlayingCardsFan } from './playingCardsFan'; @@ -136,6 +137,7 @@ export const iconNames = [ "circle", "circle-arrow-right", "clock", + "cloud-git", "code", "command-mac", "commit", @@ -267,6 +269,7 @@ const lineGlyphs = { "circle": Circle, "circle-arrow-right": CircleArrowRight, "clock": Clock, + "cloud-git": CloudGit, "git-pull-request": GitPullRequest, "history": History, "target": Target, diff --git a/design-system/packages/ui/src/components/Icon/cloudGit.ts b/design-system/packages/ui/src/components/Icon/cloudGit.ts new file mode 100644 index 0000000000..93fdef5b40 --- /dev/null +++ b/design-system/packages/ui/src/components/Icon/cloudGit.ts @@ -0,0 +1,11 @@ +import { createLucideIcon } from 'lucide-react'; + +// Lucide cloud-cog outline with the branch layout from assets/git.svg and solid nodes. +export const CloudGit = createLucideIcon('CloudGit', [ + ['path', { d: 'M4.2 15.1a7 7 0 1 1 9.93-9.858A7 7 0 0 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.2', key: 'cloud' }], + ['path', { d: 'M9 13v7', key: 'branch-main' }], + ['path', { d: 'M15 13v2.5a1 1 0 0 1-1 1h-4a1 1 0 0 0-1 1', key: 'branch-fork' }], + ['circle', { cx: '9', cy: '13', r: '1.5', fill: 'currentColor', stroke: 'none', key: 'branch-top' }], + ['circle', { cx: '9', cy: '20', r: '1.5', fill: 'currentColor', stroke: 'none', key: 'branch-bottom' }], + ['circle', { cx: '15', cy: '13', r: '1.5', fill: 'currentColor', stroke: 'none', key: 'branch-tip' }], +]); diff --git a/design-system/packages/ui/tests/icon.test.mjs b/design-system/packages/ui/tests/icon.test.mjs index 08dc3cdc6d..124ea63720 100644 --- a/design-system/packages/ui/tests/icon.test.mjs +++ b/design-system/packages/ui/tests/icon.test.mjs @@ -8,8 +8,8 @@ import { Icon, iconNames, canonicalIconNames, iconAliases } from "../dist/index. import { Network } from "lucide-react"; test("Icon exposes the complete named catalog without duplicate names", () => { - assert.equal(iconNames.length, 101); - assert.equal(canonicalIconNames.length, 98); + assert.equal(iconNames.length, 102); + assert.equal(canonicalIconNames.length, 99); assert.deepEqual(Object.keys(iconAliases).sort(), ["circle", "download"]); for (const name of ["thinking", "git", "duplicate", "chevron-left", "selected", "delete", "waitlist-message", "creative", "ultimate", "standard", "minimal", "arrow-down", "unselected"]) { assert.ok(canonicalIconNames.includes(name), name); diff --git a/src/apps/miniapp-shell/src/generated/chat-styles.css b/src/apps/miniapp-shell/src/generated/chat-styles.css index cb627db028..4d7ede8d85 100644 --- a/src/apps/miniapp-shell/src/generated/chat-styles.css +++ b/src/apps/miniapp-shell/src/generated/chat-styles.css @@ -1391,15 +1391,14 @@ height: var(--openbitfun-control-chat-composer-control-height); align-items: center; align-self: center; + gap: var(--openbitfun-space-1); padding: 0; } .openbitfun-chat-input__composer > [data-openbitfun-part=body] > [data-openbitfun-part=surface] .openbitfun-chat-input__actions-left { justify-content: flex-start; - gap: var(--openbitfun-space-2); } .openbitfun-chat-input__composer > [data-openbitfun-part=body] > [data-openbitfun-part=surface] .openbitfun-chat-input__actions-right { justify-content: flex-end; - gap: var(--openbitfun-space-1); } .openbitfun-chat-input__composer > [data-openbitfun-part=body] > [data-openbitfun-part=surface] .openbitfun-chat-input__model-usage-group, .openbitfun-chat-input__composer > [data-openbitfun-part=body] > [data-openbitfun-part=surface] .openbitfun-model-selector { @@ -1476,6 +1475,7 @@ } .openbitfun-chat-input__composer > [data-openbitfun-part=body] > [data-openbitfun-part=surface][data-openbitfun-layout=expanded] .openbitfun-harness-selector__trigger { height: var(--openbitfun-control-chat-composer-control-height); + padding-inline: var(--openbitfun-space-1); border-radius: var(--openbitfun-radius-pill); } .openbitfun-chat-input--capsule .openbitfun-chat-input__content { diff --git a/src/web-ui/src/flow_chat/components/ChatInput.scss b/src/web-ui/src/flow_chat/components/ChatInput.scss index 22b7bff0d8..64fcca4dce 100644 --- a/src/web-ui/src/flow_chat/components/ChatInput.scss +++ b/src/web-ui/src/flow_chat/components/ChatInput.scss @@ -562,17 +562,16 @@ height: var(--openbitfun-control-chat-composer-control-height); align-items: center; align-self: center; + gap: var(--openbitfun-space-1); padding: 0; } .openbitfun-chat-input__actions-left { justify-content: flex-start; - gap: var(--openbitfun-space-2); } .openbitfun-chat-input__actions-right { justify-content: flex-end; - gap: var(--openbitfun-space-1); } .openbitfun-chat-input__model-usage-group, @@ -671,6 +670,9 @@ &[data-openbitfun-layout='expanded'] { .openbitfun-harness-selector__trigger { height: var(--openbitfun-control-chat-composer-control-height); + // The idle label's inset adds to the action gap and the add icon's + // own inset. Keep that visible spacing compact in every interaction state. + padding-inline: var(--openbitfun-space-1); border-radius: var(--openbitfun-radius-pill); } } diff --git a/src/web-ui/src/flow_chat/components/ChatInput.tsx b/src/web-ui/src/flow_chat/components/ChatInput.tsx index 05ac1f817c..3b798e60c9 100644 --- a/src/web-ui/src/flow_chat/components/ChatInput.tsx +++ b/src/web-ui/src/flow_chat/components/ChatInput.tsx @@ -6350,7 +6350,8 @@ export const ChatInput: React.FC = ({ } : undefined} workspaceId={executionWorkspaceId ?? ''} repositoryPath={chatStripRepositoryPath} - workspaceLabel={chatStripWorkspaceLabel} + workspaceLabel={isAssistantWorkspace || chatInputModePolicy.fixedModeId === 'Claw' + ? '' : chatStripWorkspaceLabel} executionTarget={effectiveTargetSession?.config.executionTarget} dispatchControl={dispatchControl} worktreeControl={worktreeControl} diff --git a/src/web-ui/src/flow_chat/components/ChatInputWorkspaceStrip.tsx b/src/web-ui/src/flow_chat/components/ChatInputWorkspaceStrip.tsx index f7b39e41a3..b3f1d15402 100644 --- a/src/web-ui/src/flow_chat/components/ChatInputWorkspaceStrip.tsx +++ b/src/web-ui/src/flow_chat/components/ChatInputWorkspaceStrip.tsx @@ -598,6 +598,7 @@ export const ChatInputWorkspaceStrip: React.FC = ( return ( + {label} @@ -621,6 +622,7 @@ export const ChatInputWorkspaceStrip: React.FC = ( setWorkspaceMenuOpen(open => !open); }} > + {label} diff --git a/src/web-ui/src/flow_chat/components/HarnessProfileSelector.test.tsx b/src/web-ui/src/flow_chat/components/HarnessProfileSelector.test.tsx index d2f54ded7f..19a190bd1f 100644 --- a/src/web-ui/src/flow_chat/components/HarnessProfileSelector.test.tsx +++ b/src/web-ui/src/flow_chat/components/HarnessProfileSelector.test.tsx @@ -10,8 +10,10 @@ import { HarnessProfileSelector } from './HarnessProfileSelector'; vi.mock('react-i18next', () => ({ useTranslation: () => ({ - t: (key: string, options?: { defaultValue?: string }) => - options?.defaultValue ?? key, + t: (key: string, options?: { defaultValue?: string; name?: string }) => + key === 'chatInput.harness.modeLabel' + ? `${options?.name} mode` + : options?.defaultValue ?? key, }), })); @@ -76,7 +78,7 @@ describe('HarnessProfileSelector', () => { '[data-testid="harness-profile-selector"]', ); expect(trigger?.querySelector('.openbitfun-harness-selector__density-mark')).toBeNull(); - expect(trigger?.textContent).toBe('chatInput.harness.profiles.Standard.name'); + expect(trigger?.textContent).toBe('chatInput.harness.profiles.Standard.name mode'); expect(trigger?.dataset.harnessPending).toBeUndefined(); expect( container.querySelector('[data-testid="harness-profile-pending-dot"]'), @@ -401,7 +403,7 @@ describe('HarnessProfileSelector', () => { expect(trigger?.dataset.harnessLocked).toBe('true'); expect(trigger?.dataset.harnessFixed).toBe('true'); expect(trigger?.disabled).toBe(false); - expect(trigger?.textContent).toBe('chatInput.harness.profiles.Standard.name'); + expect(trigger?.textContent).toBe('chatInput.harness.profiles.Standard.name mode'); await act(async () => { trigger?.dispatchEvent(new MouseEvent('click', { bubbles: true })); diff --git a/src/web-ui/src/flow_chat/components/HarnessProfileSelector.tsx b/src/web-ui/src/flow_chat/components/HarnessProfileSelector.tsx index 4b4e25557c..d2cf674a0d 100644 --- a/src/web-ui/src/flow_chat/components/HarnessProfileSelector.tsx +++ b/src/web-ui/src/flow_chat/components/HarnessProfileSelector.tsx @@ -266,7 +266,12 @@ export const HarnessProfileSelector: React.FC = ({ : knownSelectedProfile ? t(`chatInput.harness.profiles.${knownSelectedProfile}.name`) : t('chatInput.harness.unsupportedProfile', { id: selectedProfile }); - const triggerLabel = primaryLabel; + const triggerLabel = presentation === 'standalone' + && !legacySession + && knownSelectedProfile + && isSelectableProfile(knownSelectedProfile) + ? t('chatInput.harness.modeLabel', { name: primaryLabel }) + : primaryLabel; const triggerTooltip = legacySession ? t('chatInput.harness.legacySessionNotice') : !selectedProfileAvailable diff --git a/src/web-ui/src/flow_chat/components/WelcomePanel.appearance.ts b/src/web-ui/src/flow_chat/components/WelcomePanel.appearance.ts index 83e825c808..60f612862e 100644 --- a/src/web-ui/src/flow_chat/components/WelcomePanel.appearance.ts +++ b/src/web-ui/src/flow_chat/components/WelcomePanel.appearance.ts @@ -6,15 +6,18 @@ export const welcomePanelAppearanceDescriptor: AppearanceSurfaceDescriptor = { { id: 'root', propertyProfile: 'layout', visualRole: 'workspace' }, { id: 'content', visualRole: 'card' }, { id: 'greeting', visualRole: 'content' }, + { id: 'caption', propertyProfile: 'paint', visualRole: 'content' }, + { id: 'modeIcon', propertyProfile: 'paint', visualRole: 'decoration' }, + { id: 'modeChoices', visualRole: 'content' }, + { id: 'modeOption', propertyProfile: 'control', visualRole: 'control' }, + { id: 'modeName', propertyProfile: 'paint', visualRole: 'content' }, { id: 'heading', propertyProfile: 'paint', visualRole: 'content' }, { id: 'tagline', propertyProfile: 'paint', visualRole: 'content' }, { id: 'divider', propertyProfile: 'paint', visualRole: 'divider' }, { id: 'narrative', propertyProfile: 'paint', visualRole: 'content' }, { id: 'openWorkspaceAction', propertyProfile: 'control', visualRole: 'control' }, { id: 'workspaceAction', propertyProfile: 'control', visualRole: 'control' }, - { id: 'gitAction', propertyProfile: 'control', visualRole: 'control' }, { id: 'workspaceMenu', propertyProfile: 'overlay', visualRole: 'popup' }, - { id: 'workspaceItem', propertyProfile: 'control', visualRole: 'control' }, { id: 'cowork', visualRole: 'content' }, ], states: [ diff --git a/src/web-ui/src/flow_chat/components/WelcomePanel.css b/src/web-ui/src/flow_chat/components/WelcomePanel.css index 26c8dcadee..0cb9fac98f 100644 --- a/src/web-ui/src/flow_chat/components/WelcomePanel.css +++ b/src/web-ui/src/flow_chat/components/WelcomePanel.css @@ -1,8 +1,15 @@ /* - * Center the heading in the viewport above ChatInput, with supporting content below. + * Center the mode icon and caption as one row above ChatInput. */ .welcome-panel { + /* Match WelcomeScene's logo dimensions, including its compact breakpoints. */ + --_welcome-mode-size: 56px; + --_welcome-mode-expanded-glyph-size: var(--openbitfun-space-12); + --_welcome-mode-expanded-size: calc(var(--openbitfun-space-16) + var(--openbitfun-space-10)); + --_welcome-mode-expanded-padding: var(--openbitfun-space-3); + --_welcome-mode-gap: var(--openbitfun-space-2); + --_welcome-mode-label-gap: var(--openbitfun-space-1); width: 100%; height: 100%; padding: var(--openbitfun-space-8) var(--openbitfun-space-6); @@ -13,6 +20,7 @@ } .welcome-panel__content { + container-type: inline-size; display: grid; /* Equal tracks keep the heading centered regardless of the details' height. */ grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr); @@ -25,10 +33,238 @@ /* ── Greeting ── */ .welcome-panel__greeting { + container-type: inline-size; grid-row: 2; display: flex; + align-items: center; + justify-content: center; + min-block-size: var(--_welcome-mode-size); + column-gap: var(--openbitfun-space-4); + transition: column-gap var(--openbitfun-motion-duration-content-swap) var(--openbitfun-motion-easing-standard); +} + +.welcome-panel__greeting[data-mode-expanded='true'] { + column-gap: 0; +} + +.welcome-panel__caption { + --_welcome-caption-width: auto; + flex: none; + inline-size: var(--_welcome-caption-width); + overflow: hidden; + opacity: 1; + transform: none; + transition: + inline-size var(--openbitfun-motion-duration-content-swap) var(--openbitfun-motion-easing-standard), + opacity var(--openbitfun-motion-duration-normal) var(--openbitfun-motion-easing-standard), + transform var(--openbitfun-motion-duration-content-swap) var(--openbitfun-motion-easing-standard); +} + +.welcome-panel__caption-content { + inline-size: max-content; + max-inline-size: max(0px, calc(100cqi - var(--_welcome-mode-size) - var(--openbitfun-space-4))); + overflow-wrap: anywhere; +} + +.welcome-panel__greeting[data-mode-expanded='true'] > .welcome-panel__caption { + inline-size: 0; + opacity: 0; + transform: translateX(var(--openbitfun-space-4)); + pointer-events: none; +} + +.welcome-panel__mode-choices { + --_welcome-mode-glyph-size: var(--_welcome-mode-size); + --_welcome-mode-option-width: var(--_welcome-mode-size); + --_welcome-mode-option-height: var(--_welcome-mode-size); + --_welcome-mode-option-padding: 0px; + flex: none; + align-self: center; + display: inline-flex; + column-gap: 0; + block-size: var(--_welcome-mode-option-height); + max-inline-size: 100%; + transition: + column-gap var(--openbitfun-motion-duration-content-swap) var(--openbitfun-motion-easing-standard), + block-size var(--openbitfun-motion-duration-content-swap) var(--openbitfun-motion-easing-standard); +} + +.welcome-panel__mode-choices[data-expanded='true'] { + --_welcome-mode-glyph-size: var(--_welcome-mode-expanded-glyph-size); + /* One edge length keeps the hover surface square throughout the morph. */ + --_welcome-mode-option-width: var(--_welcome-mode-expanded-size); + --_welcome-mode-option-height: var(--_welcome-mode-expanded-size); + --_welcome-mode-option-padding: var(--_welcome-mode-expanded-padding); + column-gap: var(--_welcome-mode-gap); +} + +.welcome-panel__mode-slot { + flex: none; + inline-size: 0; + overflow: hidden; + opacity: 0; + transform: translateX(calc(var(--openbitfun-space-2) * -1)) scale(0.92); + transition: + inline-size var(--openbitfun-motion-duration-content-swap) var(--openbitfun-motion-easing-standard), + opacity var(--openbitfun-motion-duration-normal) var(--openbitfun-motion-easing-standard), + transform var(--openbitfun-motion-duration-content-swap) var(--openbitfun-motion-easing-standard); +} + +.welcome-panel__mode-slot[data-current='true'], +.welcome-panel__mode-choices[data-expanded='true'] > .welcome-panel__mode-slot { + inline-size: var(--_welcome-mode-option-width); + opacity: 1; + transform: none; +} + +.welcome-panel__mode-option { + box-sizing: border-box; + display: flex; flex-direction: column; - gap: var(--openbitfun-control-flow-chat-inline-gap); + align-items: center; + justify-content: center; + inline-size: var(--_welcome-mode-option-width); + block-size: 100%; + gap: 0; + padding: var(--_welcome-mode-option-padding); + border: 0; + border-radius: var(--openbitfun-radius-xl); + background: transparent; + color: var(--openbitfun-color-content-secondary); + font: inherit; + cursor: pointer; + transition: + inline-size var(--openbitfun-motion-duration-content-swap) var(--openbitfun-motion-easing-standard), + padding var(--openbitfun-motion-duration-content-swap) var(--openbitfun-motion-easing-standard), + background-color var(--openbitfun-motion-duration-normal) var(--openbitfun-motion-easing-standard); +} + +.welcome-panel__mode-option:disabled { + cursor: default; +} + +.welcome-panel__mode-option:focus-visible { + outline: 2px solid var(--openbitfun-color-accent-default); + outline-offset: -2px; +} + +.welcome-panel__mode-option:hover:not(:disabled), +.welcome-panel__mode-option:focus-visible { + background: var(--openbitfun-color-action-quiet-hover); +} + +.welcome-panel__mode-name { + flex: none; + align-self: stretch; + max-block-size: 0; + margin-block-start: 0; + overflow: hidden; + color: inherit; + font-family: var(--openbitfun-type-label-lg-font-family); + font-size: var(--openbitfun-type-label-lg-font-size); + font-weight: var(--openbitfun-type-label-lg-font-weight); + line-height: var(--openbitfun-type-label-lg-line-height); + letter-spacing: var(--openbitfun-type-label-lg-letter-spacing); + text-align: center; + white-space: nowrap; + opacity: 0; + transform: translateY(calc(var(--openbitfun-space-1) * -1)); + transition: + max-block-size var(--openbitfun-motion-duration-content-swap) var(--openbitfun-motion-easing-standard), + margin-block-start var(--openbitfun-motion-duration-content-swap) var(--openbitfun-motion-easing-standard), + opacity var(--openbitfun-motion-duration-normal) var(--openbitfun-motion-easing-standard), + transform var(--openbitfun-motion-duration-content-swap) var(--openbitfun-motion-easing-standard); +} + +.welcome-panel__mode-choices[data-expanded='true'] .welcome-panel__mode-name { + max-block-size: var(--openbitfun-space-6); + margin-block-start: var(--_welcome-mode-label-gap); + opacity: 1; + transform: none; +} + +.welcome-panel__mode-slot[data-current='true'] .welcome-panel__mode-name { + font-weight: var(--openbitfun-type-label-selected-font-weight); +} + +.welcome-panel__mode-mark { + flex: none; + align-self: center; + display: inline-flex; + color: var(--openbitfun-color-content-secondary); +} + +.welcome-panel .welcome-panel__assistant-avatar[data-size] { + --assistant-avatar-size: var(--_welcome-mode-size); + /* The joystick extends above the body: its visual center sits about 10% + below the asset midpoint. Align the body with the caption, preserving + the full artwork and its layout box. Scale the correction with the IP. */ + transform: translateY(-10%); +} + +.welcome-panel__mode-mark > [data-openbitfun-component='icon'] { + inline-size: var(--_welcome-mode-size); + block-size: var(--_welcome-mode-size); +} + +.welcome-panel__mode-option .welcome-panel__mode-mark > [data-openbitfun-component='icon'] { + inline-size: var(--_welcome-mode-glyph-size); + block-size: var(--_welcome-mode-glyph-size); + transition: + inline-size var(--openbitfun-motion-duration-content-swap) var(--openbitfun-motion-easing-standard), + block-size var(--openbitfun-motion-duration-content-swap) var(--openbitfun-motion-easing-standard); +} + +.welcome-panel__mode-mark[data-harness-profile='Minimal'], +.welcome-panel__mode-option[data-harness-profile='Minimal'] { + color: var(--openbitfun-color-identity-harness-minimal); +} + +.welcome-panel__mode-mark[data-harness-profile='Standard'], +.welcome-panel__mode-option[data-harness-profile='Standard'] { + color: var(--openbitfun-color-identity-harness-standard); +} + +.welcome-panel__mode-mark[data-harness-profile='Ultimate'], +.welcome-panel__mode-option[data-harness-profile='Ultimate'] { + color: var(--openbitfun-color-identity-harness-ultimate); +} + +.welcome-panel__mode-mark[data-harness-profile='Creative'], +.welcome-panel__mode-option[data-harness-profile='Creative'] { + color: var(--openbitfun-color-identity-harness-creative); +} + +.welcome-panel__workspace-name { + appearance: none; + display: inline; + margin: 0; + padding: 0; + border: 0; + background: transparent; + font: inherit; + color: inherit; + letter-spacing: inherit; + white-space: normal; + vertical-align: baseline; + cursor: pointer; +} + +.welcome-panel__workspace-name:disabled { + opacity: 1; + cursor: inherit; +} + +.welcome-panel__workspace-name:hover:not(:disabled) { + text-decoration-line: underline; + text-decoration-style: dashed; + text-decoration-thickness: var(--openbitfun-border-width-default); + text-underline-offset: var(--openbitfun-space-1); +} + +.welcome-panel__workspace-name:focus-visible { + outline: 2px solid var(--openbitfun-color-focus-ring); + outline-offset: 2px; } .welcome-panel__details { @@ -45,6 +281,7 @@ .welcome-panel__tagline { margin: 0; + text-align: center; color: var(--openbitfun-color-content-primary); font-family: var(--openbitfun-type-page-intro-font-family); font-size: var(--openbitfun-type-page-intro-font-size); @@ -73,19 +310,6 @@ color: var(--openbitfun-color-content-muted); } -/* Lead text, chips, and trail text share one typographic line (baseline-aligned) */ -.welcome-panel__narrative-sentence { - display: inline-flex; - align-items: baseline; - flex-wrap: wrap; - column-gap: 0.35em; - row-gap: 0.25em; -} - -.welcome-panel__narrative-sentence__text { - line-height: inherit; -} - .welcome-panel__inline-btn { block-size: auto; letter-spacing: inherit; @@ -114,19 +338,6 @@ .welcome-panel__inline-btn > [data-openbitfun-part='content'] { gap: inherit; } -.welcome-panel__inline-btn [data-openbitfun-part='leading-icon'] { - --openbitfun-opacity-icon-artwork: inherit; - inline-size: 13px; - block-size: 13px; -} - -.welcome-panel__inline-btn [data-openbitfun-part='trailing-icon'] { - --openbitfun-opacity-icon-artwork: inherit; - inline-size: 11px; - block-size: 11px; - opacity: 1; -} - .welcome-panel__inline-btn--interactive { cursor: pointer; } @@ -140,74 +351,11 @@ outline-offset: 1px; } -.welcome-panel__inline-btn--active { - background: var(--openbitfun-color-surface-subtle); -} - .welcome-panel__inline-btn:disabled { opacity: 0.5; cursor: default; } -.welcome-panel__inline-icon { - flex-shrink: 0; - display: block; -} - -.welcome-panel__inline-chevron { - opacity: 0.5; - transition: transform 0.2s ease; - flex-shrink: 0; - display: block; -} - -.welcome-panel__inline-chevron--open { - transform: rotate(180deg); -} - -.welcome-panel__narrative-clean { - color: var(--openbitfun-color-content-secondary); -} - -/* ── Context row: workspace + branch always on the same line ── */ - -.welcome-panel__context-row { - display: inline-flex; - align-items: baseline; - flex-wrap: nowrap; - margin: 0 1px; -} - -.welcome-panel__context-sep { - padding: 0 2px; - line-height: inherit; - color: var(--openbitfun-color-content-muted); - opacity: 0.4; - font-weight: var(--openbitfun-type-body-sm-font-weight); - user-select: none; -} - -/* ── Workspace anchor (inline position reference for dropdown) ── */ - -.welcome-panel__workspace-anchor { - position: relative; - display: inline-flex; - align-items: baseline; -} - -/* Git status line: tight follow-up under workspace sentence (avoid
full line-gap) */ -.welcome-panel__narrative-git { - display: block; - margin-top: 0.28em; -} - -/* ── Dropdown ── */ - -.welcome-panel__dropdown { - position: fixed; - z-index: 360; -} - /* ── Cowork ── */ .welcome-panel__cowork { @@ -223,6 +371,41 @@ /* ── Responsive ── */ +@container (max-width: 560px) { + .welcome-panel__greeting { + --_welcome-mode-size: var(--openbitfun-space-12); + --_welcome-mode-expanded-glyph-size: calc(var(--openbitfun-space-8) + var(--openbitfun-space-1)); + --_welcome-mode-expanded-size: calc(var(--openbitfun-space-12) + var(--openbitfun-space-10)); + } +} + +@container (max-width: 400px) { + .welcome-panel__greeting { + --_welcome-mode-size: 36px; + --_welcome-mode-expanded-glyph-size: var(--openbitfun-space-6); + --_welcome-mode-expanded-size: var(--openbitfun-space-16); + --_welcome-mode-expanded-padding: var(--openbitfun-space-2); + --_welcome-mode-gap: var(--openbitfun-space-1); + --_welcome-mode-label-gap: var(--openbitfun-space-1); + } + + .welcome-panel__mode-name { + font-family: var(--openbitfun-type-label-sm-font-family); + font-size: var(--openbitfun-type-label-sm-font-size); + font-weight: var(--openbitfun-type-label-sm-font-weight); + line-height: var(--openbitfun-type-label-sm-line-height); + letter-spacing: var(--openbitfun-type-label-sm-letter-spacing); + } +} + +@container (max-width: 300px) { + .welcome-panel__greeting { + --_welcome-mode-expanded-glyph-size: var(--openbitfun-space-5); + --_welcome-mode-expanded-size: 56px; + --_welcome-mode-expanded-padding: var(--openbitfun-space-1); + } +} + @media (max-width: 480px) { .welcome-panel { padding: var(--openbitfun-space-5) var(--openbitfun-space-4); @@ -236,7 +419,14 @@ } .welcome-panel__inline-btn, - .welcome-panel__inline-chevron { + .welcome-panel__greeting, + .welcome-panel__caption, + .welcome-panel__mode-choices, + .welcome-panel__mode-slot, + .welcome-panel__mode-option, + .welcome-panel__mode-mark, + .welcome-panel__mode-name, + .welcome-panel__mode-option .welcome-panel__mode-mark > [data-openbitfun-component='icon'] { transition-duration: 0ms; } } diff --git a/src/web-ui/src/flow_chat/components/WelcomePanel.test.tsx b/src/web-ui/src/flow_chat/components/WelcomePanel.test.tsx index 75a6823dad..a5515e532b 100644 --- a/src/web-ui/src/flow_chat/components/WelcomePanel.test.tsx +++ b/src/web-ui/src/flow_chat/components/WelcomePanel.test.tsx @@ -6,12 +6,17 @@ import { createRoot, type Root } from 'react-dom/client'; import { AppearanceCompiler } from '@/infrastructure/appearance/compiler/AppearanceCompiler'; import { AppearanceRegistry } from '@/infrastructure/appearance/registry/AppearanceRegistry'; import { APPEARANCE_SCHEMA_VERSION, type AppearancePackage } from '@/infrastructure/appearance/types'; -import { WelcomePanel } from './WelcomePanel'; +import { WelcomeModeSelector, WelcomePanel } from './WelcomePanel'; import { welcomePanelAppearanceDescriptor } from './WelcomePanel.appearance'; import { ChatInputWorkspaceStrip } from './ChatInputWorkspaceStrip'; import { useSessionWorkspaceSelection } from '../hooks/useSessionWorkspaceSelection'; import type { Session } from '../types/flow-chat'; import type { WorkspaceInfo } from '@/shared/types'; +import { FlowChatStore } from '../store/FlowChatStore'; +import { agentAPI } from '@/infrastructure/api/service-api/AgentAPI'; +import { chatInputModePreferenceService } from '../services/ChatInputModePreferenceService'; +import type { HarnessId } from '@/shared/agents/identity'; +import * as deviceSurface from '@/infrastructure/peer-device/deviceSurface'; globalThis.IS_REACT_ACT_ENVIRONMENT = true; @@ -22,9 +27,12 @@ const gitApiMock = vi.hoisted(() => ({ })); const workspaceMocks = vi.hoisted(() => ({ + hasWorkspace: true, currentWorkspace: { id: 'workspace-1', name: 'OpenBitFun', rootPath: 'D:/workspace/OpenBitFun', workspaceKind: 'normal' }, openedWorkspaces: new Map(), selectDraftWorkspace: vi.fn(), + createChatDraft: vi.fn(), + openMainSession: vi.fn(), openWorkspace: vi.fn(), switchWorkspace: vi.fn(), switchLeftPanelTab: vi.fn(), @@ -35,13 +43,36 @@ vi.mock('../services/FlowChatManager', () => ({ FlowChatManager: { getInstance: () => workspaceMocks }, })); -vi.mock('react-i18next', () => ({ - initReactI18next: { type: '3rdParty', init: () => {} }, - useTranslation: () => ({ - t: (key: string, values?: Record) => values?.count ?? key, - }), +vi.mock('../services/sessionActivation', () => ({ + openMainSession: workspaceMocks.openMainSession, + activateMainSession: vi.fn(), })); +vi.mock('react-i18next', async importOriginal => { + const actual = await importOriginal(); + const { createInstance } = await import('i18next'); + const { default: copy } = await import('@/locales/zh-CN/flow-chat.json'); + const { default: sharedCopy } = await import('../../../../shared/i18n/resources/shared/zh-CN/terms.json'); + const i18n = createInstance(); + await i18n.init({ + lng: 'zh-CN', + resources: { 'zh-CN': { 'flow-chat': copy, shared: sharedCopy } }, + defaultNS: 'flow-chat', + interpolation: { escapeValue: false }, + }); + return { + ...actual, + initReactI18next: { type: '3rdParty', init: () => {} }, + Trans: (props: React.ComponentProps) => ( + + ), + useTranslation: () => ({ + t: (key: string, values?: Record) => key.startsWith('shared:agents.') + ? i18n.t(key) : values?.count ?? key, + }), + }; +}); + vi.mock('../../infrastructure/api', () => ({ gitAPI: gitApiMock, })); @@ -55,7 +86,7 @@ vi.mock('../../app/hooks/useApp', () => ({ vi.mock('@/infrastructure/contexts/WorkspaceContext', () => ({ getWorkspaceDisplayName: (workspace: WorkspaceInfo) => workspace.name, useWorkspaceContext: () => ({ - hasWorkspace: true, + hasWorkspace: workspaceMocks.hasWorkspace, currentWorkspace: workspaceMocks.currentWorkspace, openedWorkspaces: workspaceMocks.openedWorkspaces, openedWorkspacesList: [...workspaceMocks.openedWorkspaces.values()], @@ -72,10 +103,7 @@ vi.mock('@/app/scenes/my-agent/useAgentIdentityDocument', () => ({ useAgentIdentityDocument: () => ({ document: { name: '' } }), })); -// WelcomePanel now reads Git state through useGitState (which subscribes to -// the shared GitStateManager and participates in its 2 s polling interval) -// instead of hitting gitAPI directly. Return deterministic state so the -// render tests do not race against real timers or Tauri APIs. +// The composer still reads Git state; the welcome panel must not subscribe. vi.mock('@/tools/git/hooks/useGitState', () => ({ useGitState: ({ repositoryPath, debugSource }: { repositoryPath: { workspaceId: string }; debugSource: string }) => { const workspaceId = repositoryPath.workspaceId; @@ -114,7 +142,7 @@ function newDraft(): Session { }; } -/** Exercise the two real controls with the shared session selection adapter. */ +/** Keep draft selection in the composer while the welcome panel is visible. */ function DraftWorkspaceSurfaces() { const [session, setSession] = useState(newDraft); const { selectedWorkspace, workspaceControl } = useSessionWorkspaceSelection(session); @@ -131,13 +159,16 @@ function DraftWorkspaceSurfaces() { ; } -describe('WelcomePanel Git summary loading', () => { +describe('WelcomePanel empty session presentation', () => { let container: HTMLDivElement; let root: Root; beforeEach(() => { vi.clearAllMocks(); + workspaceMocks.hasWorkspace = true; workspaceMocks.selectDraftWorkspace.mockReset(); + workspaceMocks.createChatDraft.mockResolvedValue('selected-workspace-draft'); + workspaceMocks.openMainSession.mockReset(); workspaceMocks.gitScopes.length = 0; workspaceMocks.openedWorkspaces = new Map([ ['workspace-1', workspaceMocks.currentWorkspace as WorkspaceInfo], @@ -157,16 +188,152 @@ describe('WelcomePanel Git summary loading', () => { document.documentElement.removeAttribute('data-openbitfun-appearance'); document.documentElement.removeAttribute('data-openbitfun-appearance-revision'); container.remove(); + vi.restoreAllMocks(); + vi.unstubAllGlobals(); }); - it('renders the git branch chip when a workspace is open', async () => { + it('keeps the caption measured and mounted while inline modes expand and the pane resizes', async () => { + let captionWidth = 248; + let notifyResize = () => {}; + const originalRect = HTMLElement.prototype.getBoundingClientRect; + vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(function (this: HTMLElement) { + return this.classList.contains('welcome-panel__caption-content') + ? new DOMRect(0, 0, captionWidth, 32) : originalRect.call(this); + }); + vi.stubGlobal('ResizeObserver', class { + constructor(callback: () => void) { notifyResize = callback; } + observe() {} + disconnect() {} + }); + await act(async () => root.render()); + const caption = container.querySelector('[data-openbitfun-product-part="caption"]')!; + const workspaceTrigger = container.querySelector('[data-openbitfun-product-part="workspaceAction"]'); + expect(caption.style.getPropertyValue('--_welcome-caption-width')).toBe('248px'); + const mode = container.querySelector('[data-openbitfun-product-part="modeOption"][aria-pressed="true"]')!; + await act(async () => mode.click()); + expect(caption.getAttribute('aria-hidden')).toBe('true'); + captionWidth = 180; + act(() => notifyResize()); + expect(caption.style.getPropertyValue('--_welcome-caption-width')).toBe('180px'); await act(async () => { - root.render(); + mode.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true })); }); + expect(caption.getAttribute('aria-hidden')).toBe('false'); + expect(container.querySelector('[data-openbitfun-product-part="caption"]')).toBe(caption); + expect(container.querySelector('[data-openbitfun-product-part="workspaceAction"]')).toBe(workspaceTrigger); + }); - expect(container.querySelector('[data-openbitfun-product-part="workspaceAction"]')).not.toBeNull(); - expect(container.querySelector('[data-openbitfun-product-part="gitAction"]')).not.toBeNull(); - expect(container.querySelector('[data-openbitfun-product-part="gitAction"]')?.textContent).toContain('main'); + it('expands four named modes and gathers the same icons around the new selection', async () => { + const onSelect = vi.fn(); + function Modes() { + const [profile, setProfile] = useState('Standard'); + return { onSelect(next); setProfile(next); }} />; + } + await act(async () => root.render()); + const modeButtons = () => [...container.querySelectorAll('[data-openbitfun-product-part="modeOption"]')]; + const originalButtons = modeButtons(); + const choices = () => container.querySelector('[data-openbitfun-product-part="modeChoices"]')!; + expect(originalButtons.filter(button => !button.disabled).map(button => button.textContent)).toEqual(['标准']); + await act(async () => originalButtons[1].click()); + expect(choices().getAttribute('data-expanded')).toBe('true'); + expect(modeButtons().map(button => button.textContent)).toEqual(['极简', '标准', '极致', '创造']); + expect(modeButtons().every(button => !button.disabled)).toBe(true); + expect(modeButtons()).toEqual(originalButtons); + await act(async () => originalButtons[3].click()); + expect(onSelect).toHaveBeenCalledWith('Creative'); + expect(choices().getAttribute('data-expanded')).toBe('false'); + expect(modeButtons()).toEqual(originalButtons); + expect(modeButtons().filter(button => !button.disabled).map(button => button.textContent)).toEqual(['创造']); + }); + + it('opens modes with arrow keys and returns focus on Escape', async () => { + await act(async () => root.render()); + const buttons = [...container.querySelectorAll('[data-openbitfun-product-part="modeOption"]')]; + act(() => buttons[1].focus()); + await act(async () => { + buttons[1].dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight', bubbles: true })); + }); + expect(document.activeElement).toBe(buttons[2]); + await act(async () => { + buttons[2].dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true })); + }); + expect(document.activeElement).toBe(buttons[1]); + expect(container.querySelector('[data-expanded="true"]')).toBeNull(); + }); + + it.each([true, false])('commits an explicit mode to the owning session (draft=%s)', async draft => { + const initialSession: Session = { + ...newDraft(), + ...(draft ? {} : { draft: undefined }), + remoteConnectionId: 'ssh-host', remoteSshHost: 'dev-host', + projectWorkspacePath: '/projects/owned', + }; + let liveSession = initialSession; + let publish: (mode: string) => void = () => {}; + function SessionSurface() { + const [current, setCurrent] = useState(initialSession); + liveSession = current; + publish = mode => setCurrent(value => ({ ...value, mode })); + return ; + } + const store = FlowChatStore.getInstance(); + const initialState = store.getState(); + vi.spyOn(store, 'getState').mockImplementation(() => ({ + ...initialState, sessions: new Map([[liveSession.sessionId, liveSession]]), + })); + const update = vi.spyOn(store, 'updateSessionMode').mockImplementation((_id, mode) => publish(mode)); + const hostUpdate = vi.spyOn(agentAPI, 'updateSessionMode').mockResolvedValue(undefined); + const remember = vi.spyOn(chatInputModePreferenceService, 'rememberMode').mockResolvedValue({ + strategy: 'follow_last', fixedModeId: null, lastModeId: 'Ultimate', + }); + await act(async () => root.render()); + const caption = container.querySelector('[data-openbitfun-product-part="caption"]')!; + const buttons = [...container.querySelectorAll('[data-openbitfun-product-part="modeOption"]')]; + await act(async () => buttons[1].click()); + expect(caption.getAttribute('aria-hidden')).toBe('true'); + expect(container.querySelector('[data-openbitfun-product-part="greeting"]')?.getAttribute('data-mode-expanded')).toBe('true'); + expect(container.querySelector('[data-openbitfun-product-part="workspaceAction"]')?.disabled).toBe(true); + await act(async () => buttons[2].click()); + expect(update).toHaveBeenCalledWith('draft-session', 'Ultimate'); + expect(remember).toHaveBeenCalledWith('Ultimate'); + expect(container.querySelector('[data-expanded="true"]')).toBeNull(); + expect(container.querySelector('[data-openbitfun-product-part="caption"]')).toBe(caption); + expect(caption.getAttribute('aria-hidden')).toBe('false'); + if (draft) { + expect(hostUpdate).not.toHaveBeenCalled(); + } else { + expect(hostUpdate).toHaveBeenCalledWith({ + sessionId: 'draft-session', modeId: 'Ultimate', workspacePath: '/projects/owned', + remoteConnectionId: 'ssh-host', remoteSshHost: 'dev-host', + }); + } + }); + + it('does not apply a mode click captured on a previous device surface', async () => { + let currentSurface = true; + const scope = deviceSurface.getActiveSurfaceScope(); + vi.spyOn(deviceSurface, 'getActiveSurfaceScope').mockReturnValue({ ...scope, isCurrent: () => currentSurface }); + const update = vi.spyOn(FlowChatStore.getInstance(), 'updateSessionMode'); + await act(async () => root.render()); + const buttons = [...container.querySelectorAll('[data-openbitfun-product-part="modeOption"]')]; + await act(async () => buttons[1].click()); + currentSurface = false; + await act(async () => buttons[2].click()); + expect(update).not.toHaveBeenCalled(); + }); + + it('includes the project in the greeting without the workspace and Git summary', async () => { + await act(async () => { + root.render(); + }); + + expect(container.querySelector('[data-openbitfun-product-part="heading"]')?.textContent).toBe('在 OpenBitFun,开工。'); + expect(container.querySelector('[data-openbitfun-product-part="narrative"]')).toBeNull(); + expect(container.querySelector('[data-openbitfun-product-part="divider"]')).toBeNull(); + expect(container.querySelector('.welcome-panel__details')).toBeNull(); + expect(workspaceMocks.gitScopes).toEqual([]); + expect(gitApiMock.getStatus).not.toHaveBeenCalled(); }); it('does not render the retired panda mascot', async () => { @@ -178,32 +345,36 @@ describe('WelcomePanel Git summary loading', () => { expect(container.querySelector('img[src^="/panda_full_"]')).toBeNull(); }); - it('keeps the welcome copy, Git scope and strip selection in sync without activating a workspace', async () => { + it('keeps the welcome selector and composer in sync without activating a workspace', async () => { await act(async () => root.render()); const welcomeTrigger = () => container.querySelector('[data-openbitfun-product-part="workspaceAction"]')!; const stripTrigger = () => container.querySelector('[data-testid="chat-input-workspace-trigger"]')!; - await act(async () => stripTrigger().click()); - await act(async () => document.querySelector('[data-testid="chat-input-workspace-option-workspace-2"]')!.click()); - - expect(welcomeTrigger().textContent).toContain('Other project'); - expect(welcomeTrigger().title).toBe('D:/workspace/Other'); - expect(stripTrigger().textContent).toContain('Other project'); - expect(container.querySelector('[data-openbitfun-product-part="gitAction"]')?.textContent).toContain('feature/other'); - expect(workspaceMocks.gitScopes.at(-1)).toBe('workspace-2'); - expect(container.querySelector('[data-openbitfun-product-part="narrative"]')?.textContent).toContain('welcome.waitingToStage'); - // A preview of B must not navigate to the shell's Git panel for A. - expect(container.querySelector('[data-openbitfun-product-part="gitAction"]')?.disabled).toBe(true); - + expect(welcomeTrigger().textContent).toBe('OpenBitFun'); + expect(welcomeTrigger().querySelector('[data-openbitfun-part="trailing-icon"]')).toBeNull(); + await act(async () => { + container.querySelector('[data-openbitfun-product-part="heading"]')! + .dispatchEvent(new MouseEvent('click', { bubbles: true })); + }); + expect(document.querySelector('[data-openbitfun-product-part="workspaceMenu"]')).toBeNull(); await act(async () => welcomeTrigger().click()); - const menu = document.querySelector('[data-openbitfun-product-part="workspaceMenu"]')!; - expect(menu.textContent).not.toContain('header.newProject'); - expect(menu.querySelector('[aria-checked="true"]')?.textContent).toContain('Other project'); - await act(async () => menu.querySelector('[data-openbitfun-product-part="workspaceItem"]')!.click()); + const menu = document.querySelector('[data-openbitfun-product-part="workspaceMenu"]')!; + expect(container.contains(menu)).toBe(false); + expect(menu.closest('[data-openbitfun-overlay-host]')).not.toBeNull(); + const otherProject = [...menu.querySelectorAll('[role="menuitemradio"]')] + .find(item => item.textContent?.includes('Other project'))!; + await act(async () => otherProject.click()); - expect(welcomeTrigger().textContent).toContain('OpenBitFun'); - expect(stripTrigger().textContent).toContain('OpenBitFun'); - expect(workspaceMocks.gitScopes.at(-1)).toBe('workspace-1'); + expect(stripTrigger().textContent).toContain('Other project'); + expect(container.querySelector('[data-openbitfun-product-part="heading"]')?.textContent).toBe('在 Other project,开工。'); + expect(container.querySelector('[data-openbitfun-product-part="narrative"]')).toBeNull(); + expect(workspaceMocks.gitScopes).toEqual([]); expect(container.querySelector('[data-testid="canonical-workspace"]')?.textContent).toBe('workspace-1'); + expect(workspaceMocks.selectDraftWorkspace.mock.calls).toEqual([ + ['draft-session', 'workspace-2'], + ]); + await act(async () => stripTrigger().click()); + await act(async () => document.querySelector('[data-testid="chat-input-workspace-option-workspace-1"]')!.click()); + expect(welcomeTrigger().textContent).toContain('OpenBitFun'); expect(workspaceMocks.selectDraftWorkspace.mock.calls).toEqual([ ['draft-session', 'workspace-2'], ['draft-session', 'workspace-1'], ]); @@ -212,63 +383,80 @@ describe('WelcomePanel Git summary loading', () => { expect(workspaceMocks.switchLeftPanelTab).not.toHaveBeenCalled(); }); - it('closes the welcome selector when first submission binds the draft', async () => { - const session = newDraft(); - await act(async () => root.render()); - await act(async () => container.querySelector('[data-openbitfun-product-part="workspaceAction"]')!.click()); - expect(document.querySelector('[data-openbitfun-product-part="workspaceMenu"]')).not.toBeNull(); - await act(async () => root.render()); - expect(document.querySelector('[data-openbitfun-product-part="workspaceMenu"]')).toBeNull(); - expect(container.querySelector('[data-openbitfun-product-part="workspaceAction"]')?.disabled).toBe(true); - expect(workspaceMocks.switchWorkspace).not.toHaveBeenCalled(); - }); - - it('shows an unavailable draft target without displaying the active project or its Git state', async () => { + it('does not substitute the active project for an unavailable draft target', async () => { const session = newDraft(); session.draft!.workspaceId = 'closed-workspace'; await act(async () => root.render()); - const trigger = container.querySelector('[data-openbitfun-product-part="workspaceAction"]')!; - expect(trigger.textContent).toContain('workspaceStrip.unavailableLabel'); - expect(trigger.disabled).toBe(false); - expect(container.querySelector('[data-openbitfun-product-part="gitAction"]')).toBeNull(); - expect(workspaceMocks.gitScopes.at(-1)).toBe(''); + + expect(container.querySelector('[data-openbitfun-product-part="narrative"]')).toBeNull(); + expect(container.textContent).not.toContain('OpenBitFun'); + expect(workspaceMocks.gitScopes).toEqual([]); }); - it('keeps an existing empty session bound to its own workspace', async () => { + it('allows an existing empty session to enter another workspace without changing its owner', async () => { const session = { ...newDraft(), draft: undefined, workspaceId: 'workspace-2' }; + workspaceMocks.openMainSession.mockImplementation(async (_id, options) => { + await options.activateWorkspace(options.workspaceId); + }); await act(async () => root.render()); - const trigger = container.querySelector('[data-openbitfun-product-part="workspaceAction"]')!; - expect(trigger.textContent).toContain('Other project'); - expect(trigger.disabled).toBe(true); - expect(workspaceMocks.gitScopes.at(-1)).toBe('workspace-2'); - }); - it('portals the workspace menu outside the scrollable welcome panel', async () => { - await act(async () => { - root.render(); + expect(container.querySelector('[data-openbitfun-product-part="narrative"]')).toBeNull(); + expect(container.querySelector('[data-openbitfun-product-part="heading"]')?.textContent).toBe('在 Other project,开工。'); + const trigger = container.querySelector('[data-openbitfun-product-part="workspaceAction"]')!; + expect(trigger.disabled).toBe(false); + await act(async () => trigger.click()); + const menu = document.querySelector('[data-openbitfun-product-part="workspaceMenu"]')!; + const option = [...menu.querySelectorAll('[role="menuitemradio"]')] + .find(item => item.textContent?.includes('OpenBitFun'))!; + await act(async () => option.click()); + expect(workspaceMocks.createChatDraft).toHaveBeenCalledWith({ + workspaceId: 'workspace-1', workspacePath: 'D:/workspace/OpenBitFun', + }, 'Standard'); + expect(workspaceMocks.openMainSession).toHaveBeenCalledWith('selected-workspace-draft', { + workspaceId: 'workspace-1', activateWorkspace: expect.any(Function), isCurrent: expect.any(Function), }); + expect(workspaceMocks.switchWorkspace).toHaveBeenCalledWith(workspaceMocks.currentWorkspace); + expect(workspaceMocks.selectDraftWorkspace).not.toHaveBeenCalled(); + expect(session.workspaceId).toBe('workspace-2'); + expect(workspaceMocks.gitScopes).toEqual([]); + }); - const trigger = container.querySelector('[data-openbitfun-product-part="workspaceAction"]'); - expect(trigger?.getAttribute('data-openbitfun-component')).toBe('button'); - expect(trigger?.querySelector('[data-overflow-behavior]')).toBeNull(); - await act(async () => trigger?.querySelector('[data-openbitfun-part="label"]')?.click()); - - const menu = document.querySelector('[data-openbitfun-product-part="workspaceMenu"]'); - expect(menu?.closest('[data-openbitfun-overlay-host]')?.getAttribute('data-openbitfun-overlay-host')).toBe('true'); - expect(menu?.style.visibility).toBe('visible'); + it('opens the shared project directory flow for other local or remote sources', async () => { + const onNewProject = vi.fn(); + window.addEventListener('nav:new-project', onNewProject); + try { + await act(async () => root.render()); + await act(async () => container.querySelector('[data-openbitfun-product-part="workspaceAction"]')!.click()); + const menu = document.querySelector('[data-openbitfun-product-part="workspaceMenu"]')!; + const openOther = [...menu.querySelectorAll('button')] + .find(item => item.textContent?.includes('welcome.openOtherProject'))!; + await act(async () => openOther.click()); + expect(onNewProject).toHaveBeenCalledTimes(1); + expect(workspaceMocks.openWorkspace).not.toHaveBeenCalled(); + expect(workspaceMocks.selectDraftWorkspace).not.toHaveBeenCalled(); + } finally { + window.removeEventListener('nav:new-project', onNewProject); + } + }); - await act(async () => trigger?.querySelector('[data-openbitfun-part="trailing-icon"]')?.click()); - expect(trigger?.getAttribute('aria-expanded')).toBe('false'); - expect(document.querySelector('[data-openbitfun-product-part="workspaceMenu"]')).toBeNull(); + it('closes and locks the directory menu when submission starts', async () => { + const session = newDraft(); + await act(async () => root.render()); + await act(async () => container.querySelector('[data-openbitfun-product-part="workspaceAction"]')!.click()); + expect(container.querySelector('[aria-expanded="true"]')).not.toBeNull(); + await act(async () => root.render()); + expect(container.querySelector('[data-openbitfun-product-part="workspaceAction"]')?.disabled).toBe(true); + expect(document.querySelector('[data-openbitfun-product-part="workspaceMenu"][data-state="open"]')).toBeNull(); + expect(workspaceMocks.selectDraftWorkspace).not.toHaveBeenCalled(); }); - it('keeps saved welcome action styles targeting the migrated Button', async () => { + it('keeps saved open-workspace action styles targeting the Button', async () => { const legacyPackage: AppearancePackage = { schema: 'openbitfun.appearance', schemaVersion: APPEARANCE_SCHEMA_VERSION, id: 'test.welcome', name: 'Welcome', version: '1.0.0', mode: 'dark', components: { 'welcome-panel': { parts: { - workspaceAction: { base: { opacity: { kind: 'number', value: 0.6 } } }, + openWorkspaceAction: { base: { opacity: { kind: 'number', value: 0.6 } } }, } }, }, }; @@ -284,14 +472,16 @@ describe('WelcomePanel Git summary loading', () => { style.textContent = snapshot.cssText; document.head.appendChild(style); + workspaceMocks.hasWorkspace = false; await act(async () => root.render()); + expect(container.textContent).toContain('welcome.noWorkspaceHint'); const rule = Array.from(style.sheet!.cssRules).find(candidate => candidate instanceof CSSStyleRule && candidate.style.opacity === '0.6', ) as CSSStyleRule | undefined; expect(rule).toBeDefined(); expect(document.querySelector(rule!.selectorText)).toBe( - container.querySelector('[data-openbitfun-product-part="workspaceAction"]'), + container.querySelector('[data-openbitfun-product-part="openWorkspaceAction"]'), ); }); }); diff --git a/src/web-ui/src/flow_chat/components/WelcomePanel.tsx b/src/web-ui/src/flow_chat/components/WelcomePanel.tsx index f35f13fa4d..f97eafce08 100644 --- a/src/web-ui/src/flow_chat/components/WelcomePanel.tsx +++ b/src/web-ui/src/flow_chat/components/WelcomePanel.tsx @@ -3,29 +3,165 @@ * The heading is centered above the floating composer; supporting content follows below. */ -import React, { useEffect, useState, useCallback, useRef, useMemo } from 'react'; -import { useTranslation } from 'react-i18next'; -import { FolderOpen, FolderPlus } from 'lucide-react'; -import { subscribeOverlayInteraction, createOverlayPortal, Button, Menu, MenuItem, MenuSeparator, Icon, PageHeader } from '@openbitfun/ui'; -import { useApp } from '../../app/hooks/useApp'; +import React, { useState, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef } from 'react'; +import { Trans, useTranslation } from 'react-i18next'; +import { Button, Icon, MenuPopover, PageHeader, type MenuEntry } from '@openbitfun/ui'; import { createLogger } from '@/shared/utils/logger'; import { useWorkspaceContext } from '@/infrastructure/contexts/WorkspaceContext'; -import type { WorkspaceInfo } from '@/shared/types'; +import { WorkspaceKind, type WorkspaceInfo } from '@/shared/types'; +import { agentName, canonicalHarnessId, HARNESS_IDS, type HarnessId } from '@/shared/agents/identity'; +import { HARNESS_PRESENTATION } from '@/shared/agents/harnessPresentation'; +import { notificationService } from '@/shared/notification-system'; +import { getActiveSurfaceScope } from '@/infrastructure/peer-device/deviceSurface'; import CoworkExampleCards from './CoworkExampleCards'; +import { AssistantAvatar } from '@/app/components/AssistantAvatar'; import { useAgentIdentityDocument } from '@/app/scenes/my-agent/useAgentIdentityDocument'; -import { getAppearanceOverlayHost } from '@/infrastructure/appearance/runtime/AppearanceOverlayHost'; -import { useAnchoredPopoverPosition } from '@/shared/utils/useAnchoredPopoverPosition'; -import { useGitState } from '@/tools/git/hooks/useGitState'; +import { flowChatSessionConfigForWorkspace } from '@/app/utils/projectSessionWorkspace'; import { useSessionWorkspaceSelection } from '../hooks/useSessionWorkspaceSelection'; +import { useSessionModeSelection } from '../hooks/useSessionModeSelection'; +import { FlowChatStore } from '../store/FlowChatStore'; +import { chatInputModePreferenceService } from '../services/ChatInputModePreferenceService'; +import { FlowChatManager } from '../services/FlowChatManager'; +import { resolveChatInputExecutionLevelPolicy } from '../utils/chatInputExecutionLevelPolicy'; +import { isSessionBindingLocked } from '../utils/sessionLifecycle'; +import { acpAgentTypeFromSession } from '../utils/acpSession'; +import { sessionProjectWorkspacePath } from '../utils/sessionWorkspace'; import type { Session } from '../types/flow-chat'; -import { sessionWorkspaceId } from '../utils/sessionWorkspace'; import { useChatInputState } from '../store/chatInputStateStore'; import { computeFlowChatInputOverlayInsetPx } from '../utils/flowChatScrollLayout'; import './WelcomePanel.css'; -import './WelcomePanelSurface.scss'; const log = createLogger('WelcomePanel'); +/** Keep all four marks mounted so interrupted expansion and selection reverse smoothly. */ +export function WelcomeModeSelector({ profile, disabled, pending, onSelect, onExpandedChange }: { + profile: HarnessId; + disabled: boolean; + pending: boolean; + onSelect: (profile: HarnessId) => void; + onExpandedChange?: (expanded: boolean) => void; +}) { + const { t } = useTranslation('flow-chat'); + const [expanded, setExpanded] = useState(false); + const [focusProfile, setFocusProfile] = useState(null); + const containerRef = useRef(null); + const buttonsRef = useRef>>({}); + const choicesId = useId(); + const name = (id: HarnessId) => agentName({ id, name: id }, t); + + useLayoutEffect(() => { + onExpandedChange?.(expanded); + }, [expanded, onExpandedChange]); + + useEffect(() => { + setExpanded(false); + if (containerRef.current?.contains(document.activeElement)) { + buttonsRef.current[profile]?.focus(); + } + }, [profile, disabled]); + + useEffect(() => { + if (expanded && focusProfile) buttonsRef.current[focusProfile]?.focus(); + }, [expanded, focusProfile]); + + useEffect(() => { + if (!expanded) return; + const closeOutside = (event: PointerEvent) => { + if (event.target instanceof Node && !containerRef.current?.contains(event.target)) { + setExpanded(false); + } + }; + document.addEventListener('pointerdown', closeOutside); + return () => document.removeEventListener('pointerdown', closeOutside); + }, [expanded]); + + return ( +
{ + if (event.relatedTarget instanceof Node && !event.currentTarget.contains(event.relatedTarget)) { + setExpanded(false); + } + }} + onKeyDown={event => { + if (event.key === 'Escape') { + event.preventDefault(); + event.stopPropagation(); + setExpanded(false); + buttonsRef.current[profile]?.focus(); + return; + } + if (disabled || pending) return; + const focusedIndex = HARNESS_IDS.findIndex(id => buttonsRef.current[id] === document.activeElement); + const index = focusedIndex < 0 ? HARNESS_IDS.indexOf(profile) : focusedIndex; + let target: HarnessId | undefined; + if (event.key === 'ArrowRight') target = HARNESS_IDS[(index + 1) % HARNESS_IDS.length]; + if (event.key === 'ArrowLeft') target = HARNESS_IDS[(index + HARNESS_IDS.length - 1) % HARNESS_IDS.length]; + if (event.key === 'Home') target = HARNESS_IDS[0]; + if (event.key === 'End') target = HARNESS_IDS[HARNESS_IDS.length - 1]; + if (target) { + event.preventDefault(); + setExpanded(true); + setFocusProfile(target); + } + }} + > + {HARNESS_IDS.map(id => { + const current = profile === id; + return ( +
+ +
+ ); + })} +
+ ); +} + interface WelcomePanelProps { onQuickAction?: (command: string) => void; className?: string; @@ -48,18 +184,17 @@ export const WelcomePanel: React.FC = ({ const { t: tCommon } = useTranslation('common'); const inputHeight = useChatInputState(state => state.inputHeight); const inputOverlayInsetPx = computeFlowChatInputOverlayInsetPx(inputHeight); - const [workspaceDropdownOpen, setWorkspaceDropdownOpen] = useState(false); const [isSelectingWorkspace, setIsSelectingWorkspace] = useState(false); - const workspaceDropdownRef = useRef(null); + const [workspaceMenuOpen, setWorkspaceMenuOpen] = useState(false); + const [modeSelectorExpanded, setModeSelectorExpanded] = useState(false); const workspaceTriggerRef = useRef(null); - const workspaceMenuRef = useRef(null); + const captionRef = useRef(null); + const captionContentRef = useRef(null); - const { switchLeftPanelTab } = useApp(); const { hasWorkspace: hasActiveWorkspace, currentWorkspace, openedWorkspaces, - openedWorkspacesList, openWorkspace, switchWorkspace, } = useWorkspaceContext(); @@ -70,49 +205,119 @@ export const WelcomePanel: React.FC = ({ const workspacePath = session?.draft ? selectedWorkspace?.rootPath ?? '' : session?.workspacePath ?? initialWorkspacePath; const hasWorkspace = session ? Boolean(workspaceId) : hasActiveWorkspace; - const sessionMode = session?.mode ?? initialSessionMode; - const workspaceLabel = workspace?.name || (session - ? t('workspaceStrip.unavailableLabel') : t('shared:features.workspace')); + const sessionMode = session?.mode ?? session?.config.agentType ?? initialSessionMode; const sessionModeLower = (sessionMode || '').toLowerCase(); const isCoworkSession = sessionModeLower === 'cowork'; const isClawSession = sessionModeLower === 'claw'; - - // Subscribe to shared Git state so the welcome panel stays in sync with - // branch / worktree changes (including external ones picked up by the - // GitStateManager poll). When there is no workspace or we are in a - // cowork/claw session we pass a blank scope so the hook stays idle. - const activeWsId = !isCoworkSession && !isClawSession && workspace - ? session?.draft?.workspaceId ?? (session ? sessionWorkspaceId(session) : workspace.id) - : undefined; - const gitScope = activeWsId ? { workspaceId: activeWsId } : { workspaceId: '' }; - const { - isRepository, - currentBranch, - ahead, - staged, - unstaged, - untracked, - } = useGitState({ - repositoryPath: gitScope, - layers: ['basic', 'status'], - isActive: !!activeWsId, - refreshOnMount: !!activeWsId, - refreshOnActive: true, - participateInWindowFocusRefresh: true, - debugSource: 'welcome_panel', + const harnessProfile = canonicalHarnessId(sessionMode || 'Standard'); + const isModeExpanded = Boolean(harnessProfile && modeSelectorExpanded); + const workspaceName = hasWorkspace ? workspace?.name.trim() : undefined; + const showWorkspaceHeading = !isCoworkSession && !isClawSession && Boolean(workspaceName); + const canSelectWorkspace = !isSelectingWorkspace && (!session?.draft || session.draft.phase === 'editing'); + const surface = getActiveSurfaceScope(); + const executionPolicy = resolveChatInputExecutionLevelPolicy({ + isAssistantWorkspace: workspace?.workspaceKind === WorkspaceKind.Assistant, + sessionMode, + isAcpTargetSession: Boolean(acpAgentTypeFromSession(session)), + isSubagentInputTarget: Boolean(session?.parentSessionId || session?.isTransient), }); + const canSelectMode = Boolean(session && harnessProfile && executionPolicy.userConfigurable + && !isSessionBindingLocked(session) + && (!session.draft || session.draft.phase === 'editing') + && !session.config.dispatchTarget && !session.config.dispatchJobId); + const publishMode = useCallback((modeId: string) => { + if (surface.isCurrent() && session) { + FlowChatStore.getInstance().updateSessionMode(session.sessionId, modeId); + } + }, [session, surface]); + const reportModeFailure = useCallback((error: unknown) => { + if (!surface.isCurrent()) return; + log.warn('Failed to change welcome session mode', error); + notificationService.error(t('chatInput.modeChangeFailed')); + }, [surface, t]); + const rememberMode = useCallback((modeId: string) => { + if (!surface.isCurrent()) return; + void chatInputModePreferenceService.rememberMode(modeId).catch(error => { + if (!surface.isCurrent()) return; + log.warn('Failed to remember welcome session mode', error); + notificationService.warning(t('chatInput.harness.rememberFailed')); + }); + }, [surface, t]); + const { requestModeChange, isModeChangePending } = useSessionModeSelection(session ? { + sessionId: session.sessionId, + draft: Boolean(session.draft), + workspacePath: sessionProjectWorkspacePath(session), + remoteConnectionId: session.remoteConnectionId ?? session.config.remoteConnectionId, + remoteSshHost: session.remoteSshHost ?? session.config.remoteSshHost, + } : null, publishMode, reportModeFailure, rememberMode); + const handleSelectMode = useCallback((profile: HarnessId) => { + if (!canSelectMode || !surface.isCurrent()) return; + const live = session && FlowChatStore.getInstance().getState().sessions.get(session.sessionId); + if (!live || isSessionBindingLocked(live) || (live.draft && live.draft.phase !== 'editing')) return; + requestModeChange(profile); + }, [canSelectMode, surface, session, requestModeChange]); - // Derive the same shape the old loadGitState produced so the render and - // narrative helpers below do not have to change. - const gitState = useMemo(() => { - if (!activeWsId || !isRepository || !currentBranch) return null; - return { - currentBranch, - unstagedFiles: (unstaged?.length || 0) + (untracked?.length || 0), - stagedFiles: staged?.length || 0, - unpushedCommits: ahead || 0, - }; - }, [activeWsId, isRepository, currentBranch, ahead, staged, unstaged, untracked]); + useEffect(() => { + setWorkspaceMenuOpen(false); + }, [session?.sessionId, workspaceId, canSelectWorkspace, isModeExpanded]); + + const handleSelectWorkspace = useCallback(async (target: WorkspaceInfo) => { + setWorkspaceMenuOpen(false); + if (!surface.isCurrent() || !canSelectWorkspace || target.id === workspaceId) return; + if (session && !workspaceControl.locked) { + workspaceControl.onSelect(target.id); + return; + } + setIsSelectingWorkspace(true); + try { + if (session) { + // A persisted session keeps its owner. Enter the selected workspace + // through the same fresh-draft/navigation path as the sidebar. + const nextSessionId = await FlowChatManager.getInstance().createChatDraft( + flowChatSessionConfigForWorkspace(target), harnessProfile ?? undefined, + ); + surface.assertCurrent('open selected workspace conversation'); + const { openMainSession } = await import('../services/sessionActivation'); + surface.assertCurrent('navigate selected workspace conversation'); + await openMainSession(nextSessionId, { + workspaceId: target.id, + activateWorkspace: () => switchWorkspace(target), + isCurrent: () => surface.isCurrent(), + }); + } else { + await switchWorkspace(target); + } + } catch (error) { + if (!surface.isCurrent()) return; + log.warn('Failed to switch workspace', error); + notificationService.error(t('workspaceStrip.unavailable')); + } finally { + if (surface.isCurrent()) setIsSelectingWorkspace(false); + } + }, [session, workspaceControl, switchWorkspace, t, surface, canSelectWorkspace, workspaceId, harnessProfile]); + + const workspaceMenuItems = useMemo(() => { + const options = session ? workspaceControl.options : [...openedWorkspaces.values()] + .filter(item => item.workspaceKind !== WorkspaceKind.Assistant); + return [ + ...options.map(target => ({ + id: target.id, + label: target.name, + role: 'menuitemradio' as const, + checked: target.id === workspaceId, + onSelect: () => { void handleSelectWorkspace(target); }, + })), + { id: 'separator', label: '', separator: true }, + { + id: 'open-other-project', + label: t('welcome.openOtherProject'), + onSelect: () => { + setWorkspaceMenuOpen(false); + window.dispatchEvent(new Event('nav:new-project')); + }, + }, + ]; + }, [session, workspaceControl.options, openedWorkspaces, workspaceId, handleSelectWorkspace, t]); const identityWorkspace = useMemo( () => (isClawSession && workspaceId ? { id: workspaceId, rootPath: workspacePath } : null), @@ -123,131 +328,52 @@ export const WelcomePanel: React.FC = ({ const greeting = useMemo(() => { const hour = new Date().getHours(); - const s = isCoworkSession ? 'Cowork' : isClawSession ? 'Claw' : ''; + const showGreeting = isCoworkSession || isClawSession; if (hour >= 5 && hour < 12) return { - title: s ? t('welcome.greetingMorning') : t('welcome.openingMorning'), - subtitle: s ? t(`welcome.subtitleMorning${s}`) : undefined, + title: showGreeting ? t('welcome.greetingMorning') : t('welcome.openingMorning'), + subtitle: isCoworkSession ? t('welcome.subtitleMorningCowork') : undefined, }; if (hour >= 12 && hour < 18) return { - title: s ? t('welcome.greetingAfternoon') : t('welcome.openingAfternoon'), - subtitle: s ? t(`welcome.subtitleAfternoon${s}`) : undefined, + title: showGreeting ? t('welcome.greetingAfternoon') : t('welcome.openingAfternoon'), + subtitle: isCoworkSession ? t('welcome.subtitleAfternoonCowork') : undefined, }; if (hour >= 18 && hour < 23) return { - title: s ? t('welcome.greetingEvening') : t('welcome.openingEvening'), - subtitle: s ? t(`welcome.subtitleEvening${s}`) : undefined, + title: showGreeting ? t('welcome.greetingEvening') : t('welcome.openingEvening'), + subtitle: isCoworkSession ? t('welcome.subtitleEveningCowork') : undefined, }; return { - title: s ? t('welcome.greetingNight') : t('welcome.openingNight'), - subtitle: s ? t(`welcome.subtitleNight${s}`) : undefined, + title: showGreeting ? t('welcome.greetingNight') : t('welcome.openingNight'), + subtitle: isCoworkSession ? t('welcome.subtitleNightCowork') : undefined, }; }, [t, isCoworkSession, isClawSession]); - const aiPartnerKey = isCoworkSession ? 'welcome.aiPartnerCowork' : isClawSession ? 'welcome.aiPartnerClaw' : null; + const showNarrative = !isClawSession && !hasWorkspace; + const showDetails = Boolean(greeting.subtitle) || showNarrative || isCoworkSession; - const otherWorkspaces = useMemo( - () => (session ? workspaceControl.options : openedWorkspacesList).filter(ws => ws.id !== workspaceId), - [session, workspaceControl.options, openedWorkspacesList, workspaceId], - ); - const canSwitchWorkspace = session - ? !workspaceControl.locked && otherWorkspaces.length > 0 : true; - // The shell Git panel still follows its active workspace. A draft preview of - // another project must not open that unrelated panel or activate the project. - const canNavigateGit = !!activeWsId && activeWsId === currentWorkspace?.id; - useEffect(() => { - setWorkspaceDropdownOpen(false); - }, [session?.sessionId, workspaceId, canSwitchWorkspace]); - const workspaceMenuLayout = useAnchoredPopoverPosition({ - open: workspaceDropdownOpen, - anchorRef: workspaceTriggerRef, - popoverRef: workspaceMenuRef, - preferredPlacement: 'bottom', - alignment: 'start', - gap: 4, - layoutRevision: otherWorkspaces.length, - }); - - const handleGitClick = useCallback(() => { - if (canNavigateGit) switchLeftPanelTab('git'); - }, [canNavigateGit, switchLeftPanelTab]); - - const isGitClean = useMemo( - () => !!gitState && gitState.unstagedFiles === 0 && gitState.stagedFiles === 0 && gitState.unpushedCommits === 0, - [gitState], - ); - - const buildGitNarrative = useCallback((): React.ReactNode => { - if (!gitState) return null; - const parts: { key: string; label: string; suffix: string }[] = []; - if (gitState.unstagedFiles > 0) - parts.push({ key: 'unstaged', label: t('welcome.gitUnstaged', { count: gitState.unstagedFiles }), suffix: t('welcome.waitingToStage') }); - if (gitState.stagedFiles > 0) - parts.push({ key: 'staged', label: t('welcome.gitStaged', { count: gitState.stagedFiles }), suffix: t('welcome.stagedReady') }); - if (gitState.unpushedCommits > 0) - parts.push({ key: 'unpushed', label: t('welcome.gitUnpushed', { count: gitState.unpushedCommits }), suffix: t('welcome.toPush') }); - if (parts.length === 0) return null; - return ( - <> - {t('welcome.currentlyHas')} - {parts.map(({ key, label, suffix }, i) => ( - - {i > 0 && t('welcome.commaSeparator')} - - {' '}{suffix} - - ))} - {t('welcome.period')} - - ); - }, [gitState, handleGitClick, canNavigateGit, t]); + const aiPartnerKey = isCoworkSession ? 'welcome.aiPartnerCowork' : isClawSession ? 'welcome.aiPartnerClaw' : null; - useEffect(() => { - if (!workspaceDropdownOpen) return; - const handlePointerDown = (e: MouseEvent) => { - const target = e.target as Node; - if ( - workspaceDropdownRef.current && - !workspaceDropdownRef.current.contains(target) && - !workspaceMenuRef.current?.contains(target) - ) { - setWorkspaceDropdownOpen(false); - } - }; - const handleKeyDown = (e: KeyboardEvent) => { - if (e.key !== 'Escape') return; - e.preventDefault(); - setWorkspaceDropdownOpen(false); - workspaceTriggerRef.current?.focus(); + // Measure the caption independently of its animated shell, so it can give + // the mode choices its exact space without wrapping or jumping mid-motion. + useLayoutEffect(() => { + const shell = captionRef.current; + const content = captionContentRef.current; + if (!shell || !content) return; + const measure = () => { + const width = content.getBoundingClientRect().width; + if (width > 0) shell.style.setProperty('--_welcome-caption-width', `${width}px`); }; - const removeOverlayMousedown0 = subscribeOverlayInteraction(workspaceMenuRef, 'mousedown', handlePointerDown); - const removeOverlayKeydown1 = subscribeOverlayInteraction(workspaceMenuRef, 'keydown', handleKeyDown); + measure(); + const observer = typeof ResizeObserver === 'undefined' ? undefined : new ResizeObserver(measure); + observer?.observe(content); + window.addEventListener('resize', measure); return () => { - removeOverlayMousedown0?.(); - removeOverlayKeydown1?.(); + observer?.disconnect(); + window.removeEventListener('resize', measure); }; - }, [workspaceDropdownOpen]); - - const handleSwitchWorkspace = useCallback(async (ws: WorkspaceInfo) => { - setWorkspaceDropdownOpen(false); - if (session) { - workspaceControl.onSelect(ws.id); - return; - } - try { await switchWorkspace(ws); } - catch (err) { log.warn('Failed to switch workspace', err); } - }, [session, workspaceControl, switchWorkspace]); + }, [greeting.title, workspaceName, aiPartnerKey, assistantName, t]); const handleOpenOtherFolder = useCallback(async () => { try { - setWorkspaceDropdownOpen(false); setIsSelectingWorkspace(true); const { pickWorkspaceDirectory } = await import( '@/infrastructure/peer-device/pickWorkspaceDirectory' @@ -263,11 +389,6 @@ export const WelcomePanel: React.FC = ({ } }, [openWorkspace, tCommon]); - const handleCreateWorkspace = useCallback(() => { - setWorkspaceDropdownOpen(false); - window.dispatchEvent(new Event('nav:new-project')); - }, []); - const handleQuickActionClick = useCallback((cmd: string) => { onQuickAction?.(cmd); }, [onQuickAction]); @@ -277,29 +398,84 @@ export const WelcomePanel: React.FC = ({ style={{ height: `max(0px, calc(100% - ${inputOverlayInsetPx}px))` }}>
{/* Greeting */} -
- - {greeting.title} - {aiPartnerKey && <>,{t(aiPartnerKey)}{isClawSession && assistantName ? `,${assistantName}` : ''}} - } - /> +
+ {harnessProfile ? ( + + ) : + {isClawSession + ? + : } + } +
+ + {showWorkspaceHeading ? ( + setWorkspaceMenuOpen(open => !open)} + disabled={!canSelectWorkspace || isModeExpanded} + aria-haspopup="menu" + aria-expanded={workspaceMenuOpen && canSelectWorkspace} + title={tCommon('header.selectProjectDirectory')} + > + {workspaceName} + + ), + }} + /> + ) : greeting.title} + {aiPartnerKey && <>,{t(aiPartnerKey)}{isClawSession && assistantName ? `,${assistantName}` : ''}} + } + /> +
-
- {greeting.subtitle && ( -

{greeting.subtitle}

- )} -
+ setWorkspaceMenuOpen(false)} + placement="bottom" + aria-label={tCommon('header.selectProjectDirectory')} + data-openbitfun-product-component="welcome-panel" + data-openbitfun-product-part="workspaceMenu" + /> - {/* Narrative: workspace + git in natural language */} -
-

- {isClawSession ? ( - t('welcome.narrativeClaw') - ) : !hasWorkspace ? ( - <> + {showDetails && ( +

+ {greeting.subtitle && ( +

{greeting.subtitle}

+ )} +
+ + {showNarrative && ( +
+

{t('welcome.noWorkspaceHint')} {' '}{t('welcome.toStart')} - - ) : ( - <> - - - {isCoworkSession ? t('welcome.workingInCowork') : t('welcome.workingIn')} - - - - - {workspaceDropdownOpen && canSwitchWorkspace && createOverlayPortal( -

- {!session && } - onClick={() => { void handleCreateWorkspace(); }} - > - {tCommon('header.newProject')} - } - {!session && (hasWorkspace || otherWorkspaces.length > 0) && } - {hasWorkspace && workspace && ( - } - metadata={} - > - {workspace.name} - - )} - {otherWorkspaces.length > 0 && ( - <> - {hasWorkspace && workspace && } - {otherWorkspaces.map(ws => ( - } - onClick={() => { void handleSwitchWorkspace(ws); }} - title={ws.rootPath} - > - {ws.name} - - ))} - - )} - , - getAppearanceOverlayHost(), - )} - - {!isCoworkSession && gitState && ( - <> - / - - - )} - - - {!isCoworkSession && gitState ? t('welcome.project') : t('welcome.projectCowork')} - - - {!isCoworkSession && gitState ? ( - - {isGitClean - ? {t('welcome.gitClean')} - : buildGitNarrative()} - - ) : null} - - )} -

-
+

+
+ )} - {/* Cowork examples */} - {isCoworkSession && ( -
- handleQuickActionClick(p)} /> -
- )} -
+ {/* Cowork examples */} + {isCoworkSession && ( +
+ handleQuickActionClick(p)} /> +
+ )} +
+ )}
); diff --git a/src/web-ui/src/flow_chat/components/WelcomePanelSurface.scss b/src/web-ui/src/flow_chat/components/WelcomePanelSurface.scss deleted file mode 100644 index a6876e86e4..0000000000 --- a/src/web-ui/src/flow_chat/components/WelcomePanelSurface.scss +++ /dev/null @@ -1,5 +0,0 @@ -@use '@/shared/styles/surface-recipes' as surfaces; - -.welcome-panel__dropdown { - @include surfaces.floating; -} diff --git a/src/web-ui/src/flow_chat/components/overlayClippingContract.test.ts b/src/web-ui/src/flow_chat/components/overlayClippingContract.test.ts index fed5868d45..d645a95df0 100644 --- a/src/web-ui/src/flow_chat/components/overlayClippingContract.test.ts +++ b/src/web-ui/src/flow_chat/components/overlayClippingContract.test.ts @@ -11,7 +11,6 @@ const ANCHORED_OVERLAYS = [ { name: 'chat input pickers', path: './ChatInput.tsx' }, { name: 'chat context picker', path: './ChatContextPicker.tsx' }, { name: 'permission menu', path: './ChatInputWorkspaceStrip.tsx' }, - { name: 'welcome workspace menu', path: './WelcomePanel.tsx' }, { name: 'session menu', path: './session-menu/SessionMenu.tsx' }, { name: 'toolbar overflow menu', path: './toolbar-mode/ToolbarMode.tsx' }, { name: 'message copy menu', path: './modern/ModelRoundItem.tsx' }, diff --git a/src/web-ui/src/flow_chat/components/usage/SessionUsageEmptyState.tsx b/src/web-ui/src/flow_chat/components/usage/SessionUsageEmptyState.tsx index 84a015ed5f..d95930b99b 100644 --- a/src/web-ui/src/flow_chat/components/usage/SessionUsageEmptyState.tsx +++ b/src/web-ui/src/flow_chat/components/usage/SessionUsageEmptyState.tsx @@ -8,7 +8,6 @@ export function SessionUsageEmptyState() { data-testid="session-usage-empty" role="status" title={t('usage.empty.session')} - description={t('usage.empty.sessionDescription')} /> ); } diff --git a/src/web-ui/src/locales/en-US/flow-chat.json b/src/web-ui/src/locales/en-US/flow-chat.json index d54708e79e..6fbfc75826 100644 --- a/src/web-ui/src/locales/en-US/flow-chat.json +++ b/src/web-ui/src/locales/en-US/flow-chat.json @@ -315,8 +315,7 @@ "errorsDescription": "No sampled tool or model errors were recorded.", "slowest": "No slow spans", "slowestDescription": "No timed turn, model-call, or tool spans were recorded.", - "session": "No activity yet", - "sessionDescription": "Send a message in this session to start. Model usage, tools and timing will appear here after the session runs." + "session": "No activity yet" }, "help": { "wall": "Span from the first recorded turn start to the last recorded turn end. Idle gaps can be included.", @@ -849,6 +848,7 @@ } }, "harness": { + "modeLabel": "{{name}} mode", "selectorTooltip": "Current execution: {{name}}", "fixedTooltip": "This session uses {{name}} and is now fixed.", "compatibilityShort": "Legacy", @@ -3322,6 +3322,7 @@ } }, "welcome": { + "openingWorkspace": "Let's get to work in {{workspace}}.", "openingMorning": "Good morning. The day starts with you.", "openingAfternoon": "Good afternoon. Let's make today a little more interesting.", "openingEvening": "Good evening. Set your own pace.", diff --git a/src/web-ui/src/locales/zh-CN/flow-chat.json b/src/web-ui/src/locales/zh-CN/flow-chat.json index 75db9ff76b..3e62b44c84 100644 --- a/src/web-ui/src/locales/zh-CN/flow-chat.json +++ b/src/web-ui/src/locales/zh-CN/flow-chat.json @@ -315,8 +315,7 @@ "errorsDescription": "本次报告没有记录到可展示的工具或模型错误样例。", "slowest": "无慢耗时记录", "slowestDescription": "没有记录到带耗时的轮次、模型调用或工具片段。", - "session": "还没有会话活动", - "sessionDescription": "在此会话中发送一条消息即可开始。运行后,这里会显示模型用量、工具调用和耗时。" + "session": "还没有会话活动" }, "runtime": { "open": "生成会话用量", @@ -849,6 +848,7 @@ } }, "harness": { + "modeLabel": "{{name}}模式", "selectorTooltip": "当前执行:{{name}}", "fixedTooltip": "本会话使用 {{name}},开始后已固定。", "compatibilityShort": "兼容模式", @@ -3322,6 +3322,7 @@ } }, "welcome": { + "openingWorkspace": "在 {{workspace}},开工。", "openingMorning": "早安,今天由你开场。", "openingAfternoon": "下午好,给今天加点意思。", "openingEvening": "晚上好,按你的节奏来。", diff --git a/src/web-ui/src/locales/zh-TW/flow-chat.json b/src/web-ui/src/locales/zh-TW/flow-chat.json index d949532d7a..65d8621909 100644 --- a/src/web-ui/src/locales/zh-TW/flow-chat.json +++ b/src/web-ui/src/locales/zh-TW/flow-chat.json @@ -315,8 +315,7 @@ "errorsDescription": "本次報告沒有記錄到可顯示的工具或模型錯誤範例。", "slowest": "無慢耗時記錄", "slowestDescription": "沒有記錄到帶耗時的回合、模型呼叫或工具片段。", - "session": "還沒有工作階段活動", - "sessionDescription": "在此工作階段中傳送一則訊息即可開始。執行後,這裡會顯示模型用量、工具呼叫和耗時。" + "session": "還沒有工作階段活動" }, "runtime": { "open": "產生工作階段用量", @@ -849,6 +848,7 @@ } }, "harness": { + "modeLabel": "{{name}}模式", "selectorTooltip": "目前執行:{{name}}", "fixedTooltip": "本工作階段使用 {{name}},開始後已固定。", "compatibilityShort": "相容模式", @@ -3322,6 +3322,7 @@ } }, "welcome": { + "openingWorkspace": "在 {{workspace}},開工。", "openingMorning": "早安,今天由你開場。", "openingAfternoon": "下午好,給今天加點意思。", "openingEvening": "晚上好,按你的節奏來。", diff --git a/src/web-ui/src/tools/git/components/BranchQuickSwitch.tsx b/src/web-ui/src/tools/git/components/BranchQuickSwitch.tsx index bed7ef5f26..88daab8913 100644 --- a/src/web-ui/src/tools/git/components/BranchQuickSwitch.tsx +++ b/src/web-ui/src/tools/git/components/BranchQuickSwitch.tsx @@ -553,7 +553,7 @@ export const BranchQuickSwitch: React.FC = ({ ? : undefined} key={branch.name} - leading={} + leading={} onClick={() => void handleSwitchBranch(branch.name)} selected={branch.current} value={branch.name}