Skip to content

🀯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

♻️ refactor(styles): migrate Conversation sidebar, share and markdown plugins to StyleX (#21454)

Innei53a6b25845c8
diff --git a/scripts/stylexMigration/legacyFiles.json b/scripts/stylexMigration/legacyFiles.json
index 2a92ebe0d77..b3da5d51b3f 100644
--- a/scripts/stylexMigration/legacyFiles.json
+++ b/scripts/stylexMigration/legacyFiles.json
@@ -190,7 +190,6 @@
"src/features/AuthShell/style.ts",
"src/features/BackgroundActivity/ActivityTable.tsx",
"src/features/BackgroundActivity/ProcessExplorer/style.ts",
- "src/features/BackgroundActivity/TopicSection.tsx",
"src/features/Billboard/Carousel.tsx",
"src/features/ChatMiniMap/styles.ts",
"src/features/ChatTerminal/Content.tsx",
@@ -200,70 +199,8 @@
"src/features/Connectors/ConnectorDetail/ToolPermissionGroup.tsx",
"src/features/Connectors/ConnectorDetail/ToolPermissionRow.tsx",
"src/features/Connectors/ConnectorList/ConnectorItem.tsx",
- "src/features/Conversation/AgentWelcome/ToolAuthAlert.tsx",
- "src/features/Conversation/ChatInput/LinkedGoalTray/index.tsx",
- "src/features/Conversation/ChatInput/OpStatusTray.tsx",
- "src/features/Conversation/ChatInput/QueueTray.tsx",
- "src/features/Conversation/ChatItem/components/ErrorContent.tsx",
- "src/features/Conversation/ChatItem/components/MessageContent/index.tsx",
- "src/features/Conversation/ChatItem/style.ts",
- "src/features/Conversation/Error/PlanLimitCard/index.tsx",
- "src/features/Conversation/Error/style.tsx",
- "src/features/Conversation/FollowUp/style.ts",
- "src/features/Conversation/InterventionBar/UserInterventionErrorBoundary.tsx",
- "src/features/Conversation/InterventionBar/style.ts",
- "src/features/Conversation/Markdown/plugins/FileLink/Render.tsx",
- "src/features/Conversation/Markdown/plugins/GoalTurn/Render.tsx",
- "src/features/Conversation/Markdown/plugins/ImageSearchRef/Render.tsx",
- "src/features/Conversation/Markdown/plugins/LobeAgents/Render/index.tsx",
- "src/features/Conversation/Markdown/plugins/LobeArtifact/Render/index.tsx",
- "src/features/Conversation/Markdown/plugins/LocalFileLink/Render.tsx",
- "src/features/Conversation/Markdown/plugins/Mention/Render.tsx",
- "src/features/Conversation/Markdown/plugins/ScmEvent/Render.tsx",
- "src/features/Conversation/Markdown/plugins/Task/Render.tsx",
- "src/features/Conversation/Markdown/plugins/UserFeedback/Render.tsx",
- "src/features/Conversation/MessageForward/ForwardModal.tsx",
- "src/features/Conversation/MessageForward/MessageSelectionWrapper.tsx",
- "src/features/Conversation/MessageForward/SelectCircle.tsx",
- "src/features/Conversation/MessageForward/SelectToHereButton.tsx",
- "src/features/Conversation/MessageForward/SelectionFooterBar.tsx",
- "src/features/Conversation/MessageForward/TopicForwardModal/Content.tsx",
- "src/features/Conversation/SplitDropZone/index.tsx",
- "src/features/Conversation/TodoProgress/index.tsx",
- "src/features/Conversation/WorkingSidebar/Browser/index.tsx",
- "src/features/Conversation/WorkingSidebar/Files/index.tsx",
- "src/features/Conversation/WorkingSidebar/GoalSection/GoalWorkflowCard.tsx",
- "src/features/Conversation/WorkingSidebar/Overview/DeviceStatusSection.tsx",
- "src/features/Conversation/WorkingSidebar/Overview/OverviewHeader.tsx",
- "src/features/Conversation/WorkingSidebar/Overview/OverviewRow.tsx",
- "src/features/Conversation/WorkingSidebar/Overview/PortSwitcher.tsx",
- "src/features/Conversation/WorkingSidebar/Overview/index.tsx",
- "src/features/Conversation/WorkingSidebar/Overview/sectionStyles.ts",
- "src/features/Conversation/WorkingSidebar/ProgressSection/index.tsx",
"src/features/Conversation/WorkingSidebar/PullRequest/ActivityTimeline.tsx",
- "src/features/Conversation/WorkingSidebar/PullRequest/ChecksList.tsx",
- "src/features/Conversation/WorkingSidebar/PullRequest/DockActionButton.tsx",
- "src/features/Conversation/WorkingSidebar/PullRequest/Head.tsx",
- "src/features/Conversation/WorkingSidebar/PullRequest/MergeDock.tsx",
"src/features/Conversation/WorkingSidebar/PullRequest/Sections.tsx",
- "src/features/Conversation/WorkingSidebar/PullRequest/Skeleton.tsx",
- "src/features/Conversation/WorkingSidebar/PullRequest/index.tsx",
- "src/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.tsx",
- "src/features/Conversation/WorkingSidebar/Review/FileItem.tsx",
- "src/features/Conversation/WorkingSidebar/Review/FileRow.tsx",
- "src/features/Conversation/WorkingSidebar/Review/FileTreeNav.tsx",
- "src/features/Conversation/WorkingSidebar/Review/GroupHeader.tsx",
- "src/features/Conversation/WorkingSidebar/Review/index.tsx",
- "src/features/Conversation/WorkingSidebar/WorksSection/VersionList.tsx",
- "src/features/Conversation/WorkingSidebar/WorksSection/WorkVersionHistoryCard.tsx",
- "src/features/Conversation/WorkingSidebar/WorksSection/index.tsx",
- "src/features/Conversation/WorkingSidebar/WorkspaceTab.tsx",
- "src/features/Conversation/WorkingSidebar/index.tsx",
- "src/features/Conversation/Workspace/index.tsx",
- "src/features/Conversation/components/History/index.tsx",
- "src/features/Conversation/components/PortalResourceCard/index.tsx",
- "src/features/Conversation/components/Reaction/ReactionDisplay.tsx",
- "src/features/Conversation/components/Reaction/ReactionPicker.tsx",
"src/features/Conversation/components/ShareMessageModal/style.ts",
"src/features/Conversation/components/Thinking/index.tsx",
"src/features/DailyBrief/BriefCardArtifacts.tsx",
diff --git a/scripts/stylexMigration/verification/fixtures/ChatItemFixtureData.tsx b/scripts/stylexMigration/verification/fixtures/ChatItemFixtureData.tsx
new file mode 100644
index 00000000000..c304768d2dc
--- /dev/null
+++ b/scripts/stylexMigration/verification/fixtures/ChatItemFixtureData.tsx
@@ -0,0 +1,36 @@
+import type { ReactNode } from 'react';
+
+const state = {
+ selectRange: () => {},
+ toggleMessageSelected: () => {},
+};
+
+const select = <T,>(selector: (value: typeof state) => T) => selector(state);
+
+export const useConversationStore = select;
+export const useAgentStore = select;
+export const useGlobalStore = select;
+
+export const contextSelectors = {
+ agentId: () => undefined,
+ conversationKey: () => undefined,
+};
+export const messageStateSelectors = {
+ isMessageSelected: () => () => false,
+ isSelectionMode: () => true,
+};
+export const builtinAgentSelectors = { webOnboardingAgentId: () => undefined };
+export const systemStatusSelectors = { wideScreen: () => true };
+
+export const isDev = false;
+
+export const useActivityTime = () => ({ text: '2 minutes ago', title: '2026-11-05 10:00' });
+
+const Placeholder = ({ children, message }: { children?: ReactNode; message?: ReactNode }) => (
+ <div style={{ minHeight: 32, minWidth: 32 }}>
+ {message}
+ {children}
+ </div>
+);
+
+export default Placeholder;
diff --git a/scripts/stylexMigration/verification/fixtures/ConversationChatItemFixture.tsx b/scripts/stylexMigration/verification/fixtures/ConversationChatItemFixture.tsx
new file mode 100644
index 00000000000..415860f3a13
--- /dev/null
+++ b/scripts/stylexMigration/verification/fixtures/ConversationChatItemFixture.tsx
@@ -0,0 +1,34 @@
+import { ConversationChatItem } from 'verification:component';
+
+import MessageSelectionWrapper from '@/features/Conversation/MessageForward/MessageSelectionWrapper';
+
+const actions = (popupOpen: boolean) => (
+ <>
+ <button type="button">Copy</button>
+ <button data-popup-open={popupOpen ? '' : undefined} type="button">
+ More
+ </button>
+ </>
+);
+
+export const Fixture = ({ variant }: { variant: string }) => {
+ const isUser = variant.includes('user');
+ const item = (
+ <ConversationChatItem
+ showTitle
+ actions={actions(variant === 'popup-open')}
+ avatar={{ avatar: 'A', title: 'Fixture agent' }}
+ id={'msg_fixture'}
+ message={'A message body long enough to wrap across the fixture width.'}
+ placement={isUser ? 'right' : 'left'}
+ time={Date.UTC(2026, 10, 5, 10)}
+ {...(variant === 'locate-highlight' ? { 'data-message-locate-highlight': '' } : {})}
+ />
+ );
+ if (!variant.startsWith('selection')) return item;
+ return (
+ <MessageSelectionWrapper id={'msg_fixture'} role={isUser ? 'user' : 'assistant'}>
+ {item}
+ </MessageSelectionWrapper>
+ );
+};
diff --git a/scripts/stylexMigration/verification/fixtures/PullRequestDockActionButtonFixture.tsx b/scripts/stylexMigration/verification/fixtures/PullRequestDockActionButtonFixture.tsx
new file mode 100644
index 00000000000..57a0ee634fd
--- /dev/null
+++ b/scripts/stylexMigration/verification/fixtures/PullRequestDockActionButtonFixture.tsx
@@ -0,0 +1,28 @@
+import { PullRequestDockActionButton } from 'verification:component';
+
+const noop = () => {};
+const onAction = async () => true;
+const detail = { baseRefName: 'canary', headRefName: 'feat/fixture', headRefOid: 'abc123' };
+
+const actions = {
+ 'merge-success': { kind: 'merge', method: 'squash', tone: 'success' },
+ 'merge-error': { admin: true, kind: 'merge', method: 'merge', tone: 'error' },
+ 'merge-plain': { kind: 'merge', method: 'rebase', tone: 'plain' },
+ 'update-busy': { busy: true, kind: 'updateBranch', tone: 'success' },
+ 'secondary': { kind: 'updateBranch', tone: 'success' },
+} as const;
+
+export const Fixture = ({ variant }: { variant: string }) => {
+ const key = variant.replace(/^dark-/, '') as keyof typeof actions;
+ return (
+ <PullRequestDockActionButton
+ action={actions[key]}
+ bypass={false}
+ detail={detail}
+ secondary={key === 'secondary'}
+ onAction={onAction}
+ onPickMethod={noop}
+ onToggleBypass={noop}
+ />
+ );
+};
diff --git a/scripts/stylexMigration/verification/fixtures/ReviewFileListFixture.tsx b/scripts/stylexMigration/verification/fixtures/ReviewFileListFixture.tsx
new file mode 100644
index 00000000000..12834044125
--- /dev/null
+++ b/scripts/stylexMigration/verification/fixtures/ReviewFileListFixture.tsx
@@ -0,0 +1,20 @@
+import { ReviewFileList } from 'verification:component';
+
+import { FixtureI18n } from './FixtureI18n';
+import { flatRepo, groupedRepo } from './ReviewFileListFixtureData';
+
+const composerTarget = { reason: 'read-only', writable: false } as const;
+
+export const Fixture = ({ variant }: { variant: string }) => (
+ <FixtureI18n>
+ <div style={{ display: 'flex', flexDirection: 'column', maxWidth: 480 }}>
+ <ReviewFileList
+ active
+ composerTarget={composerTarget}
+ showTree={false}
+ workingDirectory={variant === 'flat' ? flatRepo : groupedRepo}
+ onToggleTree={() => {}}
+ />
+ </div>
+ </FixtureI18n>
+);
diff --git a/scripts/stylexMigration/verification/fixtures/ReviewFileListFixtureData.ts b/scripts/stylexMigration/verification/fixtures/ReviewFileListFixtureData.ts
new file mode 100644
index 00000000000..c52f17b0d13
--- /dev/null
+++ b/scripts/stylexMigration/verification/fixtures/ReviewFileListFixtureData.ts
@@ -0,0 +1,75 @@
+export const groupedRepo = '/Users/fixture/lobehub';
+export const flatRepo = '/Users/fixture/lobe-chat';
+
+type Status = 'added' | 'deleted' | 'modified';
+
+const file = (filePath: string, status: Status, additions: number, deletions: number) => ({
+ additions,
+ deletions,
+ filePath,
+ isBinary: false,
+ patch: '',
+ status,
+ truncated: false,
+});
+
+const parentPatches = [
+ file('src/features/Conversation/WorkingSidebar/Review/FileRow.tsx', 'modified', 18, 7),
+ file('src/features/Conversation/WorkingSidebar/Review/GroupHeader.tsx', 'modified', 9, 12),
+ file('packages/locales/src/default/chat.ts', 'added', 4, 0),
+];
+
+const reviewData: Record<string, unknown> = {
+ [flatRepo]: { mode: 'unstaged', patches: parentPatches },
+ [groupedRepo]: {
+ mode: 'unstaged',
+ patches: parentPatches,
+ submodules: [
+ {
+ absolutePath: `${groupedRepo}/packages/lobe-ui`,
+ branch: 'feat/stylex-review',
+ name: 'lobe-ui',
+ patches: [
+ file('src/PatchDiff/PatchDiff.tsx', 'modified', 6, 3),
+ file('src/PatchDiff/style.ts', 'deleted', 0, 41),
+ ],
+ relativePath: 'packages/lobe-ui',
+ },
+ {
+ absolutePath: `${groupedRepo}/packages/business`,
+ branch: 'main',
+ name: 'business',
+ patches: [],
+ relativePath: 'packages/business',
+ },
+ ],
+ },
+};
+
+export const useReviewPatches = (workingDirectory: string) => ({
+ data: reviewData[workingDirectory],
+ error: undefined,
+ isLoading: false,
+ isValidating: false,
+});
+export const useGitRemoteBranches = () => ({ data: undefined });
+export const useFetchGitBranch = (_deviceId: string | undefined, path?: string) => ({
+ data: path ? { branch: 'canary', detached: false } : undefined,
+});
+export const getReviewSummaryState = () => ({ diffPending: false, isSummary: false });
+export const invalidateGitReviewCaches = async () => {};
+
+export const itemKey = (groupPath: string, entry: { filePath: string; status: string }) =>
+ `${groupPath}|${entry.status}:${entry.filePath}`;
+export const getDefaultExpandedKeys = (): string[] => [];
+
+const storeState = { addChatContextSelection: () => {}, revealInFilesTab: () => {} };
+const select = <T>(selector: (state: typeof storeState) => T) => selector(storeState);
+export const useFileStore = select;
+export const useGlobalStore = select;
+export const gitService = { revertGitFile: async () => ({ success: true }) };
+export const nanoid = () => 'fixture';
+
+const FileTreeNav = () => null;
+
+export default FileTreeNav;
diff --git a/scripts/stylexMigration/verification/fixtures/fixtureRegistry.test.ts b/scripts/stylexMigration/verification/fixtures/fixtureRegistry.test.ts
index b7902c9b85d..f6d0c523966 100644
--- a/scripts/stylexMigration/verification/fixtures/fixtureRegistry.test.ts
+++ b/scripts/stylexMigration/verification/fixtures/fixtureRegistry.test.ts
@@ -74,7 +74,7 @@ describe('explicit fixture contract', () => {
});
it('connects all entries with explicit mounting and probe contracts', () => {
- expect(fixtureIds).toHaveLength(27);
+ expect(fixtureIds).toHaveLength(30);
for (const id of fixtureIds) {
const fixture = getStyleFixture(id);
expect(fixture.component.id).toBe(id);
diff --git a/scripts/stylexMigration/verification/fixtures/migrationProfiles.ts b/scripts/stylexMigration/verification/fixtures/migrationProfiles.ts
index 86d99125e3a..cd62a5d2e11 100644
--- a/scripts/stylexMigration/verification/fixtures/migrationProfiles.ts
+++ b/scripts/stylexMigration/verification/fixtures/migrationProfiles.ts
@@ -4,6 +4,11 @@ export const migrationFixtures = [
['AskUserQuestionView', 'packages/shared-tool-ui/src/AskUserQuestion/AskUserQuestionView.tsx'],
['AttachmentThumbs', 'src/features/Acceptance/Viewer/Evidence/attachments.tsx'],
['VideoEvidencePlayer', 'src/features/Acceptance/Viewer/Evidence/Video/VideoEvidencePlayer.tsx'],
+ ['ConversationChatItem', 'src/features/Conversation/ChatItem/ChatItem.tsx'],
+ [
+ 'PullRequestDockActionButton',
+ 'src/features/Conversation/WorkingSidebar/PullRequest/DockActionButton.tsx',
+ ],
['SidebarGroupItem', 'src/features/HomeSidebar/Body/Agent/Modals/ConfigGroupModal/GroupItem.tsx'],
['ToolbarActionButton', 'src/features/Portal/LocalFile/PreviewToolbar.tsx'],
['PreviewToolbar', 'src/features/Portal/LocalFile/PreviewToolbar.tsx'],
@@ -12,10 +17,12 @@ export const migrationFixtures = [
['AcceptanceReport', 'src/features/Acceptance/Report/ReportViewer.tsx'],
['AcceptanceEvidenceList', 'src/features/Acceptance/Viewer/Evidence/EvidenceList.tsx'],
['VoiceMessageControl', 'src/features/ChatInput/VoiceMessage/index.tsx'],
+ ['ReviewFileList', 'src/features/Conversation/WorkingSidebar/Review/index.tsx'],
] as const;
const voiceMessageImporter = 'src/features/ChatInput/VoiceMessage/index.tsx';
const voiceMessageData = 'fixtures/VoiceMessageFixtureData.ts';
+const reviewDirectory = 'src/features/Conversation/WorkingSidebar/Review';
export const migrationProfiles: Record<string, FixtureProfile> = {
AskUserQuestionView: {
@@ -71,6 +78,50 @@ export const migrationProfiles: Record<string, FixtureProfile> = {
settleFrames: 2,
variants: [{ id: 'player' }, { id: 'frame-height' }, { id: 'dark-player', appearance: 'dark' }],
},
+ ConversationChatItem: {
+ boundaries: [
+ ['ChatItem/ChatItem.tsx', '../store'],
+ ['ChatItem/ChatItem.tsx', '../FollowUp/FollowUpChips'],
+ ['ChatItem/ChatItem.tsx', './components/Avatar'],
+ ['ChatItem/ChatItem.tsx', './components/ErrorContent'],
+ ['ChatItem/ChatItem.tsx', './components/MessageContent'],
+ ['ChatItem/components/Actions.tsx', '../../store'],
+ ['ChatItem/components/Actions.tsx', '@/store/agent'],
+ ['ChatItem/components/Actions.tsx', '@/store/agent/selectors'],
+ ['ChatItem/components/Actions.tsx', '@/utils/env'],
+ ['ChatItem/components/Title.tsx', '@/hooks/useActivityTime'],
+ ['MessageForward/MessageSelectionWrapper.tsx', '../store'],
+ ['MessageForward/MessageSelectionWrapper.tsx', '@/store/global'],
+ ['MessageForward/MessageSelectionWrapper.tsx', '@/store/global/selectors'],
+ ].map(([file, source]) => ({
+ importer: `src/features/Conversation/${file}`,
+ source,
+ replacement: 'fixtures/ChatItemFixtureData.tsx',
+ })),
+ dependencies: ['lucide-react', 'i18next', 'react-i18next', 'zod'],
+ selector: '[data-component-mount] .message-wrapper',
+ variants: [
+ { id: 'assistant', states: ['default', 'hover'] },
+ { id: 'user', states: ['default', 'hover'] },
+ { id: 'popup-open' },
+ { id: 'locate-highlight' },
+ { id: 'selection-assistant', states: ['default', 'hover'] },
+ { id: 'selection-user' },
+ { id: 'dark-assistant', appearance: 'dark', states: ['default', 'hover'] },
+ ],
+ },
+ PullRequestDockActionButton: {
+ dependencies: ['lucide-react', 'i18next', 'react-i18next'],
+ selector: '[data-component-mount] button',
+ variants: [
+ { id: 'merge-success', states: ['default', 'hover', 'focus-visible'] },
+ { id: 'merge-error', states: ['default', 'hover', 'focus-visible'] },
+ { id: 'merge-plain', states: ['default', 'hover'] },
+ { id: 'update-busy', states: ['default', 'hover'] },
+ { id: 'secondary', states: ['default', 'hover'] },
+ { id: 'dark-merge-error', appearance: 'dark', states: ['default', 'hover'] },
+ ],
+ },
SidebarGroupItem: {
dependencies: ['lucide-react', 'i18next', 'react-i18next'],
i18n: true,
@@ -185,6 +236,31 @@ export const migrationProfiles: Record<string, FixtureProfile> = {
},
].map((boundary) => ({ ...boundary, replacement: 'fixtures/AcceptanceReportData.ts' })),
},
+ ReviewFileList: {
+ boundaries: [
+ ['index.tsx', '@/store/device'],
+ ['index.tsx', './useReviewPatches'],
+ ['index.tsx', './FileTreeNav'],
+ ['index.tsx', './reviewTreeNodes'],
+ ['FileItem.tsx', '@lobechat/utils'],
+ ['FileItem.tsx', '@/services/git'],
+ ['FileItem.tsx', '@/store/file'],
+ ['FileItem.tsx', '@/store/global'],
+ ].map(([file, source]) => ({
+ importer: `${reviewDirectory}/${file}`,
+ source,
+ replacement: 'fixtures/ReviewFileListFixtureData.ts',
+ })),
+ dependencies: ['lucide-react', 'i18next', 'react-i18next', 'path-browserify-esm'],
+ i18n: true,
+ selector: '[data-component-mount] [data-review-row]',
+ settleFrames: 2,
+ variants: [
+ { id: 'grouped', states: ['default', 'hover'] },
+ { id: 'flat', states: ['default', 'hover'] },
+ { id: 'dark-grouped', appearance: 'dark', states: ['default', 'hover'] },
+ ],
+ },
AcceptanceEvidenceList: {
assets: ['fixtures/AcceptanceEvidenceData.ts'],
dependencies: [
diff --git a/scripts/stylexMigration/verification/fixtures/modules.d.ts b/scripts/stylexMigration/verification/fixtures/modules.d.ts
index e3669578291..4f93b16937c 100644
--- a/scripts/stylexMigration/verification/fixtures/modules.d.ts
+++ b/scripts/stylexMigration/verification/fixtures/modules.d.ts
@@ -26,6 +26,25 @@ declare module 'verification:component' {
tableLayout: 'auto' | 'fixed';
}
export const LiteTable: ComponentType<Props>;
+ export const ConversationChatItem: ComponentType<{
+ 'actions'?: ReactNode;
+ 'avatar': { avatar: string; title: string };
+ 'data-message-locate-highlight'?: string;
+ 'id': string;
+ 'message': ReactNode;
+ 'placement': 'left' | 'right';
+ 'showTitle'?: boolean;
+ 'time'?: number;
+ }>;
+ export const PullRequestDockActionButton: ComponentType<{
+ action: Record<string, unknown> & { kind: string };
+ bypass?: boolean;
+ detail: { baseRefName: string; headRefName: string; headRefOid: string };
+ onAction: () => Promise<boolean>;
+ onPickMethod: () => void;
+ onToggleBypass: () => void;
+ secondary?: boolean;
+ }>;
export const WorkPreview: ComponentType<{
item: WorkSummaryItem;
title: string;
@@ -133,6 +152,13 @@ declare module 'verification:component' {
}>;
export const AcceptanceReport: ComponentType<{ runId?: string }>;
export const AcceptanceEvidenceList: ComponentType<{ evidence: unknown[] }>;
+ export const ReviewFileList: ComponentType<{
+ active: boolean;
+ composerTarget: { reason: 'read-only'; writable: false };
+ onToggleTree: () => void;
+ showTree: boolean;
+ workingDirectory: string;
+ }>;
}
declare module 'verification:locale/chat' {
diff --git a/src/features/AgentSidebar/Topic/TopicListContent/ThreadList/ThreadListSection.tsx b/src/features/AgentSidebar/Topic/TopicListContent/ThreadList/ThreadListSection.tsx
index b8fe42fd389..9efcfa37ddb 100644
--- a/src/features/AgentSidebar/Topic/TopicListContent/ThreadList/ThreadListSection.tsx
+++ b/src/features/AgentSidebar/Topic/TopicListContent/ThreadList/ThreadListSection.tsx
@@ -1,8 +1,12 @@
import { Flexbox } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
-import { sectionStyles } from '@/features/Conversation/WorkingSidebar/Overview/sectionStyles';
+import {
+ sectionProps,
+ sectionStyles,
+} from '@/features/Conversation/WorkingSidebar/Overview/sectionStyles';
import { useChatStore } from '@/store/chat';
import { threadSelectors } from '@/store/chat/selectors';
@@ -16,21 +20,25 @@ import ThreadList from './index';
* The mobile topic list uses `ThreadList` directly instead β€” it has no room for
* a section header and nests the rows under the topic row.
*/
-const ThreadListSection = memo(({ topicId }: { topicId: string }) => {
- const { t } = useTranslation('chat');
- const threads = useChatStore(threadSelectors.getThreadsByTopic(topicId));
+const ThreadListSection = memo(
+ ({ afterBreak, topicId }: { afterBreak?: boolean; topicId: string }) => {
+ const { t } = useTranslation('chat');
+ const threads = useChatStore(threadSelectors.getThreadsByTopic(topicId));
- if (!threads || threads.length === 0) return;
+ if (!threads || threads.length === 0) return;
- return (
- <Flexbox className={sectionStyles.section}>
- <Flexbox className={sectionStyles.sectionHeader}>
- <span className={sectionStyles.sectionTitle}>{t(getThreadListHeadingKey(threads))}</span>
+ return (
+ <Flexbox {...sectionProps(afterBreak)}>
+ <Flexbox {...stylex.props(sectionStyles.sectionHeader)}>
+ <span {...stylex.props(sectionStyles.sectionTitle)}>
+ {t(getThreadListHeadingKey(threads))}
+ </span>
+ </Flexbox>
+ <ThreadList topicId={topicId} />
</Flexbox>
- <ThreadList topicId={topicId} />
- </Flexbox>
- );
-});
+ );
+ },
+);
ThreadListSection.displayName = 'ThreadListSection';
diff --git a/src/features/BackgroundActivity/TopicSection.tsx b/src/features/BackgroundActivity/TopicSection.tsx
index f107244b895..0c7818c7f32 100644
--- a/src/features/BackgroundActivity/TopicSection.tsx
+++ b/src/features/BackgroundActivity/TopicSection.tsx
@@ -1,4 +1,6 @@
-import { Button, createStaticStyles, cssVar, cx, Flexbox, Icon, Tooltip } from '@lobehub/ui';
+import { Button, Flexbox, Icon, Tooltip } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { RefreshCwIcon, SquareTerminalIcon, TriangleAlertIcon } from 'lucide-react';
import { useEffect, useRef } from 'react';
import { useTranslation } from 'react-i18next';
@@ -8,7 +10,10 @@ import {
OverviewRow,
rowStyles,
} from '@/features/Conversation/WorkingSidebar/Overview/OverviewRow';
-import { sectionStyles } from '@/features/Conversation/WorkingSidebar/Overview/sectionStyles';
+import {
+ sectionProps,
+ sectionStyles,
+} from '@/features/Conversation/WorkingSidebar/Overview/sectionStyles';
import {
type Activity,
@@ -20,31 +25,22 @@ import {
} from './state';
import StopButton from './StopButton';
-const styles = createStaticStyles(({ css }) => ({
- critical: css`
- color: ${cssVar.colorError};
- `,
- metrics: css`
- font-family: ${cssVar.fontFamilyCode};
- font-size: 11.5px;
- `,
- selected: css`
- @keyframes background-activity-flash {
- from {
- background: ${cssVar.colorWarningBg};
- }
- }
+const flash = stylex.keyframes({
+ from: { backgroundColor: cssVar.colorWarningBg },
+});
- border-radius: 8px;
- animation: background-activity-flash 1.6s ease-out;
- `,
- stale: css`
- opacity: 0.55;
- `,
- warning: css`
- color: ${cssVar.colorWarning};
- `,
-}));
+const styles = stylex.create({
+ critical: { color: cssVar.colorError },
+ metrics: { fontFamily: cssVar.fontFamilyCode, fontSize: '11.5px' },
+ selected: {
+ borderRadius: '8px',
+ animationName: flash,
+ animationDuration: '1.6s',
+ animationTimingFunction: 'ease-out',
+ },
+ stale: { opacity: 0.55 },
+ warning: { color: cssVar.colorWarning },
+});
function ActivityRow({ activity, selected }: { activity: Activity; selected: boolean }) {
const { t } = useTranslation('chat');
@@ -55,25 +51,25 @@ function ActivityRow({ activity, selected }: { activity: Activity; selected: boo
const alert = activity.severity !== 'normal';
const tone = activity.severity === 'critical' ? styles.critical : styles.warning;
return (
- <div className={cx(selected && styles.selected)} ref={ref}>
+ <div {...stylex.props(selected && styles.selected)} ref={ref}>
<OverviewRow
title={t('backgroundActivity.processCount', { count: activity.processes.length })}
value={activity.label}
iconNode={
alert ? (
<Tooltip title={t('backgroundActivity.highUsage')}>
- <Icon className={tone} icon={TriangleAlertIcon} size={16} />
+ <Icon {...stylex.props(tone)} icon={TriangleAlertIcon} size={16} />
</Tooltip>
) : (
- <Icon className={rowStyles.icon} icon={SquareTerminalIcon} size={16} />
+ <Icon {...stylex.props(rowStyles.icon)} icon={SquareTerminalIcon} size={16} />
)
}
trailing={
<>
- <span className={cx(styles.metrics, alert && tone)}>
+ <span {...stylex.props(styles.metrics, alert && tone)}>
{formatMemory(activity.memoryMB)}
</span>
- <span className={styles.metrics}>{formatCpu(activity.cpuPercent)}</span>
+ <span {...stylex.props(styles.metrics)}>{formatCpu(activity.cpuPercent)}</span>
<StopButton rootId={activity.rootId} />
</>
}
@@ -89,21 +85,21 @@ export function TopicBackgroundActivity({ topicId }: { topicId?: string }) {
const activities = state.activities.filter((row) => row.topicId === topicId);
if (activities.length === 0 && !state.error) return null;
return (
- <Flexbox className={sectionStyles.section}>
+ <Flexbox {...sectionProps()}>
<Flexbox
horizontal
align={'center'}
- className={sectionStyles.sectionHeader}
+ {...stylex.props(sectionStyles.sectionHeader)}
justify={'space-between'}
>
<Flexbox horizontal align={'center'} gap={6}>
- <span className={sectionStyles.sectionTitle}>{t('backgroundActivity.title')}</span>
+ <span {...stylex.props(sectionStyles.sectionTitle)}>{t('backgroundActivity.title')}</span>
{activities.length > 0 && (
- <span className={sectionStyles.count}>{activities.length}</span>
+ <span {...stylex.props(sectionStyles.count)}>{activities.length}</span>
)}
</Flexbox>
{activities.length > 1 && (
- <span className={cx(rowStyles.rowTrailing, styles.metrics)}>
+ <span {...stylex.props(rowStyles.rowTrailing, styles.metrics)}>
{formatMemory(activities.reduce((sum, row) => sum + row.memoryMB, 0))} Β·{' '}
{formatCpu(sumCpu(activities))}
</span>
@@ -127,7 +123,7 @@ export function TopicBackgroundActivity({ topicId }: { topicId?: string }) {
}
/>
)}
- <div className={cx(state.error && styles.stale)}>
+ <div {...stylex.props(state.error && styles.stale)}>
{activities.map((activity) => (
<ActivityRow
activity={activity}
diff --git a/src/features/Conversation/AgentWelcome/ToolAuthAlert.tsx b/src/features/Conversation/AgentWelcome/ToolAuthAlert.tsx
index 4c0bd9b3721..0130a003bfe 100644
--- a/src/features/Conversation/AgentWelcome/ToolAuthAlert.tsx
+++ b/src/features/Conversation/AgentWelcome/ToolAuthAlert.tsx
@@ -6,15 +6,14 @@ import {
Alert,
Avatar,
Button,
- createStaticStyles,
- cssVar,
- cx,
Divider,
Flexbox,
Icon,
Text,
toast,
} from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import isEqual from 'fast-deep-equal';
import { PlusIcon, XIcon } from 'lucide-react';
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
@@ -43,18 +42,14 @@ import type {
} from './resolvePendingAuthTools';
import { resolvePendingAuthTools } from './resolvePendingAuthTools';
-const styles = createStaticStyles(({ css }) => ({
- // Reveal the remove icon only when the row is hovered.
- row: css`
- &:hover .tool-auth-remove {
- opacity: 1;
- }
- `,
- removeIcon: css`
- opacity: 0;
- transition: opacity 0.2s ease;
- `,
-}));
+const styles = stylex.create({
+ // The row carries the default marker; the remove icon shows only while it is hovered.
+ row: { cursor: 'pointer' },
+ removeIcon: {
+ opacity: { default: 0, [stylex.when.ancestor(':hover')]: 1 },
+ transition: 'opacity 0.2s ease',
+ },
+});
// Tools that require Market authentication
const MARKET_AUTH_TOOLS = [
@@ -239,19 +234,16 @@ const ComposioToolAuthItem = memo<ComposioToolAuthItemProps>(({ tool, onAuthComp
<Flexbox
horizontal
align="center"
- className={cx(styles.row)}
+ {...stylex.props(styles.row, stylex.defaultMarker())}
gap={12}
justify="space-between"
- style={{
- cursor: 'pointer',
- }}
onClick={handleAuthorize}
>
<Flexbox horizontal align="center" gap={8}>
{renderIcon()}
<Text>{tool.label}</Text>
<ActionIcon
- className={cx('tool-auth-remove', styles.removeIcon)}
+ {...stylex.props(styles.removeIcon)}
icon={XIcon}
size="small"
title={t('toolAuth.remove')}
@@ -326,17 +318,16 @@ const LobehubToolAuthItem = ({ tool }: LobehubToolAuthItemProps) => {
<Flexbox
horizontal
align="center"
- className={cx(styles.row)}
+ {...stylex.props(styles.row, stylex.defaultMarker())}
gap={12}
justify="space-between"
- style={{ cursor: 'pointer' }}
onClick={handleAuthorize}
>
<Flexbox horizontal align="center" gap={8}>
{icon}
<Text>{tool.label}</Text>
<ActionIcon
- className={cx('tool-auth-remove', styles.removeIcon)}
+ {...stylex.props(styles.removeIcon)}
icon={XIcon}
size="small"
title={t('toolAuth.remove')}
@@ -392,19 +383,16 @@ const MarketToolAuthItem = memo<MarketToolAuthItemProps>(({ tool }) => {
<Flexbox
horizontal
align="center"
- className={cx(styles.row)}
+ {...stylex.props(styles.row, stylex.defaultMarker())}
gap={12}
justify="space-between"
- style={{
- cursor: 'pointer',
- }}
onClick={handleSignIn}
>
<Flexbox horizontal align="center" gap={8}>
<Avatar alt={tool.label} avatar={tool.avatar} size={20} style={{ flex: 'none' }} />
<Text>{tool.label}</Text>
<ActionIcon
- className={cx('tool-auth-remove', styles.removeIcon)}
+ {...stylex.props(styles.removeIcon)}
icon={XIcon}
size="small"
title={t('toolAuth.remove')}
diff --git a/src/features/Conversation/ChatInput/LinkedGoalTray/index.tsx b/src/features/Conversation/ChatInput/LinkedGoalTray/index.tsx
index 02b53c88609..f38f7c79351 100644
--- a/src/features/Conversation/ChatInput/LinkedGoalTray/index.tsx
+++ b/src/features/Conversation/ChatInput/LinkedGoalTray/index.tsx
@@ -1,6 +1,8 @@
'use client';
-import { createStaticStyles, cssVar, cx, Flexbox, Icon, Text } from '@lobehub/ui';
+import { Flexbox, Icon, Text } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { ChevronRight, CircleAlert, CircleDashed } from 'lucide-react';
import { memo, useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -17,33 +19,35 @@ import { dataSelectors, messageStateSelectors, useConversationStore } from '../.
import { isGoalRequestGenerating, linkedGoalConfirmState, selectLinkedGoals } from './linkedGoals';
import { useMarkSidebarTopicGoal } from './useMarkSidebarTopicGoal';
-const styles = createStaticStyles(({ css }) => ({
- container: css`
- border: 1px solid ${cssVar.colorFillSecondary};
- border-block-end: none;
- border-start-start-radius: 12px;
- border-start-end-radius: 12px;
-
- background: ${cssVar.colorBgElevated};
- `,
- containerTopAttached: css`
- border-start-start-radius: 0;
- border-start-end-radius: 0;
- `,
- row: css`
- cursor: pointer;
- padding-block: 6px;
- padding-inline: 12px;
-
- & + & {
- border-block-start: 1px solid ${cssVar.colorFillTertiary};
- }
-
- &:hover {
- background: ${cssVar.colorFillQuaternary};
- }
- `,
-}));
+const styles = stylex.create({
+ container: {
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorFillSecondary,
+ borderBlockEndWidth: 0,
+ borderBlockEndStyle: 'none',
+ borderBlockEndColor: 'currentcolor',
+ borderStartStartRadius: '12px',
+ borderStartEndRadius: '12px',
+ backgroundColor: cssVar.colorBgElevated,
+ backgroundImage: 'none',
+ },
+ containerTopAttached: { borderStartStartRadius: 0, borderStartEndRadius: 0 },
+ // Rows carry the default marker so each one can see the row before it.
+ row: {
+ cursor: 'pointer',
+ paddingBlock: '6px',
+ paddingInline: '12px',
+ borderBlockStartWidth: { default: null, [stylex.when.siblingBefore(':is(*)')]: '1px' },
+ borderBlockStartStyle: { default: null, [stylex.when.siblingBefore(':is(*)')]: 'solid' },
+ borderBlockStartColor: {
+ default: null,
+ [stylex.when.siblingBefore(':is(*)')]: cssVar.colorFillTertiary,
+ },
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillQuaternary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ },
+});
/**
* `confirmed` is false while the row is still the persisted copy: its status,
@@ -70,7 +74,7 @@ const LinkedGoalRow = memo<{
horizontal
align={'center'}
aria-label={t(failed ? 'goalProcess.linked.retry' : 'goalProcess.linked.open')}
- className={styles.row}
+ {...stylex.props(styles.row, stylex.defaultMarker())}
gap={8}
role={'button'}
tabIndex={0}
@@ -170,7 +174,7 @@ const LinkedGoalTray = memo<LinkedGoalTrayProps>(({ topAttached }) => {
if (!enabled || !topicId || goals.length === 0) return null;
return (
- <Flexbox className={cx(styles.container, topAttached && styles.containerTopAttached)}>
+ <Flexbox {...stylex.props(styles.container, topAttached && styles.containerTopAttached)}>
{goals.map((item) => (
<LinkedGoalRow
confirmed={confirmed}
diff --git a/src/features/Conversation/ChatInput/OpStatusTray.tsx b/src/features/Conversation/ChatInput/OpStatusTray.tsx
index dab78f11042..ecf7b6f9fd4 100644
--- a/src/features/Conversation/ChatInput/OpStatusTray.tsx
+++ b/src/features/Conversation/ChatInput/OpStatusTray.tsx
@@ -1,7 +1,9 @@
'use client';
import { formatElapsedClockTime } from '@lobechat/utils';
-import { createStaticStyles, cx, Flexbox, Icon, Popover, Tooltip } from '@lobehub/ui';
+import { Flexbox, Icon, Popover, Tooltip } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import type { LucideIcon } from 'lucide-react';
import { CircleDollarSignIcon, CoinsIcon, FootprintsIcon } from 'lucide-react';
import type { ReactNode } from 'react';
@@ -23,186 +25,145 @@ import { parseStatusPhrases, pickRotatingStatusPhrase } from './OpStatusTray/log
// stare back with the same line the whole time.
const STATUS_PHRASE_ROTATION_MS = 4000;
-const styles = createStaticStyles(({ css, cssVar }) => ({
- container: css`
- container-type: inline-size;
-
- padding-block: 8px;
- padding-inline: 14px;
- border: 1px solid ${cssVar.colorFillSecondary};
- border-block-end: none;
- border-start-start-radius: 12px;
- border-start-end-radius: 12px;
-
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
-
- background: ${cssVar.colorBgElevated};
- `,
- containerTopAttached: css`
- border-start-start-radius: 0;
- border-start-end-radius: 0;
- `,
- containerSeamless: css`
- border: none;
-
- /* keep a hairline divider on top so the tray still reads as separated from
- the conversation above, even without the full card chrome */
- border-block-start: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: 0;
- background: transparent;
- `,
- divider: css`
- width: 1px;
- height: 12px;
- background: ${cssVar.colorBorderSecondary};
- `,
- metric: css`
- display: inline-flex;
- gap: 4px;
- align-items: center;
-
- font-variant-numeric: tabular-nums;
- white-space: nowrap;
- `,
- metricGroup: css`
- display: inline-flex;
- flex: none;
- gap: 10px;
- align-items: center;
- `,
- metricGroupFull: css`
- @container (max-width: 360px) {
- display: none;
- }
- `,
- metricIcon: css`
- flex: none;
- color: ${cssVar.colorTextTertiary};
- `,
- metricPopover: css`
- min-width: 150px;
- padding: 2px;
- `,
- metricPopoverLabel: css`
- color: ${cssVar.colorTextTertiary};
- `,
- metricPopoverRow: css`
- font-size: 12px;
- `,
- metricPopoverValue: css`
- font-variant-numeric: tabular-nums;
- color: ${cssVar.colorTextSecondary};
- `,
- metricValue: css`
- overflow: hidden;
- max-width: 56px;
- text-overflow: ellipsis;
- `,
- compactMetric: css`
- cursor: default;
- display: none;
- flex: none;
-
- @container (max-width: 360px) {
- display: inline-flex;
- }
- `,
- statusMetric: css`
- overflow: hidden;
- flex: 1 1 auto;
- min-width: 0;
- `,
- statusText: css`
- overflow: hidden;
- font-weight: 500;
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- statusPhrase: css`
- @keyframes op-status-tray-phrase-enter {
- from {
- transform: translateY(3px);
- opacity: 0;
- }
-
- to {
- transform: translateY(0);
- opacity: 1;
- }
- }
-
- display: inline-block;
- animation: op-status-tray-phrase-enter 0.4s ease;
- `,
- timerValue: css`
- flex: none;
- color: ${cssVar.colorTextTertiary};
-
- @container (max-width: 260px) {
- display: none;
- }
- `,
- activityGlyph: css`
- overflow: visible;
- flex: none;
-
- width: 16px;
- height: 16px;
-
- color: ${cssVar.colorPrimary};
-
- @keyframes op-status-tray-glyph-spin {
- to {
- transform: rotate(360deg);
- }
- }
-
- @keyframes op-status-tray-glyph-core {
- 0%,
- 100% {
- transform: scale(0.86);
- opacity: 0.9;
- }
+const REDUCED_MOTION = '@media (prefers-reduced-motion: reduce)';
+const NARROW = '@container (max-width: 360px)';
+const NARROWER = '@container (max-width: 260px)';
- 50% {
- transform: scale(1);
- opacity: 1;
- }
- }
- `,
- glyphCore: css`
- transform-origin: center;
- transform-box: fill-box;
- fill: ${cssVar.colorPrimary};
- animation: op-status-tray-glyph-core 1.5s ease-in-out infinite;
-
- @media (prefers-reduced-motion: reduce) {
- animation: none;
- }
- `,
- glyphOrbit: css`
- transform-origin: center;
- transform-box: fill-box;
+const phraseEnter = stylex.keyframes({
+ from: { transform: 'translateY(3px)', opacity: 0 },
+ to: { transform: 'translateY(0)', opacity: 1 },
+});
- fill: none;
- stroke: color-mix(in srgb, ${cssVar.colorPrimary} 76%, transparent);
- stroke-dasharray: 9 18;
- stroke-linecap: round;
- stroke-width: 1.5;
+const glyphSpin = stylex.keyframes({
+ to: { transform: 'rotate(360deg)' },
+});
- animation: op-status-tray-glyph-spin 2s linear infinite;
+const glyphCore = stylex.keyframes({
+ '0%, 100%': { transform: 'scale(0.86)', opacity: 0.9 },
+ '50%': { transform: 'scale(1)', opacity: 1 },
+});
- @media (prefers-reduced-motion: reduce) {
- animation: none;
- }
- `,
-}));
+const styles = stylex.create({
+ container: {
+ containerType: 'inline-size',
+ paddingBlock: '8px',
+ paddingInline: '14px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorFillSecondary,
+ borderBlockEndWidth: 0,
+ borderBlockEndStyle: 'none',
+ borderBlockEndColor: 'currentcolor',
+ borderStartStartRadius: '12px',
+ borderStartEndRadius: '12px',
+ fontSize: '12px',
+ color: cssVar.colorTextSecondary,
+ backgroundColor: cssVar.colorBgElevated,
+ backgroundImage: 'none',
+ },
+ containerTopAttached: { borderStartStartRadius: 0, borderStartEndRadius: 0 },
+ // Keeps a hairline divider on top so the tray still reads as separated from
+ // the conversation above, even without the full card chrome.
+ containerSeamless: {
+ borderWidth: 0,
+ borderStyle: 'none',
+ borderColor: 'currentcolor',
+ borderBlockStartWidth: '1px',
+ borderBlockStartStyle: 'solid',
+ borderBlockStartColor: cssVar.colorBorderSecondary,
+ borderStartStartRadius: 0,
+ borderStartEndRadius: 0,
+ borderEndStartRadius: 0,
+ borderEndEndRadius: 0,
+ backgroundColor: 'transparent',
+ },
+ divider: {
+ width: '1px',
+ height: '12px',
+ backgroundColor: cssVar.colorBorderSecondary,
+ backgroundImage: 'none',
+ },
+ metric: {
+ display: 'inline-flex',
+ gap: '4px',
+ alignItems: 'center',
+ fontVariantNumeric: 'tabular-nums',
+ whiteSpace: 'nowrap',
+ },
+ metricGroup: { display: 'inline-flex', flex: 'none', gap: '10px', alignItems: 'center' },
+ // Composed after `metricGroup`: a conditional value replaces the whole
+ // property, so the resting display is restated here.
+ metricGroupFull: { display: { default: 'inline-flex', [NARROW]: 'none' } },
+ metricIcon: { flex: 'none', color: cssVar.colorTextTertiary },
+ metricPopover: { minWidth: '150px', padding: '2px' },
+ metricPopoverLabel: { color: cssVar.colorTextTertiary },
+ metricPopoverRow: { fontSize: '12px' },
+ metricPopoverValue: { fontVariantNumeric: 'tabular-nums', color: cssVar.colorTextSecondary },
+ metricValue: { overflow: 'hidden', maxWidth: '56px', textOverflow: 'ellipsis' },
+ compactMetric: {
+ cursor: 'default',
+ display: { default: 'none', [NARROW]: 'inline-flex' },
+ flex: 'none',
+ },
+ statusMetric: {
+ overflow: 'hidden',
+ flexGrow: '1',
+ flexShrink: '1',
+ flexBasis: 'auto',
+ minWidth: 0,
+ },
+ statusText: {
+ overflow: 'hidden',
+ fontWeight: 500,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ statusPhrase: {
+ display: 'inline-block',
+ animationName: phraseEnter,
+ animationDuration: '0.4s',
+ animationTimingFunction: 'ease',
+ },
+ timerValue: {
+ flex: 'none',
+ color: cssVar.colorTextTertiary,
+ display: { default: null, [NARROWER]: 'none' },
+ },
+ activityGlyph: {
+ overflow: 'visible',
+ flex: 'none',
+ width: '16px',
+ height: '16px',
+ color: cssVar.colorPrimary,
+ },
+ glyphCore: {
+ transformOrigin: 'center',
+ transformBox: 'fill-box',
+ fill: cssVar.colorPrimary,
+ animationName: { default: glyphCore, [REDUCED_MOTION]: 'none' },
+ animationDuration: { default: '1.5s', [REDUCED_MOTION]: '0s' },
+ animationTimingFunction: { default: 'ease-in-out', [REDUCED_MOTION]: 'ease' },
+ animationIterationCount: { default: 'infinite', [REDUCED_MOTION]: 1 },
+ },
+ glyphOrbit: {
+ transformOrigin: 'center',
+ transformBox: 'fill-box',
+ fill: 'none',
+ stroke: `color-mix(in srgb, ${cssVar.colorPrimary} 76%, transparent)`,
+ strokeDasharray: '9 18',
+ strokeLinecap: 'round',
+ strokeWidth: 1.5,
+ animationName: { default: glyphSpin, [REDUCED_MOTION]: 'none' },
+ animationDuration: { default: '2s', [REDUCED_MOTION]: '0s' },
+ animationTimingFunction: { default: 'linear', [REDUCED_MOTION]: 'ease' },
+ animationIterationCount: { default: 'infinite', [REDUCED_MOTION]: 1 },
+ },
+});
const ActivityGlyph = () => (
- <svg aria-hidden className={styles.activityGlyph} viewBox="0 0 16 16">
- <circle className={styles.glyphOrbit} cx="8" cy="8" r="6.1" />
- <circle className={styles.glyphCore} cx="8" cy="8" r="2.7" />
+ <svg aria-hidden {...stylex.props(styles.activityGlyph)} viewBox="0 0 16 16">
+ <circle {...stylex.props(styles.glyphOrbit)} cx="8" cy="8" r="6.1" />
+ <circle {...stylex.props(styles.glyphCore)} cx="8" cy="8" r="2.7" />
</svg>
);
@@ -383,29 +344,29 @@ const OpStatusTray = memo<OpStatusTrayProps>(({ seamless, topAttached }) => {
const renderMetric = ({ icon, title, value }: MetricItem) => (
<Tooltip title={title}>
- <span className={styles.metric}>
- <Icon className={styles.metricIcon} icon={icon} size={13} />
- <span className={styles.metricValue}>{value}</span>
+ <span {...stylex.props(styles.metric)}>
+ <Icon {...stylex.props(styles.metricIcon)} icon={icon} size={13} />
+ <span {...stylex.props(styles.metricValue)}>{value}</span>
</span>
</Tooltip>
);
const metricPopoverContent = (
- <Flexbox className={styles.metricPopover} gap={8}>
+ <Flexbox {...stylex.props(styles.metricPopover)} gap={8}>
{metrics.map(({ icon, key, label, value }) => (
<Flexbox
horizontal
align="center"
- className={styles.metricPopoverRow}
+ {...stylex.props(styles.metricPopoverRow)}
gap={20}
justify="space-between"
key={key}
>
- <span className={cx(styles.metric, styles.metricPopoverLabel)}>
- <Icon className={styles.metricIcon} icon={icon} size={13} />
+ <span {...stylex.props(styles.metric, styles.metricPopoverLabel)}>
+ <Icon {...stylex.props(styles.metricIcon)} icon={icon} size={13} />
<span>{label}</span>
</span>
- <span className={styles.metricPopoverValue}>{value}</span>
+ <span {...stylex.props(styles.metricPopoverValue)}>{value}</span>
</Flexbox>
))}
</Flexbox>
@@ -416,37 +377,37 @@ const OpStatusTray = memo<OpStatusTrayProps>(({ seamless, topAttached }) => {
horizontal
align="center"
justify="space-between"
- className={cx(
+ {...stylex.props(
styles.container,
topAttached && styles.containerTopAttached,
seamless && styles.containerSeamless,
)}
>
- <span className={cx(styles.metric, styles.statusMetric)}>
+ <span {...stylex.props(styles.metric, styles.statusMetric)}>
<ActivityGlyph />
- <span className={styles.statusText}>
- <span className={styles.statusPhrase} key={statusText}>
+ <span {...stylex.props(styles.statusText)}>
+ <span {...stylex.props(styles.statusPhrase)} key={statusText}>
<span className={shinyTextStyles.shinyText}>{statusText}...</span>
</span>
</span>
- <span className={styles.timerValue}>{formatElapsedClockTime(elapsed)}</span>
+ <span {...stylex.props(styles.timerValue)}>{formatElapsedClockTime(elapsed)}</span>
</span>
{metrics.length > 0 && (
<>
- <span className={cx(styles.metricGroup, styles.metricGroupFull)}>
+ <span {...stylex.props(styles.metricGroup, styles.metricGroupFull)}>
{metrics.map((metric, i) => (
<Fragment key={metric.key}>
- {i > 0 && <span className={styles.divider} />}
+ {i > 0 && <span {...stylex.props(styles.divider)} />}
{renderMetric(metric)}
</Fragment>
))}
</span>
{tokenMetric && (
<Popover content={metricPopoverContent} placement="topRight" trigger="hover">
- <span className={cx(styles.metric, styles.compactMetric)}>
- <Icon className={styles.metricIcon} icon={tokenMetric.icon} size={13} />
- <span className={styles.metricValue}>{tokenMetric.value}</span>
+ <span {...stylex.props(styles.metric, styles.compactMetric)}>
+ <Icon {...stylex.props(styles.metricIcon)} icon={tokenMetric.icon} size={13} />
+ <span {...stylex.props(styles.metricValue)}>{tokenMetric.value}</span>
</span>
</Popover>
)}
diff --git a/src/features/Conversation/ChatInput/QueueTray.tsx b/src/features/Conversation/ChatInput/QueueTray.tsx
index 95330e6f825..eda23c45a6a 100644
--- a/src/features/Conversation/ChatInput/QueueTray.tsx
+++ b/src/features/Conversation/ChatInput/QueueTray.tsx
@@ -1,6 +1,8 @@
'use client';
-import { ActionIcon, createStaticStyles, Flexbox, Icon, Image, toast, Tooltip } from '@lobehub/ui';
+import { ActionIcon, Flexbox, Icon, Image, toast, Tooltip } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { ArrowUp, Info, ListEnd, Pencil, Trash2 } from 'lucide-react';
import { memo, useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -32,109 +34,97 @@ import {
const PREVIEW_SIZE = 28;
-const styles = createStaticStyles(({ css, cssVar }) => ({
- container: css`
- container-type: inline-size;
-
- border: 1px solid ${cssVar.colorFillSecondary};
- border-block-end: none;
- border-radius: 12px 12px 0 0;
-
- background: ${cssVar.colorBgElevated};
- `,
- fileChip: css`
- overflow: hidden;
- flex-shrink: 0;
-
- max-width: 160px;
- height: 28px;
- padding-block: 0;
- padding-inline: 6px;
- border: 1px solid ${cssVar.colorFillTertiary};
- border-radius: 6px;
-
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
- white-space: nowrap;
- `,
- fileChipName: css`
- overflow: hidden;
- text-overflow: ellipsis;
- `,
- hint: css`
- display: inline-flex;
- flex: none;
- gap: 4px;
- align-items: center;
-
- font-size: 12px;
- color: ${cssVar.colorTextDescription};
- `,
- hintGlyph: css`
- cursor: help;
-
- display: none;
-
- padding: 0;
- border: none;
- border-radius: 4px;
-
- color: inherit;
-
- background: none;
-
- /* Too narrow to spare a sentence on the send timing: keep the meaning on the
- glyph's tooltip instead of squeezing the message text. */
- @container (max-width: 480px) {
- display: inline-flex;
- }
- `,
- hintText: css`
- white-space: nowrap;
-
- @container (max-width: 480px) {
- display: none;
- }
- `,
- icon: css`
- flex-shrink: 0;
- color: ${cssVar.colorTextDescription};
- `,
- imageThumb: css`
- flex-shrink: 0;
-
- width: 28px !important;
- height: 28px !important;
- margin-block: 0 !important;
- border: 1px solid ${cssVar.colorFillTertiary};
- border-radius: 6px;
-
- box-shadow: none;
-
- img {
- width: 28px !important;
- height: 28px !important;
- object-fit: cover;
- }
- `,
- item: css`
- padding-block: 6px;
- padding-inline: 12px 8px;
- `,
- itemDivider: css`
- border-block-start: 1px solid ${cssVar.colorFillTertiary};
- `,
- text: css`
- overflow: hidden;
-
- min-width: 0;
-
- font-size: 13px;
- line-height: 1.4;
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
-}));
+const NARROW = '@container (max-width: 480px)';
+
+const styles = stylex.create({
+ container: {
+ containerType: 'inline-size',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorFillSecondary,
+ borderBlockEndWidth: 0,
+ borderBlockEndStyle: 'none',
+ borderBlockEndColor: 'currentcolor',
+ borderStartStartRadius: '12px',
+ borderStartEndRadius: '12px',
+ borderEndStartRadius: 0,
+ borderEndEndRadius: 0,
+ backgroundColor: cssVar.colorBgElevated,
+ backgroundImage: 'none',
+ },
+ fileChip: {
+ overflow: 'hidden',
+ flexShrink: 0,
+ maxWidth: '160px',
+ height: '28px',
+ paddingBlock: 0,
+ paddingInline: '6px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorFillTertiary,
+ borderRadius: '6px',
+ fontSize: '12px',
+ color: cssVar.colorTextSecondary,
+ whiteSpace: 'nowrap',
+ },
+ fileChipName: { overflow: 'hidden', textOverflow: 'ellipsis' },
+ hint: {
+ display: 'inline-flex',
+ flex: 'none',
+ gap: '4px',
+ alignItems: 'center',
+ fontSize: '12px',
+ color: cssVar.colorTextDescription,
+ },
+ // Too narrow to spare a sentence on the send timing: keep the meaning on the
+ // glyph's tooltip instead of squeezing the message text.
+ hintGlyph: {
+ cursor: 'help',
+ display: { default: 'none', [NARROW]: 'inline-flex' },
+ padding: 0,
+ borderWidth: 0,
+ borderStyle: 'none',
+ borderRadius: '4px',
+ color: 'inherit',
+ backgroundColor: 'transparent',
+ backgroundImage: 'none',
+ },
+ hintText: {
+ whiteSpace: 'nowrap',
+ display: { default: null, [NARROW]: 'none' },
+ },
+ icon: { flexShrink: 0, color: cssVar.colorTextDescription },
+ imageThumb: {
+ flexShrink: 0,
+ width: '28px',
+ height: '28px',
+ marginBlock: 0,
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorFillTertiary,
+ borderRadius: '6px',
+ boxShadow: 'none',
+ },
+ imageThumbImage: { width: '28px', height: '28px', objectFit: 'cover' },
+ item: {
+ paddingBlock: '6px',
+ paddingInlineStart: '12px',
+ paddingInlineEnd: '8px',
+ },
+ itemDivider: {
+ borderBlockStartWidth: '1px',
+ borderBlockStartStyle: 'solid',
+ borderBlockStartColor: cssVar.colorFillTertiary,
+ },
+ text: {
+ overflow: 'hidden',
+ minWidth: 0,
+ fontSize: '13px',
+ lineHeight: 1.4,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+});
const isImageFile = (f: QueuedFile) => f.mimeType.startsWith('image') && !!f.url;
@@ -150,12 +140,15 @@ const QueuedFilePreview = memo<QueuedFilePreviewProps>(({ file }) => {
return (
<Image
alt={file.name}
- classNames={{ wrapper: styles.imageThumb }}
objectFit={'cover'}
size={PREVIEW_SIZE}
src={file.url}
title={file.name}
variant={'borderless'}
+ classNames={{
+ image: stylex.props(styles.imageThumbImage).className,
+ wrapper: stylex.props(styles.imageThumb).className,
+ }}
styles={{
image: { height: PREVIEW_SIZE, width: PREVIEW_SIZE },
wrapper: { height: PREVIEW_SIZE, width: PREVIEW_SIZE },
@@ -165,9 +158,15 @@ const QueuedFilePreview = memo<QueuedFilePreviewProps>(({ file }) => {
}
return (
- <Flexbox horizontal align={'center'} className={styles.fileChip} gap={4} title={file.name}>
+ <Flexbox
+ horizontal
+ align={'center'}
+ {...stylex.props(styles.fileChip)}
+ gap={4}
+ title={file.name}
+ >
<FileIcon fileName={file.name} fileType={file.mimeType} size={14} />
- <span className={styles.fileChipName}>{file.name}</span>
+ <span {...stylex.props(styles.fileChipName)}>{file.name}</span>
</Flexbox>
);
});
@@ -320,7 +319,7 @@ const QueueTray = memo(() => {
const hintText = t(getQueuedHintKey({ count: waitingCount, mode: followUpMode, waitsForRunEnd }));
return (
- <Flexbox className={styles.container} gap={0}>
+ <Flexbox {...stylex.props(styles.container)} gap={0}>
{queuedMessages.map((msg, index) => {
const previews = msg.filesPreview ?? [];
// A "send now" in progress keeps its row as is: it is interrupting the
@@ -340,11 +339,11 @@ const QueueTray = memo(() => {
<Flexbox
horizontal
align="center"
- className={index > 0 ? `${styles.item} ${styles.itemDivider}` : styles.item}
+ {...stylex.props(styles.item, index > 0 && styles.itemDivider)}
gap={8}
key={msg.id}
>
- <Icon className={styles.icon} icon={ListEnd} size={14} />
+ <Icon {...stylex.props(styles.icon)} icon={ListEnd} size={14} />
<Flexbox
horizontal
align={'center'}
@@ -360,7 +359,7 @@ const QueueTray = memo(() => {
</Flexbox>
)}
{msg.content && (
- <Flexbox className={styles.text} flex={'0 1 auto'}>
+ <Flexbox {...stylex.props(styles.text)} flex={'0 1 auto'}>
{msg.content}
</Flexbox>
)}
@@ -369,16 +368,16 @@ const QueueTray = memo(() => {
message row right after the content instead of taking a line.
Several queued messages are merged into a single send on drain,
so the wording changes with the queue size. */}
- <span className={styles.hint}>
+ <span {...stylex.props(styles.hint)}>
{/* Collapsed form. It is display:none while the sentence fits, so
it adds no tab stop there; when it shows it is a real
focusable control carrying the wording as its name. */}
<Tooltip title={rowHint}>
- <button aria-label={rowHint} className={styles.hintGlyph} type={'button'}>
+ <button aria-label={rowHint} {...stylex.props(styles.hintGlyph)} type={'button'}>
<Icon icon={Info} size={13} />
</button>
</Tooltip>
- <span className={styles.hintText}>{rowHint}</span>
+ <span {...stylex.props(styles.hintText)}>{rowHint}</span>
</span>
<div style={{ flex: 1 }} />
{!delivering && (
diff --git a/src/features/Conversation/ChatItem/ChatItem.tsx b/src/features/Conversation/ChatItem/ChatItem.tsx
index 67eacfb287e..cc3e8f546ff 100644
--- a/src/features/Conversation/ChatItem/ChatItem.tsx
+++ b/src/features/Conversation/ChatItem/ChatItem.tsx
@@ -2,18 +2,73 @@
import { agentDisplayName } from '@lobechat/types';
import { cx, Flexbox } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { memo } from 'react';
+import { sx } from '@/styles/sx';
+
import FollowUpChips from '../FollowUp/FollowUpChips';
+import { selectionStyles } from '../MessageForward/selectionStyles';
import { contextSelectors, useConversationStore } from '../store';
import Actions from './components/Actions';
import Avatar from './components/Avatar';
import ErrorContent from './components/ErrorContent';
import MessageContent from './components/MessageContent';
import Title from './components/Title';
-import { styles } from './style';
+import { chatItemMarker } from './markers.stylex';
import type { ChatItemProps } from './type';
+const LOCATE_HIGHLIGHT = ':is([data-message-locate-highlight])';
+const REDUCED_MOTION = '@media (prefers-reduced-motion: reduce)';
+
+const backgroundReset = {
+ backgroundAttachment: 'initial',
+ backgroundClip: 'initial',
+ backgroundImage: 'initial',
+ backgroundOrigin: 'initial',
+ backgroundPositionX: 'initial',
+ backgroundPositionY: 'initial',
+ backgroundRepeat: 'initial',
+ backgroundSize: 'initial',
+} as const;
+
+const locateHighlight = stylex.keyframes({
+ '0%, 100%': { ...backgroundReset, backgroundColor: 'transparent' },
+ '15%, 55%': { ...backgroundReset, backgroundColor: cssVar.colorPrimaryBg },
+});
+
+const styles = stylex.create({
+ container: {
+ position: 'relative',
+ maxWidth: '100%',
+ borderRadius: { default: null, [LOCATE_HIGHLIGHT]: cssVar.borderRadiusLG },
+ backgroundColor: {
+ default: null,
+ [REDUCED_MOTION]: { default: null, [LOCATE_HIGHLIGHT]: cssVar.colorPrimaryBg },
+ },
+ backgroundImage: {
+ default: null,
+ [REDUCED_MOTION]: { default: null, [LOCATE_HIGHLIGHT]: 'none' },
+ },
+ animationName: {
+ default: null,
+ [LOCATE_HIGHLIGHT]: locateHighlight,
+ [REDUCED_MOTION]: { default: null, [LOCATE_HIGHLIGHT]: 'none' },
+ },
+ animationDuration: {
+ default: null,
+ [LOCATE_HIGHLIGHT]: '1400ms',
+ [REDUCED_MOTION]: { default: null, [LOCATE_HIGHLIGHT]: '0s' },
+ },
+ animationTimingFunction: {
+ default: null,
+ [LOCATE_HIGHLIGHT]: cssVar.motionEaseOut,
+ [REDUCED_MOTION]: { default: null, [LOCATE_HIGHLIGHT]: 'ease' },
+ },
+ },
+});
+
const ChatItem = memo<ChatItemProps>(
({
onAvatarClick,
@@ -72,20 +127,19 @@ const ChatItem = memo<ChatItemProps>(
return (
<Flexbox
align={isUser ? 'flex-end' : 'flex-start'}
- className={cx('message-wrapper', styles.container, className)}
data-message-id={id}
gap={8}
paddingBlock={8}
- style={{
+ {...rest}
+ {...sx(styles.container, chatItemMarker, cx('message-wrapper', className), {
paddingInlineStart: isUser ? 36 : 0,
...style,
- }}
- {...rest}
+ })}
>
{showHeader && (
<Flexbox
align={quietHeader ? 'baseline' : 'center'}
- className={'message-header'}
+ className={cx('message-header', stylex.props(selectionStyles.hidden).className)}
direction={isUser ? 'horizontal-reverse' : 'horizontal'}
gap={8}
// The row wraps nothing, so without a cap it is sized by its content and
diff --git a/src/features/Conversation/ChatItem/components/Actions.tsx b/src/features/Conversation/ChatItem/components/Actions.tsx
index 823b2871fc5..cfd26f397a1 100644
--- a/src/features/Conversation/ChatItem/components/Actions.tsx
+++ b/src/features/Conversation/ChatItem/components/Actions.tsx
@@ -1,4 +1,5 @@
import { Flexbox } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
import { memo } from 'react';
import { useAgentStore } from '@/store/agent';
@@ -6,6 +7,7 @@ import { builtinAgentSelectors } from '@/store/agent/selectors';
import { isDev } from '@/utils/env';
import { contextSelectors, useConversationStore } from '../../store';
+import { revealStyles } from '../revealStyles';
import type { ChatItemProps } from '../type';
export interface ActionsProps {
@@ -31,7 +33,7 @@ const Actions = memo<ActionsProps>(({ actionAddon, placement, actions }) => {
>
{!isUser && actionAddon}
{actions && (
- <Flexbox horizontal align={'center'} role="menubar">
+ <Flexbox horizontal align={'center'} role="menubar" {...stylex.props(revealStyles.menubar)}>
{actions}
</Flexbox>
)}
diff --git a/src/features/Conversation/ChatItem/components/ErrorContent.tsx b/src/features/Conversation/ChatItem/components/ErrorContent.tsx
index c3fd2aadd09..083e1919ecc 100644
--- a/src/features/Conversation/ChatItem/components/ErrorContent.tsx
+++ b/src/features/Conversation/ChatItem/components/ErrorContent.tsx
@@ -1,4 +1,5 @@
-import { Alert, Button, createStaticStyles, cx, Skeleton } from '@lobehub/ui';
+import { Alert, Button, cx, Skeleton } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
import { RotateCcw } from 'lucide-react';
import { memo, Suspense } from 'react';
import { useTranslation } from 'react-i18next';
@@ -11,33 +12,27 @@ import {
import { type ChatItemProps } from '../type';
-const styles = createStaticStyles(({ css }) => ({
- close: css`
- @media (width <= 480px) {
- width: 24px;
- height: 24px;
- }
- `,
- extraContent: css`
- padding: 0;
- background: transparent;
+const NARROW = '@media (width <= 480px)';
- @media (width <= 480px) {
- margin-inline: 8px;
- }
- `,
- extraHeader: css`
- @media (width <= 480px) {
- padding-inline: 8px;
- }
- `,
- root: css`
- @media (width <= 480px) {
- gap: 6px;
- padding-inline: 8px;
- }
- `,
-}));
+const styles = stylex.create({
+ close: {
+ width: { default: null, [NARROW]: '24px' },
+ height: { default: null, [NARROW]: '24px' },
+ },
+ extraContent: {
+ padding: 0,
+ backgroundColor: 'transparent',
+ backgroundImage: 'none',
+ marginInline: { default: null, [NARROW]: '8px' },
+ },
+ extraHeader: {
+ paddingInline: { default: null, [NARROW]: '8px' },
+ },
+ root: {
+ gap: { default: null, [NARROW]: '6px' },
+ paddingInline: { default: null, [NARROW]: '8px' },
+ },
+});
export interface ErrorContentProps {
customErrorRender?: ChatItemProps['customErrorRender'];
@@ -105,10 +100,13 @@ const ErrorContent = memo<ErrorContentProps>(({ customErrorRender, error, id, on
}}
classNames={{
...error.classNames,
- close: cx(styles.close, error.classNames?.close),
- extraContent: cx(styles.extraContent, error.classNames?.extraContent),
- extraHeader: cx(styles.extraHeader, error.classNames?.extraHeader),
- root: cx(styles.root, error.classNames?.root),
+ close: cx(stylex.props(styles.close).className, error.classNames?.close),
+ extraContent: cx(
+ stylex.props(styles.extraContent).className,
+ error.classNames?.extraContent,
+ ),
+ extraHeader: cx(stylex.props(styles.extraHeader).className, error.classNames?.extraHeader),
+ root: cx(stylex.props(styles.root).className, error.classNames?.root),
}}
style={{
overflow: 'hidden',
diff --git a/src/features/Conversation/ChatItem/components/MessageContent/index.tsx b/src/features/Conversation/ChatItem/components/MessageContent/index.tsx
index c9c7e437440..cd6ed7f83dd 100644
--- a/src/features/Conversation/ChatItem/components/MessageContent/index.tsx
+++ b/src/features/Conversation/ChatItem/components/MessageContent/index.tsx
@@ -1,4 +1,6 @@
-import { createStaticStyles, cx, Flexbox, type ModalInstance } from '@lobehub/ui';
+import { Flexbox, type ModalInstance } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { type ReactNode } from 'react';
import { memo, useCallback, useEffect, useRef } from 'react';
import { useTranslation } from 'react-i18next';
@@ -7,30 +9,29 @@ import { usePrintMode } from '@/features/Conversation/components/PrintModeContex
import { dataSelectors, useConversationStore } from '@/features/Conversation/store';
import { openEditorModal } from '@/features/EditorModal';
import { usePermission } from '@/hooks/usePermission';
+import { sx } from '@/styles/sx';
import { type ChatItemProps } from '../../type';
import { useEditConfirmation } from './useEditConfirmation';
export const MSG_CONTENT_CLASSNAME = 'msg_content_flag';
-export const styles = createStaticStyles(({ css, cssVar }) => {
- return {
- bubble: css`
- padding-block: 8px;
- padding-inline: 12px;
- border-radius: ${cssVar.borderRadiusLG};
- background-color: ${cssVar.colorFillTertiary};
- `,
- disabled: css`
- user-select: ${'none'};
- color: ${cssVar.colorTextSecondary};
- `,
- message: css`
- position: relative;
- overflow: hidden;
- max-width: 100%;
- `,
- };
+const styles = stylex.create({
+ bubble: {
+ paddingBlock: '8px',
+ paddingInline: '12px',
+ borderRadius: cssVar.borderRadiusLG,
+ backgroundColor: cssVar.colorFillTertiary,
+ },
+ disabled: {
+ userSelect: 'none',
+ color: cssVar.colorTextSecondary,
+ },
+ message: {
+ position: 'relative',
+ overflow: 'hidden',
+ maxWidth: '100%',
+ },
});
export interface MessageContentProps {
@@ -109,12 +110,11 @@ const MessageContent = memo<MessageContentProps>(
return (
<Flexbox
gap={16}
- className={cx(
- MSG_CONTENT_CLASSNAME,
+ {...sx(
styles.message,
variant === 'bubble' && styles.bubble,
disabled && styles.disabled,
- className,
+ [MSG_CONTENT_CLASSNAME, className].filter(Boolean).join(' '),
)}
onDoubleClick={onDoubleClick}
>
diff --git a/src/features/Conversation/ChatItem/components/Title.tsx b/src/features/Conversation/ChatItem/components/Title.tsx
index 9f7c05a4d06..e1dc73dd915 100644
--- a/src/features/Conversation/ChatItem/components/Title.tsx
+++ b/src/features/Conversation/ChatItem/components/Title.tsx
@@ -1,11 +1,13 @@
import { agentDisplayName } from '@lobechat/types';
import { Text } from '@lobehub/ui';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { useActivityTime } from '@/hooks/useActivityTime';
+import { revealStyles } from '../revealStyles';
import { type ChatItemProps } from '../type';
export interface TitleProps {
@@ -40,6 +42,7 @@ const Title = memo<TitleProps>(({ showTitle, time, avatar, quiet, titleAddon })
<Text
aria-label="published-date"
as={'time'}
+ className={stylex.props(revealStyles.time).className}
fontSize={12}
title={timeTitle}
type={'secondary'}
diff --git a/src/features/Conversation/ChatItem/markers.stylex.ts b/src/features/Conversation/ChatItem/markers.stylex.ts
new file mode 100644
index 00000000000..340759cd466
--- /dev/null
+++ b/src/features/Conversation/ChatItem/markers.stylex.ts
@@ -0,0 +1,3 @@
+import * as stylex from '@stylexjs/stylex';
+
+export const chatItemMarker = stylex.defineMarker();
diff --git a/src/features/Conversation/ChatItem/revealStyles.ts b/src/features/Conversation/ChatItem/revealStyles.ts
new file mode 100644
index 00000000000..9f073d973d1
--- /dev/null
+++ b/src/features/Conversation/ChatItem/revealStyles.ts
@@ -0,0 +1,28 @@
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
+
+import { chatItemMarker } from './markers.stylex';
+
+export const revealStyles = stylex.create({
+ menubar: {
+ pointerEvents: {
+ default: 'none',
+ [stylex.when.ancestor(':hover', chatItemMarker)]: 'unset',
+ [stylex.when.ancestor(':has([data-popup-open])', chatItemMarker)]: 'unset',
+ },
+ display: 'flex',
+ opacity: {
+ default: 0,
+ [stylex.when.ancestor(':hover', chatItemMarker)]: 1,
+ [stylex.when.ancestor(':has([data-popup-open])', chatItemMarker)]: 1,
+ },
+ transition: `opacity 200ms ${cssVar.motionEaseOut}`,
+ },
+ time: {
+ pointerEvents: { default: 'none', [stylex.when.ancestor(':hover', chatItemMarker)]: 'unset' },
+ display: 'inline-block',
+ whiteSpace: 'nowrap',
+ opacity: { default: 0, [stylex.when.ancestor(':hover', chatItemMarker)]: 1 },
+ transition: `opacity 200ms ${cssVar.motionEaseOut}`,
+ },
+});
diff --git a/src/features/Conversation/ChatItem/style.ts b/src/features/Conversation/ChatItem/style.ts
deleted file mode 100644
index 8ca6df01491..00000000000
--- a/src/features/Conversation/ChatItem/style.ts
+++ /dev/null
@@ -1,77 +0,0 @@
-import { createStaticStyles, keyframes } from '@lobehub/ui';
-
-export const styles = createStaticStyles(({ css, cssVar }) => {
- const locateHighlight = keyframes`
- 0%, 100% {
- background: transparent;
- }
-
- 15%, 55% {
- background: ${cssVar.colorPrimaryBg};
- }
- `;
-
- return {
- container: css`
- position: relative;
- max-width: 100%;
-
- &[data-message-locate-highlight] {
- border-radius: ${cssVar.borderRadiusLG};
- animation: ${locateHighlight} 1400ms ${cssVar.motionEaseOut};
- }
-
- time,
- div[role='menubar'] {
- pointer-events: none;
- opacity: 0;
- transition: opacity 200ms ${cssVar.motionEaseOut};
- }
-
- time {
- display: inline-block;
- white-space: nowrap;
- }
-
- div[role='menubar'] {
- display: flex;
- }
-
- &:has([data-popup-open]) {
- div[role='menubar'] {
- pointer-events: unset;
- opacity: 1;
- }
- }
-
- &:hover {
- time,
- div[role='menubar'] {
- pointer-events: unset;
- opacity: 1;
- }
- }
-
- @media (prefers-reduced-motion: reduce) {
- &[data-message-locate-highlight] {
- background: ${cssVar.colorPrimaryBg};
- animation: none;
- }
- }
- `,
- loading: css`
- position: absolute;
- inset-block-end: 0;
- inset-inline-start: -4px;
- inset-inline-end: unset;
-
- width: 16px;
- height: 16px;
- border-radius: 50%;
-
- color: ${cssVar.colorBgLayout};
-
- background: ${cssVar.colorPrimary};
- `,
- };
-});
diff --git a/src/features/Conversation/Error/PlanLimitCard/index.tsx b/src/features/Conversation/Error/PlanLimitCard/index.tsx
index 1da43974f42..ae90ad6ce8a 100644
--- a/src/features/Conversation/Error/PlanLimitCard/index.tsx
+++ b/src/features/Conversation/Error/PlanLimitCard/index.tsx
@@ -1,6 +1,8 @@
import { BRANDING_URL } from '@lobechat/business-const';
import { ChatErrorType, Plans } from '@lobechat/types';
-import { Avatar, Button, Center, createStaticStyles, Flexbox, Text } from '@lobehub/ui';
+import { Avatar, Button, Center, Flexbox, Text } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -25,53 +27,32 @@ const PLAN_TITLE_KEYS = {
[Plans.Ultimate]: 'plans.plan.ultimate.title',
} as const satisfies Record<Plans, string>;
-const styles = createStaticStyles(({ css, cssVar }) => ({
- centered: css`
- text-align: center;
-
- /* even line lengths: a wrapped sentence never leaves a lone character on the last line */
- text-wrap: balance;
- `,
- fact: css`
- display: flex;
- gap: 12px;
- justify-content: space-between;
-
- width: 100%;
-
- font-size: 13px;
- line-height: 1.4;
- `,
- factLabel: css`
- color: ${cssVar.colorTextSecondary};
- `,
- factValue: css`
- font-weight: 600;
- font-variant-numeric: tabular-nums;
- color: ${cssVar.colorText};
- text-align: end;
- white-space: nowrap;
- `,
- factWarningValue: css`
- font-weight: 700;
- color: ${cssVar.colorError};
- `,
- facts: css`
- width: 100%;
- `,
- form: css`
- width: 100%;
- max-width: 360px;
-
- @media (width <= 768px) {
- max-width: 90%;
- }
- `,
- title: css`
- font-size: 16px;
- font-weight: bold;
- `,
-}));
+const styles = stylex.create({
+ centered: { textAlign: 'center', textWrap: 'balance' },
+ fact: {
+ display: 'flex',
+ gap: '12px',
+ justifyContent: 'space-between',
+ width: '100%',
+ fontSize: '13px',
+ lineHeight: 1.4,
+ },
+ factLabel: { color: cssVar.colorTextSecondary },
+ factValue: {
+ fontWeight: 600,
+ fontVariantNumeric: 'tabular-nums',
+ color: cssVar.colorText,
+ textAlign: 'end',
+ whiteSpace: 'nowrap',
+ },
+ factWarningValue: { fontWeight: 700, color: cssVar.colorError },
+ facts: { width: '100%' },
+ form: {
+ width: '100%',
+ maxWidth: { 'default': '360px', '@media (width <= 768px)': '90%' },
+ },
+ title: { fontSize: '16px', fontWeight: 'bold' },
+});
const getBudgetDescriptionKey = (pricingBasis?: PlanLimitPricingBasis) => {
switch (pricingBasis) {
@@ -140,27 +121,31 @@ const PlanLimitCard = memo<PlanLimitCardProps>(({ errorBody, errorType, onRetry
return (
<Center paddingBlock={12} width={'100%'}>
- <Flexbox className={styles.form} gap={16}>
+ <Flexbox className={stylex.props(styles.form).className} gap={16}>
<Center gap={8}>
<Avatar animation avatar={'πŸ’°'} background={'transparent'} size={40} />
<Center gap={4}>
- <Text className={styles.title}>{title}</Text>
- <Text className={styles.centered} fontSize={13} type={'secondary'}>
+ <Text className={stylex.props(styles.title).className}>{title}</Text>
+ <Text
+ className={stylex.props(styles.centered).className}
+ fontSize={13}
+ type={'secondary'}
+ >
{description}
</Text>
</Center>
</Center>
{facts.length > 0 && (
- <Flexbox className={styles.facts} gap={8}>
+ <Flexbox className={stylex.props(styles.facts).className} gap={8}>
{facts.map((fact) => (
- <div className={styles.fact} key={fact.label}>
- <span className={styles.factLabel}>{fact.label}</span>
+ <div {...stylex.props(styles.fact)} key={fact.label}>
+ <span {...stylex.props(styles.factLabel)}>{fact.label}</span>
<span
className={
fact.warning
- ? `${styles.factValue} ${styles.factWarningValue}`
- : styles.factValue
+ ? stylex.props(styles.factValue, styles.factWarningValue).className
+ : stylex.props(styles.factValue).className
}
>
{formatCreditAmount(fact.value!)}
diff --git a/src/features/Conversation/Error/style.tsx b/src/features/Conversation/Error/style.tsx
index ed4cb76b97a..dbf2da53672 100644
--- a/src/features/Conversation/Error/style.tsx
+++ b/src/features/Conversation/Error/style.tsx
@@ -1,33 +1,33 @@
import { type CenterProps } from '@lobehub/ui';
-import { Avatar, Center, createStaticStyles, cssVar, cx, Flexbox } from '@lobehub/ui';
+import { Avatar, Center, Flexbox } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { type ReactNode } from 'react';
import { memo } from 'react';
-export const styles = createStaticStyles(({ css, cssVar }) => ({
- container: css`
- border: 1px solid ${cssVar.colorSplit};
- border-radius: 8px;
- color: ${cssVar.colorText};
- background: ${cssVar.colorBgContainer};
- `,
- desc: css`
- color: ${cssVar.colorTextTertiary};
- text-align: center;
- `,
- form: css`
- width: 100%;
- max-width: 360px;
+import { sx } from '@/styles/sx';
- @media (width <= 768px) {
- max-width: 90%;
- }
- `,
-}));
+export const styles = stylex.create({
+ container: {
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorSplit,
+ borderRadius: '8px',
+ color: cssVar.colorText,
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+ desc: { color: cssVar.colorTextTertiary, textAlign: 'center' },
+ form: {
+ width: '100%',
+ maxWidth: { 'default': '360px', '@media (width <= 768px)': '90%' },
+ },
+});
export const ErrorActionContainer = memo<CenterProps>(
- ({ children, className, gap = 24, padding = 24, ...rest }) => {
+ ({ children, className, gap = 24, padding = 24, style, ...rest }) => {
return (
- <Center className={cx(styles.container, className)} gap={gap} padding={padding} {...rest}>
+ <Center {...sx(styles.container, className, style)} gap={gap} padding={padding} {...rest}>
{children}
</Center>
);
@@ -52,10 +52,11 @@ export const FormAction = memo<
animation,
className,
gap = 16,
+ style,
...rest
}) => {
return (
- <Center className={cx(styles.form, className)} gap={gap} {...rest}>
+ <Center {...sx(styles.form, className, style)} gap={gap} {...rest}>
<Avatar
animation={animation}
avatar={avatar}
@@ -67,7 +68,7 @@ export const FormAction = memo<
<Flexbox style={{ fontSize: 18, fontWeight: 'bold', textAlign: 'center' }}>
{title}
</Flexbox>
- <Flexbox className={styles.desc}>{description}</Flexbox>
+ <Flexbox {...stylex.props(styles.desc)}>{description}</Flexbox>
</Flexbox>
{children}
</Center>
diff --git a/src/features/Conversation/FollowUp/FollowUpChips.tsx b/src/features/Conversation/FollowUp/FollowUpChips.tsx
index 7bc60b4eb2f..abcd34894db 100644
--- a/src/features/Conversation/FollowUp/FollowUpChips.tsx
+++ b/src/features/Conversation/FollowUp/FollowUpChips.tsx
@@ -1,12 +1,15 @@
'use client';
import type { FollowUpChip } from '@lobechat/types';
+import * as stylex from '@stylexjs/stylex';
import { Reply } from 'lucide-react';
import { memo, useCallback, useMemo } from 'react';
import { messageStateSelectors, useConversationStore } from '@/features/Conversation/store';
import { followUpActionSelectors, useFollowUpActionStore } from '@/store/followUpAction';
+import { sx } from '@/styles/sx';
+import { chipMarker } from './markers.stylex';
import { styles } from './style';
interface FollowUpChipsProps {
@@ -41,17 +44,18 @@ const FollowUpChips = memo<FollowUpChipsProps>(({ conversationKey, messageId })
if (chips.length === 0 || isGenerating) return null;
return (
- <div className={styles.root}>
+ <div {...stylex.props(styles.root)}>
{chips.map((chip, i) => (
<button
aria-label={chip.label}
- className={styles.chip}
key={`${messageId}-${i}`}
- style={{ animationDelay: `${i * 60}ms` }}
+ {...sx(styles.chip, chipMarker, {
+ animationDelay: `${i * 60}ms`,
+ })}
type="button"
onClick={() => handleClick(chip, i)}
>
- <Reply className={`${styles.chipIcon} followup-icon`} size={14} />
+ <Reply {...stylex.props(styles.chipIcon)} size={14} />
<span>{chip.label}</span>
</button>
))}
diff --git a/src/features/Conversation/FollowUp/markers.stylex.ts b/src/features/Conversation/FollowUp/markers.stylex.ts
new file mode 100644
index 00000000000..266c8651508
--- /dev/null
+++ b/src/features/Conversation/FollowUp/markers.stylex.ts
@@ -0,0 +1,3 @@
+import * as stylex from '@stylexjs/stylex';
+
+export const chipMarker = stylex.defineMarker();
diff --git a/src/features/Conversation/FollowUp/style.ts b/src/features/Conversation/FollowUp/style.ts
index 7eb78141b05..86ae04a41d2 100644
--- a/src/features/Conversation/FollowUp/style.ts
+++ b/src/features/Conversation/FollowUp/style.ts
@@ -1,71 +1,53 @@
-import { createStaticStyles, keyframes } from '@lobehub/ui';
-
-const slideUp = keyframes`
- from {
- opacity: 0;
- transform: translateY(8px);
- }
- to {
- opacity: 1;
- transform: translateY(0);
- }
-`;
-
-export const styles = createStaticStyles(({ css, cssVar }) => ({
- root: css`
- display: flex;
- flex-direction: column;
- gap: 6px;
- align-items: flex-start;
-
- max-inline-size: 460px;
- margin-block-start: 8px;
- `,
- chip: css`
- cursor: pointer;
-
- transform: translateY(8px);
-
- display: inline-flex;
- gap: 8px;
- align-items: center;
-
- padding-block: 7px;
- padding-inline: 10px 14px;
- border: none;
- border-radius: 8px;
-
- font-size: 13px;
- color: ${cssVar.colorText};
-
- opacity: 0;
- background: ${cssVar.colorFillTertiary};
-
- transition:
- background 0.15s,
- color 0.15s;
- animation: ${slideUp} 320ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
-
- &:hover {
- background: ${cssVar.colorFillSecondary};
- }
-
- &:hover .followup-icon {
- color: ${cssVar.colorPrimary};
- opacity: 1;
- }
-
- @media (prefers-reduced-motion: reduce) {
- transform: none;
- opacity: 1;
- animation: none;
- }
- `,
- chipIcon: css`
- flex: none;
- opacity: 0.55;
- transition:
- opacity 0.15s,
- color 0.15s;
- `,
-}));
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
+
+import { chipMarker } from './markers.stylex';
+
+const REDUCED_MOTION = '@media (prefers-reduced-motion: reduce)';
+
+const slideUp = stylex.keyframes({
+ from: { opacity: 0, transform: 'translateY(8px)' },
+ to: { opacity: 1, transform: 'translateY(0)' },
+});
+
+export const styles = stylex.create({
+ chip: {
+ cursor: 'pointer',
+ display: 'inline-flex',
+ gap: '8px',
+ alignItems: 'center',
+ paddingBlock: '7px',
+ paddingInlineStart: '10px',
+ paddingInlineEnd: '14px',
+ borderStyle: 'none',
+ borderRadius: '8px',
+ fontSize: '13px',
+ color: cssVar.colorText,
+ backgroundColor: { 'default': cssVar.colorFillTertiary, ':hover': cssVar.colorFillSecondary },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ transform: { default: 'translateY(8px)', [REDUCED_MOTION]: 'none' },
+ opacity: { default: 0, [REDUCED_MOTION]: 1 },
+ transition: 'background 0.15s, color 0.15s',
+ animationName: { default: slideUp, [REDUCED_MOTION]: 'none' },
+ animationDuration: { default: '320ms', [REDUCED_MOTION]: '0s' },
+ animationTimingFunction: {
+ default: 'cubic-bezier(0.22, 1, 0.36, 1)',
+ [REDUCED_MOTION]: 'ease',
+ },
+ animationFillMode: { default: 'forwards', [REDUCED_MOTION]: 'none' },
+ },
+ chipIcon: {
+ flex: 'none',
+ color: { default: null, [stylex.when.ancestor(':hover', chipMarker)]: cssVar.colorPrimary },
+ opacity: { default: 0.55, [stylex.when.ancestor(':hover', chipMarker)]: 1 },
+ transition: 'opacity 0.15s, color 0.15s',
+ },
+ root: {
+ display: 'flex',
+ flexDirection: 'column',
+ gap: '6px',
+ alignItems: 'flex-start',
+ maxInlineSize: '460px',
+ marginBlockStart: '8px',
+ },
+});
diff --git a/src/features/Conversation/InterventionBar/InterventionContent.tsx b/src/features/Conversation/InterventionBar/InterventionContent.tsx
index 53ec39d462c..49af20ac826 100644
--- a/src/features/Conversation/InterventionBar/InterventionContent.tsx
+++ b/src/features/Conversation/InterventionBar/InterventionContent.tsx
@@ -1,3 +1,4 @@
+import * as stylex from '@stylexjs/stylex';
import { memo } from 'react';
import Intervention from '../Messages/AssistantGroup/Tool/Detail/Intervention';
@@ -21,7 +22,7 @@ const InterventionContent = memo<InterventionContentProps>(
].join('|');
return (
- <div className={styles.content}>
+ <div {...stylex.props(styles.content)}>
<UserInterventionErrorBoundary
actionsPortalTarget={actionsPortalTarget}
apiName={intervention.apiName}
diff --git a/src/features/Conversation/InterventionBar/InterventionTabBar.tsx b/src/features/Conversation/InterventionBar/InterventionTabBar.tsx
index 6021d882ea6..df5ccafcad0 100644
--- a/src/features/Conversation/InterventionBar/InterventionTabBar.tsx
+++ b/src/features/Conversation/InterventionBar/InterventionTabBar.tsx
@@ -1,4 +1,5 @@
import { Button, Tabs, Tooltip } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
import { CheckCheck } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -34,15 +35,15 @@ const InterventionTabBar = memo<InterventionTabBarProps>(
);
return (
- <div className={styles.tabBar}>
+ <div className={stylex.props(styles.tabBar).className}>
<Tabs
activeKey={String(activeIndex)}
items={labels.map((label, index) => ({ key: String(index), label }))}
size={'small'}
onChange={(key) => onTabChange(Number(key))}
/>
- <div className={styles.tabTrailing}>
- <span className={styles.tabCounter}>
+ <div className={stylex.props(styles.tabTrailing).className}>
+ <span className={stylex.props(styles.tabCounter).className}>
{activeIndex + 1} / {interventions.length}
</span>
{/* Only shown for a real batch: with one pending call in the active
diff --git a/src/features/Conversation/InterventionBar/UserInterventionErrorBoundary.tsx b/src/features/Conversation/InterventionBar/UserInterventionErrorBoundary.tsx
index 147ee2a61b5..574f3025a99 100644
--- a/src/features/Conversation/InterventionBar/UserInterventionErrorBoundary.tsx
+++ b/src/features/Conversation/InterventionBar/UserInterventionErrorBoundary.tsx
@@ -1,7 +1,9 @@
'use client';
import { safeParseJSON } from '@lobechat/utils';
-import { createStaticStyles, Flexbox, Highlighter, Icon, Text } from '@lobehub/ui';
+import { Flexbox, Highlighter, Icon, Text } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { AlertTriangle } from 'lucide-react';
import type { ErrorInfo, ReactNode } from 'react';
import { Component, memo, useMemo } from 'react';
@@ -13,38 +15,27 @@ import { toolInterventionSelectors } from '@/store/user/selectors';
import ApprovalActions from '../Messages/AssistantGroup/Tool/Detail/Intervention/ApprovalActions';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- description: css`
- overflow: hidden;
- flex: 1;
-
- min-width: 0;
-
- color: ${cssVar.colorTextSecondary};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- icon: css`
- flex: none;
- color: ${cssVar.colorWarning};
- `,
- notice: css`
- display: flex;
- gap: 6px;
- align-items: center;
-
- min-width: 0;
- padding-block: 2px;
-
- font-size: 12px;
- line-height: 1.5;
- `,
- title: css`
- flex: none;
- font-weight: 500;
- color: ${cssVar.colorWarning};
- `,
-}));
+const styles = stylex.create({
+ description: {
+ overflow: 'hidden',
+ flex: '1',
+ minWidth: '0',
+ color: cssVar.colorTextSecondary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ icon: { flex: 'none', color: cssVar.colorWarning },
+ notice: {
+ display: 'flex',
+ gap: '6px',
+ alignItems: 'center',
+ minWidth: '0',
+ paddingBlock: '2px',
+ fontSize: '12px',
+ lineHeight: 1.5,
+ },
+ title: { flex: 'none', fontWeight: 500, color: cssVar.colorWarning },
+});
interface UserInterventionFallbackProps {
actionsPortalTarget?: HTMLDivElement | null;
@@ -100,10 +91,10 @@ const UserInterventionFallback = memo<UserInterventionFallbackProps>(
return (
<Flexbox gap={8}>
- <div className={styles.notice}>
- <Icon className={styles.icon} icon={AlertTriangle} size={14} />
- <span className={styles.title}>{t('tool.intervention.renderFallback.title')}</span>
- <span className={styles.description}>
+ <div {...stylex.props(styles.notice)}>
+ <Icon className={stylex.props(styles.icon).className} icon={AlertTriangle} size={14} />
+ <span {...stylex.props(styles.title)}>{t('tool.intervention.renderFallback.title')}</span>
+ <span {...stylex.props(styles.description)}>
{t('tool.intervention.renderFallback.description')}
</span>
</div>
diff --git a/src/features/Conversation/InterventionBar/index.tsx b/src/features/Conversation/InterventionBar/index.tsx
index 7936ec70d78..d289bfbabdf 100644
--- a/src/features/Conversation/InterventionBar/index.tsx
+++ b/src/features/Conversation/InterventionBar/index.tsx
@@ -1,4 +1,5 @@
import { ChatInput } from '@lobehub/editor/react';
+import * as stylex from '@stylexjs/stylex';
import { memo, useCallback, useMemo, useState } from 'react';
import { useConversationResourceAccess } from '../hooks/useConversationResourceAccess';
@@ -73,8 +74,8 @@ const InterventionBar = memo<InterventionBarProps>(({ interventions }) => {
return (
<ChatInput
data-pending-hotkey-scope
- className={styles.container}
- footer={<div className={styles.actions} ref={setActionsPortalTarget} />}
+ className={stylex.props(styles.container).className}
+ footer={<div {...stylex.props(styles.actions)} ref={setActionsPortalTarget} />}
// The card's action row β€” Stop sits beside Submit inside `ApprovalActions`
// and the whole row portals in here.
maxHeight={'50vh' as any}
diff --git a/src/features/Conversation/InterventionBar/style.ts b/src/features/Conversation/InterventionBar/style.ts
index 3bff3ef302d..c41dcaf261f 100644
--- a/src/features/Conversation/InterventionBar/style.ts
+++ b/src/features/Conversation/InterventionBar/style.ts
@@ -1,57 +1,60 @@
-import { createStaticStyles } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
-export const styles = createStaticStyles(({ css, cssVar }) => ({
- actions: css`
- padding-block: 8px 10px;
- padding-inline: 10px;
- border-block-start: 1px solid ${cssVar.colorBorderSecondary};
+export const styles = stylex.create({
+ actions: {
+ paddingBlockStart: '8px',
+ paddingBlockEnd: '10px',
+ paddingInline: '10px',
+ borderBlockStartWidth: '1px',
+ borderBlockStartStyle: 'solid',
+ borderBlockStartColor: cssVar.colorBorderSecondary,
- /* ChatInput rounds its border without clipping, so this tinted strip would
- paint square over the card's bottom corners. Sits inside the 1px border. */
- border-end-start-radius: calc(${cssVar.borderRadiusLG} - 1px);
- border-end-end-radius: calc(${cssVar.borderRadiusLG} - 1px);
+ // ChatInput rounds its border without clipping, so this tinted strip would
+ // paint square over the card's bottom corners. Sits inside the 1px border.
+ borderEndStartRadius: `calc(${cssVar.borderRadiusLG} - 1px)`,
+ borderEndEndRadius: `calc(${cssVar.borderRadiusLG} - 1px)`,
- background: color-mix(in srgb, ${cssVar.colorBgElevated} 92%, ${cssVar.colorFillSecondary});
-
- &:empty {
- display: none;
- }
- `,
- container: css`
- margin-block-end: 12px;
- `,
- content: css`
- /* ChatInput's maxHeight owns the vertical scrolling; an overflow:auto here
- never scrolls itself but still severs position:sticky inside intervention
- bodies from that real scroll container. */
- overflow-y: visible;
- flex: 1;
- min-height: 0;
- padding-block: 0 8px;
- `,
- tabBar: css`
- overflow-x: auto;
- display: flex;
- gap: 8px;
- align-items: center;
-
- padding-block: 6px;
- padding-inline: 4px;
- border-block-end: 1px solid ${cssVar.colorBorderSecondary};
- `,
- tabCounter: css`
- font-size: 11px;
- color: ${cssVar.colorTextTertiary};
- white-space: nowrap;
- `,
- tabTrailing: css`
- display: flex;
- flex-shrink: 0;
- gap: 8px;
- align-items: center;
-
- margin-inline-start: auto;
- padding-block: 4px;
- padding-inline: 10px;
- `,
-}));
+ backgroundColor: `color-mix(in srgb, ${cssVar.colorBgElevated} 92%, ${cssVar.colorFillSecondary})`,
+ backgroundImage: 'none',
+ display: { 'default': null, ':empty': 'none' },
+ },
+ container: {
+ marginBlockEnd: '12px',
+ },
+ content: {
+ // ChatInput's maxHeight owns the vertical scrolling; an overflow:auto here
+ // never scrolls itself but still severs position:sticky inside intervention
+ // bodies from that real scroll container.
+ overflowY: 'visible',
+ flex: '1',
+ minHeight: '0',
+ paddingBlockStart: 0,
+ paddingBlockEnd: '8px',
+ },
+ tabBar: {
+ overflowX: 'auto',
+ display: 'flex',
+ gap: '8px',
+ alignItems: 'center',
+ paddingBlock: '6px',
+ paddingInline: '4px',
+ borderBlockEndWidth: '1px',
+ borderBlockEndStyle: 'solid',
+ borderBlockEndColor: cssVar.colorBorderSecondary,
+ },
+ tabCounter: {
+ fontSize: '11px',
+ color: cssVar.colorTextTertiary,
+ whiteSpace: 'nowrap',
+ },
+ tabTrailing: {
+ display: 'flex',
+ flexShrink: 0,
+ gap: '8px',
+ alignItems: 'center',
+ marginInlineStart: 'auto',
+ paddingBlock: '4px',
+ paddingInline: '10px',
+ },
+});
diff --git a/src/features/Conversation/Markdown/plugins/FileLink/Render.tsx b/src/features/Conversation/Markdown/plugins/FileLink/Render.tsx
index 23dfa0ba773..d2e8df3e292 100644
--- a/src/features/Conversation/Markdown/plugins/FileLink/Render.tsx
+++ b/src/features/Conversation/Markdown/plugins/FileLink/Render.tsx
@@ -2,7 +2,9 @@
import { isDesktop } from '@lobechat/const';
import { RENDERER_HANDLED_LINK_ATTR } from '@lobechat/desktop-bridge';
-import { A, copyToClipboard, createStaticStyles, Icon, toast } from '@lobehub/ui';
+import { A, copyToClipboard, Icon, toast } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { CopyIcon } from 'lucide-react';
import type { MouseEvent } from 'react';
import { memo, useCallback } from 'react';
@@ -17,6 +19,7 @@ import { useFileStore } from '@/store/file';
import { useConversationStore } from '../../../store';
import type { MarkdownElementProps } from '../type';
+import { fileLinkMarker } from './markers.stylex';
import {
getFileLinkCopyHref,
getFileLinkOpenAction,
@@ -25,6 +28,55 @@ import {
resolveAppOrigin,
} from './parse';
+const stylesAtomic = stylex.create({
+ icon: { display: 'inline-flex', flexShrink: 0, alignItems: 'center' },
+ label: {
+ textDecorationColor: {
+ default: cssVar.colorTextTertiary,
+ [stylex.when.ancestor(':hover', fileLinkMarker)]: cssVar.colorTextSecondary,
+ },
+ textDecorationLine: 'underline',
+ textDecorationThickness: '1px',
+ textUnderlineOffset: '3px',
+ transition: 'text-decoration-color 0.15s',
+ },
+ link: {
+ cursor: 'pointer',
+ display: 'inline-flex',
+ gap: '4px',
+ alignItems: 'center',
+ color: cssVar.colorText,
+ textDecoration: 'none',
+ verticalAlign: '-0.16em',
+ borderRadius: { 'default': null, ':focus-visible': '2px' },
+ outlineWidth: { 'default': null, ':focus-visible': '2px' },
+ outlineStyle: { 'default': null, ':focus-visible': 'solid' },
+ outlineColor: { 'default': null, ':focus-visible': cssVar.colorPrimaryBorder },
+ outlineOffset: { 'default': null, ':focus-visible': '2px' },
+ },
+ copy: {
+ cursor: 'pointer',
+ display: 'inline-flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: '18px',
+ height: '18px',
+ marginInlineStart: '2px',
+ padding: '0',
+ borderStyle: 'none',
+ borderRadius: 'var(--lobe-border-radius-sm)',
+ color: { 'default': 'var(--lobe-color-text-quaternary)', ':hover': 'var(--lobe-color-text)' },
+ verticalAlign: '-0.2em',
+ backgroundColor: { 'default': 'transparent', ':hover': 'var(--lobe-color-fill-secondary)' },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ transition: 'color 0.15s, background 0.15s',
+ outlineWidth: { 'default': null, ':focus-visible': '2px' },
+ outlineStyle: { 'default': null, ':focus-visible': 'solid' },
+ outlineColor: { 'default': null, ':focus-visible': 'var(--lobe-color-primary-border)' },
+ outlineOffset: { 'default': null, ':focus-visible': '1px' },
+ },
+});
+
interface FileLinkProperties {
fileId?: string;
linkHref?: string;
@@ -46,88 +98,12 @@ const getAppOrigin = () =>
windowOrigin: () => window.location.origin,
});
-const styles = createStaticStyles(({ css, cssVar }) => ({
- copy: css`
- cursor: pointer;
-
- display: inline-flex;
- align-items: center;
- justify-content: center;
-
- width: 18px;
- height: 18px;
- margin-inline-start: 2px;
- padding: 0;
- border: none;
- border-radius: ${cssVar.borderRadiusSM};
-
- color: ${cssVar.colorTextQuaternary};
- vertical-align: -0.2em;
-
- background: transparent;
-
- transition:
- color 0.15s,
- background 0.15s;
-
- &:hover {
- color: ${cssVar.colorText};
- background: ${cssVar.colorFillSecondary};
- }
-
- &:focus-visible {
- outline: 2px solid ${cssVar.colorPrimaryBorder};
- outline-offset: 1px;
- }
- `,
- icon: css`
- display: inline-flex;
- flex-shrink: 0;
- align-items: center;
- `,
- label: css`
- /* The same treatment as an internal entity link: body text with an
- underline, not link blue β€” the file icon already says what it is. */
- text-decoration-color: ${cssVar.colorTextTertiary};
- text-decoration-line: underline;
- text-decoration-thickness: 1px;
- text-underline-offset: 3px;
-
- transition: text-decoration-color 0.15s;
- `,
- link: css`
- cursor: pointer;
-
- display: inline-flex;
- gap: 4px;
- align-items: center;
-
- color: ${cssVar.colorText} !important;
- text-decoration: none;
- vertical-align: -0.16em;
-
- &:hover {
- color: ${cssVar.colorText} !important;
- }
-
- &:hover > span:last-child {
- text-decoration-color: ${cssVar.colorTextSecondary};
- }
-
- &:focus-visible {
- border-radius: 2px;
- outline: 2px solid ${cssVar.colorPrimaryBorder};
- outline-offset: 2px;
- }
- `,
-}));
-
const FileLabel = ({ label }: { label: string }) => (
<>
- <span aria-hidden className={styles.icon}>
+ <span aria-hidden {...stylex.props(stylesAtomic['icon'])}>
<FileIcon fileName={label} size={16} variant={'raw'} />
</span>
- <span className={styles.label}>{label}</span>
+ <span {...stylex.props(stylesAtomic['label'])}>{label}</span>
</>
);
@@ -207,7 +183,7 @@ const Render = memo<MarkdownElementProps<FileLinkProperties>>(({ node }) => {
<>
<A
{...(fileId ? { [RENDERER_HANDLED_LINK_ATTR]: 'true' } : {})}
- className={styles.link}
+ {...stylex.props(stylesAtomic['link'], fileLinkMarker)}
href={targetHref}
rel="noopener noreferrer"
onClick={handleClick}
@@ -221,7 +197,7 @@ const Render = memo<MarkdownElementProps<FileLinkProperties>>(({ node }) => {
{targetHref && (
<button
aria-label={t('copy')}
- className={styles.copy}
+ {...stylex.props(stylesAtomic['copy'])}
title={t('copy')}
type={'button'}
onClick={handleCopy}
diff --git a/src/features/Conversation/Markdown/plugins/FileLink/markers.stylex.ts b/src/features/Conversation/Markdown/plugins/FileLink/markers.stylex.ts
new file mode 100644
index 00000000000..3278889602f
--- /dev/null
+++ b/src/features/Conversation/Markdown/plugins/FileLink/markers.stylex.ts
@@ -0,0 +1,3 @@
+import * as stylex from '@stylexjs/stylex';
+
+export const fileLinkMarker = stylex.defineMarker();
diff --git a/src/features/Conversation/Markdown/plugins/GoalTurn/Render.tsx b/src/features/Conversation/Markdown/plugins/GoalTurn/Render.tsx
index 0e05c9ed92d..a19f886e37d 100644
--- a/src/features/Conversation/Markdown/plugins/GoalTurn/Render.tsx
+++ b/src/features/Conversation/Markdown/plugins/GoalTurn/Render.tsx
@@ -1,14 +1,8 @@
'use client';
-import {
- Accordion,
- type AccordionItemType,
- createStaticStyles,
- cx,
- Flexbox,
- Icon,
- Text,
-} from '@lobehub/ui';
+import { Accordion, type AccordionItemType, Flexbox, Icon, Text } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import dayjs from 'dayjs';
import { TargetIcon } from 'lucide-react';
import { useMemo, useState } from 'react';
@@ -22,119 +16,104 @@ import {
parseGoalTurn,
} from './parseGoalTurn';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- /* The chat bubble folds tall messages, so a long comment is clamped and the
- new feedback stays in the first view. */
- clamp3: css`
- overflow: hidden;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 3;
- `,
- feedback: css`
- padding-block: 6px;
- `,
- folded: css`
- padding-block: 6px 2px;
-
- font-size: 12px;
- line-height: 1.6;
- color: ${cssVar.colorTextSecondary};
- word-break: break-word;
- white-space: pre-wrap;
- `,
- header: css`
- padding-block: 4px 10px;
- padding-inline: 0;
- border-block-end: 1px solid ${cssVar.colorBorderSecondary};
- `,
- label: css`
- font-size: 12px;
- `,
- mark: css`
- display: flex;
- flex: none;
- align-items: center;
- justify-content: center;
-
- inline-size: 28px;
- block-size: 28px;
- border-radius: 6px;
-
- color: ${cssVar.colorText};
-
- background: ${cssVar.colorFillTertiary};
- `,
- pill: css`
- flex: none;
- align-self: flex-start;
-
- padding-block: 2px;
- padding-inline: 8px;
- border-radius: 999px;
-
- font-size: 12px;
- font-weight: 500;
- line-height: 18px;
- `,
- pillNeutral: css`
- color: ${cssVar.colorTextSecondary};
- background: ${cssVar.colorFillSecondary};
- `,
- pillWarning: css`
- color: ${cssVar.colorWarning};
- background: ${cssVar.colorWarningBg};
- `,
- quote: css`
- margin-block-start: 4px;
- padding-inline-start: 10px;
- border-inline-start: 2px solid ${cssVar.colorBorder};
-
- font-size: 13px;
- line-height: 1.6;
- color: ${cssVar.colorText};
- word-break: break-word;
- white-space: pre-wrap;
- `,
- root: css`
- overflow: hidden;
-
- inline-size: 100%;
-
- /* The goal supervision panel is narrower than 320px of bubble content;
- a fixed minimum pushed the trigger pill past the bubble's edge. */
- min-inline-size: min(320px, 100%);
-
- font-size: 13px;
- text-align: start;
- `,
- section: css`
- padding-block: 8px 2px;
- border-block-end: 1px solid ${cssVar.colorBorderSecondary};
-
- &:last-child {
- border-block-end: none;
- }
- `,
- toggle: css`
- cursor: pointer;
-
- margin: 0;
- padding-block: 0;
- padding-inline: 12px 0;
- border: none;
-
- font: inherit;
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
-
- background: none;
-
- &:hover {
- color: ${cssVar.colorText};
- }
- `,
-}));
+const styles = stylex.create({
+ clamp3: {
+ overflow: 'hidden',
+ display: '-webkit-box',
+ WebkitBoxOrient: 'vertical',
+ WebkitLineClamp: '3',
+ },
+ feedback: { paddingBlock: '6px' },
+ folded: {
+ paddingBlockStart: '6px',
+ paddingBlockEnd: '2px',
+ fontSize: '12px',
+ lineHeight: 1.6,
+ color: cssVar.colorTextSecondary,
+ wordBreak: 'break-word',
+ whiteSpace: 'pre-wrap',
+ },
+ header: {
+ paddingBlockStart: '4px',
+ paddingBlockEnd: '10px',
+ paddingInline: '0',
+ borderBlockEndWidth: '1px',
+ borderBlockEndStyle: 'solid',
+ borderBlockEndColor: cssVar.colorBorderSecondary,
+ },
+ label: { fontSize: '12px' },
+ mark: {
+ display: 'flex',
+ flex: 'none',
+ alignItems: 'center',
+ justifyContent: 'center',
+ inlineSize: '28px',
+ blockSize: '28px',
+ borderRadius: '6px',
+ color: cssVar.colorText,
+ backgroundColor: cssVar.colorFillTertiary,
+ backgroundImage: 'none',
+ },
+ pill: {
+ flex: 'none',
+ alignSelf: 'flex-start',
+ paddingBlock: '2px',
+ paddingInline: '8px',
+ borderRadius: '999px',
+ fontSize: '12px',
+ fontWeight: 500,
+ lineHeight: '18px',
+ },
+ pillNeutral: {
+ color: cssVar.colorTextSecondary,
+ backgroundColor: cssVar.colorFillSecondary,
+ backgroundImage: 'none',
+ },
+ pillWarning: {
+ color: cssVar.colorWarning,
+ backgroundColor: cssVar.colorWarningBg,
+ backgroundImage: 'none',
+ },
+ quote: {
+ marginBlockStart: '4px',
+ paddingInlineStart: '10px',
+ borderInlineStartWidth: '2px',
+ borderInlineStartStyle: 'solid',
+ borderInlineStartColor: cssVar.colorBorder,
+ fontSize: '13px',
+ lineHeight: 1.6,
+ color: cssVar.colorText,
+ wordBreak: 'break-word',
+ whiteSpace: 'pre-wrap',
+ },
+ root: {
+ overflow: 'hidden',
+ inlineSize: '100%',
+ minInlineSize: 'min(320px, 100%)',
+ fontSize: '13px',
+ textAlign: 'start',
+ },
+ section: {
+ paddingBlockStart: '8px',
+ paddingBlockEnd: '2px',
+ borderBlockEndWidth: '1px',
+ borderBlockEndStyle: { 'default': 'solid', ':last-child': 'none' },
+ borderBlockEndColor: cssVar.colorBorderSecondary,
+ },
+ toggle: {
+ cursor: 'pointer',
+ margin: '0',
+ paddingBlock: '0',
+ paddingInlineStart: '12px',
+ paddingInlineEnd: '0',
+ borderStyle: 'none',
+ font: 'inherit',
+ fontSize: '12px',
+ color: { 'default': cssVar.colorTextSecondary, ':hover': cssVar.colorText },
+ backgroundColor: 'transparent',
+ backgroundImage: 'none',
+ },
+});
/** Rough line count past which a body is clamped and gets its own toggle. */
const isLong = (text: string) => text.length > 120 || text.split('\n').length > 3;
@@ -154,25 +133,29 @@ const FeedbackRow = ({ feedback }: { feedback: GoalTurnFeedback }) => {
const task = feedback.taskTitle || feedback.taskId;
return (
- <div className={styles.feedback}>
+ <div {...stylex.props(styles.feedback)}>
<Flexbox horizontal align="baseline" gap={8}>
{task ? (
<Text ellipsis style={{ flex: 1, minWidth: 0 }} weight={500}>
{task}
</Text>
) : null}
- <Text className={styles.label} style={{ flex: 'none' }} type="secondary">
+ <Text
+ className={stylex.props(styles.label).className}
+ style={{ flex: 'none' }}
+ type="secondary"
+ >
{meta}
</Text>
</Flexbox>
- <div className={cx(styles.quote, long && !expanded && styles.clamp3)}>
+ <div {...stylex.props(styles.quote, long && !expanded && styles.clamp3)}>
{feedback.body}
{expanded && feedback.truncated ? '…' : null}
</div>
{long ? (
<button
aria-expanded={expanded}
- className={styles.toggle}
+ {...stylex.props(styles.toggle)}
type="button"
onClick={() => setExpanded((v) => !v)}
>
@@ -214,7 +197,7 @@ const Render = ({ children, node }: MarkdownElementProps<GoalTurnAttributes>) =>
<FeedbackRow feedback={feedback} key={`${feedback.taskId}-${index}`} />
))}
{parsed.omitted.earlier > 0 ? (
- <Text className={styles.label} type="secondary">
+ <Text className={stylex.props(styles.label).className} type="secondary">
{t('goalTurn.omitted', { count: parsed.omitted.earlier })}
</Text>
) : null}
@@ -222,7 +205,7 @@ const Render = ({ children, node }: MarkdownElementProps<GoalTurnAttributes>) =>
),
key: 'earlier',
title: (
- <Text className={styles.label} type="secondary">
+ <Text className={stylex.props(styles.label).className} type="secondary">
{t('goalTurn.earlierFeedback', { count: earlier.length + parsed.omitted.earlier })}
</Text>
),
@@ -233,14 +216,14 @@ const Render = ({ children, node }: MarkdownElementProps<GoalTurnAttributes>) =>
? [
{
children: (
- <div className={styles.folded}>
+ <div {...stylex.props(styles.folded)}>
{parsed.requirement}
{parsed.ownerInstruction ? `\n\n${parsed.ownerInstruction}` : ''}
</div>
),
key: 'requirement',
title: (
- <Text className={styles.label} type="secondary">
+ <Text className={stylex.props(styles.label).className} type="secondary">
{t('goalTurn.requirement')}
</Text>
),
@@ -250,10 +233,10 @@ const Render = ({ children, node }: MarkdownElementProps<GoalTurnAttributes>) =>
...(parsed.instruction
? [
{
- children: <div className={styles.folded}>{parsed.instruction}</div>,
+ children: <div {...stylex.props(styles.folded)}>{parsed.instruction}</div>,
key: 'instruction',
title: (
- <Text className={styles.label} type="secondary">
+ <Text className={stylex.props(styles.label).className} type="secondary">
{t('goalTurn.instruction')}
</Text>
),
@@ -263,9 +246,9 @@ const Render = ({ children, node }: MarkdownElementProps<GoalTurnAttributes>) =>
];
return (
- <div className={styles.root}>
- <Flexbox horizontal align="center" className={styles.header} gap={10}>
- <span className={styles.mark}>
+ <div {...stylex.props(styles.root)}>
+ <Flexbox horizontal align="center" className={stylex.props(styles.header).className} gap={10}>
+ <span {...stylex.props(styles.mark)}>
<Icon icon={TargetIcon} size={16} />
</span>
<Flexbox flex={1} gap={1} style={{ minWidth: 0 }}>
@@ -274,7 +257,7 @@ const Render = ({ children, node }: MarkdownElementProps<GoalTurnAttributes>) =>
</Text>
{/* The reason itself is the previous reply, right above this card. */}
{previous ? (
- <Text ellipsis className={styles.label} type="secondary">
+ <Text ellipsis className={stylex.props(styles.label).className} type="secondary">
{t(`goalTurn.outcome.${previous.outcome}` as any, {
action: previous.action,
defaultValue: previous.outcome,
@@ -283,7 +266,7 @@ const Render = ({ children, node }: MarkdownElementProps<GoalTurnAttributes>) =>
) : null}
</Flexbox>
<span
- className={cx(
+ {...stylex.props(
styles.pill,
trigger === 'takeover' ? styles.pillWarning : styles.pillNeutral,
)}
@@ -293,24 +276,24 @@ const Render = ({ children, node }: MarkdownElementProps<GoalTurnAttributes>) =>
</Flexbox>
{reason ? (
- <Flexbox className={styles.section} gap={4}>
- <Text className={styles.label} type="secondary">
+ <Flexbox className={stylex.props(styles.section).className} gap={4}>
+ <Text className={stylex.props(styles.label).className} type="secondary">
{t(parsed.problem ? 'goalTurn.problem' : 'goalTurn.continuation')}
</Text>
- <div className={styles.quote}>{reason}</div>
+ <div {...stylex.props(styles.quote)}>{reason}</div>
</Flexbox>
) : null}
{fresh.length > 0 || parsed.omitted.new > 0 ? (
- <div className={styles.section}>
- <Text className={styles.label} type="secondary">
+ <div {...stylex.props(styles.section)}>
+ <Text className={stylex.props(styles.label).className} type="secondary">
{t('goalTurn.newFeedback', { count: fresh.length + parsed.omitted.new })}
</Text>
{fresh.map((feedback, index) => (
<FeedbackRow feedback={feedback} key={`${feedback.taskId}-${index}`} />
))}
{parsed.omitted.new > 0 ? (
- <Text className={styles.label} type="secondary">
+ <Text className={stylex.props(styles.label).className} type="secondary">
{t('goalTurn.omitted', { count: parsed.omitted.new })}
</Text>
) : null}
diff --git a/src/features/Conversation/Markdown/plugins/ImageSearchRef/Render.tsx b/src/features/Conversation/Markdown/plugins/ImageSearchRef/Render.tsx
index f868252c575..d608feacc73 100644
--- a/src/features/Conversation/Markdown/plugins/ImageSearchRef/Render.tsx
+++ b/src/features/Conversation/Markdown/plugins/ImageSearchRef/Render.tsx
@@ -1,6 +1,8 @@
'use client';
-import { createStaticStyles, Flexbox, Popover } from '@lobehub/ui';
+import { Flexbox, Popover } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import isEqual from 'fast-deep-equal';
import { memo } from 'react';
@@ -9,79 +11,63 @@ import Image from '@/libs/next/Image';
import { dataSelectors, useConversationStore } from '../../../store';
import { type MarkdownElementProps } from '../type';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- imageCardLink: css`
- color: inherit;
- text-decoration: none;
- transition: opacity 0.2s;
-
- &:hover {
- opacity: 0.75;
- }
- `,
- imageDomain: css`
- overflow: hidden;
-
- font-size: 0.8em;
- line-height: 1;
- color: ${cssVar.colorTextQuaternary};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- imageThumb: css`
- display: block;
-
- width: 100%;
- height: 160px;
- border-radius: 6px;
-
- object-fit: cover;
- `,
- imageTitle: css`
- overflow: hidden;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
-
- font-size: 0.95em;
- line-height: 1.4;
- color: ${cssVar.colorTextSecondary};
- text-overflow: ellipsis;
- `,
- refChip: css`
- cursor: pointer;
-
- display: inline-flex;
- gap: 4px;
- align-items: center;
-
- padding-block: 1px;
- padding-inline: 6px;
- border-radius: 4px;
-
- font-size: 0.8em;
- color: ${cssVar.colorTextSecondary};
- text-decoration: none;
- vertical-align: -1px;
-
- background: ${cssVar.colorFillSecondary};
-
- transition: background 0.15s;
-
- &:hover {
- background: ${cssVar.colorFill};
- }
- `,
- thumbWrap: css`
- overflow: hidden;
- display: inline-flex;
- flex-shrink: 0;
-
- width: 16px;
- height: 16px;
- border-radius: 3px;
- `,
-}));
+const styles = stylex.create({
+ imageCardLink: {
+ color: 'inherit',
+ textDecoration: 'none',
+ transition: 'opacity 0.2s',
+ opacity: { 'default': null, ':hover': 0.75 },
+ },
+ imageDomain: {
+ overflow: 'hidden',
+ fontSize: '0.8em',
+ lineHeight: 1,
+ color: cssVar.colorTextQuaternary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ imageThumb: {
+ display: 'block',
+ width: '100%',
+ height: '160px',
+ borderRadius: '6px',
+ objectFit: 'cover',
+ },
+ imageTitle: {
+ overflow: 'hidden',
+ display: '-webkit-box',
+ WebkitBoxOrient: 'vertical',
+ WebkitLineClamp: '2',
+ fontSize: '0.95em',
+ lineHeight: 1.4,
+ color: cssVar.colorTextSecondary,
+ textOverflow: 'ellipsis',
+ },
+ refChip: {
+ cursor: 'pointer',
+ display: 'inline-flex',
+ gap: '4px',
+ alignItems: 'center',
+ paddingBlock: '1px',
+ paddingInline: '6px',
+ borderRadius: '4px',
+ fontSize: '0.8em',
+ color: cssVar.colorTextSecondary,
+ textDecoration: 'none',
+ verticalAlign: '-1px',
+ backgroundColor: { 'default': cssVar.colorFillSecondary, ':hover': cssVar.colorFill },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ transition: 'background 0.15s',
+ },
+ thumbWrap: {
+ overflow: 'hidden',
+ display: 'inline-flex',
+ flexShrink: 0,
+ width: '16px',
+ height: '16px',
+ borderRadius: '3px',
+ },
+});
interface ImageSearchRefProperties {
imageIndex: number;
@@ -106,27 +92,27 @@ const Render = memo<MarkdownElementProps<ImageSearchRefProperties>>(({ node, id
<Flexbox gap={4} style={{ maxWidth: 240 }}>
{image.imageUri && (
<a
- className={styles.imageCardLink}
+ {...stylex.props(styles.imageCardLink)}
href={image.imageUri}
rel="noopener noreferrer"
target="_blank"
>
<img
alt={image.title ? stripHtml(image.title) : ''}
- className={styles.imageThumb}
+ {...stylex.props(styles.imageThumb)}
src={image.imageUri}
/>
</a>
)}
<a
- className={styles.imageCardLink}
+ {...stylex.props(styles.imageCardLink)}
href={image.sourceUri || image.imageUri}
rel="noopener noreferrer"
target="_blank"
title={image.title ? stripHtml(image.title) : undefined}
>
<Flexbox gap={2}>
- {image.title && <div className={styles.imageTitle}>{stripHtml(image.title)}</div>}
+ {image.title && <div {...stylex.props(styles.imageTitle)}>{stripHtml(image.title)}</div>}
{image.domain && (
<Flexbox horizontal align="center" gap={4}>
<Image
@@ -137,7 +123,7 @@ const Render = memo<MarkdownElementProps<ImageSearchRefProperties>>(({ node, id
style={{ borderRadius: 2, flexShrink: 0 }}
width={12}
/>
- <div className={styles.imageDomain}>{image.domain}</div>
+ <div {...stylex.props(styles.imageDomain)}>{image.domain}</div>
</Flexbox>
)}
</Flexbox>
@@ -153,9 +139,9 @@ const Render = memo<MarkdownElementProps<ImageSearchRefProperties>>(({ node, id
style={{ color: 'inherit', textDecoration: 'none' }}
target="_blank"
>
- <span className={styles.refChip}>
+ <span {...stylex.props(styles.refChip)}>
{image.imageUri && (
- <span className={styles.thumbWrap}>
+ <span {...stylex.props(styles.thumbWrap)}>
<img
alt=""
src={image.imageUri}
diff --git a/src/features/Conversation/Markdown/plugins/LobeAgents/Render/index.tsx b/src/features/Conversation/Markdown/plugins/LobeAgents/Render/index.tsx
index 057056f7f78..6d69c90062f 100644
--- a/src/features/Conversation/Markdown/plugins/LobeAgents/Render/index.tsx
+++ b/src/features/Conversation/Markdown/plugins/LobeAgents/Render/index.tsx
@@ -1,7 +1,9 @@
'use client';
import { AGENT_CHAT_URL } from '@lobechat/const';
-import { createStaticStyles, Flexbox } from '@lobehub/ui';
+import { Flexbox } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { ArrowRight } from 'lucide-react';
import { memo, useCallback } from 'react';
@@ -10,48 +12,33 @@ import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwar
import { type MarkdownElementProps } from '../../type';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- arrowIcon: css`
- flex-shrink: 0;
- color: ${cssVar.colorTextTertiary};
- `,
- card: css`
- cursor: pointer;
-
- padding-block: 14px;
- padding-inline: 14px;
- border-radius: 10px;
-
- background: ${cssVar.colorFillQuaternary};
-
- transition: background 0.15s;
-
- &:hover {
- background: ${cssVar.colorFillTertiary};
- }
- `,
- description: css`
- overflow: hidden;
-
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- content: css`
- /* Allow the text column to shrink below its content width so the
- nowrap title/description ellipsize instead of overflowing the card. */
- min-width: 0;
- `,
- title: css`
- overflow: hidden;
-
- font-size: 14px;
- font-weight: 500;
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
-}));
+const styles = stylex.create({
+ arrowIcon: { flexShrink: 0, color: cssVar.colorTextTertiary },
+ card: {
+ cursor: 'pointer',
+ paddingBlock: '14px',
+ paddingInline: '14px',
+ borderRadius: '10px',
+ backgroundColor: { 'default': cssVar.colorFillQuaternary, ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ transition: 'background 0.15s',
+ },
+ description: {
+ overflow: 'hidden',
+ fontSize: '12px',
+ color: cssVar.colorTextSecondary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ content: { minWidth: '0' },
+ title: {
+ overflow: 'hidden',
+ fontSize: '14px',
+ fontWeight: 500,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+});
interface LobeAgentsProps extends MarkdownElementProps {
avatar?: string;
@@ -73,7 +60,13 @@ const Render = memo<LobeAgentsProps>(
if (!identifier) return null;
return (
- <Flexbox horizontal align={'center'} className={styles.card} gap={12} onClick={handleClick}>
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={stylex.props(styles.card).className}
+ gap={12}
+ onClick={handleClick}
+ >
<AgentAvatar
agentId={identifier}
avatar={avatar}
@@ -82,11 +75,11 @@ const Render = memo<LobeAgentsProps>(
size={40}
title={title || undefined}
/>
- <Flexbox className={styles.content} flex={1} gap={4}>
- <span className={styles.title}>{title || identifier}</span>
- {description && <span className={styles.description}>{description}</span>}
+ <Flexbox className={stylex.props(styles.content).className} flex={1} gap={4}>
+ <span {...stylex.props(styles.title)}>{title || identifier}</span>
+ {description && <span {...stylex.props(styles.description)}>{description}</span>}
</Flexbox>
- <ArrowRight className={styles.arrowIcon} size={16} />
+ <ArrowRight className={stylex.props(styles.arrowIcon).className} size={16} />
</Flexbox>
);
},
diff --git a/src/features/Conversation/Markdown/plugins/LobeArtifact/Render/index.tsx b/src/features/Conversation/Markdown/plugins/LobeArtifact/Render/index.tsx
index 4e76cd1cb09..c974e0aee99 100644
--- a/src/features/Conversation/Markdown/plugins/LobeArtifact/Render/index.tsx
+++ b/src/features/Conversation/Markdown/plugins/LobeArtifact/Render/index.tsx
@@ -1,4 +1,6 @@
-import { Center, createStaticStyles, cx, Flexbox, Spin } from '@lobehub/ui';
+import { Center, cx, Flexbox, Spin } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { memo, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
@@ -11,42 +13,36 @@ import { type MarkdownElementProps } from '../../type';
import ArtifactIcon from './Icon';
import { useArtifactCodeLength } from './useArtifactCodeLength';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- avatar: css`
- border-inline-end: 1px solid ${cssVar.colorSplit};
- background: ${cssVar.colorFillQuaternary};
- `,
- container: css`
- cursor: pointer;
-
- margin-block-start: 12px;
- border: 1px solid ${cssVar.colorBorder};
- border-radius: 8px;
-
- color: ${cssVar.colorText};
-
- box-shadow: ${cssVar.boxShadowTertiary};
-
- &:hover {
- background: ${cssVar.colorFillQuaternary};
- }
- `,
- container_dark: css`
- box-shadow: ${cssVar.boxShadowSecondary};
- `,
- desc: css`
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
- `,
- title: css`
- overflow: hidden;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 1;
-
- text-overflow: ellipsis;
- `,
-}));
+const styles = stylex.create({
+ avatar: {
+ borderInlineEndWidth: '1px',
+ borderInlineEndStyle: 'solid',
+ borderInlineEndColor: cssVar.colorSplit,
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+ container: {
+ cursor: 'pointer',
+ marginBlockStart: '12px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorder,
+ borderRadius: '8px',
+ color: cssVar.colorText,
+ boxShadow: cssVar.boxShadowTertiary,
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillQuaternary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ },
+ container_dark: { boxShadow: cssVar.boxShadowSecondary },
+ desc: { fontSize: '12px', color: cssVar.colorTextTertiary },
+ title: {
+ overflow: 'hidden',
+ display: '-webkit-box',
+ WebkitBoxOrient: 'vertical',
+ WebkitLineClamp: '1',
+ textOverflow: 'ellipsis',
+ },
+});
interface ArtifactProps extends MarkdownElementProps {
identifier: string;
@@ -84,7 +80,7 @@ const Render = memo<ArtifactProps>(({ identifier, title, type, language, childre
return (
<Flexbox
- className={cx(styles.container, isDarkMode && styles.container_dark)}
+ className={stylex.props(styles.container, isDarkMode && styles.container_dark).className}
gap={16}
width={'100%'}
onClick={() => {
@@ -99,7 +95,7 @@ const Render = memo<ArtifactProps>(({ identifier, title, type, language, childre
}}
>
<Flexbox horizontal align={'center'} flex={1}>
- <Center horizontal className={styles.avatar} height={64} width={64}>
+ <Center horizontal className={stylex.props(styles.avatar).className} height={64} width={64}>
<ArtifactIcon type={type} />
</Center>
<Flexbox gap={4} paddingBlock={8} paddingInline={12}>
@@ -108,10 +104,12 @@ const Render = memo<ArtifactProps>(({ identifier, title, type, language, childre
{t('artifact.generating')}
</Flexbox>
) : (
- <Flexbox className={cx(styles.title)}>{title || t('artifact.unknownTitle')}</Flexbox>
+ <Flexbox className={stylex.props(styles.title).className}>
+ {title || t('artifact.unknownTitle')}
+ </Flexbox>
)}
{hasChildren && (
- <Flexbox horizontal align={'center'} className={styles.desc}>
+ <Flexbox horizontal align={'center'} className={stylex.props(styles.desc).className}>
{identifier} Β·&nbsp;
<Flexbox horizontal align={'center'} gap={4}>
{!isArtifactTagClosed && <Spin size="small" />}
diff --git a/src/features/Conversation/Markdown/plugins/LocalFileLink/Render.tsx b/src/features/Conversation/Markdown/plugins/LocalFileLink/Render.tsx
index d3b8a9ecc09..3ce9197ce6f 100644
--- a/src/features/Conversation/Markdown/plugins/LocalFileLink/Render.tsx
+++ b/src/features/Conversation/Markdown/plugins/LocalFileLink/Render.tsx
@@ -2,7 +2,9 @@
import { isDesktop } from '@lobechat/const';
import { RENDERER_HANDLED_LINK_ATTR } from '@lobechat/desktop-bridge';
-import { A, createStaticStyles, Tooltip } from '@lobehub/ui';
+import { A, Tooltip } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import type { MouseEvent } from 'react';
import { memo, useCallback } from 'react';
@@ -20,57 +22,37 @@ interface LocalFileLinkProperties {
linkLabel?: string;
}
-const styles = createStaticStyles(({ css, cssVar }) => ({
- reference: css`
- display: inline-flex;
- gap: 4px;
- align-items: center;
- vertical-align: -0.16em;
- `,
- icon: css`
- display: inline-flex;
- flex-shrink: 0;
- align-items: center;
- `,
- link: css`
- cursor: pointer;
-
- display: inline-flex;
- gap: 4px;
- align-items: center;
-
- margin-inline: -2px;
- padding-inline: 2px;
- border-radius: ${cssVar.borderRadiusSM};
-
- text-decoration: none;
- vertical-align: -0.16em;
-
- transition:
- color 0.2s ${cssVar.motionEaseOut},
+const styles = stylex.create({
+ reference: { display: 'inline-flex', gap: '4px', alignItems: 'center', verticalAlign: '-0.16em' },
+ icon: { display: 'inline-flex', flexShrink: 0, alignItems: 'center' },
+ link: {
+ cursor: 'pointer',
+ display: 'inline-flex',
+ gap: '4px',
+ alignItems: 'center',
+ marginInline: '-2px',
+ paddingInline: '2px',
+ borderRadius: cssVar.borderRadiusSM,
+ textDecoration: { 'default': 'none', ':hover': 'underline' },
+ verticalAlign: '-0.16em',
+ transition: `color 0.2s ${cssVar.motionEaseOut},
background 0.2s ${cssVar.motionEaseOut},
- box-shadow 0.2s ${cssVar.motionEaseOut};
-
- &:hover {
- color: ${cssVar.colorLinkHover};
- text-decoration: underline;
- text-underline-offset: 2px;
-
- background: ${cssVar.colorFillSecondary};
- box-shadow: inset 0 0 0 1px ${cssVar.colorPrimaryBorder};
- }
-
- &:active {
- color: ${cssVar.colorLinkActive};
- background: ${cssVar.colorFill};
- }
-
- &:focus-visible {
- outline: 2px solid ${cssVar.colorPrimaryBorder};
- outline-offset: 2px;
- }
- `,
-}));
+ box-shadow 0.2s ${cssVar.motionEaseOut}`,
+ color: { 'default': null, ':hover': cssVar.colorLinkHover, ':active': cssVar.colorLinkActive },
+ textUnderlineOffset: { 'default': null, ':hover': '2px' },
+ backgroundColor: {
+ 'default': null,
+ ':hover': cssVar.colorFillSecondary,
+ ':active': cssVar.colorFill,
+ },
+ backgroundImage: { 'default': null, ':hover': 'none', ':active': 'none' },
+ boxShadow: { 'default': null, ':hover': `inset 0 0 0 1px ${cssVar.colorPrimaryBorder}` },
+ outlineWidth: { 'default': null, ':focus-visible': '2px' },
+ outlineStyle: { 'default': null, ':focus-visible': 'solid' },
+ outlineColor: { 'default': null, ':focus-visible': cssVar.colorPrimaryBorder },
+ outlineOffset: { 'default': null, ':focus-visible': '2px' },
+ },
+});
const getFileName = (filePath: string) => filePath.split(/[\\/]/).at(-1) || filePath;
@@ -114,8 +96,8 @@ const Render = memo<MarkdownElementProps<LocalFileLinkProperties>>(({ node }) =>
if (!canPreview) {
return (
<Tooltip mouseEnterDelay={0.1} placement={'topLeft'} title={title}>
- <span className={styles.reference} data-file-path={parsed?.filePath}>
- <span aria-hidden className={styles.icon}>
+ <span {...stylex.props(styles.reference)} data-file-path={parsed?.filePath}>
+ <span aria-hidden {...stylex.props(styles.icon)}>
<FileIcon fileName={iconFileName} size={16} variant={'raw'} />
</span>
<span>{label}</span>
@@ -128,11 +110,11 @@ const Render = memo<MarkdownElementProps<LocalFileLinkProperties>>(({ node }) =>
<Tooltip mouseEnterDelay={0.1} placement={'topLeft'} title={title}>
<A
{...(parsed ? { [RENDERER_HANDLED_LINK_ATTR]: 'true' } : {})}
- className={styles.link}
+ className={stylex.props(styles.link).className}
href={linkHref}
onClick={handleClick}
>
- <span aria-hidden className={styles.icon}>
+ <span aria-hidden {...stylex.props(styles.icon)}>
<FileIcon fileName={iconFileName} size={16} variant={'raw'} />
</span>
<span>{label}</span>
diff --git a/src/features/Conversation/Markdown/plugins/Mention/Render.tsx b/src/features/Conversation/Markdown/plugins/Mention/Render.tsx
index f63c42fac50..5edcd386210 100644
--- a/src/features/Conversation/Markdown/plugins/Mention/Render.tsx
+++ b/src/features/Conversation/Markdown/plugins/Mention/Render.tsx
@@ -1,6 +1,7 @@
'use client';
-import { createStaticStyles } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import isEqual from 'fast-deep-equal';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -11,32 +12,27 @@ import { sessionSelectors } from '@/store/session/selectors';
import { type MarkdownElementProps } from '../type';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- mention: css`
- cursor: pointer;
-
- position: relative;
-
- display: inline;
-
- margin-inline: 0.25em;
- padding-block: 0.2em;
- padding-inline: 0.4em;
- border-radius: 0.25em;
-
- font-size: 0.875em;
- line-height: 1;
- color: ${cssVar.colorInfo};
- word-break: break-word;
- white-space: break-spaces;
-
- background: ${cssVar.colorInfoBg};
-
- &:hover {
- background: color-mix(in srgb, ${cssVar.colorInfo} 15%, ${cssVar.colorBgContainer});
- }
- `,
-}));
+const styles = stylex.create({
+ mention: {
+ cursor: 'pointer',
+ position: 'relative',
+ display: 'inline',
+ marginInline: '0.25em',
+ paddingBlock: '0.2em',
+ paddingInline: '0.4em',
+ borderRadius: '0.25em',
+ fontSize: '0.875em',
+ lineHeight: 1,
+ color: cssVar.colorInfo,
+ wordBreak: 'break-word',
+ whiteSpace: 'break-spaces',
+ backgroundColor: {
+ 'default': cssVar.colorInfoBg,
+ ':hover': `color-mix(in srgb, ${cssVar.colorInfo} 15%, ${cssVar.colorBgContainer})`,
+ },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ },
+});
interface MentionProps {
id: string;
@@ -51,7 +47,7 @@ const Render = memo<MarkdownElementProps<MentionProps>>(({ children, node }) =>
// Handle "ALL_MEMBERS" special case
if (mentionId === 'ALL_MEMBERS') {
return (
- <span className={styles.mention}>
+ <span {...stylex.props(styles.mention)}>
{'@'}
{t('memberSelection.allMembers')}
</span>
@@ -78,7 +74,7 @@ const Render = memo<MarkdownElementProps<MentionProps>>(({ children, node }) =>
: { title: name }
}
>
- <span className={styles.mention}>
+ <span {...stylex.props(styles.mention)}>
{'@'}
{label}
</span>
diff --git a/src/features/Conversation/Markdown/plugins/ScmEvent/Render.tsx b/src/features/Conversation/Markdown/plugins/ScmEvent/Render.tsx
index aaa4c76f3a8..68d40a982b1 100644
--- a/src/features/Conversation/Markdown/plugins/ScmEvent/Render.tsx
+++ b/src/features/Conversation/Markdown/plugins/ScmEvent/Render.tsx
@@ -1,6 +1,8 @@
'use client';
-import { createStaticStyles, cx, Flexbox, Icon, Text } from '@lobehub/ui';
+import { Flexbox, Icon, Text } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import {
ChevronRightIcon,
CircleCheckIcon,
@@ -11,6 +13,8 @@ import {
import { memo, type ReactNode, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import { sx } from '@/styles/sx';
+
import { type MarkdownElementProps } from '../type';
import {
type ParsedScmEvent,
@@ -20,140 +24,114 @@ import {
type ScmEventReview,
} from './parseScmEvent';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- body: css`
- padding-block: 2px;
- padding-inline: 0;
- `,
- check: css`
- padding-block: 8px;
-
- &:not(:last-child) {
- border-block-end: 1px solid ${cssVar.colorBorderSecondary};
- }
- `,
- checkFailed: css`
- color: ${cssVar.colorError};
- `,
- checkPassed: css`
- color: ${cssVar.colorSuccess};
- `,
- instruction: css`
- padding-block: 8px 2px;
- padding-inline: 0;
- border-block-start: 1px solid ${cssVar.colorBorderSecondary};
-
- font-size: 12px;
- line-height: 1.6;
- color: ${cssVar.colorTextTertiary};
- `,
- link: css`
- /* The Markdown host paints anchors in the link colour; inside the card
- a link reads as text and the trailing icon says it can be clicked. */
- display: inline-flex;
- gap: 4px;
- align-items: center;
-
- color: inherit !important;
- text-decoration: none;
-
- &:hover {
- color: ${cssVar.colorTextSecondary} !important;
- text-decoration: none;
- }
- `,
- log: css`
- overflow: auto;
-
- max-block-size: 320px;
- margin-block: 6px 0;
- margin-inline: 0;
- padding-block: 8px;
- padding-inline: 10px;
- border-radius: ${cssVar.borderRadiusSM};
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 11px;
- line-height: 1.5;
- color: ${cssVar.colorTextSecondary};
- white-space: pre;
-
- background: ${cssVar.colorFillQuaternary};
- `,
- logToggle: css`
- cursor: pointer;
- user-select: none;
-
- display: inline-flex;
- flex: none;
- gap: 2px;
- align-items: center;
-
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
-
- &:hover {
- color: ${cssVar.colorText};
- }
- `,
- logToggleOpen: css`
- svg {
- transform: rotate(90deg);
- }
- `,
- mono: css`
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- `,
- pill: css`
- flex: none;
-
- padding-block: 2px;
- padding-inline: 8px;
- border-radius: 999px;
-
- font-size: 12px;
- font-weight: 500;
- line-height: 18px;
- `,
- pillDanger: css`
- color: ${cssVar.colorError};
- background: ${cssVar.colorErrorBg};
- `,
- pillNeutral: css`
- color: ${cssVar.colorTextSecondary};
- background: ${cssVar.colorFillSecondary};
- `,
- pillWarning: css`
- color: ${cssVar.colorWarning};
- background: ${cssVar.colorWarningBg};
- `,
- review: css`
- padding-block: 8px;
-
- &:not(:last-child) {
- border-block-end: 1px solid ${cssVar.colorBorderSecondary};
- }
- `,
- reviewBody: css`
- font-size: 13px;
- line-height: 1.6;
- color: ${cssVar.colorText};
- word-break: break-word;
- white-space: pre-wrap;
- `,
- root: css`
- overflow: hidden;
-
- inline-size: 100%;
- min-inline-size: 320px;
-
- font-size: 13px;
- text-align: start;
- `,
-}));
+const NOT_LAST = ':not(:last-child)';
+
+const styles = stylex.create({
+ body: { paddingBlock: '2px', paddingInline: 0 },
+ check: {
+ paddingBlock: '8px',
+ borderBlockEndWidth: { default: null, [NOT_LAST]: '1px' },
+ borderBlockEndStyle: { default: null, [NOT_LAST]: 'solid' },
+ borderBlockEndColor: { default: null, [NOT_LAST]: cssVar.colorBorderSecondary },
+ },
+ checkFailed: { color: cssVar.colorError },
+ checkPassed: { color: cssVar.colorSuccess },
+ instruction: {
+ paddingBlockStart: '8px',
+ paddingBlockEnd: '2px',
+ paddingInline: 0,
+ borderBlockStartWidth: '1px',
+ borderBlockStartStyle: 'solid',
+ borderBlockStartColor: cssVar.colorBorderSecondary,
+ fontSize: '12px',
+ lineHeight: 1.6,
+ color: cssVar.colorTextTertiary,
+ },
+ // The Markdown host paints anchors in the link colour; inside the card
+ // a link reads as text and the trailing icon says it can be clicked.
+ link: {
+ display: 'inline-flex',
+ gap: '4px',
+ alignItems: 'center',
+ color: { 'default': 'inherit', ':hover': cssVar.colorTextSecondary },
+ textDecoration: 'none',
+ },
+ log: {
+ overflow: 'auto',
+ maxBlockSize: '320px',
+ marginBlockStart: '6px',
+ marginBlockEnd: 0,
+ marginInline: 0,
+ paddingBlock: '8px',
+ paddingInline: '10px',
+ borderRadius: cssVar.borderRadiusSM,
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '11px',
+ lineHeight: 1.5,
+ color: cssVar.colorTextSecondary,
+ whiteSpace: 'pre',
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+ logToggleChevronOpen: { transform: 'rotate(90deg)' },
+ logToggle: {
+ cursor: 'pointer',
+ userSelect: 'none',
+ display: 'inline-flex',
+ flex: 'none',
+ gap: '2px',
+ alignItems: 'center',
+ fontSize: '12px',
+ color: { 'default': cssVar.colorTextSecondary, ':hover': cssVar.colorText },
+ },
+ mono: { fontFamily: cssVar.fontFamilyCode, fontSize: '12px' },
+ pill: {
+ flex: 'none',
+ paddingBlock: '2px',
+ paddingInline: '8px',
+ borderRadius: '999px',
+ fontSize: '12px',
+ fontWeight: 500,
+ lineHeight: '18px',
+ },
+ pillDanger: {
+ color: cssVar.colorError,
+ backgroundColor: cssVar.colorErrorBg,
+ backgroundImage: 'none',
+ },
+ pillNeutral: {
+ color: cssVar.colorTextSecondary,
+ backgroundColor: cssVar.colorFillSecondary,
+ backgroundImage: 'none',
+ },
+ pillWarning: {
+ color: cssVar.colorWarning,
+ backgroundColor: cssVar.colorWarningBg,
+ backgroundImage: 'none',
+ },
+ review: {
+ paddingBlock: '8px',
+ borderBlockEndWidth: { default: null, [NOT_LAST]: '1px' },
+ borderBlockEndStyle: { default: null, [NOT_LAST]: 'solid' },
+ borderBlockEndColor: { default: null, [NOT_LAST]: cssVar.colorBorderSecondary },
+ },
+ reviewBody: {
+ fontSize: '13px',
+ lineHeight: 1.6,
+ color: cssVar.colorText,
+ wordBreak: 'break-word',
+ whiteSpace: 'pre-wrap',
+ },
+ root: {
+ overflow: 'hidden',
+ inlineSize: '100%',
+ minInlineSize: '320px',
+ fontSize: '13px',
+ textAlign: 'start',
+ },
+});
-const PILL_STYLE: Record<string, string> = {
+const PILL_STYLE: Record<string, (typeof styles)['pillDanger']> = {
ci_failed: styles.pillDanger,
review_changes_requested: styles.pillWarning,
review_commented: styles.pillNeutral,
@@ -174,11 +152,11 @@ const CheckRow = memo<{ check: ScmEventCheck; leading?: ReactNode }>(({ check, l
const failed = isFailed(check);
return (
- <Flexbox className={styles.check} gap={4}>
+ <Flexbox {...stylex.props(styles.check)} gap={4}>
<Flexbox horizontal align="center" gap={8}>
{leading ?? (
<Icon
- className={failed ? styles.checkFailed : styles.checkPassed}
+ {...stylex.props(failed ? styles.checkFailed : styles.checkPassed)}
icon={failed ? CircleXIcon : CircleCheckIcon}
size="small"
/>
@@ -193,7 +171,7 @@ const CheckRow = memo<{ check: ScmEventCheck; leading?: ReactNode }>(({ check, l
) : null}
<span style={{ flex: 1 }} />
{check.url ? (
- <a className={styles.link} href={check.url} rel="noreferrer" target="_blank">
+ <a {...stylex.props(styles.link)} href={check.url} rel="noreferrer" target="_blank">
<Text style={{ fontSize: 12 }} type="secondary">
{t('scmEvent.details')}
</Text>
@@ -201,16 +179,17 @@ const CheckRow = memo<{ check: ScmEventCheck; leading?: ReactNode }>(({ check, l
</a>
) : null}
{check.log ? (
- <span
- className={cx(styles.logToggle, open && styles.logToggleOpen)}
- onClick={() => setOpen((v) => !v)}
- >
+ <span {...stylex.props(styles.logToggle)} onClick={() => setOpen((v) => !v)}>
{open ? t('scmEvent.hideLog') : t('scmEvent.showLog')}
- <Icon icon={ChevronRightIcon} size={12} />
+ <Icon
+ {...stylex.props(open && styles.logToggleChevronOpen)}
+ icon={ChevronRightIcon}
+ size={12}
+ />
</span>
) : null}
</Flexbox>
- {check.log && open ? <pre className={styles.log}>{check.log}</pre> : null}
+ {check.log && open ? <pre {...stylex.props(styles.log)}>{check.log}</pre> : null}
</Flexbox>
);
});
@@ -223,7 +202,7 @@ const ReviewRow = memo<{ review: ScmEventReview }>(({ review }) => {
: undefined;
const meta = [review.state?.replaceAll('_', ' '), location].filter(Boolean).join(' Β· ');
const author = review.url ? (
- <a className={styles.link} href={review.url} rel="noreferrer" target="_blank">
+ <a {...stylex.props(styles.link)} href={review.url} rel="noreferrer" target="_blank">
@{review.author}
<Icon icon={ExternalLinkIcon} size={12} />
</a>
@@ -232,19 +211,17 @@ const ReviewRow = memo<{ review: ScmEventReview }>(({ review }) => {
);
return (
- <Flexbox className={styles.review} gap={4}>
+ <Flexbox {...stylex.props(styles.review)} gap={4}>
<Flexbox horizontal align="center" gap={8}>
<Icon icon={MessageSquareTextIcon} size="small" style={{ opacity: 0.6 }} />
<Text weight={500}>{author}</Text>
{meta ? (
- <Text className={styles.mono} type="secondary">
+ <Text {...stylex.props(styles.mono)} type="secondary">
{meta}
</Text>
) : null}
</Flexbox>
- <div className={styles.reviewBody} style={{ paddingInlineStart: 24 }}>
- {review.body}
- </div>
+ <div {...sx(styles.reviewBody, { paddingInlineStart: 24 })}>{review.body}</div>
</Flexbox>
);
});
@@ -267,7 +244,7 @@ const Render = memo<MarkdownElementProps<ScmEventAttributes>>(({ children, node
const kindLabel = t(`scmEvent.kind.${attrs.kind}` as any, { defaultValue: attrs.kind });
const pill = (
- <span className={cx(styles.pill, PILL_STYLE[attrs.kind] ?? styles.pillNeutral)}>
+ <span {...stylex.props(styles.pill, PILL_STYLE[attrs.kind] ?? styles.pillNeutral)}>
{kindLabel}
</span>
);
@@ -277,12 +254,12 @@ const Render = memo<MarkdownElementProps<ScmEventAttributes>>(({ children, node
const reviewers = [...new Set(parsed.reviews.map((review) => `@${review.author}`))];
return (
- <div className={styles.root}>
- <div className={styles.body}>
+ <div {...stylex.props(styles.root)}>
+ <div {...stylex.props(styles.body)}>
{single ? <CheckRow check={single} leading={pill} /> : null}
{many ? (
<>
- <Flexbox horizontal align="center" className={styles.check} gap={8}>
+ <Flexbox horizontal align="center" {...stylex.props(styles.check)} gap={8}>
{pill}
<Text type="secondary">
{t('scmEvent.failedChecks', {
@@ -296,7 +273,7 @@ const Render = memo<MarkdownElementProps<ScmEventAttributes>>(({ children, node
</>
) : null}
{!single && !many ? (
- <Flexbox horizontal align="center" className={styles.check} gap={8}>
+ <Flexbox horizontal align="center" {...stylex.props(styles.check)} gap={8}>
{pill}
{reviewers.length > 0 ? <Text type="secondary">{reviewers.join(' Β· ')}</Text> : null}
</Flexbox>
@@ -306,7 +283,9 @@ const Render = memo<MarkdownElementProps<ScmEventAttributes>>(({ children, node
))}
</div>
- {parsed.instruction ? <div className={styles.instruction}>{parsed.instruction}</div> : null}
+ {parsed.instruction ? (
+ <div {...stylex.props(styles.instruction)}>{parsed.instruction}</div>
+ ) : null}
</div>
);
});
diff --git a/src/features/Conversation/Markdown/plugins/Task/Render.tsx b/src/features/Conversation/Markdown/plugins/Task/Render.tsx
index 8a65d8a8317..30b84d22c10 100644
--- a/src/features/Conversation/Markdown/plugins/Task/Render.tsx
+++ b/src/features/Conversation/Markdown/plugins/Task/Render.tsx
@@ -1,4 +1,6 @@
-import { createStaticStyles, Flexbox, Text } from '@lobehub/ui';
+import { Flexbox, Text } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { ClipboardList } from 'lucide-react';
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -7,104 +9,79 @@ import { type MarkdownElementProps } from '../type';
import { useTaskCardScope } from './context';
import { type ParsedTaskContent, parseTaskContent } from './parseTaskContent';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- divider: css`
- inline-size: 100%;
- block-size: 1px;
- background: ${cssVar.colorSplit};
- `,
- fallback: css`
- overflow: auto;
-
- padding-block: 12px;
- padding-inline: 14px;
- border: 1px dashed ${cssVar.colorBorderSecondary};
- border-radius: 8px;
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
- white-space: pre-wrap;
- `,
- fieldKey: css`
- flex: none;
- min-inline-size: 64px;
- color: ${cssVar.colorTextTertiary};
- `,
- fieldRow: css`
- font-size: 13px;
- line-height: 1.6;
- `,
- fieldValue: css`
- color: ${cssVar.colorTextSecondary};
- word-break: break-word;
- `,
- headerIcon: css`
- display: flex;
- flex: none;
- align-items: center;
- justify-content: center;
-
- inline-size: 32px;
- block-size: 32px;
-
- color: ${cssVar.colorTextSecondary};
- `,
- identifier: css`
- flex: none;
-
- padding-block: 1px;
- padding-inline: 6px;
- border-radius: 4px;
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
-
- background: ${cssVar.colorFillQuaternary};
- `,
- instruction: css`
- font-size: 13px;
- line-height: 1.7;
- color: ${cssVar.colorText};
- white-space: pre-wrap;
- `,
- rawList: css`
- margin: 0;
- padding: 0;
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- line-height: 1.6;
- color: ${cssVar.colorTextSecondary};
- list-style: none;
-
- li {
- white-space: pre-wrap;
- }
- `,
- section: css`
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
-
- summary {
- cursor: pointer;
- padding-block: 4px;
- color: ${cssVar.colorTextSecondary};
-
- &:hover {
- color: ${cssVar.colorText};
- }
- }
- `,
-}));
+const styles = stylex.create({
+ divider: {
+ inlineSize: '100%',
+ blockSize: '1px',
+ backgroundColor: cssVar.colorSplit,
+ backgroundImage: 'none',
+ },
+ fallback: {
+ overflow: 'auto',
+ paddingBlock: '12px',
+ paddingInline: '14px',
+ borderWidth: '1px',
+ borderStyle: 'dashed',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: '8px',
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '12px',
+ color: cssVar.colorTextSecondary,
+ whiteSpace: 'pre-wrap',
+ },
+ fieldKey: { flex: 'none', minInlineSize: '64px', color: cssVar.colorTextTertiary },
+ fieldRow: { fontSize: '13px', lineHeight: 1.6 },
+ fieldValue: { color: cssVar.colorTextSecondary, wordBreak: 'break-word' },
+ headerIcon: {
+ display: 'flex',
+ flex: 'none',
+ alignItems: 'center',
+ justifyContent: 'center',
+ inlineSize: '32px',
+ blockSize: '32px',
+ color: cssVar.colorTextSecondary,
+ },
+ identifier: {
+ flex: 'none',
+ paddingBlock: '1px',
+ paddingInline: '6px',
+ borderRadius: '4px',
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '12px',
+ color: cssVar.colorTextSecondary,
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+ instruction: {
+ fontSize: '13px',
+ lineHeight: 1.7,
+ color: cssVar.colorText,
+ whiteSpace: 'pre-wrap',
+ },
+ rawItem: { whiteSpace: 'pre-wrap' },
+ rawList: {
+ margin: 0,
+ padding: 0,
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '12px',
+ lineHeight: 1.6,
+ color: cssVar.colorTextSecondary,
+ listStyle: 'none',
+ },
+ section: { fontSize: '12px', color: cssVar.colorTextTertiary },
+ sectionSummary: {
+ cursor: 'pointer',
+ paddingBlock: '4px',
+ color: { 'default': cssVar.colorTextSecondary, ':hover': cssVar.colorText },
+ },
+});
const FieldRow = memo<{ label: string; value?: string }>(({ label, value }) => {
if (!value) return null;
return (
- <Flexbox horizontal className={styles.fieldRow} gap={8}>
- <span className={styles.fieldKey}>{label}</span>
- <span className={styles.fieldValue}>{value}</span>
+ <Flexbox horizontal {...stylex.props(styles.fieldRow)} gap={8}>
+ <span {...stylex.props(styles.fieldKey)}>{label}</span>
+ <span {...stylex.props(styles.fieldValue)}>{value}</span>
</Flexbox>
);
});
@@ -112,13 +89,15 @@ const FieldRow = memo<{ label: string; value?: string }>(({ label, value }) => {
const RawSection = memo<{ items: string[]; label: string }>(({ items, label }) => {
if (!items || items.length === 0) return null;
return (
- <details className={styles.section}>
- <summary>
+ <details {...stylex.props(styles.section)}>
+ <summary {...stylex.props(styles.sectionSummary)}>
{label} ({items.length})
</summary>
- <ul className={styles.rawList}>
+ <ul {...stylex.props(styles.rawList)}>
{items.map((line, idx) => (
- <li key={idx}>{line}</li>
+ <li {...stylex.props(styles.rawItem)} key={idx}>
+ {line}
+ </li>
))}
</ul>
</details>
@@ -136,7 +115,7 @@ const Render = memo<TaskRenderProps>(({ children }) => {
const { t } = useTranslation('chat');
if (!enabled) {
- return <pre className={styles.fallback}>{text}</pre>;
+ return <pre {...stylex.props(styles.fallback)}>{text}</pre>;
}
const titleText = parsed.name || parsed.identifier || '';
@@ -144,12 +123,14 @@ const Render = memo<TaskRenderProps>(({ children }) => {
return (
<Flexbox gap={12}>
<Flexbox horizontal align={'center'} gap={12}>
- <span className={styles.headerIcon}>
+ <span {...stylex.props(styles.headerIcon)}>
<ClipboardList size={16} />
</span>
<Flexbox flex={1} gap={4} style={{ minWidth: 0 }}>
<Flexbox horizontal align={'center'} gap={8} style={{ minWidth: 0 }}>
- {parsed.identifier && <span className={styles.identifier}>{parsed.identifier}</span>}
+ {parsed.identifier && (
+ <span {...stylex.props(styles.identifier)}>{parsed.identifier}</span>
+ )}
<Text ellipsis style={{ flex: 1, minWidth: 0 }} weight={500}>
{titleText}
</Text>
@@ -159,12 +140,12 @@ const Render = memo<TaskRenderProps>(({ children }) => {
{parsed.instruction && (
<>
- <div className={styles.divider} />
+ <div {...stylex.props(styles.divider)} />
<Flexbox gap={4}>
<Text fontSize={12} type={'secondary'}>
{t('taskCard.field.instruction')}
</Text>
- <div className={styles.instruction}>{parsed.instruction}</div>
+ <div {...stylex.props(styles.instruction)}>{parsed.instruction}</div>
</Flexbox>
</>
)}
diff --git a/src/features/Conversation/Markdown/plugins/UserFeedback/Render.tsx b/src/features/Conversation/Markdown/plugins/UserFeedback/Render.tsx
index 831c1a56863..94d6dd9bf87 100644
--- a/src/features/Conversation/Markdown/plugins/UserFeedback/Render.tsx
+++ b/src/features/Conversation/Markdown/plugins/UserFeedback/Render.tsx
@@ -1,4 +1,6 @@
-import { createStaticStyles, Flexbox, Text } from '@lobehub/ui';
+import { Flexbox, Text } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { MessageSquareText } from 'lucide-react';
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -6,73 +8,66 @@ import { useTranslation } from 'react-i18next';
import { type MarkdownElementProps } from '../type';
import { type ParsedUserFeedbackComment, parseUserFeedback } from './parseUserFeedback';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- body: css`
- padding-block-start: 12px;
- padding-inline-start: 44px;
- `,
- comment: css`
- font-size: 13px;
- line-height: 1.6;
- color: ${cssVar.colorText};
- word-break: break-word;
- white-space: pre-wrap;
- `,
- countBadge: css`
- flex: none;
-
- padding-block: 1px;
- padding-inline: 6px;
- border-radius: 4px;
-
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
-
- background: ${cssVar.colorFillQuaternary};
- `,
- headerIcon: css`
- display: flex;
- flex: none;
- align-items: center;
- justify-content: center;
-
- inline-size: 32px;
- block-size: 32px;
-
- color: ${cssVar.colorTextSecondary};
- `,
- root: css`
- /* Override @lobehub/ui Markdown's default <details> card chrome (bg + padding + box-shadow).
- Need !important because the lib targets via .parent details (higher specificity).
- padding-bottom puts a 12px gap above the divider; margin-bottom puts a 12px gap below it,
- matching the symmetric 12px the task card uses around its own internal divider. */
- margin-block: 0 12px !important;
- padding-block: 0 12px !important;
- padding-inline: 0 !important;
- border-block-end: 1px solid ${cssVar.colorSplit} !important;
- border-radius: 0 !important;
-
- background: transparent !important;
- box-shadow: none !important;
- `,
- summary: css`
- cursor: pointer;
- list-style: none;
-
- &::-webkit-details-marker {
- display: none;
- }
- `,
- time: css`
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
- `,
-}));
+const styles = stylex.create({
+ body: { paddingBlockStart: '12px', paddingInlineStart: '44px' },
+ comment: {
+ fontSize: '13px',
+ lineHeight: 1.6,
+ color: cssVar.colorText,
+ wordBreak: 'break-word',
+ whiteSpace: 'pre-wrap',
+ },
+ countBadge: {
+ flex: 'none',
+ paddingBlock: '1px',
+ paddingInline: '6px',
+ borderRadius: '4px',
+ fontSize: '12px',
+ color: cssVar.colorTextSecondary,
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+ headerIcon: {
+ display: 'flex',
+ flex: 'none',
+ alignItems: 'center',
+ justifyContent: 'center',
+ inlineSize: '32px',
+ blockSize: '32px',
+ color: cssVar.colorTextSecondary,
+ },
+ // Override @lobehub/ui Markdown's default <details> card chrome (bg + padding +
+ // box-shadow). The lib targets it via `.parent details`, but its rules sit in
+ // the layered lobe-ui sheet, so these unlayered rules win without !important.
+ // paddingBlockEnd puts a 12px gap above the divider; marginBlockEnd puts a 12px
+ // gap below it, matching the symmetric 12px the task card uses around its own
+ // internal divider.
+ root: {
+ marginBlockStart: 0,
+ marginBlockEnd: '12px',
+ paddingBlockStart: 0,
+ paddingBlockEnd: '12px',
+ paddingInline: 0,
+ borderBlockEndWidth: '1px',
+ borderBlockEndStyle: 'solid',
+ borderBlockEndColor: cssVar.colorSplit,
+ borderRadius: 0,
+ backgroundColor: 'transparent',
+ backgroundImage: 'none',
+ boxShadow: 'none',
+ },
+ summary: {
+ cursor: 'pointer',
+ display: { 'default': null, '::-webkit-details-marker': 'none' },
+ listStyle: 'none',
+ },
+ time: { fontSize: '12px', color: cssVar.colorTextTertiary },
+});
const Comment = memo<{ comment: ParsedUserFeedbackComment }>(({ comment }) => (
<Flexbox gap={2}>
- {comment.time && <span className={styles.time}>{comment.time}</span>}
- <div className={styles.comment}>{comment.content}</div>
+ {comment.time && <span {...stylex.props(styles.time)}>{comment.time}</span>}
+ <div {...stylex.props(styles.comment)}>{comment.content}</div>
</Flexbox>
));
@@ -88,21 +83,21 @@ const Render = memo<MarkdownElementProps>(({ children }) => {
const countLabel = t('userFeedbackCard.count', { count: comments.length });
return (
- <details className={styles.root}>
- <summary className={styles.summary}>
+ <details {...stylex.props(styles.root)}>
+ <summary {...stylex.props(styles.summary)}>
<Flexbox horizontal align={'center'} gap={12}>
- <span className={styles.headerIcon}>
+ <span {...stylex.props(styles.headerIcon)}>
<MessageSquareText size={16} />
</span>
<Flexbox horizontal align={'center'} flex={1} gap={8} style={{ minWidth: 0 }}>
<Text ellipsis weight={500}>
{t('userFeedbackCard.title')}
</Text>
- <span className={styles.countBadge}>{countLabel}</span>
+ <span {...stylex.props(styles.countBadge)}>{countLabel}</span>
</Flexbox>
</Flexbox>
</summary>
- <Flexbox className={styles.body} gap={12}>
+ <Flexbox {...stylex.props(styles.body)} gap={12}>
{comments.map((comment, idx) => (
<Comment comment={comment} key={comment.id ?? idx} />
))}
diff --git a/src/features/Conversation/MessageForward/ForwardModal.tsx b/src/features/Conversation/MessageForward/ForwardModal.tsx
index ae96a8a51d3..54e8060a033 100644
--- a/src/features/Conversation/MessageForward/ForwardModal.tsx
+++ b/src/features/Conversation/MessageForward/ForwardModal.tsx
@@ -4,15 +4,14 @@ import { type StoreApiWithSelector } from '@lobechat/types';
import {
Button,
createModal,
- createStaticStyles,
- cssVar,
- cx,
Flexbox,
SearchBar,
Text,
TextArea,
useModalContext,
} from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import isEqual from 'fast-deep-equal';
import { t as translate } from 'i18next';
import { memo, useState } from 'react';
@@ -35,73 +34,52 @@ import SelectCircle from './SelectCircle';
import { useForwardMessages } from './useForwardMessages';
import { useForwardTargets } from './useForwardTargets';
-const styles = createStaticStyles(({ css }) => ({
- body: css`
- block-size: 460px;
- `,
- divider: css`
- align-self: stretch;
- inline-size: 1px;
- background: ${cssVar.colorBorderSecondary};
- `,
- list: css`
- overflow-y: auto;
- flex: 1;
- margin-inline: -4px;
- padding-inline: 4px;
- `,
- // Shared container holding the message preview and the note input, split by a
- // divider above the input.
- preview: css`
- overflow: hidden;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: ${cssVar.borderRadiusLG};
- background: ${cssVar.colorFillQuaternary};
- `,
- previewLines: css`
- overflow-y: auto;
- flex: 1;
- padding-block: 12px;
- padding-inline: 12px;
- `,
- note: css`
- background: transparent;
- `,
- noteDivider: css`
- block-size: 1px;
- background: ${cssVar.colorBorderSecondary};
- `,
- previewLine: css`
- overflow: hidden;
-
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- previewMore: css`
- padding-block-start: 2px;
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
- `,
- row: css`
- cursor: pointer;
-
- min-block-size: 44px;
- padding-block: 6px;
- padding-inline: 8px;
- border-radius: ${cssVar.borderRadiusLG};
-
- transition: background-color 0.1s ${cssVar.motionEaseInOut};
-
- &:hover {
- background-color: ${cssVar.colorFillTertiary};
- }
- `,
- rowSelected: css`
- background-color: ${cssVar.colorFillQuaternary};
- `,
-}));
+const styles = stylex.create({
+ body: { blockSize: '460px' },
+ divider: {
+ alignSelf: 'stretch',
+ inlineSize: '1px',
+ backgroundColor: cssVar.colorBorderSecondary,
+ backgroundImage: 'none',
+ },
+ list: { overflowY: 'auto', flex: '1', marginInline: '-4px', paddingInline: '4px' },
+ preview: {
+ overflow: 'hidden',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: cssVar.borderRadiusLG,
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+ previewLines: { overflowY: 'auto', flex: '1', paddingBlock: '12px', paddingInline: '12px' },
+ note: { backgroundColor: 'transparent', backgroundImage: 'none' },
+ noteDivider: {
+ blockSize: '1px',
+ backgroundColor: cssVar.colorBorderSecondary,
+ backgroundImage: 'none',
+ },
+ previewLine: {
+ overflow: 'hidden',
+ fontSize: '12px',
+ color: cssVar.colorTextSecondary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ previewMore: { paddingBlockStart: '2px', fontSize: '12px', color: cssVar.colorTextTertiary },
+ row: {
+ cursor: 'pointer',
+ minBlockSize: '44px',
+ paddingBlock: '6px',
+ paddingInline: '8px',
+ borderRadius: cssVar.borderRadiusLG,
+ transition: `background-color 0.1s ${cssVar.motionEaseInOut}`,
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
+ },
+ rowSelected: {
+ backgroundColor: { 'default': cssVar.colorFillQuaternary, ':hover': cssVar.colorFillTertiary },
+ },
+});
const ForwardModalContent = memo(() => {
const { t } = useTranslation('chat');
@@ -138,7 +116,7 @@ const ForwardModalContent = memo(() => {
const avatarOf = (avatar: unknown) => (typeof avatar === 'string' ? avatar : undefined);
return (
- <Flexbox horizontal className={styles.body} gap={16}>
+ <Flexbox horizontal className={stylex.props(styles.body).className} gap={16}>
{/* Left: searchable multi-select agent list */}
<Flexbox flex={1} gap={8} style={{ minWidth: 0 }}>
<SearchBar
@@ -147,7 +125,7 @@ const ForwardModalContent = memo(() => {
value={keyword}
onChange={(e) => setKeyword(e.target.value)}
/>
- <Flexbox className={styles.list} gap={4}>
+ <Flexbox className={stylex.props(styles.list).className} gap={4}>
{candidates.length === 0 ? (
<Flexbox align={'center'} justify={'center'} padding={24}>
<Text type={'secondary'}>{t('messageForward.modal.empty')}</Text>
@@ -159,7 +137,7 @@ const ForwardModalContent = memo(() => {
<Flexbox
horizontal
align={'center'}
- className={cx(styles.row, checked && styles.rowSelected)}
+ className={stylex.props(styles.row, checked && styles.rowSelected).className}
gap={8}
key={agent.id}
onClick={() => toggle(agent.id)}
@@ -182,17 +160,17 @@ const ForwardModalContent = memo(() => {
</Flexbox>
</Flexbox>
- <div className={styles.divider} />
+ <div {...stylex.props(styles.divider)} />
{/* Right: forwarded content preview + note */}
<Flexbox flex={1} gap={8} style={{ minWidth: 0 }}>
<Text style={{ fontSize: 12 }} type={'secondary'}>
{t('messageForward.transcript.header', { count: preview.count })}
</Text>
- <Flexbox className={styles.preview} flex={1}>
- <Flexbox className={styles.previewLines} flex={1} gap={4}>
+ <Flexbox className={stylex.props(styles.preview).className} flex={1}>
+ <Flexbox className={stylex.props(styles.previewLines).className} flex={1} gap={4}>
{preview.lines.map((line, i) => (
- <div className={styles.previewLine} key={i}>
+ <div {...stylex.props(styles.previewLine)} key={i}>
<Text strong style={{ fontSize: 12 }}>
{line.role}:
</Text>{' '}
@@ -200,17 +178,17 @@ const ForwardModalContent = memo(() => {
</div>
))}
{preview.count > preview.lines.length && (
- <div className={styles.previewMore}>
+ <div {...stylex.props(styles.previewMore)}>
{t('messageForward.modal.moreMessages', {
count: preview.count - preview.lines.length,
})}
</div>
)}
</Flexbox>
- <div className={styles.noteDivider} />
+ <div {...stylex.props(styles.noteDivider)} />
<TextArea
autoSize={{ maxRows: 4, minRows: 2 }}
- className={styles.note}
+ className={stylex.props(styles.note).className}
placeholder={t('messageForward.modal.notePlaceholder')}
resize={false}
value={note}
diff --git a/src/features/Conversation/MessageForward/MessageSelectionWrapper.tsx b/src/features/Conversation/MessageForward/MessageSelectionWrapper.tsx
index 0b13e78eb66..3ee8ff6a2de 100644
--- a/src/features/Conversation/MessageForward/MessageSelectionWrapper.tsx
+++ b/src/features/Conversation/MessageForward/MessageSelectionWrapper.tsx
@@ -1,6 +1,8 @@
'use client';
-import { createStaticStyles, cssVar, cx, Flexbox } from '@lobehub/ui';
+import { Flexbox } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { memo, type MouseEvent, type ReactNode, useCallback } from 'react';
import { CONVERSATION_MIN_WIDTH } from '@/const/layoutTokens';
@@ -8,85 +10,45 @@ import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
import { messageStateSelectors, useConversationStore } from '../store';
+import { messageSelectionMarker } from './markers.stylex';
import { isSelectableRole } from './selectableRoles';
import SelectCircle from './SelectCircle';
-const styles = createStaticStyles(({ css }) => ({
+const styles = stylex.create({
// Full-bleed clickable band, WeChat-style. Stretches to the full stream width
// regardless of the reading-column preference; the lane inside keeps the
// content at its normal width. Kept light: selection uses the weakest fill
// (the filled circle is the real indicator); hover is one notch up.
- band: css`
- cursor: pointer;
- user-select: none;
- inline-size: 100%;
- transition: background-color 0.1s ${cssVar.motionEaseInOut};
-
- &:hover {
- background-color: ${cssVar.colorFillTertiary};
- }
- `,
- bandSelected: css`
- background-color: ${cssVar.colorFillQuaternary};
-
- &:hover {
- background-color: ${cssVar.colorFillQuaternary};
- }
- `,
+ band: {
+ cursor: 'pointer',
+ userSelect: 'none',
+ inlineSize: '100%',
+ transition: `background-color 0.1s ${cssVar.motionEaseInOut}`,
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
+ },
+ // Composed after `band`: a conditional value replaces the whole property.
+ bandSelected: { backgroundColor: cssVar.colorFillQuaternary },
// Pinned to the band's leading edge; vertical centering is handled by the
// band's cross-axis alignment.
- checkbox: css`
- flex: none;
- padding-inline-start: 16px;
- `,
- content: css`
- /* Content is non-interactive while selecting β€” the whole row is the toggle. */
- pointer-events: none;
- flex: 1;
- min-width: 0;
-
- /* The hover action bar is suppressed in selection mode, so collapse its 28px
- placeholder too β€” otherwise every selected row carries a big empty
- highlighted strip beneath the bubble. */
- [data-user-action-bar-portal],
- [data-assitant-action-bar-portal],
- [data-assistant-group-action-bar-portal] {
- display: none;
- }
-
- /* The avatar + name + time header is redundant while scanning to select β€”
- drop it so every turn reads as one clean line. */
- .message-header {
- display: none;
- }
- `,
- // Assistant turns flow from the leading edge of the lane. User turns keep their
- // native right alignment + indent so they still read as "sent by the user".
- contentAssistant: css`
- .message-wrapper {
- align-items: flex-start !important;
- padding-inline-start: 0 !important;
- }
- `,
+ checkbox: { flex: 'none', paddingInlineStart: '16px' },
+ content: {
+ // Content is non-interactive while selecting β€” the whole row is the toggle.
+ pointerEvents: 'none',
+ flex: '1',
+ minWidth: 0,
+ },
// Assistant turns (esp. tool-call workflows) are long; fold them to a preview
// height while selecting so the list stays scannable. Fades out at the bottom.
- contentCollapsed: css`
- overflow: hidden;
- max-height: 84px;
-
- mask-image: linear-gradient(to bottom, #000 56%, transparent 100%);
- `,
- disabledBand: css`
- cursor: not-allowed;
- inline-size: 100%;
- opacity: 0.4;
- `,
+ contentCollapsed: {
+ overflow: 'hidden',
+ maxHeight: '84px',
+ maskImage: 'linear-gradient(to bottom, #000 56%, transparent 100%)',
+ },
+ disabledBand: { cursor: 'not-allowed', inlineSize: '100%', opacity: 0.4 },
// Centered reading column inside the full-bleed band β€” the width preference the
// rest of the conversation follows.
- lane: css`
- padding-inline: 16px;
- `,
-}));
+ lane: { paddingInline: '16px' },
+});
interface MessageSelectionWrapperProps {
children: ReactNode;
@@ -128,14 +90,16 @@ const MessageSelectionWrapper = memo<MessageSelectionWrapperProps>(({ children,
const inner = (
<>
- <div className={styles.checkbox}>{selectable && <SelectCircle checked={isSelected} />}</div>
+ <div {...stylex.props(styles.checkbox)}>
+ {selectable && <SelectCircle checked={isSelected} />}
+ </div>
<Flexbox align={'center'} flex={1} style={{ minWidth: 0 }}>
- <Flexbox className={styles.lane} width={laneWidth}>
+ <Flexbox {...stylex.props(styles.lane)} width={laneWidth}>
<div
- className={cx(
+ {...stylex.props(
styles.content,
- isAssistant && styles.contentAssistant,
isAssistant && styles.contentCollapsed,
+ messageSelectionMarker,
)}
>
{children}
@@ -147,7 +111,7 @@ const MessageSelectionWrapper = memo<MessageSelectionWrapperProps>(({ children,
if (!selectable) {
return (
- <Flexbox horizontal align={'center'} className={styles.disabledBand}>
+ <Flexbox horizontal align={'center'} {...stylex.props(styles.disabledBand)}>
{inner}
</Flexbox>
);
@@ -157,7 +121,7 @@ const MessageSelectionWrapper = memo<MessageSelectionWrapperProps>(({ children,
<Flexbox
horizontal
align={'center'}
- className={cx(styles.band, isSelected && styles.bandSelected)}
+ {...stylex.props(styles.band, isSelected && styles.bandSelected)}
onClick={handleToggle}
>
{inner}
diff --git a/src/features/Conversation/MessageForward/SelectCircle.tsx b/src/features/Conversation/MessageForward/SelectCircle.tsx
index 8463fb8dacb..0f83053fa1b 100644
--- a/src/features/Conversation/MessageForward/SelectCircle.tsx
+++ b/src/features/Conversation/MessageForward/SelectCircle.tsx
@@ -1,28 +1,31 @@
'use client';
-import { Center, createStaticStyles, cssVar, cx, Icon } from '@lobehub/ui';
+import { Center, Icon } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { Check } from 'lucide-react';
import { memo } from 'react';
-const styles = createStaticStyles(({ css }) => ({
- checked: css`
- border-color: ${cssVar.colorPrimary};
- color: ${cssVar.colorBgContainer};
- background: ${cssVar.colorPrimary};
- `,
- circle: css`
- flex: none;
-
- inline-size: 20px;
- block-size: 20px;
- border: 1.5px solid ${cssVar.colorBorder};
- border-radius: 50%;
-
- transition:
- background-color 0.15s ${cssVar.motionEaseInOut},
- border-color 0.15s ${cssVar.motionEaseInOut};
- `,
-}));
+import { sx } from '@/styles/sx';
+
+const styles = stylex.create({
+ checked: {
+ borderColor: cssVar.colorPrimary,
+ color: cssVar.colorBgContainer,
+ backgroundColor: cssVar.colorPrimary,
+ backgroundImage: 'none',
+ },
+ circle: {
+ flex: 'none',
+ inlineSize: '20px',
+ blockSize: '20px',
+ borderWidth: '1.5px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorder,
+ borderRadius: '50%',
+ transition: `background-color 0.15s ${cssVar.motionEaseInOut}, border-color 0.15s ${cssVar.motionEaseInOut}`,
+ },
+});
interface SelectCircleProps {
checked?: boolean;
@@ -35,7 +38,7 @@ interface SelectCircleProps {
* multi-select rows.
*/
const SelectCircle = memo<SelectCircleProps>(({ checked, className }) => (
- <Center className={cx(styles.circle, checked && styles.checked, className)}>
+ <Center {...sx(styles.circle, checked && styles.checked, className)}>
{checked && <Icon icon={Check} size={14} />}
</Center>
));
diff --git a/src/features/Conversation/MessageForward/SelectToHereButton.tsx b/src/features/Conversation/MessageForward/SelectToHereButton.tsx
index 236df3a4ec1..a70871f0a4f 100644
--- a/src/features/Conversation/MessageForward/SelectToHereButton.tsx
+++ b/src/features/Conversation/MessageForward/SelectToHereButton.tsx
@@ -1,36 +1,37 @@
'use client';
-import { Button, createStaticStyles, cssVar, Flexbox, Icon } from '@lobehub/ui';
+import { Button, Flexbox, Icon } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { ArrowDownToLine } from 'lucide-react';
import { memo, useCallback, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { messageStateSelectors, useConversationStore } from '../store';
-const styles = createStaticStyles(({ css }) => ({
- button: css`
- pointer-events: auto;
- background: ${cssVar.colorBgElevated};
- box-shadow: ${cssVar.boxShadowSecondary};
- `,
- line: css`
- flex: 1;
- block-size: 0;
- border-block-start: 1px dashed ${cssVar.colorBorder};
- `,
- // The "here" marker: a dashed rule across the chat area at ~25% from the
- // bottom edge, with the trigger centered on it. Purely a visual guide except
- // for the button, so it never blocks scrolling or message clicks.
- wrap: css`
- pointer-events: none;
-
- position: absolute;
- z-index: 20;
- inset-block-start: 75%;
- inset-inline: 0;
- transform: translateY(-50%);
- `,
-}));
+const styles = stylex.create({
+ button: {
+ pointerEvents: 'auto',
+ backgroundColor: cssVar.colorBgElevated,
+ backgroundImage: 'none',
+ boxShadow: cssVar.boxShadowSecondary,
+ },
+ line: {
+ flex: '1',
+ blockSize: '0',
+ borderBlockStartWidth: '1px',
+ borderBlockStartStyle: 'dashed',
+ borderBlockStartColor: cssVar.colorBorder,
+ },
+ wrap: {
+ pointerEvents: 'none',
+ position: 'absolute',
+ zIndex: 20,
+ insetBlockStart: '75%',
+ insetInline: '0',
+ transform: 'translateY(-50%)',
+ },
+});
/**
* "Select to here" marker shown while multi-selecting: a dashed line across the
@@ -68,14 +69,14 @@ const SelectToHereButton = memo(() => {
<Flexbox
horizontal
align={'center'}
- className={styles.wrap}
+ className={stylex.props(styles.wrap).className}
gap={12}
paddingInline={16}
ref={wrapRef}
>
- <div className={styles.line} />
+ <div {...stylex.props(styles.line)} />
<Button
- className={styles.button}
+ className={stylex.props(styles.button).className}
icon={<Icon icon={ArrowDownToLine} />}
shape={'round'}
size={'small'}
@@ -83,7 +84,7 @@ const SelectToHereButton = memo(() => {
>
{t('messageForward.bar.selectToHere')}
</Button>
- <div className={styles.line} />
+ <div {...stylex.props(styles.line)} />
</Flexbox>
);
});
diff --git a/src/features/Conversation/MessageForward/SelectionFooterBar.tsx b/src/features/Conversation/MessageForward/SelectionFooterBar.tsx
index ab455adf1f8..b60d3f07250 100644
--- a/src/features/Conversation/MessageForward/SelectionFooterBar.tsx
+++ b/src/features/Conversation/MessageForward/SelectionFooterBar.tsx
@@ -1,15 +1,8 @@
'use client';
-import {
- Button,
- confirmModal,
- createStaticStyles,
- cssVar,
- Flexbox,
- Icon,
- Text,
- toast,
-} from '@lobehub/ui';
+import { Button, confirmModal, Flexbox, Icon, Text, toast } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { Forward, Trash2, X } from 'lucide-react';
import { memo, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -17,28 +10,25 @@ import { useTranslation } from 'react-i18next';
import { messageStateSelectors, useConversationStore, useConversationStoreApi } from '../store';
import { openForwardModal } from './ForwardModal';
-const styles = createStaticStyles(({ css }) => ({
- // Full-width bar docked at the bottom in place of the composer (hidden by
- // MessageForwardFooter while selecting). Count on the leading edge, actions on
- // the trailing edge.
- bar: css`
- position: relative;
-
- inline-size: 100%;
- padding-block: 12px;
- padding-inline: 16px;
- border-block-start: 1px solid ${cssVar.colorBorderSecondary};
-
- background: ${cssVar.colorBgContainer};
- `,
- // Pinned to the side so the actions stay centered regardless of the count.
- count: css`
- position: absolute;
- inset-block-start: 50%;
- inset-inline-start: 16px;
- transform: translateY(-50%);
- `,
-}));
+const styles = stylex.create({
+ bar: {
+ position: 'relative',
+ inlineSize: '100%',
+ paddingBlock: '12px',
+ paddingInline: '16px',
+ borderBlockStartWidth: '1px',
+ borderBlockStartStyle: 'solid',
+ borderBlockStartColor: cssVar.colorBorderSecondary,
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+ count: {
+ position: 'absolute',
+ insetBlockStart: '50%',
+ insetInlineStart: '16px',
+ transform: 'translateY(-50%)',
+ },
+});
/**
* Bottom action bar shown while multi-selecting: selection count on the leading
@@ -94,8 +84,13 @@ const SelectionFooterBar = memo(() => {
};
return (
- <Flexbox horizontal align={'center'} className={styles.bar} justify={'center'}>
- <Text className={styles.count} type={'secondary'}>
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={stylex.props(styles.bar).className}
+ justify={'center'}
+ >
+ <Text className={stylex.props(styles.count).className} type={'secondary'}>
{t('messageForward.bar.selected', { count: selectedCount })}
</Text>
<Flexbox horizontal align={'center'} gap={4}>
diff --git a/src/features/Conversation/MessageForward/TopicForwardModal/Content.tsx b/src/features/Conversation/MessageForward/TopicForwardModal/Content.tsx
index 3020a2aabe3..7cd3ffa2207 100644
--- a/src/features/Conversation/MessageForward/TopicForwardModal/Content.tsx
+++ b/src/features/Conversation/MessageForward/TopicForwardModal/Content.tsx
@@ -1,16 +1,8 @@
'use client';
-import {
- Button,
- createStaticStyles,
- cssVar,
- cx,
- Flexbox,
- SearchBar,
- Text,
- TextArea,
- useModalContext,
-} from '@lobehub/ui';
+import { Button, Flexbox, SearchBar, Text, TextArea, useModalContext } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -23,44 +15,39 @@ import SelectCircle from '../SelectCircle';
import { useForwardTargets } from '../useForwardTargets';
import { useForwardTopic } from '../useForwardTopic';
-const styles = createStaticStyles(({ css }) => ({
- body: css`
- block-size: 460px;
- `,
- context: css`
- flex: 1;
-
- padding: 12px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: ${cssVar.borderRadiusLG};
-
- background: ${cssVar.colorFillQuaternary};
- `,
- divider: css`
- align-self: stretch;
- inline-size: 1px;
- background: ${cssVar.colorBorderSecondary};
- `,
- list: css`
- overflow-y: auto;
- flex: 1;
- `,
- row: css`
- cursor: pointer;
-
- min-block-size: 44px;
- padding-block: 6px;
- padding-inline: 8px;
- border-radius: ${cssVar.borderRadiusLG};
-
- &:hover {
- background: ${cssVar.colorFillTertiary};
- }
- `,
- selected: css`
- background: ${cssVar.colorFillQuaternary};
- `,
-}));
+const styles = stylex.create({
+ body: { blockSize: '460px' },
+ context: {
+ flex: '1',
+ padding: '12px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: cssVar.borderRadiusLG,
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+ divider: {
+ alignSelf: 'stretch',
+ inlineSize: '1px',
+ backgroundColor: cssVar.colorBorderSecondary,
+ backgroundImage: 'none',
+ },
+ list: { overflowY: 'auto', flex: '1' },
+ row: {
+ cursor: 'pointer',
+ minBlockSize: '44px',
+ paddingBlock: '6px',
+ paddingInline: '8px',
+ borderRadius: cssVar.borderRadiusLG,
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ },
+ selected: {
+ backgroundColor: { 'default': cssVar.colorFillQuaternary, ':hover': cssVar.colorFillTertiary },
+ backgroundImage: 'none',
+ },
+});
export interface TopicForwardContentProps {
cancelSourceContinuation?: boolean;
@@ -99,7 +86,7 @@ export const TopicForwardContent = ({
};
return (
- <Flexbox horizontal className={styles.body} gap={16}>
+ <Flexbox horizontal className={stylex.props(styles.body).className} gap={16}>
<Flexbox flex={1} gap={8} style={{ minWidth: 0 }}>
<SearchBar
allowClear
@@ -107,7 +94,7 @@ export const TopicForwardContent = ({
value={keyword}
onChange={(event) => setKeyword(event.target.value)}
/>
- <Flexbox className={styles.list} gap={4}>
+ <Flexbox className={stylex.props(styles.list).className} gap={4}>
{candidates.length === 0 ? (
<Flexbox align={'center'} justify={'center'} padding={24}>
<Text type={'secondary'}>{t('messageForward.modal.empty')}</Text>
@@ -119,7 +106,7 @@ export const TopicForwardContent = ({
<Flexbox
horizontal
align={'center'}
- className={cx(styles.row, selected && styles.selected)}
+ className={stylex.props(styles.row, selected && styles.selected).className}
gap={8}
key={agent.id}
onClick={() => toggle(agent.id)}
@@ -142,11 +129,11 @@ export const TopicForwardContent = ({
</Flexbox>
</Flexbox>
- <div className={styles.divider} />
+ <div {...stylex.props(styles.divider)} />
<Flexbox flex={1} gap={12} style={{ minWidth: 0 }}>
<Text type={'secondary'}>{t('messageForward.topic.context')}</Text>
- <Flexbox className={styles.context} gap={8}>
+ <Flexbox className={stylex.props(styles.context).className} gap={8}>
<Text ellipsis strong>
{topicTitle}
</Text>
diff --git a/src/features/Conversation/MessageForward/markers.stylex.ts b/src/features/Conversation/MessageForward/markers.stylex.ts
new file mode 100644
index 00000000000..58e065151c0
--- /dev/null
+++ b/src/features/Conversation/MessageForward/markers.stylex.ts
@@ -0,0 +1,3 @@
+import * as stylex from '@stylexjs/stylex';
+
+export const messageSelectionMarker = stylex.defineMarker();
diff --git a/src/features/Conversation/MessageForward/selectionStyles.ts b/src/features/Conversation/MessageForward/selectionStyles.ts
new file mode 100644
index 00000000000..a6b01da57b6
--- /dev/null
+++ b/src/features/Conversation/MessageForward/selectionStyles.ts
@@ -0,0 +1,9 @@
+import * as stylex from '@stylexjs/stylex';
+
+import { messageSelectionMarker } from './markers.stylex';
+
+export const selectionStyles = stylex.create({
+ hidden: {
+ display: { default: null, [stylex.when.ancestor(':is(*)', messageSelectionMarker)]: 'none' },
+ },
+});
diff --git a/src/features/Conversation/Messages/AgentCouncil/components/CouncilMember.tsx b/src/features/Conversation/Messages/AgentCouncil/components/CouncilMember.tsx
index b792b644194..f0ecd302ad2 100644
--- a/src/features/Conversation/Messages/AgentCouncil/components/CouncilMember.tsx
+++ b/src/features/Conversation/Messages/AgentCouncil/components/CouncilMember.tsx
@@ -8,8 +8,10 @@ import { LOADING_FLAT } from '@/const/message';
import { MESSAGE_ACTION_BAR_PORTAL_ATTRIBUTES } from '@/const/messageActionPortal';
import { ChatItem } from '@/features/Conversation/ChatItem';
import ErrorMessageExtra, { useErrorContent } from '@/features/Conversation/Error';
+import { selectionStyles } from '@/features/Conversation/MessageForward/selectionStyles';
import { AssistantMessageExtra } from '@/features/Conversation/Messages/Assistant/Extra';
import { normalizeThinkTags, processWithArtifact } from '@/features/Conversation/utils/markdown';
+import { sx } from '@/styles/sx';
import { type UIChatMessage } from '@/types/index';
import { useAgentMeta } from '../../../hooks';
@@ -22,7 +24,10 @@ import {
import AutoScrollShadow from './AutoScrollShadow';
const actionBarHolder = (
- <div {...{ [MESSAGE_ACTION_BAR_PORTAL_ATTRIBUTES.assistant]: '' }} style={{ height: '28px' }} />
+ <div
+ {...{ [MESSAGE_ACTION_BAR_PORTAL_ATTRIBUTES.assistant]: '' }}
+ {...sx(selectionStyles.hidden, { height: '28px' })}
+ />
);
interface CouncilMemberProps {
diff --git a/src/features/Conversation/Messages/Assistant/index.tsx b/src/features/Conversation/Messages/Assistant/index.tsx
index 80c2fa11d30..6bde2d09cfb 100644
--- a/src/features/Conversation/Messages/Assistant/index.tsx
+++ b/src/features/Conversation/Messages/Assistant/index.tsx
@@ -9,10 +9,12 @@ import { memo, useCallback, useMemo } from 'react';
import AssistantMessageNotice from '@/business/client/components/AssistantMessageNotice';
import { MESSAGE_ACTION_BAR_PORTAL_ATTRIBUTES } from '@/const/messageActionPortal';
import { ChatItem } from '@/features/Conversation/ChatItem';
+import { selectionStyles } from '@/features/Conversation/MessageForward/selectionStyles';
import { useMessageCommentCount } from '@/features/TopicComment/hooks';
import MessageCommentBadge from '@/features/TopicComment/MessageCommentBadge';
import { useUserStore } from '@/store/user';
import { userGeneralSettingsSelectors, userProfileSelectors } from '@/store/user/selectors';
+import { sx } from '@/styles/sx';
import { ReactionDisplay } from '../../components/Reaction';
import ErrorMessageExtra, { useErrorContent } from '../../Error';
@@ -33,7 +35,10 @@ import ThreadExecutionSummary from './components/ThreadExecutionSummary';
import { AssistantMessageExtra } from './Extra';
const actionBarHolder = (
- <div {...{ [MESSAGE_ACTION_BAR_PORTAL_ATTRIBUTES.assistant]: '' }} style={{ height: '28px' }} />
+ <div
+ {...{ [MESSAGE_ACTION_BAR_PORTAL_ATTRIBUTES.assistant]: '' }}
+ {...sx(selectionStyles.hidden, { height: '28px' })}
+ />
);
interface AssistantMessageProps {
diff --git a/src/features/Conversation/Messages/AssistantGroup/index.tsx b/src/features/Conversation/Messages/AssistantGroup/index.tsx
index 7193634a6e2..2bb40fb88fd 100644
--- a/src/features/Conversation/Messages/AssistantGroup/index.tsx
+++ b/src/features/Conversation/Messages/AssistantGroup/index.tsx
@@ -11,6 +11,7 @@ import { useTranslation } from 'react-i18next';
import { MESSAGE_ACTION_BAR_PORTAL_ATTRIBUTES } from '@/const/messageActionPortal';
import AgentGroupAvatar from '@/features/AgentGroupAvatar';
import { ChatItem } from '@/features/Conversation/ChatItem';
+import { selectionStyles } from '@/features/Conversation/MessageForward/selectionStyles';
import { useMessageCommentCount } from '@/features/TopicComment/hooks';
import MessageCommentBadge from '@/features/TopicComment/MessageCommentBadge';
import { useOpenChatSettings } from '@/hooks/useInterceptingRoutes';
@@ -22,6 +23,7 @@ import { agentGroupSelectors } from '@/store/agentGroup/selectors';
import { useGlobalStore } from '@/store/global';
import { useUserStore } from '@/store/user';
import { userGeneralSettingsSelectors, userProfileSelectors } from '@/store/user/selectors';
+import { sx } from '@/styles/sx';
import { ReactionDisplay } from '../../components/Reaction';
import { useAgentMeta } from '../../hooks';
@@ -59,7 +61,7 @@ const EditState = dynamic(() => import('./components/EditState'), {
const actionBarHolder = (
<div
{...{ [MESSAGE_ACTION_BAR_PORTAL_ATTRIBUTES.assistantGroup]: '' }}
- style={{ height: '28px' }}
+ {...sx(selectionStyles.hidden, { height: '28px' })}
/>
);
diff --git a/src/features/Conversation/Messages/User/Actions/index.tsx b/src/features/Conversation/Messages/User/Actions/index.tsx
index 881cfa149dc..0640bb4af2d 100644
--- a/src/features/Conversation/Messages/User/Actions/index.tsx
+++ b/src/features/Conversation/Messages/User/Actions/index.tsx
@@ -1,11 +1,15 @@
import { type UIChatMessage } from '@lobechat/types';
import { Flexbox } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
import { memo, useMemo } from 'react';
import { MESSAGE_ACTION_BAR_PORTAL_ATTRIBUTES } from '@/const/messageActionPortal';
+import { selectionStyles } from '@/features/Conversation/MessageForward/selectionStyles';
import { useUserStore } from '@/store/user';
import { userGeneralSettingsSelectors } from '@/store/user/selectors';
+import { sx } from '@/styles/sx';
+import { revealStyles } from '../../../ChatItem/revealStyles';
import { type MessageActionsConfig } from '../../../types';
import {
MessageActionBar,
@@ -59,7 +63,10 @@ interface ActionsProps {
}
const actionBarHolder = (
- <div {...{ [MESSAGE_ACTION_BAR_PORTAL_ATTRIBUTES.user]: '' }} style={{ height: '28px' }} />
+ <div
+ {...{ [MESSAGE_ACTION_BAR_PORTAL_ATTRIBUTES.user]: '' }}
+ {...sx(selectionStyles.hidden, { height: '28px' })}
+ />
);
const Actions = memo<ActionsProps>(({ id, data, disableEditing }) => {
@@ -71,7 +78,7 @@ const Actions = memo<ActionsProps>(({ id, data, disableEditing }) => {
return (
<Flexbox horizontal align={'center'}>
{!disableEditing && (
- <Flexbox align={'flex-start'} role="menubar">
+ <Flexbox align={'flex-start'} role="menubar" {...stylex.props(revealStyles.menubar)}>
{actionBarHolder}
</Flexbox>
)}
diff --git a/src/features/Conversation/SplitDropZone/index.tsx b/src/features/Conversation/SplitDropZone/index.tsx
index 30d52b5ecce..b7d29c82c52 100644
--- a/src/features/Conversation/SplitDropZone/index.tsx
+++ b/src/features/Conversation/SplitDropZone/index.tsx
@@ -1,36 +1,32 @@
'use client';
-import { createStaticStyles, cssVar, Flexbox, Icon, Text } from '@lobehub/ui';
+import { Flexbox, Icon, Text } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { PanelRight } from 'lucide-react';
import { memo, type ReactNode } from 'react';
import { useTranslation } from 'react-i18next';
import { useConversationPanelDrop } from './useConversationPanelDrop';
-const styles = createStaticStyles(({ css }) => ({
- overlay: css`
- pointer-events: none;
-
- position: absolute;
- z-index: 20;
-
- /* The chat input below overlaps this zone's last 12px, so the bottom
- inset clears it to keep the highlight off the input. */
- inset-block: 8px 16px;
- inset-inline: 8px;
-
- border: 2px dashed ${cssVar.colorInfoBorder};
- border-radius: ${cssVar.borderRadiusLG};
-
- opacity: 0.9;
- background: ${cssVar.colorInfoBg};
- `,
- root: css`
- position: relative;
- flex: 1;
- min-height: 0;
- `,
-}));
+const styles = stylex.create({
+ overlay: {
+ pointerEvents: 'none',
+ position: 'absolute',
+ zIndex: 20,
+ insetBlockStart: '8px',
+ insetBlockEnd: '16px',
+ insetInline: '8px',
+ borderWidth: '2px',
+ borderStyle: 'dashed',
+ borderColor: cssVar.colorInfoBorder,
+ borderRadius: cssVar.borderRadiusLG,
+ opacity: 0.9,
+ backgroundColor: cssVar.colorInfoBg,
+ backgroundImage: 'none',
+ },
+ root: { position: 'relative', flex: '1', minHeight: '0' },
+});
/**
* Wraps the main conversation body so a topic/thread dragged from the sidebar
@@ -44,7 +40,7 @@ const SplitDropZone = memo<{ children: ReactNode }>(({ children }) => {
return (
<Flexbox
- className={styles.root}
+ className={stylex.props(styles.root).className}
onDragEnter={onDragEnter}
onDragLeave={onDragLeave}
onDragOver={onDragOver}
@@ -53,7 +49,11 @@ const SplitDropZone = memo<{ children: ReactNode }>(({ children }) => {
>
{children}
{dragKind && (
- <Flexbox align={'center'} className={styles.overlay} justify={'center'}>
+ <Flexbox
+ align={'center'}
+ className={stylex.props(styles.overlay).className}
+ justify={'center'}
+ >
<Flexbox align={'center'} gap={8} style={{ color: cssVar.colorInfo }}>
<Icon icon={PanelRight} size={28} />
<Text style={{ color: 'inherit', fontSize: 14, fontWeight: 500 }}>
diff --git a/src/features/Conversation/TodoProgress/index.tsx b/src/features/Conversation/TodoProgress/index.tsx
index 31d2f87b68a..43c1c70d07e 100644
--- a/src/features/Conversation/TodoProgress/index.tsx
+++ b/src/features/Conversation/TodoProgress/index.tsx
@@ -1,13 +1,16 @@
'use client';
import { type StepContextTodos } from '@lobechat/types';
-import { Checkbox, createStaticStyles, cssVar, cx, Flexbox, Icon, Tag } from '@lobehub/ui';
+import { Checkbox, Flexbox, Icon, Tag } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { ChevronDown, ChevronUp, CircleArrowRight } from 'lucide-react';
import { memo, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { selectCurrentTurnTodosFromMessages } from '@/store/chat/slices/message/selectors/dbMessage';
import { shinyTextStyles } from '@/styles';
+import { sx } from '@/styles/sx';
import { dataSelectors, messageStateSelectors, useConversationStore } from '../store';
@@ -16,110 +19,85 @@ const RING_STROKE = 2;
const RING_RADIUS = (RING_SIZE - RING_STROKE) / 2;
const RING_CIRCUM = 2 * Math.PI * RING_RADIUS;
-const styles = createStaticStyles(({ css, cssVar }) => ({
- collapsed: css`
- max-height: 0;
- margin-block-start: 0 !important;
- padding-block: 0 !important;
- border-block-start: none !important;
-
- opacity: 0;
- `,
- container: css`
- cursor: pointer;
- user-select: none;
-
- padding-block: 8px 10px;
- padding-inline: 12px;
- border: 1px solid ${cssVar.colorFillSecondary};
- border-block-end: none;
- border-start-start-radius: 12px;
- border-start-end-radius: 12px;
-
- background: ${cssVar.colorBgElevated};
-
- transition: all 0.2s ${cssVar.motionEaseInOut};
- `,
- containerTopAttached: css`
- border-start-start-radius: 0;
- border-start-end-radius: 0;
- `,
- count: css`
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
- `,
- expanded: css`
- max-height: 300px;
- opacity: 1;
- `,
- header: css`
- overflow: hidden;
-
- font-size: 13px;
- font-weight: 500;
- color: ${cssVar.colorText};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- itemRow: css`
- padding-block: 6px;
- padding-inline: 4px;
- border-block-end: 1px dashed ${cssVar.colorBorderSecondary};
- font-size: 13px;
-
- &:last-child {
- border-block-end: none;
- }
- `,
- listContainer: css`
- overflow: hidden auto;
- overscroll-behavior-y: contain;
-
- /* The rows are Base UI Checkbox labels, which are inline-flex. In a plain
- block container they lay out as INLINE boxes β€” two or three short todos
- share a line and the list wraps like prose. A column flex container
- blockifies them, so one todo is one row again. */
- display: flex;
- flex-direction: column;
-
- margin-block-start: 8px;
- padding-block: 4px;
- border-block-start: 1px solid ${cssVar.colorBorderSecondary};
-
- transition:
- max-height 0.25s ${cssVar.motionEaseInOut},
- opacity 0.2s ${cssVar.motionEaseInOut},
- padding 0.2s ${cssVar.motionEaseInOut};
- `,
- processingRow: css`
- display: flex;
- gap: 6px;
- align-items: center;
- `,
- ring: css`
- transform: rotate(-90deg);
- flex-shrink: 0;
- `,
- ringProgress: css`
- transition:
- stroke-dashoffset 240ms ease,
- stroke 240ms ease;
- `,
- ringTrack: css`
- stroke: ${cssVar.colorFillSecondary};
- `,
- textCompleted: css`
- color: ${cssVar.colorTextQuaternary};
- text-decoration: line-through;
- `,
- textProcessing: css`
- color: ${cssVar.colorText};
- `,
- textTodo: css`
- color: ${cssVar.colorTextSecondary};
- `,
-}));
+const styles = stylex.create({
+ collapsed: {
+ maxHeight: 0,
+ marginBlockStart: 0,
+ paddingBlockStart: 0,
+ paddingBlockEnd: 0,
+ borderBlockStartWidth: 0,
+ borderBlockStartStyle: 'none',
+ borderBlockStartColor: 'currentcolor',
+ opacity: 0,
+ },
+ container: {
+ cursor: 'pointer',
+ userSelect: 'none',
+ paddingBlockStart: '8px',
+ paddingBlockEnd: '10px',
+ paddingInline: '12px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorFillSecondary,
+ borderBlockEndWidth: 0,
+ borderBlockEndStyle: 'none',
+ borderBlockEndColor: 'currentcolor',
+ borderStartStartRadius: '12px',
+ borderStartEndRadius: '12px',
+ backgroundColor: cssVar.colorBgElevated,
+ backgroundImage: 'none',
+ transition: `all 0.2s ${cssVar.motionEaseInOut}`,
+ },
+ containerTopAttached: { borderStartStartRadius: 0, borderStartEndRadius: 0 },
+ count: {
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '12px',
+ color: cssVar.colorTextSecondary,
+ },
+ expanded: { maxHeight: '300px', opacity: 1 },
+ header: {
+ overflow: 'hidden',
+ fontSize: '13px',
+ fontWeight: 500,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ // Left off while the shiny text effect runs: it paints the text through a
+ // clipped gradient and owns `color`.
+ headerColor: { color: cssVar.colorText },
+ itemRow: {
+ paddingBlock: '6px',
+ paddingInline: '4px',
+ borderBlockEndWidth: '1px',
+ borderBlockEndStyle: { 'default': 'dashed', ':last-child': 'none' },
+ borderBlockEndColor: cssVar.colorBorderSecondary,
+ fontSize: '13px',
+ },
+ listContainer: {
+ overflowX: 'hidden',
+ overflowY: 'auto',
+ overscrollBehaviorY: 'contain',
+ // The rows are Base UI Checkbox labels, which are inline-flex. In a plain
+ // block container they lay out as INLINE boxes β€” two or three short todos
+ // share a line and the list wraps like prose. A column flex container
+ // blockifies them, so one todo is one row again.
+ display: 'flex',
+ flexDirection: 'column',
+ marginBlockStart: '8px',
+ paddingBlock: '4px',
+ borderBlockStartWidth: '1px',
+ borderBlockStartStyle: 'solid',
+ borderBlockStartColor: cssVar.colorBorderSecondary,
+ transition: `max-height 0.25s ${cssVar.motionEaseInOut}, opacity 0.2s ${cssVar.motionEaseInOut}, padding 0.2s ${cssVar.motionEaseInOut}`,
+ },
+ processingRow: { display: 'flex', gap: '6px', alignItems: 'center' },
+ ring: { transform: 'rotate(-90deg)', flexShrink: 0 },
+ ringProgress: { transition: 'stroke-dashoffset 240ms ease, stroke 240ms ease' },
+ ringTrack: { stroke: cssVar.colorFillSecondary },
+ textCompleted: { color: cssVar.colorTextQuaternary, textDecoration: 'line-through' },
+ textProcessing: { color: cssVar.colorText },
+ textTodo: { color: cssVar.colorTextSecondary },
+});
interface TodoProgressProps {
className?: string;
@@ -168,15 +146,15 @@ const TodoProgress = memo<TodoProgressProps>(({ className, topAttached }) => {
return (
<div
- className={cx(styles.container, topAttached && styles.containerTopAttached, className)}
+ {...sx(styles.container, topAttached && styles.containerTopAttached, className)}
onClick={toggleExpanded}
>
{/* Header */}
<Flexbox horizontal align="center" gap={8} justify="space-between">
<Flexbox horizontal align="center" gap={8} style={{ flex: 1, minWidth: 0 }}>
- <svg className={styles.ring} height={RING_SIZE} width={RING_SIZE}>
+ <svg {...stylex.props(styles.ring)} height={RING_SIZE} width={RING_SIZE}>
<circle
- className={styles.ringTrack}
+ {...stylex.props(styles.ringTrack)}
cx={RING_SIZE / 2}
cy={RING_SIZE / 2}
fill="none"
@@ -184,7 +162,7 @@ const TodoProgress = memo<TodoProgressProps>(({ className, topAttached }) => {
strokeWidth={RING_STROKE}
/>
<circle
- className={styles.ringProgress}
+ {...stylex.props(styles.ringProgress)}
cx={RING_SIZE / 2}
cy={RING_SIZE / 2}
fill="none"
@@ -196,12 +174,18 @@ const TodoProgress = memo<TodoProgressProps>(({ className, topAttached }) => {
strokeWidth={RING_STROKE}
/>
</svg>
- <span className={cx(styles.header, isAIGenerating && shinyTextStyles.shinyText)}>
+ <span
+ {...sx(
+ styles.header,
+ !isAIGenerating && styles.headerColor,
+ isAIGenerating ? shinyTextStyles.shinyText : undefined,
+ )}
+ >
{currentPendingTask?.text ||
t('todoProgress.allCompleted', { defaultValue: 'All tasks completed' })}
</span>
<Tag size="small" style={{ flexShrink: 0 }}>
- <span className={styles.count}>
+ <span {...stylex.props(styles.count)}>
{completed}/{total}
</span>
</Tag>
@@ -214,7 +198,7 @@ const TodoProgress = memo<TodoProgressProps>(({ className, topAttached }) => {
</Flexbox>
{/* Expandable Todo List */}
- <div className={cx(styles.listContainer, expanded ? styles.expanded : styles.collapsed)}>
+ <div {...stylex.props(styles.listContainer, expanded ? styles.expanded : styles.collapsed)}>
{items.map((item, index) => {
const isCompleted = item.status === 'completed';
const isProcessing = item.status === 'processing';
@@ -222,13 +206,13 @@ const TodoProgress = memo<TodoProgressProps>(({ className, topAttached }) => {
// Processing state uses CircleArrowRight icon
if (isProcessing) {
return (
- <div className={cx(styles.itemRow, styles.processingRow)} key={index}>
+ <div {...stylex.props(styles.itemRow, styles.processingRow)} key={index}>
<Icon
icon={CircleArrowRight}
size={17}
style={{ color: cssVar.colorTextSecondary }}
/>
- <span className={styles.textProcessing}>{item.text}</span>
+ <span {...stylex.props(styles.textProcessing)}>{item.text}</span>
</div>
);
}
@@ -242,8 +226,8 @@ const TodoProgress = memo<TodoProgressProps>(({ className, topAttached }) => {
shape="circle"
style={{ borderWidth: 1.5, cursor: 'default', pointerEvents: 'none' }}
classNames={{
- text: cx(styles.textTodo, isCompleted && styles.textCompleted),
- wrapper: styles.itemRow,
+ text: stylex.props(styles.textTodo, isCompleted && styles.textCompleted).className,
+ wrapper: stylex.props(styles.itemRow).className,
}}
textProps={{
type: isCompleted ? 'secondary' : undefined,
diff --git a/src/features/Conversation/WorkingSidebar/Browser/index.tsx b/src/features/Conversation/WorkingSidebar/Browser/index.tsx
index 7ea6874f14d..77e6f9d398d 100644
--- a/src/features/Conversation/WorkingSidebar/Browser/index.tsx
+++ b/src/features/Conversation/WorkingSidebar/Browser/index.tsx
@@ -1,17 +1,8 @@
import { isDesktop } from '@lobechat/const';
import { nanoid } from '@lobechat/utils';
-import {
- ActionIcon,
- Button,
- Center,
- createStaticStyles,
- Empty,
- Flexbox,
- Icon,
- Input,
- Text,
- toast,
-} from '@lobehub/ui';
+import { ActionIcon, Button, Center, Empty, Flexbox, Icon, Input, Text, toast } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import {
Camera,
ChevronLeft,
@@ -45,118 +36,88 @@ import {
normalizeBrowserUrl,
} from './utils';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- loadingBar: css`
- pointer-events: none;
-
- position: absolute;
- z-index: 3;
-
- /* Anchored to the toolbar's bottom border. */
- inset-block-end: -1px;
- inset-inline: 0;
-
- overflow: hidden;
-
- height: 2px;
-
- &::after {
- content: '';
-
- position: absolute;
- inset-block: 0;
- inset-inline-start: 0;
-
- width: 36%;
-
- background: ${cssVar.colorInfo};
-
- animation: browser-loading-progress 1.15s ease-in-out infinite;
- }
-
- @keyframes browser-loading-progress {
- from {
- transform: translateX(-110%);
- }
-
- to {
- transform: translateX(310%);
- }
- }
-
- @media (prefers-reduced-motion: reduce) {
- &::after {
- width: 100%;
- animation: none;
- }
- }
- `,
- container: css`
- position: relative;
-
- overflow: hidden;
- flex: 1;
-
- width: 100%;
- min-height: 0;
-
- background: ${cssVar.colorBgContainer};
- `,
- toolbar: css`
- position: relative;
-
- flex-shrink: 0;
+const REDUCED_MOTION = '@media (prefers-reduced-motion: reduce)';
+const NARROW_BANNER = '@container (max-width: 480px)';
- min-height: 56px;
- padding-inline: 16px;
- border-block-end: 1px solid ${cssVar.colorBorderSecondary};
- `,
- address: css`
- flex: 1;
- min-width: 0;
- max-width: 720px;
-
- /* The filled variant keeps its tinted fill while focused; lift it to the
- container surface so the focus ring reads as an editable field. Doubling
- the class outranks antd's own :focus rule. */
- &&:focus {
- background: ${cssVar.colorBgContainer};
- }
- `,
- importBanner: css`
- container-type: inline-size;
- flex-shrink: 0;
- flex-wrap: wrap;
-
- min-height: 72px;
- padding-block: 12px;
- padding-inline: 16px;
- border-block-end: 1px solid ${cssVar.colorBorderSecondary};
-
- background: ${cssVar.colorBgContainer};
- `,
- importCopy: css`
- flex: 1;
- min-width: 0;
- `,
- importActions: css`
- margin-inline-start: auto;
+const loadingProgress = stylex.keyframes({
+ from: { transform: 'translateX(-110%)' },
+ to: { transform: 'translateX(310%)' },
+});
- @container (max-width: 480px) {
- flex-basis: 100%;
- justify-content: flex-end;
- margin-inline-start: 44px;
- }
- `,
- toolbarActions: css`
- margin-inline-start: auto;
- `,
- /* The retained Electron webview is imperatively attached inside this host. */
- viewport: css`
- position: absolute;
- inset: 0;
- `,
-}));
+const styles = stylex.create({
+ loadingBar: {
+ 'pointerEvents': 'none',
+ 'position': 'absolute',
+ 'zIndex': 3,
+ // Anchored to the toolbar's bottom border.
+ 'insetBlockEnd': '-1px',
+ 'insetInline': 0,
+ 'overflow': 'hidden',
+ 'height': '2px',
+ '::after': {
+ content: '""',
+ position: 'absolute',
+ insetBlock: 0,
+ insetInlineStart: 0,
+ width: { default: '36%', [REDUCED_MOTION]: '100%' },
+ backgroundColor: cssVar.colorInfo,
+ backgroundImage: 'none',
+ animationName: { default: loadingProgress, [REDUCED_MOTION]: 'none' },
+ animationDuration: { default: '1.15s', [REDUCED_MOTION]: '0s' },
+ animationTimingFunction: { default: 'ease-in-out', [REDUCED_MOTION]: 'ease' },
+ animationIterationCount: { default: 'infinite', [REDUCED_MOTION]: 1 },
+ },
+ },
+ container: {
+ position: 'relative',
+ overflow: 'hidden',
+ flex: '1',
+ width: '100%',
+ minHeight: 0,
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+ toolbar: {
+ position: 'relative',
+ flexShrink: 0,
+ minHeight: '56px',
+ paddingInline: '16px',
+ borderBlockEndWidth: '1px',
+ borderBlockEndStyle: 'solid',
+ borderBlockEndColor: cssVar.colorBorderSecondary,
+ },
+ address: {
+ flex: '1',
+ minWidth: 0,
+ maxWidth: '720px',
+ // The filled variant keeps its tinted fill while focused; lift it to the
+ // container surface so the focus ring reads as an editable field.
+ backgroundColor: { 'default': null, ':focus': cssVar.colorBgContainer },
+ backgroundImage: { 'default': null, ':focus': 'none' },
+ },
+ importBanner: {
+ containerType: 'inline-size',
+ flexShrink: 0,
+ flexWrap: 'wrap',
+ minHeight: '72px',
+ paddingBlock: '12px',
+ paddingInline: '16px',
+ borderBlockEndWidth: '1px',
+ borderBlockEndStyle: 'solid',
+ borderBlockEndColor: cssVar.colorBorderSecondary,
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+ importCopy: { flex: '1', minWidth: 0 },
+ importActions: {
+ flexBasis: { default: null, [NARROW_BANNER]: '100%' },
+ justifyContent: { default: null, [NARROW_BANNER]: 'flex-end' },
+ marginInlineStart: { default: 'auto', [NARROW_BANNER]: '44px' },
+ },
+ toolbarActions: { marginInlineStart: 'auto' },
+ // The retained Electron webview is imperatively attached inside this host.
+ viewport: { position: 'absolute', insetBlock: 0, insetInline: 0 },
+});
interface BrowserPaneProps {
/** The conversation the chat input belongs to β€” screenshots are attached there. */
@@ -371,7 +332,7 @@ const BrowserPane = memo<BrowserPaneProps>((props) => {
return (
<Flexbox height={'100%'} width={'100%'}>
- <Flexbox horizontal align={'center'} className={styles.toolbar} gap={4}>
+ <Flexbox horizontal align={'center'} {...stylex.props(styles.toolbar)} gap={4}>
<Flexbox horizontal align={'center'} gap={4}>
<ActionIcon
disabled={!state.canGoBack}
@@ -406,7 +367,7 @@ const BrowserPane = memo<BrowserPaneProps>((props) => {
/>
</Flexbox>
<Input
- className={styles.address}
+ {...stylex.props(styles.address)}
placeholder={t('workingPanel.browser.addressPlaceholder')}
value={address}
variant={'filled'}
@@ -421,7 +382,7 @@ const BrowserPane = memo<BrowserPaneProps>((props) => {
openUrl(address);
}}
/>
- <Flexbox horizontal align={'center'} className={styles.toolbarActions} gap={4}>
+ <Flexbox horizontal align={'center'} {...stylex.props(styles.toolbarActions)} gap={4}>
{isPicking ? (
<ActionIcon
active
@@ -464,21 +425,21 @@ const BrowserPane = memo<BrowserPaneProps>((props) => {
<div
aria-label={t('workingPanel.browser.loading')}
aria-valuetext={t('workingPanel.browser.loading')}
- className={styles.loadingBar}
+ {...stylex.props(styles.loadingBar)}
role="progressbar"
/>
)}
</Flexbox>
{!isImportBannerDismissed && (
- <Flexbox horizontal align={'center'} className={styles.importBanner} gap={12}>
+ <Flexbox horizontal align={'center'} {...stylex.props(styles.importBanner)} gap={12}>
<BrowserIcon browser={'Chrome'} size={32} />
- <Flexbox className={styles.importCopy} gap={0}>
+ <Flexbox {...stylex.props(styles.importCopy)} gap={0}>
<Text strong>{t('workingPanel.browser.import.title')}</Text>
<Text ellipsis type={'secondary'}>
{t('workingPanel.browser.import.desc')}
</Text>
</Flexbox>
- <Flexbox horizontal align={'center'} className={styles.importActions} gap={4}>
+ <Flexbox horizontal align={'center'} {...stylex.props(styles.importActions)} gap={4}>
<Button
icon={<Icon icon={Import} />}
loading={isImporting}
@@ -495,8 +456,8 @@ const BrowserPane = memo<BrowserPaneProps>((props) => {
</Flexbox>
</Flexbox>
)}
- <Flexbox className={styles.container}>
- <div className={styles.viewport} ref={viewportRef} />
+ <Flexbox {...stylex.props(styles.container)}>
+ <div {...stylex.props(styles.viewport)} ref={viewportRef} />
</Flexbox>
</Flexbox>
);
diff --git a/src/features/Conversation/WorkingSidebar/Files/index.tsx b/src/features/Conversation/WorkingSidebar/Files/index.tsx
index da9b8e407ed..5facbdd1bd7 100644
--- a/src/features/Conversation/WorkingSidebar/Files/index.tsx
+++ b/src/features/Conversation/WorkingSidebar/Files/index.tsx
@@ -4,7 +4,6 @@ import type { ProjectFileIndexEntry } from '@lobechat/electron-client-ipc';
import {
ActionIcon,
Center,
- createStaticStyles,
DropdownMenu,
Empty,
Flexbox,
@@ -13,7 +12,9 @@ import {
Spin,
stopPropagation,
} from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import type { GitStatusEntry } from '@pierre/trees';
+import * as stylex from '@stylexjs/stylex';
import {
EllipsisIcon,
FileIcon,
@@ -68,47 +69,43 @@ interface FilesProps {
workingDirectory: string;
}
-const styles = createStaticStyles(({ css, cssVar }) => ({
- tree: css`
- --trees-bg-override: transparent;
- --trees-border-color-override: transparent;
- --trees-selected-bg-override: ${cssVar.colorFillSecondary};
- --trees-selected-fg-override: ${cssVar.colorText};
- --trees-bg-muted-override: ${cssVar.colorFillTertiary};
- --trees-fg-override: ${cssVar.colorTextSecondary};
- --trees-fg-muted-override: ${cssVar.colorTextSecondary};
- --trees-accent-override: ${cssVar.colorPrimary};
- --trees-padding-inline-override: 0px;
- --trees-font-size-override: 12px;
- --trees-border-radius-override: 6px;
-
- flex: 1;
- min-height: 0;
- `,
- subheader: css`
- display: flex;
- flex-shrink: 0;
- gap: 4px;
- align-items: center;
-
- padding-block: 6px 8px;
- padding-inline: 12px;
- `,
- search: css`
- flex: 1;
- min-width: 0;
- `,
- truncated: css`
- flex-shrink: 0;
-
- padding-block: 4px;
- padding-inline: 12px;
- border-block-start: 1px solid ${cssVar.colorBorderSecondary};
-
- font-size: 11px;
- color: ${cssVar.colorTextTertiary};
- `,
-}));
+const styles = stylex.create({
+ tree: {
+ '--trees-bg-override': 'transparent',
+ '--trees-border-color-override': 'transparent',
+ '--trees-selected-bg-override': cssVar.colorFillSecondary,
+ '--trees-selected-fg-override': cssVar.colorText,
+ '--trees-bg-muted-override': cssVar.colorFillTertiary,
+ '--trees-fg-override': cssVar.colorTextSecondary,
+ '--trees-fg-muted-override': cssVar.colorTextSecondary,
+ '--trees-accent-override': cssVar.colorPrimary,
+ '--trees-padding-inline-override': '0px',
+ '--trees-font-size-override': '12px',
+ '--trees-border-radius-override': '6px',
+ 'flex': '1',
+ 'minHeight': '0',
+ },
+ subheader: {
+ display: 'flex',
+ flexShrink: 0,
+ gap: '4px',
+ alignItems: 'center',
+ paddingBlockStart: '6px',
+ paddingBlockEnd: '8px',
+ paddingInline: '12px',
+ },
+ search: { flex: '1', minWidth: '0' },
+ truncated: {
+ flexShrink: 0,
+ paddingBlock: '4px',
+ paddingInline: '12px',
+ borderBlockStartWidth: '1px',
+ borderBlockStartStyle: 'solid',
+ borderBlockStartColor: cssVar.colorBorderSecondary,
+ fontSize: '11px',
+ color: cssVar.colorTextTertiary,
+ },
+});
const FILE_SEARCH_DEBOUNCE_MS = 180;
const PROJECT_FILE_TREE_SEARCH_LIMIT = 200;
@@ -497,9 +494,9 @@ const Files = memo<FilesProps>(
return (
<Flexbox height={'100%'} style={{ overflow: 'hidden' }} width={'100%'}>
- <div className={styles.subheader}>
+ <div {...stylex.props(styles.subheader)}>
{searchExpanded ? (
- <div className={styles.search}>
+ <div {...stylex.props(styles.search)}>
<FilesSearchBar
onClose={() => setSearchExpanded(false)}
onDebouncedChange={setDebouncedQuery}
@@ -575,7 +572,7 @@ const Files = memo<FilesProps>(
/>
</Center>
) : (
- <div className={styles.tree} style={treeStyleVars}>
+ <div className={stylex.props(styles.tree).className} style={treeStyleVars}>
<ExplorerTree<ProjectFileIndexEntry>
iconsColored
canDrag={actions.canDrag}
@@ -602,12 +599,14 @@ const Files = memo<FilesProps>(
</div>
)}
{showsRefreshFailure ? (
- <div className={styles.truncated}>{t('workingPanel.files.refreshFailed')}</div>
+ <div {...stylex.props(styles.truncated)}>{t('workingPanel.files.refreshFailed')}</div>
) : showsPartialIndex ? (
- <div className={styles.truncated}>{t('workingPanel.files.partialIndexNotice')}</div>
+ <div {...stylex.props(styles.truncated)}>
+ {t('workingPanel.files.partialIndexNotice')}
+ </div>
) : (
truncatedCount > 0 && (
- <div className={styles.truncated}>{t('workingPanel.files.truncatedNotice')}</div>
+ <div {...stylex.props(styles.truncated)}>{t('workingPanel.files.truncatedNotice')}</div>
)
)}
</Flexbox>
diff --git a/src/features/Conversation/WorkingSidebar/GoalSection/GoalWorkflowCard.tsx b/src/features/Conversation/WorkingSidebar/GoalSection/GoalWorkflowCard.tsx
index 7fa46b3e3e2..6c1dd626d0a 100644
--- a/src/features/Conversation/WorkingSidebar/GoalSection/GoalWorkflowCard.tsx
+++ b/src/features/Conversation/WorkingSidebar/GoalSection/GoalWorkflowCard.tsx
@@ -1,6 +1,8 @@
'use client';
-import { Button, createStaticStyles, cssVar, cx, Flexbox, Icon, Skeleton } from '@lobehub/ui';
+import { Button, Flexbox, Icon, Skeleton } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import {
ArrowUpRight,
CheckCircle2,
@@ -17,6 +19,7 @@ import { useTranslation } from 'react-i18next';
import AsyncError from '@/components/AsyncError';
import AssigneeProfileAvatar from '@/features/AgentGoals/ProcessControl/AssigneeProfileAvatar';
import { useChatStore } from '@/store/chat';
+import { sx } from '@/styles/sx';
import {
buildGoalStepSegments,
@@ -27,176 +30,134 @@ import {
} from './goalWorkflowView';
import { type GoalWorkflowView, useGoalWorkflow } from './useGoalSection';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- collapsed: css`
- display: none;
- `,
- count: css`
- flex-shrink: 0;
-
- padding-block: 1px;
- padding-inline: 6px;
- border-radius: 4px;
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 11px;
- color: ${cssVar.colorTextSecondary};
-
- background: ${cssVar.colorFillSecondary};
- `,
- decisionRow: css`
- cursor: pointer;
-
- margin-block: 2px 6px;
- padding-block: 5px;
- padding-inline: 8px;
- border: 1px solid ${cssVar.colorWarningBorder};
- border-radius: 6px;
-
- font-size: 12px;
- color: ${cssVar.colorWarning};
-
- background: ${cssVar.colorWarningBg};
-
- &:hover {
- background: ${cssVar.colorWarningBorder};
- }
- `,
- footer: css`
- padding-block: 6px 2px;
- `,
- headerRow: css`
- cursor: pointer;
- user-select: none;
-
- padding-block: 4px 6px;
- padding-inline: 10px;
- border-radius: 6px;
-
- transition: background-color 0.12s ease;
-
- &:hover {
- background: ${cssVar.colorFillTertiary};
- }
-
- &:focus-visible {
- outline: 2px solid ${cssVar.colorPrimaryBorder};
- outline-offset: 2px;
- }
- `,
- lessRow: css`
- cursor: pointer;
-
- justify-content: center;
-
- padding-block: 4px;
-
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
-
- &:hover {
- color: ${cssVar.colorText};
- }
- `,
- moreRow: css`
- cursor: pointer;
-
- justify-content: center;
-
- margin-block-start: 2px;
- padding-block: 5px;
- border: 1px dashed ${cssVar.colorBorder};
- border-radius: 6px;
-
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
-
- &:hover {
- color: ${cssVar.colorText};
- background: ${cssVar.colorFillQuaternary};
- }
- `,
- progress: css`
- overflow: hidden;
- flex: 1;
-
- height: 4px;
- border-radius: 2px;
-
- background: ${cssVar.colorFillSecondary};
- `,
- progressFill: css`
- height: 100%;
- border-radius: inherit;
- background: ${cssVar.colorSuccess};
- transition: width 0.25s ${cssVar.motionEaseOut};
- `,
- row: css`
- cursor: pointer;
- padding-block: 5px;
- padding-inline: 8px;
- border-radius: 6px;
-
- &:hover {
- background: ${cssVar.colorFillTertiary};
- }
-
- &:focus-visible {
- outline: 2px solid ${cssVar.colorPrimaryBorder};
- outline-offset: -2px;
- }
- `,
- loading: css`
- padding-block: 4px 8px;
- padding-inline: 10px;
- `,
- segActive: css`
- background: ${cssVar.colorInfo};
- animation: sidebar-goal-step-pulse 1.6s ${cssVar.motionEaseInOut} infinite;
- `,
- segDone: css`
- background: ${cssVar.colorSuccess};
- `,
- segPending: css`
- background: ${cssVar.colorFillSecondary};
- `,
- segment: css`
- flex: 1;
- height: 4px;
- border-radius: 2px;
- `,
- stepTrack: css`
- display: flex;
- gap: 3px;
-
- height: 4px;
- margin-block: 2px 8px;
- margin-inline: 10px;
-
- @keyframes sidebar-goal-step-pulse {
- 0%,
- 100% {
- opacity: 1;
- }
-
- 50% {
- opacity: 0.45;
- }
- }
- `,
- sectionTitle: css`
- overflow: hidden;
- flex: 1;
-
- min-width: 0;
+const stepPulse = stylex.keyframes({
+ '0%, 100%': { opacity: 1 },
+ '50%': { opacity: 0.45 },
+});
- font-size: 13px;
- font-weight: 500;
- color: ${cssVar.colorText};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
-}));
+const styles = stylex.create({
+ collapsed: { display: 'none' },
+ count: {
+ flexShrink: 0,
+ paddingBlock: '1px',
+ paddingInline: '6px',
+ borderRadius: '4px',
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '11px',
+ color: cssVar.colorTextSecondary,
+ backgroundColor: cssVar.colorFillSecondary,
+ backgroundImage: 'none',
+ },
+ decisionRow: {
+ cursor: 'pointer',
+ marginBlockStart: '2px',
+ marginBlockEnd: '6px',
+ paddingBlock: '5px',
+ paddingInline: '8px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorWarningBorder,
+ borderRadius: '6px',
+ fontSize: '12px',
+ color: cssVar.colorWarning,
+ backgroundColor: { 'default': cssVar.colorWarningBg, ':hover': cssVar.colorWarningBorder },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ },
+ footer: { paddingBlockStart: '6px', paddingBlockEnd: '2px', paddingInline: '10px' },
+ headerRow: {
+ cursor: 'pointer',
+ userSelect: 'none',
+ paddingBlockStart: '4px',
+ paddingBlockEnd: '6px',
+ paddingInline: '10px',
+ borderRadius: '6px',
+ transition: 'background-color 0.12s ease',
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ outlineWidth: { 'default': null, ':focus-visible': '2px' },
+ outlineStyle: { 'default': null, ':focus-visible': 'solid' },
+ outlineColor: { 'default': null, ':focus-visible': cssVar.colorPrimaryBorder },
+ outlineOffset: { 'default': null, ':focus-visible': '2px' },
+ },
+ lessRow: {
+ cursor: 'pointer',
+ justifyContent: 'center',
+ paddingBlock: '4px',
+ fontSize: '12px',
+ color: { 'default': cssVar.colorTextTertiary, ':hover': cssVar.colorText },
+ },
+ moreRow: {
+ cursor: 'pointer',
+ justifyContent: 'center',
+ marginBlockStart: '2px',
+ paddingBlock: '5px',
+ borderWidth: '1px',
+ borderStyle: 'dashed',
+ borderColor: cssVar.colorBorder,
+ borderRadius: '6px',
+ fontSize: '12px',
+ color: { 'default': cssVar.colorTextSecondary, ':hover': cssVar.colorText },
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillQuaternary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ },
+ progress: {
+ overflow: 'hidden',
+ flex: '1',
+ height: '4px',
+ borderRadius: '2px',
+ backgroundColor: cssVar.colorFillSecondary,
+ backgroundImage: 'none',
+ },
+ progressFill: {
+ height: '100%',
+ borderRadius: 'inherit',
+ backgroundColor: cssVar.colorSuccess,
+ backgroundImage: 'none',
+ transition: `width 0.25s ${cssVar.motionEaseOut}`,
+ },
+ row: {
+ cursor: 'pointer',
+ paddingBlock: '5px',
+ paddingInline: '8px',
+ borderRadius: '6px',
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ outlineWidth: { 'default': null, ':focus-visible': '2px' },
+ outlineStyle: { 'default': null, ':focus-visible': 'solid' },
+ outlineColor: { 'default': null, ':focus-visible': cssVar.colorPrimaryBorder },
+ outlineOffset: { 'default': null, ':focus-visible': '-2px' },
+ },
+ loading: { paddingBlockStart: '4px', paddingBlockEnd: '8px', paddingInline: '10px' },
+ segActive: {
+ backgroundColor: cssVar.colorInfo,
+ backgroundImage: 'none',
+ animationName: stepPulse,
+ animationDuration: '1.6s',
+ animationTimingFunction: cssVar.motionEaseInOut,
+ animationIterationCount: 'infinite',
+ },
+ segDone: { backgroundColor: cssVar.colorSuccess, backgroundImage: 'none' },
+ segPending: { backgroundColor: cssVar.colorFillSecondary, backgroundImage: 'none' },
+ segment: { flex: '1', height: '4px', borderRadius: '2px' },
+ stepTrack: {
+ display: 'flex',
+ gap: '3px',
+ height: '4px',
+ marginBlockStart: '2px',
+ marginBlockEnd: '8px',
+ marginInline: '10px',
+ },
+ sectionTitle: {
+ overflow: 'hidden',
+ flex: '1',
+ minWidth: 0,
+ fontSize: '13px',
+ fontWeight: 500,
+ color: cssVar.colorText,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+});
const STATE_VISUALS = {
done: { color: cssVar.colorSuccess, icon: CheckCircle2 },
@@ -219,7 +180,7 @@ const WorkflowRow = memo<{ onOpen: () => void; row: GoalWorkflowRow }>(({ row, o
<Flexbox
horizontal
align={'center'}
- className={styles.row}
+ {...stylex.props(styles.row)}
gap={8}
role={'button'}
tabIndex={0}
@@ -267,9 +228,9 @@ const StepTrack = memo<{ rows: GoalWorkflowRow[] }>(({ rows }) => {
if (segments.length === 0) return null;
return (
- <div aria-hidden className={styles.stepTrack} data-testid={'goal-workflow-step-track'}>
+ <div aria-hidden {...stylex.props(styles.stepTrack)} data-testid={'goal-workflow-step-track'}>
{segments.map((state, index) => (
- <div className={cx(styles.segment, SEGMENT_CLASS[state])} key={index} />
+ <div {...stylex.props(styles.segment, SEGMENT_CLASS[state])} key={index} />
))}
</div>
);
@@ -320,7 +281,7 @@ const GoalWorkflowCard = memo<{
align={'center'}
aria-controls={bodyId}
aria-expanded={!collapsed}
- className={styles.headerRow}
+ {...stylex.props(styles.headerRow)}
gap={8}
justify="space-between"
role={'button'}
@@ -330,14 +291,14 @@ const GoalWorkflowCard = memo<{
>
<Flexbox horizontal align={'center'} gap={8} style={{ flex: 1, minWidth: 0 }}>
<Icon icon={Workflow} size={14} style={{ color: cssVar.colorTextSecondary }} />
- <span className={styles.sectionTitle} title={title}>
+ <span {...stylex.props(styles.sectionTitle)} title={title}>
{title}
</span>
{hasSnapshot && goal.phase !== 'running' && (
- <span className={styles.count}>{t(`goalTask.status.${goal.phase}`)}</span>
+ <span {...stylex.props(styles.count)}>{t(`goalTask.status.${goal.phase}`)}</span>
)}
{hasSnapshot && (
- <span className={styles.count}>
+ <span {...stylex.props(styles.count)}>
{goal.summary.done}/{goal.summary.total}
</span>
)}
@@ -349,13 +310,13 @@ const GoalWorkflowCard = memo<{
/>
</Flexbox>
- <div className={cx(collapsed && styles.collapsed)} id={bodyId}>
+ <div hidden={collapsed} {...stylex.props(collapsed && styles.collapsed)} id={bodyId}>
{goal.error ? (
- <div className={styles.loading}>
+ <div {...stylex.props(styles.loading)}>
<AsyncError error={goal.error} variant={'inline'} onRetry={goal.retry} />
</div>
) : goal.loading ? (
- <Flexbox className={styles.loading} data-testid={'goal-workflow-loading'} gap={8}>
+ <Flexbox {...stylex.props(styles.loading)} data-testid={'goal-workflow-loading'} gap={8}>
<Skeleton height={12} radius={4} />
<Skeleton height={28} radius={6} />
<Skeleton height={28} radius={6} />
@@ -368,7 +329,7 @@ const GoalWorkflowCard = memo<{
<Flexbox
horizontal
align={'center'}
- className={styles.decisionRow}
+ {...stylex.props(styles.decisionRow)}
gap={6}
justify={'space-between'}
role={'button'}
@@ -393,7 +354,7 @@ const GoalWorkflowCard = memo<{
<Flexbox
horizontal
align={'center'}
- className={styles.moreRow}
+ {...stylex.props(styles.moreRow)}
gap={4}
role={'button'}
tabIndex={0}
@@ -413,7 +374,7 @@ const GoalWorkflowCard = memo<{
<Flexbox
horizontal
align={'center'}
- className={styles.lessRow}
+ {...stylex.props(styles.lessRow)}
role={'button'}
tabIndex={0}
onClick={() => setRowsExpanded(false)}
@@ -432,12 +393,11 @@ const GoalWorkflowCard = memo<{
<Flexbox
horizontal
align={'center'}
- className={styles.footer}
+ className={stylex.props(styles.footer).className}
gap={8}
- style={{ paddingInline: 10 }}
>
- <div className={styles.progress}>
- <div className={styles.progressFill} style={{ width: `${percent}%` }} />
+ <div {...stylex.props(styles.progress)}>
+ <div {...sx(styles.progressFill, { width: `${percent}%` })} />
</div>
<Button outdent={'end'} size={'small'} type={'text'} onClick={open}>
{t('workingPanel.goal.viewDetails')}
diff --git a/src/features/Conversation/WorkingSidebar/Overview/BackgroundTasks/index.tsx b/src/features/Conversation/WorkingSidebar/Overview/BackgroundTasks/index.tsx
index a27b6cb9c52..8ab1d78ab4f 100644
--- a/src/features/Conversation/WorkingSidebar/Overview/BackgroundTasks/index.tsx
+++ b/src/features/Conversation/WorkingSidebar/Overview/BackgroundTasks/index.tsx
@@ -1,6 +1,7 @@
'use client';
import { Button, Flexbox } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
import { useCallback, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -11,7 +12,7 @@ import { getLocalBackgroundTaskStopper } from '@/store/chat/slices/agentRun/acti
import { useUserStore } from '@/store/user';
import { labPreferSelectors } from '@/store/user/selectors';
-import { sectionStyles } from '../sectionStyles';
+import { sectionProps, sectionStyles } from '../sectionStyles';
import {
type BackgroundTaskItem,
groupBackgroundTasks,
@@ -23,6 +24,7 @@ import { BackgroundTaskRow } from './BackgroundTaskRow';
import { useBackgroundTasks } from './useBackgroundTasks';
interface BackgroundTasksSectionProps {
+ afterBreak?: boolean;
/** Routes the output read to a connected device; empty for this device. */
deviceId?: string;
/** Whether this client can read the run's files (this device or a connected one). */
@@ -45,7 +47,11 @@ const locate = ({ toolCallId }: BackgroundTaskItem) => {
* Monitor), Better Coding Experience only. Running ones all show; finished ones
* fold to the most recent few.
*/
-const BackgroundTasksBody = ({ deviceId, outputReadable }: BackgroundTasksSectionProps) => {
+const BackgroundTasksBody = ({
+ afterBreak,
+ deviceId,
+ outputReadable,
+}: BackgroundTasksSectionProps) => {
const { t } = useTranslation('chat');
const { items, liveOperations } = useBackgroundTasks();
const [showAllFinished, setShowAllFinished] = useState(false);
@@ -81,12 +87,12 @@ const BackgroundTasksBody = ({ deviceId, outputReadable }: BackgroundTasksSectio
);
return (
- <Flexbox className={sectionStyles.section}>
- <Flexbox horizontal align={'center'} className={sectionStyles.sectionHeader} gap={6}>
- <span className={sectionStyles.sectionTitle}>
+ <Flexbox {...sectionProps(afterBreak)}>
+ <Flexbox horizontal align={'center'} {...stylex.props(sectionStyles.sectionHeader)} gap={6}>
+ <span {...stylex.props(sectionStyles.sectionTitle)}>
{t('workingPanel.overview.backgroundTasks.title')}
</span>
- {running.length > 0 && <span className={sectionStyles.count}>{running.length}</span>}
+ {running.length > 0 && <span {...stylex.props(sectionStyles.count)}>{running.length}</span>}
</Flexbox>
{running.map(renderRow)}
{finished.map(renderRow)}
diff --git a/src/features/Conversation/WorkingSidebar/Overview/DeviceStatusSection.tsx b/src/features/Conversation/WorkingSidebar/Overview/DeviceStatusSection.tsx
index 6c7f669a54d..b898facdfc4 100644
--- a/src/features/Conversation/WorkingSidebar/Overview/DeviceStatusSection.tsx
+++ b/src/features/Conversation/WorkingSidebar/Overview/DeviceStatusSection.tsx
@@ -1,7 +1,9 @@
'use client';
import type { DeviceListItem, DeviceMetricSeries } from '@lobechat/types';
-import { Button, createStaticStyles, cssVar, Flexbox, Icon, Skeleton, Text } from '@lobehub/ui';
+import { Button, Flexbox, Icon, Skeleton, Text } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { RefreshCwIcon, TriangleAlertIcon } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -17,66 +19,51 @@ import { getDeviceIcon, getPlatformLabel } from '@/features/DeviceManager/getDev
import { useDeviceActivityText } from '@/features/DeviceManager/useDeviceActivityText';
import { OverviewRow } from './OverviewRow';
-import { sectionStyles } from './sectionStyles';
+import { sectionProps, sectionStyles } from './sectionStyles';
import { useBoundDevice } from './useBoundDevice';
-const styles = createStaticStyles(({ css }) => ({
- body: css`
- padding-block: 4px;
- padding-inline: 8px;
- `,
- code: css`
- overflow: hidden;
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- infoGrid: css`
- display: grid;
- grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
- gap: 12px;
- `,
- name: css`
- overflow: hidden;
-
- font-size: 13px;
- font-weight: 600;
- line-height: 18px;
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- presence: css`
- flex: none;
- width: 6px;
- height: 6px;
- border-radius: 50%;
- `,
- sub: css`
- overflow: hidden;
-
- font-size: 12px;
- line-height: 16px;
- color: ${cssVar.colorTextTertiary};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- tile: css`
- display: grid;
- flex-shrink: 0;
- place-items: center;
-
- width: 32px;
- height: 32px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: 9px;
-
- color: ${cssVar.colorTextSecondary};
-
- background: ${cssVar.colorFillTertiary};
- `,
-}));
+const styles = stylex.create({
+ body: { paddingBlock: '4px', paddingInline: '8px' },
+ code: {
+ overflow: 'hidden',
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '12px',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ infoGrid: { display: 'grid', gridTemplateColumns: 'minmax(0, 1fr) minmax(0, 1fr)', gap: '12px' },
+ name: {
+ overflow: 'hidden',
+ fontSize: '13px',
+ fontWeight: 600,
+ lineHeight: '18px',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ presence: { flex: 'none', width: '6px', height: '6px', borderRadius: '50%' },
+ sub: {
+ overflow: 'hidden',
+ fontSize: '12px',
+ lineHeight: '16px',
+ color: cssVar.colorTextTertiary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ tile: {
+ display: 'grid',
+ flexShrink: 0,
+ placeItems: 'center',
+ width: '32px',
+ height: '32px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: '9px',
+ color: cssVar.colorTextSecondary,
+ backgroundColor: cssVar.colorFillTertiary,
+ backgroundImage: 'none',
+ },
+});
interface DeviceStatusSectionProps {
/** Polls the device's presence and CPU / memory / disk series only while the Overview is on screen. */
@@ -98,8 +85,8 @@ const DeviceStatusSection = memo<DeviceStatusSectionProps>(({ active, deviceId }
if (bound.status === 'loading')
return (
- <Flexbox className={sectionStyles.section}>
- <div className={sectionStyles.skeleton}>
+ <Flexbox {...sectionProps()}>
+ <div {...stylex.props(sectionStyles.skeleton)}>
<Skeleton.Text rows={2} />
</div>
</Flexbox>
@@ -108,7 +95,7 @@ const DeviceStatusSection = memo<DeviceStatusSectionProps>(({ active, deviceId }
// A failed read is not a removed device: say so and offer a retry.
if (bound.status === 'error')
return (
- <Flexbox className={sectionStyles.section}>
+ <Flexbox {...sectionProps()}>
<OverviewRow
danger
icon={TriangleAlertIcon}
@@ -150,33 +137,33 @@ const DeviceStatusContent = ({ data, device, error }: DeviceStatusContentProps)
const displayName = device.friendlyName || device.hostname || device.deviceId;
return (
- <Flexbox className={sectionStyles.section} data-testid={'overview-device-status'}>
- <Flexbox className={styles.body} gap={14}>
+ <Flexbox {...sectionProps()} data-testid={'overview-device-status'}>
+ <Flexbox className={stylex.props(styles.body).className} gap={14}>
<Flexbox horizontal align={'center'} gap={10}>
- <span className={styles.tile}>{getDeviceIcon(device.platform, 16)}</span>
+ <span {...stylex.props(styles.tile)}>{getDeviceIcon(device.platform, 16)}</span>
<Flexbox flex={1} gap={1} style={{ minWidth: 0 }}>
- <span className={styles.name} title={displayName}>
+ <span {...stylex.props(styles.name)} title={displayName}>
{displayName}
</span>
<Flexbox horizontal align={'center'} gap={6} style={{ minWidth: 0 }}>
<span
aria-hidden
- className={styles.presence}
+ className={stylex.props(styles.presence).className}
style={{ background: online ? cssVar.colorSuccess : cssVar.colorTextQuaternary }}
/>
- <span className={styles.sub} title={activityText}>
+ <span {...stylex.props(styles.sub)} title={activityText}>
{platformLabel ? `${activityText} Β· ${platformLabel}` : activityText}
</span>
</Flexbox>
</Flexbox>
</Flexbox>
- <div className={styles.infoGrid}>
+ <div {...stylex.props(styles.infoGrid)}>
<Flexbox gap={2} style={{ minWidth: 0 }}>
<Text fontSize={12} type={'secondary'}>
{t('devices.card.hostname')}
</Text>
- <span className={styles.code} title={device.hostname ?? undefined}>
+ <span {...stylex.props(styles.code)} title={device.hostname ?? undefined}>
{device.hostname || 'β€”'}
</span>
</Flexbox>
diff --git a/src/features/Conversation/WorkingSidebar/Overview/OverviewHeader.tsx b/src/features/Conversation/WorkingSidebar/Overview/OverviewHeader.tsx
index edbf8a12d67..92c76d4e999 100644
--- a/src/features/Conversation/WorkingSidebar/Overview/OverviewHeader.tsx
+++ b/src/features/Conversation/WorkingSidebar/Overview/OverviewHeader.tsx
@@ -1,75 +1,71 @@
import { Github } from '@lobehub/icons';
-import { createStaticStyles, cssVar, cx, Flexbox, Icon } from '@lobehub/ui';
+import { Flexbox, Icon } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { FolderGit2Icon, FolderIcon } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- dot: css`
- flex-shrink: 0;
-
- width: 6px;
- height: 6px;
- border-radius: 50%;
-
- background: ${cssVar.colorSuccess};
- `,
- header: css`
- cursor: pointer;
- flex-shrink: 0;
- padding-block: 14px 2px;
- padding-inline: 16px 14px;
- `,
- identity: css`
- overflow: hidden;
- display: flex;
- flex: 1;
- flex-direction: column;
- gap: 1px;
-
- min-width: 0;
- `,
- name: css`
- overflow: hidden;
-
- font-size: 14px;
- font-weight: 600;
- line-height: 18px;
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- sub: css`
- overflow: hidden;
- display: flex;
- gap: 6px;
- align-items: center;
-
- font-size: 12px;
- line-height: 16px;
- color: ${cssVar.colorTextTertiary};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- subText: css`
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- tile: css`
- display: grid;
- flex-shrink: 0;
- place-items: center;
-
- width: 32px;
- height: 32px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: 9px;
-
- color: ${cssVar.colorText};
-
- background: ${cssVar.colorFillTertiary};
- `,
-}));
+const styles = stylex.create({
+ dot: {
+ flexShrink: 0,
+ width: '6px',
+ height: '6px',
+ borderRadius: '50%',
+ backgroundColor: cssVar.colorSuccess,
+ backgroundImage: 'none',
+ },
+ header: {
+ cursor: 'pointer',
+ flexShrink: 0,
+ paddingBlockStart: '14px',
+ paddingBlockEnd: '2px',
+ paddingInlineStart: '16px',
+ paddingInlineEnd: '14px',
+ },
+ identity: {
+ overflow: 'hidden',
+ display: 'flex',
+ flex: '1',
+ flexDirection: 'column',
+ gap: '1px',
+ minWidth: '0',
+ },
+ name: {
+ overflow: 'hidden',
+ fontSize: '14px',
+ fontWeight: 600,
+ lineHeight: '18px',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ sub: {
+ overflow: 'hidden',
+ display: 'flex',
+ gap: '6px',
+ alignItems: 'center',
+ fontSize: '12px',
+ lineHeight: '16px',
+ color: cssVar.colorTextTertiary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ subText: { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
+ tile: {
+ display: 'grid',
+ flexShrink: 0,
+ placeItems: 'center',
+ width: '32px',
+ height: '32px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: '9px',
+ color: cssVar.colorText,
+ backgroundColor: cssVar.colorFillTertiary,
+ backgroundImage: 'none',
+ },
+});
interface OverviewHeaderProps {
deviceId?: string;
@@ -89,24 +85,27 @@ const OverviewHeader = memo<OverviewHeaderProps>(
<Flexbox
horizontal
align={'center'}
- className={styles.header}
+ className={stylex.props(styles.header).className}
gap={10}
role={'button'}
title={path}
onClick={onClick}
>
- <span className={styles.tile}>
+ <span {...stylex.props(styles.tile)}>
{repoType === 'github' ? (
<Github size={18} />
) : (
<Icon icon={repoType ? FolderGit2Icon : FolderIcon} size={18} />
)}
</span>
- <span className={styles.identity}>
- <span className={styles.name}>{name}</span>
- <span className={styles.sub}>
- <i className={cx(styles.dot)} style={dotColor ? { background: dotColor } : undefined} />
- <span className={styles.subText}>
+ <span {...stylex.props(styles.identity)}>
+ <span {...stylex.props(styles.name)}>{name}</span>
+ <span {...stylex.props(styles.sub)}>
+ <i
+ className={stylex.props(styles.dot).className}
+ style={dotColor ? { background: dotColor } : undefined}
+ />
+ <span {...stylex.props(styles.subText)}>
{t(
deviceId
? 'workingPanel.overview.execution.device'
diff --git a/src/features/Conversation/WorkingSidebar/Overview/OverviewRow.tsx b/src/features/Conversation/WorkingSidebar/Overview/OverviewRow.tsx
index 6c7f2198820..27bbcb2d487 100644
--- a/src/features/Conversation/WorkingSidebar/Overview/OverviewRow.tsx
+++ b/src/features/Conversation/WorkingSidebar/Overview/OverviewRow.tsx
@@ -1,87 +1,62 @@
-import { createStaticStyles, cx, Flexbox, Icon, type IconProps } from '@lobehub/ui';
+import { Flexbox, Icon, type IconProps } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { ChevronRightIcon, ChevronsUpDownIcon } from 'lucide-react';
import { memo, type ReactNode } from 'react';
-export const rowStyles = createStaticStyles(({ css, cssVar }) => ({
- changeAdditions: css`
- font-variant-numeric: tabular-nums;
- color: ${cssVar.colorSuccess};
- `,
- changeDeletions: css`
- font-variant-numeric: tabular-nums;
- color: ${cssVar.colorError};
- `,
- icon: css`
- flex-shrink: 0;
- color: ${cssVar.colorTextTertiary};
- `,
- num: css`
- margin-inline-end: 5px;
+import { sx } from '@/styles/sx';
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- font-weight: 500;
- color: ${cssVar.colorTextTertiary};
- `,
- row: css`
- cursor: pointer;
-
- flex-shrink: 0;
-
- min-height: 32px;
- padding-block: 5px;
- padding-inline: 8px;
- border-radius: 8px;
-
- transition: background-color 0.12s ease;
-
- &:hover {
- background: ${cssVar.colorFillTertiary};
- }
- `,
- rowAction: css`
- font-size: 12px;
- font-weight: 500;
- color: ${cssVar.colorTextSecondary};
- `,
- rowStatic: css`
- cursor: default;
-
- &:hover {
- background: transparent;
- }
- `,
- rowTrailing: css`
- display: flex;
- flex-shrink: 0;
- gap: 6px;
- align-items: center;
-
- font-size: 12px;
- font-variant-numeric: tabular-nums;
- line-height: 18px;
- color: ${cssVar.colorTextTertiary};
- `,
- rowValue: css`
- overflow: hidden;
- flex: 1;
-
- min-width: 0;
-
- font-size: 13px;
- line-height: 20px;
- color: ${cssVar.colorText};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- rowValueDanger: css`
- color: ${cssVar.colorError};
- `,
- rowValueWeak: css`
- font-size: 12.5px;
- color: ${cssVar.colorTextSecondary};
- `,
-}));
+export const rowStyles = stylex.create({
+ changeAdditions: { fontVariantNumeric: 'tabular-nums', color: cssVar.colorSuccess },
+ changeDeletions: { fontVariantNumeric: 'tabular-nums', color: cssVar.colorError },
+ icon: { flexShrink: 0, color: cssVar.colorTextTertiary },
+ num: {
+ marginInlineEnd: '5px',
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '12px',
+ fontWeight: 500,
+ color: cssVar.colorTextTertiary,
+ },
+ row: {
+ cursor: 'pointer',
+ flexShrink: 0,
+ minHeight: '32px',
+ paddingBlock: '5px',
+ paddingInline: '8px',
+ borderRadius: '8px',
+ transition: 'background-color 0.12s ease',
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ },
+ rowAction: { fontSize: '12px', fontWeight: 500, color: cssVar.colorTextSecondary },
+ rowStatic: {
+ cursor: 'default',
+ backgroundColor: { 'default': null, ':hover': 'transparent' },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ },
+ rowTrailing: {
+ display: 'flex',
+ flexShrink: 0,
+ gap: '6px',
+ alignItems: 'center',
+ fontSize: '12px',
+ fontVariantNumeric: 'tabular-nums',
+ lineHeight: '18px',
+ color: cssVar.colorTextTertiary,
+ },
+ rowValue: {
+ overflow: 'hidden',
+ flex: '1',
+ minWidth: '0',
+ fontSize: '13px',
+ lineHeight: '20px',
+ color: cssVar.colorText,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ rowValueDanger: { color: cssVar.colorError },
+ rowValueWeak: { fontSize: '12.5px', color: cssVar.colorTextSecondary },
+});
export interface OverviewRowProps {
danger?: boolean;
@@ -116,23 +91,22 @@ export const OverviewRow = memo<OverviewRowProps>(
<Flexbox
horizontal
align={'center'}
- className={cx(rowStyles.row, !onClick && !interactive && rowStyles.rowStatic)}
+ {...stylex.props(rowStyles.row, !onClick && !interactive && rowStyles.rowStatic)}
gap={10}
role={onClick || interactive ? 'button' : undefined}
onClick={onClick}
>
{iconNode ?? (
<Icon
- className={rowStyles.icon}
icon={icon!}
size={iconSize}
spin={spin}
- style={iconColor ? { color: iconColor } : undefined}
+ {...sx(rowStyles.icon, iconColor ? { color: iconColor } : undefined)}
/>
)}
<span
title={title}
- className={cx(
+ {...stylex.props(
rowStyles.rowValue,
danger && rowStyles.rowValueDanger,
weak && rowStyles.rowValueWeak,
@@ -140,7 +114,7 @@ export const OverviewRow = memo<OverviewRowProps>(
>
{value}
</span>
- {trailing ? <span className={rowStyles.rowTrailing}>{trailing}</span> : null}
+ {trailing ? <span {...stylex.props(rowStyles.rowTrailing)}>{trailing}</span> : null}
</Flexbox>
),
);
diff --git a/src/features/Conversation/WorkingSidebar/Overview/PortSwitcher.tsx b/src/features/Conversation/WorkingSidebar/Overview/PortSwitcher.tsx
index 6ebba0adf7a..aac24514f8c 100644
--- a/src/features/Conversation/WorkingSidebar/Overview/PortSwitcher.tsx
+++ b/src/features/Conversation/WorkingSidebar/Overview/PortSwitcher.tsx
@@ -1,7 +1,5 @@
import type { DeviceListeningPort } from '@lobechat/types';
import {
- createStaticStyles,
- cx,
DropdownMenuItem,
DropdownMenuPopup,
DropdownMenuPortal,
@@ -11,6 +9,8 @@ import {
Icon,
Tooltip,
} from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import {
CopyIcon,
GlobeIcon,
@@ -34,168 +34,125 @@ import type { DeviceTunnelLink } from '@/store/device';
import { OverviewRow, PickerGlyph } from './OverviewRow';
import { usePortTunnels } from './usePortTunnels';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- action: css`
- cursor: pointer;
-
- display: flex;
- flex-shrink: 0;
- align-items: center;
- justify-content: center;
-
- width: 20px;
- height: 20px;
- padding: 0;
- border: none;
- border-radius: 4px;
-
- color: ${cssVar.colorTextTertiary};
-
- background: transparent;
-
- &:hover {
- color: ${cssVar.colorText};
- background: ${cssVar.colorFillSecondary};
- }
-
- &:focus-visible {
- outline: 2px solid ${cssVar.colorPrimaryBorder};
- outline-offset: 1px;
- }
- `,
- actions: css`
- display: flex;
- flex-shrink: 0;
- gap: 2px;
- align-items: center;
-
- /* Pull the last glyph flush with the text trailing of the other rows. */
- margin-inline-end: -4px;
- `,
- available: css`
- font-size: 12px;
- color: ${cssVar.colorPrimary};
- `,
- command: css`
- overflow: hidden;
- flex-shrink: 1;
-
- min-width: 0;
-
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- container: css`
- display: flex;
- flex-direction: column;
- width: 260px;
- padding: 4px;
- `,
- empty: css`
- padding-block: 10px;
- padding-inline: 8px;
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
- `,
- expose: css`
- flex-shrink: 0;
- font-size: 12px;
- font-weight: 500;
- `,
+const styles = stylex.create({
+ action: {
+ cursor: 'pointer',
+ display: 'flex',
+ flexShrink: 0,
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: '20px',
+ height: '20px',
+ padding: 0,
+ borderWidth: 0,
+ borderStyle: 'none',
+ borderRadius: '4px',
+ color: { 'default': cssVar.colorTextTertiary, ':hover': cssVar.colorText },
+ backgroundColor: { 'default': 'transparent', ':hover': cssVar.colorFillSecondary },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ outlineWidth: { 'default': null, ':focus-visible': '2px' },
+ outlineStyle: { 'default': null, ':focus-visible': 'solid' },
+ outlineColor: { 'default': null, ':focus-visible': cssVar.colorPrimaryBorder },
+ outlineOffset: { 'default': null, ':focus-visible': '1px' },
+ },
+ actions: {
+ display: 'flex',
+ flexShrink: 0,
+ gap: '2px',
+ alignItems: 'center',
+ // Pull the last glyph flush with the text trailing of the other rows.
+ marginInlineEnd: '-4px',
+ },
+ available: { fontSize: '12px', color: cssVar.colorPrimary },
+ command: {
+ overflow: 'hidden',
+ flexShrink: 1,
+ minWidth: 0,
+ fontSize: '12px',
+ color: cssVar.colorTextTertiary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ container: { display: 'flex', flexDirection: 'column', width: '260px', padding: '4px' },
+ empty: {
+ paddingBlock: '10px',
+ paddingInline: '8px',
+ fontSize: '12px',
+ color: cssVar.colorTextTertiary,
+ },
+ expose: { flexShrink: 0, fontSize: '12px', fontWeight: 500 },
/**
* A port that is running but not exposed yet stays one step quieter than an
* exposed one; the full text color is kept for what is actually reachable.
* Port, glyph and "Open" inherit it, so hover lifts the whole row at once.
*/
- idle: css`
- color: ${cssVar.colorTextSecondary};
-
- &:hover,
- &[data-highlighted] {
- color: ${cssVar.colorText};
- }
- `,
- host: css`
- overflow: hidden;
- flex: 1;
-
- min-width: 0;
-
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- header: css`
- display: flex;
- align-items: center;
- justify-content: space-between;
-
- padding-block: 6px 4px;
- padding-inline: 8px 4px;
-
- font-size: 11px;
- font-weight: 500;
- color: ${cssVar.colorTextTertiary};
- `,
- item: css`
- display: flex;
- gap: 8px;
- align-items: center;
- `,
- othersList: css`
- overflow-y: auto;
- display: flex;
- flex-direction: column;
-
- /* A dev machine listens on dozens of ports; the list scrolls inside the
- menu instead of pushing it past the viewport. */
- max-height: 200px;
- `,
- port: css`
- flex-shrink: 0;
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- font-weight: 500;
- color: ${cssVar.colorText};
- `,
- portIdle: css`
- color: inherit;
- `,
- retry: css`
- cursor: pointer;
-
- padding: 0;
- border: none;
-
- font-size: 12px;
- color: ${cssVar.colorInfo};
-
- background: transparent;
- `,
- spacer: css`
- flex: 1;
- min-width: 0;
- `,
- state: css`
- display: flex;
- gap: 6px;
- align-items: center;
-
- padding-block: 10px;
- padding-inline: 8px;
-
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
- `,
- toggle: css`
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
- `,
-}));
+ idle: {
+ color: {
+ 'default': cssVar.colorTextSecondary,
+ ':hover': cssVar.colorText,
+ '[data-highlighted]': cssVar.colorText,
+ },
+ },
+ host: {
+ overflow: 'hidden',
+ flex: '1',
+ minWidth: 0,
+ fontSize: '12px',
+ color: cssVar.colorTextTertiary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ header: {
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ paddingBlockStart: '6px',
+ paddingBlockEnd: '4px',
+ paddingInlineStart: '8px',
+ paddingInlineEnd: '4px',
+ fontSize: '11px',
+ fontWeight: 500,
+ color: cssVar.colorTextTertiary,
+ },
+ item: { display: 'flex', gap: '8px', alignItems: 'center' },
+ othersList: {
+ overflowY: 'auto',
+ display: 'flex',
+ flexDirection: 'column',
+ // A dev machine listens on dozens of ports; the list scrolls inside the
+ // menu instead of pushing it past the viewport.
+ maxHeight: '200px',
+ },
+ port: {
+ flexShrink: 0,
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '12px',
+ fontWeight: 500,
+ color: cssVar.colorText,
+ },
+ portIdle: { color: 'inherit' },
+ retry: {
+ cursor: 'pointer',
+ padding: 0,
+ borderWidth: 0,
+ borderStyle: 'none',
+ fontSize: '12px',
+ color: cssVar.colorInfo,
+ backgroundColor: 'transparent',
+ backgroundImage: 'none',
+ },
+ spacer: { flex: '1', minWidth: 0 },
+ state: {
+ display: 'flex',
+ gap: '6px',
+ alignItems: 'center',
+ paddingBlock: '10px',
+ paddingInline: '8px',
+ fontSize: '12px',
+ color: cssVar.colorTextTertiary,
+ },
+ toggle: { fontSize: '12px', color: cssVar.colorTextTertiary },
+});
interface PortSwitcherProps {
/** Whether the working panel is showing; detection only runs while it is. */
@@ -247,13 +204,13 @@ const PortSwitcher = memo<PortSwitcherProps>(({ active, deviceId, workingDirecto
*/
const renderLabel = (port: number, info?: DeviceListeningPort) => (
<>
- <span className={cx(styles.port, styles.portIdle)}>{port}</span>
+ <span {...stylex.props(styles.port, styles.portIdle)}>{port}</span>
{info?.command && (
- <span className={styles.command} title={info.cwd}>
+ <span {...stylex.props(styles.command)} title={info.cwd}>
{info.command}
</span>
)}
- <span className={styles.spacer} />
+ <span {...stylex.props(styles.spacer)} />
</>
);
@@ -276,7 +233,7 @@ const PortSwitcher = memo<PortSwitcherProps>(({ active, deviceId, workingDirecto
const renderLink = (link: DeviceTunnelLink) => (
<DropdownMenuItem
- className={styles.item}
+ {...stylex.props(styles.item)}
key={link.slug}
onClick={(event) => {
event.preventDefault();
@@ -292,21 +249,21 @@ const PortSwitcher = memo<PortSwitcherProps>(({ active, deviceId, workingDirecto
right beside it. A link starts with its port (`5199--slug.lobe.sh`),
so the port is drawn as the link's own prefix instead of repeated
before it β€” that leaves room for the whole domain. */}
- <span className={styles.host} title={link.hostname}>
+ <span {...stylex.props(styles.host)} title={link.hostname}>
{link.hostname.startsWith(`${link.port}--`) ? (
<>
- <span className={styles.port}>{link.port}</span>
+ <span {...stylex.props(styles.port)}>{link.port}</span>
{link.hostname.slice(String(link.port).length)}
</>
) : (
link.hostname
)}
</span>
- <span className={styles.actions}>
+ <span {...stylex.props(styles.actions)}>
<Tooltip title={t('workingPanel.overview.ports.copy')}>
<button
aria-label={t('workingPanel.overview.ports.copy')}
- className={styles.action}
+ {...stylex.props(styles.action)}
type={'button'}
{...ownPress(() => void copyLink(link))}
>
@@ -316,7 +273,7 @@ const PortSwitcher = memo<PortSwitcherProps>(({ active, deviceId, workingDirecto
<Tooltip title={t('workingPanel.overview.ports.revoke')}>
<button
aria-label={t('workingPanel.overview.ports.revoke')}
- className={styles.action}
+ {...stylex.props(styles.action)}
type={'button'}
{...ownPress(() => void revokeLink(link))}
>
@@ -329,7 +286,7 @@ const PortSwitcher = memo<PortSwitcherProps>(({ active, deviceId, workingDirecto
const renderDetected = (item: DeviceListeningPort) => (
<DropdownMenuItem
- className={cx(styles.item, styles.idle)}
+ {...stylex.props(styles.item, styles.idle)}
// A port from an earlier probe may have stopped: shown, not exposable,
// until the device confirms it still listens.
disabled={detectionChecking}
@@ -345,21 +302,23 @@ const PortSwitcher = memo<PortSwitcherProps>(({ active, deviceId, workingDirecto
spin={creatingPort === item.port}
/>
{renderLabel(item.port, item)}
- <span className={styles.expose}>{t('workingPanel.overview.ports.detected.expose')}</span>
+ <span {...stylex.props(styles.expose)}>
+ {t('workingPanel.overview.ports.detected.expose')}
+ </span>
</DropdownMenuItem>
);
const checkingState = (
- <div className={styles.state}>
+ <div {...stylex.props(styles.state)}>
<Icon spin icon={LoaderCircleIcon} size={13} />
{t('workingPanel.overview.ports.detected.checking')}
</div>
);
const loadFailedState = (
- <div className={styles.state}>
+ <div {...stylex.props(styles.state)}>
{t('workingPanel.overview.ports.loadFailed')}
- <button className={styles.retry} type={'button'} onClick={() => void refresh()}>
+ <button {...stylex.props(styles.retry)} type={'button'} onClick={() => void refresh()}>
{tCommon('retry')}
</button>
</div>
@@ -368,7 +327,7 @@ const PortSwitcher = memo<PortSwitcherProps>(({ active, deviceId, workingDirecto
let body: ReactNode;
if (isLoading) {
body = (
- <div className={styles.state}>
+ <div {...stylex.props(styles.state)}>
<Icon spin icon={LoaderCircleIcon} size={13} />
{t('workingPanel.overview.ports.loading')}
</div>
@@ -381,7 +340,7 @@ const PortSwitcher = memo<PortSwitcherProps>(({ active, deviceId, workingDirecto
body = checkingState;
} else if (tunnels.length === 0 && detected.length === 0) {
body = (
- <div className={styles.empty}>
+ <div {...stylex.props(styles.empty)}>
{detectionAvailable
? t('workingPanel.overview.ports.detected.none')
: t('workingPanel.overview.ports.unavailable')}
@@ -414,7 +373,7 @@ const PortSwitcher = memo<PortSwitcherProps>(({ active, deviceId, workingDirecto
// A running dev server the user hasn't exposed yet β€” say so
// without making them open the menu. Ports from an earlier
// probe are not known to be running, so they wait for the device.
- <span className={styles.available}>
+ <span {...stylex.props(styles.available)}>
{t('workingPanel.overview.ports.detected.available', { count: detected.length })}
</span>
)}
@@ -426,15 +385,15 @@ const PortSwitcher = memo<PortSwitcherProps>(({ active, deviceId, workingDirecto
<DropdownMenuPortal>
<DropdownMenuPositioner placement={'bottomLeft'} sideOffset={8}>
<DropdownMenuPopup>
- <div className={styles.container}>
- <div className={styles.header}>
+ <div {...stylex.props(styles.container)}>
+ <div {...stylex.props(styles.header)}>
{t('workingPanel.overview.ports.title')}
{/* Kept even when detection is unavailable: a device that just came
back online is otherwise stuck on the stale answer. */}
<Tooltip title={t('workingPanel.overview.ports.detected.refresh')}>
<button
aria-label={t('workingPanel.overview.ports.detected.refresh')}
- className={styles.action}
+ {...stylex.props(styles.action)}
type={'button'}
{...ownPress(() => void refreshDetected())}
>
@@ -448,7 +407,7 @@ const PortSwitcher = memo<PortSwitcherProps>(({ active, deviceId, workingDirecto
{otherPorts.length > 0 && (
<>
<DropdownMenuItem
- className={styles.toggle}
+ {...stylex.props(styles.toggle)}
closeOnClick={false}
onClick={() => setShowOthers((value) => !value)}
>
@@ -459,7 +418,7 @@ const PortSwitcher = memo<PortSwitcherProps>(({ active, deviceId, workingDirecto
})}
</DropdownMenuItem>
{showOthers && (
- <div className={styles.othersList}>{otherPorts.map(renderDetected)}</div>
+ <div {...stylex.props(styles.othersList)}>{otherPorts.map(renderDetected)}</div>
)}
</>
)}
diff --git a/src/features/Conversation/WorkingSidebar/Overview/PullRequestRow.tsx b/src/features/Conversation/WorkingSidebar/Overview/PullRequestRow.tsx
index 6495fb55509..0ac1ebed78a 100644
--- a/src/features/Conversation/WorkingSidebar/Overview/PullRequestRow.tsx
+++ b/src/features/Conversation/WorkingSidebar/Overview/PullRequestRow.tsx
@@ -1,6 +1,7 @@
import type { DeviceGitLinkedPullRequest } from '@lobechat/types';
import { ActionIcon, Icon, Tooltip } from '@lobehub/ui';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { TriangleAlertIcon, XIcon } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -10,6 +11,7 @@ import {
getPullRequestState,
PR_STATE_VISUAL,
} from '@/features/AgentSidebar/Topic/List/Item/metaCardData';
+import { sx } from '@/styles/sx';
import { shouldShowCiLabel } from './overviewData';
import { OverviewRow, rowStyles } from './OverviewRow';
@@ -53,8 +55,10 @@ const PullRequestRow = memo<PullRequestRowProps>(
</Tooltip>
)}
<span
- className={sectionStyles.pill}
- style={{ background: `color-mix(in srgb, 12%, transparent)`, color: ci.color }}
+ {...sx(sectionStyles.pill, {
+ background: `color-mix(in srgb, 12%, transparent)`,
+ color: ci.color,
+ })}
>
<Icon icon={ci.icon} size={12} />
{shouldShowCiLabel(ciStatus)
@@ -79,7 +83,7 @@ const PullRequestRow = memo<PullRequestRowProps>(
}
value={
<>
- <span className={rowStyles.num}>#{pullRequest.number}</span>
+ <span {...stylex.props(rowStyles.num)}>#{pullRequest.number}</span>
{pullRequest.title}
</>
}
diff --git a/src/features/Conversation/WorkingSidebar/Overview/index.tsx b/src/features/Conversation/WorkingSidebar/Overview/index.tsx
index b9e9e550a70..546148578c9 100644
--- a/src/features/Conversation/WorkingSidebar/Overview/index.tsx
+++ b/src/features/Conversation/WorkingSidebar/Overview/index.tsx
@@ -1,18 +1,10 @@
'use client';
import type { DeviceGitLinkedPullRequest } from '@lobechat/types';
-import {
- Button,
- createStaticStyles,
- cssVar,
- cx,
- Empty,
- Flexbox,
- Icon,
- Skeleton,
- toast,
-} from '@lobehub/ui';
+import { Button, Empty, Flexbox, Icon, Skeleton, toast } from '@lobehub/ui';
import { SkillsIcon } from '@lobehub/ui/icons';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import {
ArrowDownIcon,
ArrowUpIcon,
@@ -67,18 +59,18 @@ import OverviewHeader from './OverviewHeader';
import { ChevronRight, OverviewRow, PickerGlyph, rowStyles } from './OverviewRow';
import PortSwitcher from './PortSwitcher';
import PullRequestRow from './PullRequestRow';
-import { sectionStyles } from './sectionStyles';
+import { sectionProps, sectionStyles } from './sectionStyles';
import { TerminalRow } from './TerminalRow';
-const styles = createStaticStyles(({ css }) => ({
- body: css`
- overflow-y: auto;
- `,
- emptyWorkspace: css`
- padding-block: 28px 30px;
- padding-inline: 20px;
- `,
-}));
+const styles = stylex.create({
+ body: { overflowY: 'auto' },
+ emptyWorkspace: {
+ flexShrink: 0,
+ paddingBlockStart: '28px',
+ paddingBlockEnd: '30px',
+ paddingInline: '20px',
+ },
+});
interface OverviewProps {
active: boolean;
@@ -203,6 +195,7 @@ const Overview = memo<OverviewProps>(
const visibleWorks = works.slice(0, 3);
const directoryName = workingDirectory ? pathBasename(workingDirectory) : undefined;
const hasWorkspace = environmentAvailable && !!workingDirectory;
+ const showEmptyWorkspace = environmentAvailable && !workingDirectory;
const isLinkedWorktree = isLinkedWorktreeCheckout(workingDirectory, worktrees);
@@ -289,7 +282,7 @@ const Overview = memo<OverviewProps>(
value={
detached ? (
<>
- <span className={rowStyles.num}>{branch}</span>
+ <span {...stylex.props(rowStyles.num)}>{branch}</span>
{t('workingPanel.overview.branch.detached')}
</>
) : (
@@ -367,7 +360,9 @@ const Overview = memo<OverviewProps>(
pulling ? (
<RingLoadingIcon size={12} />
) : (
- <span className={rowStyles.rowAction}>{t('workingPanel.overview.sync.pull')}</span>
+ <span {...stylex.props(rowStyles.rowAction)}>
+ {t('workingPanel.overview.sync.pull')}
+ </span>
)
}
onClick={actionsBlocked ? undefined : handlePull}
@@ -383,7 +378,9 @@ const Overview = memo<OverviewProps>(
pushing ? (
<RingLoadingIcon size={12} />
) : (
- <span className={rowStyles.rowAction}>{t('workingPanel.overview.sync.push')}</span>
+ <span {...stylex.props(rowStyles.rowAction)}>
+ {t('workingPanel.overview.sync.push')}
+ </span>
)
}
onClick={actionsBlocked ? undefined : handlePush}
@@ -423,8 +420,8 @@ const Overview = memo<OverviewProps>(
<RingLoadingIcon size={12} />
) : changeStats.files > 0 ? (
<>
- <span className={rowStyles.changeAdditions}>+{changeStats.additions}</span>
- <span className={rowStyles.changeDeletions}>βˆ’{changeStats.deletions}</span>
+ <span {...stylex.props(rowStyles.changeAdditions)}>+{changeStats.additions}</span>
+ <span {...stylex.props(rowStyles.changeDeletions)}>βˆ’{changeStats.deletions}</span>
</>
) : (
t('workingPanel.overview.changes.none')
@@ -444,7 +441,7 @@ const Overview = memo<OverviewProps>(
const workspaceSection = repoType ? (
isGitLoading ? (
- <div className={sectionStyles.skeleton}>
+ <div {...stylex.props(sectionStyles.skeleton)}>
<Skeleton.Text rows={3} />
</div>
) : gitError ? (
@@ -472,7 +469,7 @@ const Overview = memo<OverviewProps>(
) : null;
return (
- <Flexbox className={styles.body}>
+ <Flexbox className={stylex.props(styles.body).className}>
{hasWorkspace && (
<>
<OverviewHeader
@@ -483,7 +480,7 @@ const Overview = memo<OverviewProps>(
repoType={repoType}
onClick={() => onOpenTab('files')}
/>
- <Flexbox className={sectionStyles.section}>
+ <Flexbox {...sectionProps()}>
{/* A worktree the archive cleanup kept for its uncommitted work. */}
<KeptWorktreeRows
entries={topicWorktrees.entries}
@@ -511,27 +508,27 @@ const Overview = memo<OverviewProps>(
{statusDeviceId && <DeviceStatusSection active={active} deviceId={statusDeviceId} />}
<TopicBackgroundActivity topicId={topicId} />
- {environmentAvailable && !workingDirectory && (
+ {showEmptyWorkspace && (
<Empty
- className={cx(sectionStyles.section, styles.emptyWorkspace)}
+ className={stylex.props(styles.emptyWorkspace).className}
description={t('workingPanel.overview.workspace.emptyDesc')}
icon={LaptopIcon}
title={t('workingPanel.overview.workspace.empty')}
/>
)}
- <GoalSection className={sectionStyles.section} />
- <ProgressSection className={sectionStyles.section} />
+ <GoalSection className={sectionProps(showEmptyWorkspace).className} />
+ <ProgressSection className={sectionProps(showEmptyWorkspace).className} />
{visibleWorks.length > 0 && (
- <Flexbox className={sectionStyles.section}>
+ <Flexbox {...sectionProps(showEmptyWorkspace)}>
<Flexbox
horizontal
align={'center'}
- className={sectionStyles.sectionHeader}
+ {...stylex.props(sectionStyles.sectionHeader)}
justify={'space-between'}
>
- <span className={sectionStyles.sectionTitle}>
+ <span {...stylex.props(sectionStyles.sectionTitle)}>
{t('workingPanel.overview.outputs')}
</span>
<Button
@@ -551,7 +548,7 @@ const Overview = memo<OverviewProps>(
{!environmentAvailable && !topicId && visibleWorks.length === 0 && (
<Empty
- className={sectionStyles.section}
+ className={sectionProps().className}
description={t('workingPanel.overview.empty')}
icon={BoxesIcon}
title={t('workingPanel.overview.emptyTitle')}
@@ -559,13 +556,17 @@ const Overview = memo<OverviewProps>(
)}
{/* Claude Code background tasks; async subagents stay in the thread list below. */}
- <BackgroundTasksSection deviceId={deviceId} outputReadable={environmentAvailable} />
+ <BackgroundTasksSection
+ afterBreak={showEmptyWorkspace}
+ deviceId={deviceId}
+ outputReadable={environmentAvailable}
+ />
{/* Thread rows open in the Portal; the list labels itself as subagents and
sits in its own section so the resource rows below aren't grouped under it. */}
- {topicId && <ThreadListSection topicId={topicId} />}
+ {topicId && <ThreadListSection afterBreak={showEmptyWorkspace} topicId={topicId} />}
- <Flexbox className={sectionStyles.section}>
+ <Flexbox {...sectionProps(showEmptyWorkspace)}>
{hasWorkspace && (
<OverviewRow
weak
diff --git a/src/features/Conversation/WorkingSidebar/Overview/markers.stylex.ts b/src/features/Conversation/WorkingSidebar/Overview/markers.stylex.ts
new file mode 100644
index 00000000000..c6512470f6f
--- /dev/null
+++ b/src/features/Conversation/WorkingSidebar/Overview/markers.stylex.ts
@@ -0,0 +1,4 @@
+import * as stylex from '@stylexjs/stylex';
+
+export const sectionMarker = stylex.defineMarker();
+export const sectionAfterBreakMarker = stylex.defineMarker();
diff --git a/src/features/Conversation/WorkingSidebar/Overview/sectionStyles.ts b/src/features/Conversation/WorkingSidebar/Overview/sectionStyles.ts
index b383b31d226..b1cb0c6133b 100644
--- a/src/features/Conversation/WorkingSidebar/Overview/sectionStyles.ts
+++ b/src/features/Conversation/WorkingSidebar/Overview/sectionStyles.ts
@@ -1,53 +1,77 @@
-import { createStaticStyles } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
-export const sectionStyles = createStaticStyles(({ css, cssVar }) => ({
- count: css`
- padding-block: 1px;
- padding-inline: 6px;
- border-radius: 4px;
+import { sx } from '@/styles/sx';
- font-family: ${cssVar.fontFamilyCode};
- font-size: 11px;
- font-weight: 500;
- color: ${cssVar.colorTextSecondary};
- text-transform: none;
- letter-spacing: 0;
+import { sectionAfterBreakMarker, sectionMarker } from './markers.stylex';
- background: ${cssVar.colorFillSecondary};
- `,
- pill: css`
- display: inline-flex;
- gap: 4px;
- align-items: center;
+export const sectionStyles = stylex.create({
+ count: {
+ paddingBlock: '1px',
+ paddingInline: '6px',
+ borderRadius: '4px',
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '11px',
+ fontWeight: 500,
+ color: cssVar.colorTextSecondary,
+ textTransform: 'none',
+ letterSpacing: 0,
+ backgroundColor: cssVar.colorFillSecondary,
+ backgroundImage: 'none',
+ },
+ pill: {
+ display: 'inline-flex',
+ gap: '4px',
+ alignItems: 'center',
+ height: '20px',
+ paddingInline: '7px',
+ borderRadius: '6px',
+ fontSize: '11.5px',
+ fontWeight: 500,
+ lineHeight: '20px',
+ },
+ // Emotion's `& + &` divided a section from the one directly before it. StyleX only has
+ // `~`, so a section that follows a non-section sibling (a header, an empty state) passes
+ // `afterBreak` and keys its divider on a marker no section before that break carries.
+ section: {
+ flexShrink: 0,
+ paddingBlock: '8px',
+ paddingInline: '8px',
+ borderBlockStartWidth: {
+ default: null,
+ [stylex.when.siblingBefore(':is(*)', sectionMarker)]: '1px',
+ },
+ borderBlockStartStyle: {
+ default: null,
+ [stylex.when.siblingBefore(':is(*)', sectionMarker)]: 'solid',
+ },
+ borderBlockStartColor: {
+ default: null,
+ [stylex.when.siblingBefore(':is(*)', sectionMarker)]: cssVar.colorBorderSecondary,
+ },
+ },
+ sectionAfterBreak: {
+ borderBlockStartWidth: {
+ default: null,
+ [stylex.when.siblingBefore(':is(*)', sectionAfterBreakMarker)]: '1px',
+ },
+ borderBlockStartStyle: {
+ default: null,
+ [stylex.when.siblingBefore(':is(*)', sectionAfterBreakMarker)]: 'solid',
+ },
+ borderBlockStartColor: {
+ default: null,
+ [stylex.when.siblingBefore(':is(*)', sectionAfterBreakMarker)]: cssVar.colorBorderSecondary,
+ },
+ },
+ sectionHeader: { paddingBlockStart: 0, paddingBlockEnd: '4px', paddingInline: '8px' },
+ sectionTitle: { fontSize: '10.5px', fontWeight: 600, color: cssVar.colorTextTertiary },
+ skeleton: { paddingBlock: '4px', paddingInline: '8px' },
+});
- height: 20px;
- padding-inline: 7px;
- border-radius: 6px;
-
- font-size: 11.5px;
- font-weight: 500;
- line-height: 20px;
- `,
- section: css`
- flex-shrink: 0;
- padding-block: 8px;
- padding-inline: 8px;
-
- & + & {
- border-block-start: 1px solid ${cssVar.colorBorderSecondary};
- }
- `,
- sectionHeader: css`
- padding-block: 0 4px;
- padding-inline: 8px;
- `,
- sectionTitle: css`
- font-size: 10.5px;
- font-weight: 600;
- color: ${cssVar.colorTextTertiary};
- `,
- skeleton: css`
- padding-block: 4px;
- padding-inline: 8px;
- `,
-}));
+export const sectionProps = (afterBreak = false) =>
+ sx(
+ sectionStyles.section,
+ afterBreak && sectionStyles.sectionAfterBreak,
+ afterBreak ? sectionAfterBreakMarker : sectionMarker,
+ );
diff --git a/src/features/Conversation/WorkingSidebar/ProgressSection/index.tsx b/src/features/Conversation/WorkingSidebar/ProgressSection/index.tsx
index 1cb3be3306b..a00548aa694 100644
--- a/src/features/Conversation/WorkingSidebar/ProgressSection/index.tsx
+++ b/src/features/Conversation/WorkingSidebar/ProgressSection/index.tsx
@@ -1,4 +1,6 @@
-import { Checkbox, createStaticStyles, cssVar, cx, Flexbox, Icon } from '@lobehub/ui';
+import { Checkbox, Flexbox, Icon } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { ChevronDown, ChevronUp, CircleArrowRight } from 'lucide-react';
import { type KeyboardEvent, memo, useCallback, useId, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -15,109 +17,72 @@ const RING_STROKE = 2;
const RING_RADIUS = (RING_SIZE - RING_STROKE) / 2;
const RING_CIRCUM = 2 * Math.PI * RING_RADIUS;
-const styles = createStaticStyles(({ css, cssVar }) => ({
- collapsed: css`
- grid-template-rows: 0fr;
- margin-block-start: 0 !important;
- padding-block: 0 !important;
- opacity: 0;
- `,
- count: css`
- flex-shrink: 0;
-
- padding-block: 1px;
- padding-inline: 6px;
- border-radius: 4px;
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 11px;
- color: ${cssVar.colorTextSecondary};
-
- background: ${cssVar.colorFillSecondary};
- `,
- expanded: css`
- grid-template-rows: 1fr;
- opacity: 1;
- `,
- header: css`
- font-size: 10.5px;
- font-weight: 600;
- color: ${cssVar.colorTextSecondary};
- `,
- headerRow: css`
- cursor: pointer;
- user-select: none;
-
- padding-block: 4px 6px;
- padding-inline: 10px;
- border-radius: 6px;
-
- transition: background-color 0.12s ease;
-
- &:hover {
- background: ${cssVar.colorFillTertiary};
- }
-
- &:focus-visible {
- outline: 2px solid ${cssVar.colorPrimaryBorder};
- outline-offset: 2px;
- }
- `,
- itemRow: css`
- padding-block: 6px;
- padding-inline: 4px;
- border-block-end: 1px dashed ${cssVar.colorBorderSecondary};
- font-size: 13px;
-
- &:last-child {
- border-block-end: none;
- }
- `,
- listContainer: css`
- display: grid;
- padding-block: 4px;
- padding-inline: 10px;
- transition:
- grid-template-rows 0.25s ${cssVar.motionEaseInOut},
- opacity 0.2s ${cssVar.motionEaseInOut},
- padding 0.2s ${cssVar.motionEaseInOut};
- `,
- listInner: css`
- /* Blockify the inline-flex Base UI Checkbox labels β€” without this the todo
- rows flow inline and wrap several per line. */
- overflow: hidden;
- display: flex;
- flex-direction: column;
- min-height: 0;
- `,
- processingRow: css`
- display: flex;
- gap: 6px;
- align-items: center;
- `,
- ring: css`
- transform: rotate(-90deg);
- flex-shrink: 0;
- `,
- ringProgress: css`
- transition:
- stroke-dashoffset 240ms ease,
- stroke 240ms ease;
- `,
- ringTrack: css`
- stroke: ${cssVar.colorFillSecondary};
- `,
- textCompleted: css`
- color: ${cssVar.colorTextQuaternary};
- text-decoration: line-through;
- `,
- textProcessing: css`
- color: ${cssVar.colorText};
- `,
- textTodo: css`
- color: ${cssVar.colorTextSecondary};
- `,
-}));
+const styles = stylex.create({
+ collapsed: {
+ gridTemplateRows: '0fr',
+ marginBlockStart: 0,
+ paddingBlockStart: 0,
+ paddingBlockEnd: 0,
+ opacity: 0,
+ },
+ count: {
+ flexShrink: 0,
+ paddingBlock: '1px',
+ paddingInline: '6px',
+ borderRadius: '4px',
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '11px',
+ color: cssVar.colorTextSecondary,
+ backgroundColor: cssVar.colorFillSecondary,
+ backgroundImage: 'none',
+ },
+ expanded: { gridTemplateRows: '1fr', opacity: 1 },
+ header: { fontSize: '10.5px', fontWeight: 600, color: cssVar.colorTextSecondary },
+ headerRow: {
+ cursor: 'pointer',
+ userSelect: 'none',
+ paddingBlockStart: '4px',
+ paddingBlockEnd: '6px',
+ paddingInline: '10px',
+ borderRadius: '6px',
+ transition: 'background-color 0.12s ease',
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ outlineWidth: { 'default': null, ':focus-visible': '2px' },
+ outlineStyle: { 'default': null, ':focus-visible': 'solid' },
+ outlineColor: { 'default': null, ':focus-visible': cssVar.colorPrimaryBorder },
+ outlineOffset: { 'default': null, ':focus-visible': '2px' },
+ },
+ itemRow: {
+ paddingBlock: '6px',
+ paddingInline: '4px',
+ borderBlockEndWidth: '1px',
+ borderBlockEndStyle: { 'default': 'dashed', ':last-child': 'none' },
+ borderBlockEndColor: cssVar.colorBorderSecondary,
+ fontSize: '13px',
+ },
+ listContainer: {
+ display: 'grid',
+ paddingBlock: '4px',
+ paddingInline: '10px',
+ transition: `grid-template-rows 0.25s ${cssVar.motionEaseInOut}, opacity 0.2s ${cssVar.motionEaseInOut}, padding 0.2s ${cssVar.motionEaseInOut}`,
+ },
+ listInner: {
+ // Blockify the inline-flex Base UI Checkbox labels β€” without this the todo
+ // rows flow inline and wrap several per line.
+ overflow: 'hidden',
+ display: 'flex',
+ flexDirection: 'column',
+ minHeight: 0,
+ },
+ processingRow: { display: 'flex', gap: '6px', alignItems: 'center' },
+ ring: { transform: 'rotate(-90deg)', flexShrink: 0 },
+ ringProgress: { transition: 'stroke-dashoffset 240ms ease, stroke 240ms ease' },
+ ringTrack: { stroke: cssVar.colorFillSecondary },
+ textCompleted: { color: cssVar.colorTextQuaternary, textDecoration: 'line-through' },
+ textProcessing: { color: cssVar.colorText },
+ textTodo: { color: cssVar.colorTextSecondary },
+});
const ProgressSection = memo<{ className?: string }>(({ className }) => {
const { t } = useTranslation('chat');
@@ -160,7 +125,7 @@ const ProgressSection = memo<{ className?: string }>(({ className }) => {
align="center"
aria-controls={listId}
aria-expanded={expanded}
- className={styles.headerRow}
+ {...stylex.props(styles.headerRow)}
gap={8}
justify="space-between"
role="button"
@@ -169,9 +134,9 @@ const ProgressSection = memo<{ className?: string }>(({ className }) => {
onKeyDown={handleHeaderKeyDown}
>
<Flexbox horizontal align="center" gap={8} style={{ flex: 1, minWidth: 0 }}>
- <svg className={styles.ring} height={RING_SIZE} width={RING_SIZE}>
+ <svg {...stylex.props(styles.ring)} height={RING_SIZE} width={RING_SIZE}>
<circle
- className={styles.ringTrack}
+ {...stylex.props(styles.ringTrack)}
cx={RING_SIZE / 2}
cy={RING_SIZE / 2}
fill="none"
@@ -179,7 +144,7 @@ const ProgressSection = memo<{ className?: string }>(({ className }) => {
strokeWidth={RING_STROKE}
/>
<circle
- className={styles.ringProgress}
+ {...stylex.props(styles.ringProgress)}
cx={RING_SIZE / 2}
cy={RING_SIZE / 2}
fill="none"
@@ -191,8 +156,8 @@ const ProgressSection = memo<{ className?: string }>(({ className }) => {
strokeWidth={RING_STROKE}
/>
</svg>
- <span className={styles.header}>{t('workingPanel.progress')}</span>
- <span className={styles.count}>
+ <span {...stylex.props(styles.header)}>{t('workingPanel.progress')}</span>
+ <span {...stylex.props(styles.count)}>
{completed}/{total}
</span>
</Flexbox>
@@ -204,23 +169,23 @@ const ProgressSection = memo<{ className?: string }>(({ className }) => {
</Flexbox>
<div
- className={cx(styles.listContainer, expanded ? styles.expanded : styles.collapsed)}
+ {...stylex.props(styles.listContainer, expanded ? styles.expanded : styles.collapsed)}
id={listId}
>
- <div className={styles.listInner}>
+ <div {...stylex.props(styles.listInner)}>
{items.map((item, index) => {
const isCompleted = item.status === 'completed';
const isProcessing = item.status === 'processing';
if (isProcessing) {
return (
- <div className={cx(styles.itemRow, styles.processingRow)} key={item.id ?? index}>
+ <div {...stylex.props(styles.itemRow, styles.processingRow)} key={item.id ?? index}>
<Icon
icon={CircleArrowRight}
size={17}
style={{ color: cssVar.colorTextSecondary }}
/>
- <span className={styles.textProcessing}>{item.text}</span>
+ <span {...stylex.props(styles.textProcessing)}>{item.text}</span>
</div>
);
}
@@ -233,8 +198,9 @@ const ProgressSection = memo<{ className?: string }>(({ className }) => {
shape="circle"
style={{ borderWidth: 1.5, cursor: 'default', pointerEvents: 'none' }}
classNames={{
- text: cx(styles.textTodo, isCompleted && styles.textCompleted),
- wrapper: styles.itemRow,
+ text: stylex.props(styles.textTodo, isCompleted && styles.textCompleted)
+ .className,
+ wrapper: stylex.props(styles.itemRow).className,
}}
textProps={{
type: isCompleted ? 'secondary' : undefined,
diff --git a/src/features/Conversation/WorkingSidebar/PullRequest/ActivityTimeline.tsx b/src/features/Conversation/WorkingSidebar/PullRequest/ActivityTimeline.tsx
index 12760a4b8b6..28acdcca731 100644
--- a/src/features/Conversation/WorkingSidebar/PullRequest/ActivityTimeline.tsx
+++ b/src/features/Conversation/WorkingSidebar/PullRequest/ActivityTimeline.tsx
@@ -3,42 +3,61 @@ import type {
DeviceGitPullRequestDetail,
DeviceGitPullRequestReview,
} from '@lobechat/types';
+// oxlint-disable-next-line stylex-migration/no-emotion-styles -- Markdown output gets no className
import { Avatar, Button, createStaticStyles, Flexbox, Icon, Markdown, TextArea } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import type { LucideIcon } from 'lucide-react';
import { CheckIcon, CircleSlashIcon, EyeIcon, GitCommitHorizontalIcon, XIcon } from 'lucide-react';
import { memo, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { electronSystemService } from '@/services/electron/system';
+import { sx } from '@/styles/sx';
import type { Tone } from './mergeDockData';
import { timeAgo, TONE_COLOR, type TranslateKey } from './prVisual';
import type { PullRequestBusy } from './usePullRequestActions';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- comment: css`
- padding-block: 6px;
- padding-inline: 8px;
- border-radius: 8px;
+const styles = stylex.create({
+ comment: {
+ paddingBlock: '6px',
+ paddingInline: '8px',
+ borderRadius: '8px',
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillQuaternary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ },
+ commentBody: {
+ overflow: 'hidden',
+ minWidth: 0,
+ fontSize: '13px',
+ lineHeight: '20px',
+ overflowWrap: 'anywhere',
+ },
+ commentBodyWrap: { overflow: 'hidden', minWidth: 0, paddingInlineStart: '26px' },
+ commentHead: { fontSize: '12px', color: cssVar.colorTextTertiary },
+ commentHeadAuthor: { fontWeight: 500, color: cssVar.colorText },
+ composer: { paddingBlockStart: '4px', paddingBlockEnd: 0, paddingInline: '8px' },
+ event: {
+ minHeight: '28px',
+ paddingBlock: '2px',
+ paddingInline: '8px',
+ fontSize: '12px',
+ color: cssVar.colorTextTertiary,
+ },
+ eventAuthor: { fontWeight: 500, color: cssVar.colorTextSecondary },
+ eventCode: { fontFamily: cssVar.fontFamilyCode, fontSize: '11px' },
+ sha: {
+ cursor: 'pointer',
+ textDecorationLine: 'underline',
+ textDecorationStyle: 'dotted',
+ textUnderlineOffset: '2px',
+ color: { 'default': null, ':hover': cssVar.colorText },
+ },
+});
- &:hover {
- background: ${cssVar.colorFillQuaternary};
- }
- `,
- commentBodyWrap: css`
- overflow: hidden;
- min-width: 0;
- padding-inline-start: 26px;
- `,
+const fallback = createStaticStyles(({ css }) => ({
commentBody: css`
- overflow: hidden;
-
- min-width: 0;
-
- font-size: 13px;
- line-height: 20px;
- overflow-wrap: anywhere;
-
table {
overflow-x: auto;
display: block;
@@ -55,46 +74,6 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
max-width: 100%;
}
`,
- commentHead: css`
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
-
- strong {
- font-weight: 500;
- color: ${cssVar.colorText};
- }
- `,
- composer: css`
- padding-block: 4px 0;
- padding-inline: 8px;
- `,
- event: css`
- min-height: 28px;
- padding-block: 2px;
- padding-inline: 8px;
-
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
-
- strong {
- font-weight: 500;
- color: ${cssVar.colorTextSecondary};
- }
-
- code {
- font-family: ${cssVar.fontFamilyCode};
- font-size: 11px;
- }
- `,
- sha: css`
- cursor: pointer;
- text-decoration: underline dotted;
- text-underline-offset: 2px;
-
- &:hover {
- color: ${cssVar.colorText};
- }
- `,
}));
const githubAvatar = (login: string) => `https://github.com/${login}.png?size=36`;
@@ -171,14 +150,18 @@ const ActivityTimeline = memo<ActivityTimelineProps>(
{timeline.map((entry) => {
if (entry.kind === 'comment')
return (
- <div className={styles.comment} key={entry.id}>
- <Flexbox horizontal align={'center'} className={styles.commentHead} gap={8}>
+ <div {...stylex.props(styles.comment)} key={entry.id}>
+ <Flexbox horizontal align={'center'} {...stylex.props(styles.commentHead)} gap={8}>
<Avatar avatar={githubAvatar(entry.author)} size={18} />
- <strong>{entry.author}</strong>
+ <strong {...stylex.props(styles.commentHeadAuthor)}>{entry.author}</strong>
<span>{timeAgo(entry.at)}</span>
</Flexbox>
- <div className={styles.commentBodyWrap}>
- <Markdown className={styles.commentBody} fontSize={13} variant={'chat'}>
+ <div {...stylex.props(styles.commentBodyWrap)}>
+ <Markdown
+ fontSize={13}
+ variant={'chat'}
+ {...sx(styles.commentBody, fallback.commentBody)}
+ >
{entry.body}
</Markdown>
</div>
@@ -196,7 +179,7 @@ const ActivityTimeline = memo<ActivityTimelineProps>(
<Flexbox
horizontal
align={'center'}
- className={styles.event}
+ {...stylex.props(styles.event)}
gap={8}
key={entry.kind === 'commit' ? entry.sha : `review:${entry.author}:${entry.at}`}
>
@@ -206,10 +189,11 @@ const ActivityTimeline = memo<ActivityTimelineProps>(
style={visual.tone === 'neutral' ? undefined : { color: TONE_COLOR[visual.tone] }}
/>
<span>
- <strong>{entry.author}</strong> {tr(visual.labelKey)}{' '}
+ <strong {...stylex.props(styles.eventAuthor)}>{entry.author}</strong>{' '}
+ {tr(visual.labelKey)}{' '}
{entry.kind === 'commit' && (
<code
- className={styles.sha}
+ {...stylex.props(styles.eventCode, styles.sha)}
onClick={() =>
void electronSystemService.openExternalLink(
`https://github.com/${detail.repo.owner}/${detail.repo.name}/pull/${detail.number}/commits/${entry.sha}`,
@@ -224,7 +208,7 @@ const ActivityTimeline = memo<ActivityTimelineProps>(
</Flexbox>
);
})}
- <Flexbox className={styles.composer} gap={6}>
+ <Flexbox {...stylex.props(styles.composer)} gap={6}>
<TextArea
autoSize={{ minRows: 1 }}
placeholder={t('workingPanel.pr.composer.placeholder')}
diff --git a/src/features/Conversation/WorkingSidebar/PullRequest/ChecksList.tsx b/src/features/Conversation/WorkingSidebar/PullRequest/ChecksList.tsx
index e626eef0c50..8c860f7919c 100644
--- a/src/features/Conversation/WorkingSidebar/PullRequest/ChecksList.tsx
+++ b/src/features/Conversation/WorkingSidebar/PullRequest/ChecksList.tsx
@@ -1,5 +1,7 @@
import type { DeviceGitPullRequestCheck } from '@lobechat/types';
-import { createStaticStyles, Icon } from '@lobehub/ui';
+import { Icon } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { ExternalLinkIcon } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -9,14 +11,10 @@ import { electronSystemService } from '@/services/electron/system';
import { OverviewRow } from '../Overview/OverviewRow';
import { formatCheckDuration, getCheckVisual, TONE_COLOR } from './prVisual';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- duration: css`
- font-family: ${cssVar.fontFamilyCode};
- `,
- list: css`
- padding-inline-start: 18px;
- `,
-}));
+const styles = stylex.create({
+ duration: { fontFamily: cssVar.fontFamilyCode },
+ list: { paddingInlineStart: '18px' },
+});
interface ChecksListProps {
checks: DeviceGitPullRequestCheck[];
@@ -26,7 +24,7 @@ const ChecksList = memo<ChecksListProps>(({ checks }) => {
const { t } = useTranslation('chat');
const hasRequiredCheck = checks.some((check) => check.required);
return (
- <div className={styles.list}>
+ <div {...stylex.props(styles.list)}>
{checks.map((check, index) => {
const visual = getCheckVisual(check.status);
const duration =
@@ -47,7 +45,7 @@ const ChecksList = memo<ChecksListProps>(({ checks }) => {
{hasRequiredCheck && !check.required && (
<span>{t('workingPanel.pr.check.optional')}</span>
)}
- {duration && <span className={styles.duration}>{duration}</span>}
+ {duration && <span {...stylex.props(styles.duration)}>{duration}</span>}
{check.detailsUrl && <Icon icon={ExternalLinkIcon} size={12} />}
</>
}
diff --git a/src/features/Conversation/WorkingSidebar/PullRequest/DockActionButton.tsx b/src/features/Conversation/WorkingSidebar/PullRequest/DockActionButton.tsx
index b6647f05ecd..a78d1ebbafa 100644
--- a/src/features/Conversation/WorkingSidebar/PullRequest/DockActionButton.tsx
+++ b/src/features/Conversation/WorkingSidebar/PullRequest/DockActionButton.tsx
@@ -3,7 +3,9 @@ import type {
DeviceGitPullRequestDetail,
DeviceGitPullRequestMergeMethod,
} from '@lobechat/types';
-import { Button, createStaticStyles, type DropdownItem, SplitButton } from '@lobehub/ui';
+import { Button, type DropdownItem, SplitButton } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -12,31 +14,31 @@ import { MERGE_METHODS } from './mergeMethodStorage';
import type { TranslateKey } from './prVisual';
import type { PullRequestBusy } from './usePullRequestActions';
-const tone = (base: string, hover: string) => `
- && > :where(button, a) {
- border-color: ${base};
- background: ${base};
- }
+const ITEM_HOVER = ':has(> :where(button, a):hover:not(:disabled, [aria-disabled="true"]))';
- &&:has(> :where(button, a):hover:not(:disabled, [aria-disabled='true'])) > :where(button, a) {
- border-color: ${hover};
- background: ${hover};
- }
-`;
-
-const styles = createStaticStyles(({ css, cssVar }) => ({
- toneError: css`
- ${tone(cssVar.colorError, cssVar.colorErrorHover)}
- `,
- toneSuccess: css`
- ${tone(cssVar.colorSuccess, cssVar.colorSuccessHover)}
- `,
-}));
+const styles = stylex.create({
+ toneError: {
+ '--lobe-color-primary': cssVar.colorError,
+ '--lobe-color-primary-hover': cssVar.colorErrorHover,
+ '--lobe-color-primary-active': {
+ default: cssVar.colorError,
+ [ITEM_HOVER]: cssVar.colorErrorHover,
+ },
+ },
+ toneSuccess: {
+ '--lobe-color-primary': cssVar.colorSuccess,
+ '--lobe-color-primary-hover': cssVar.colorSuccessHover,
+ '--lobe-color-primary-active': {
+ default: cssVar.colorSuccess,
+ [ITEM_HOVER]: cssVar.colorSuccessHover,
+ },
+ },
+});
const TONE_CLASS = {
- error: styles.toneError,
+ error: stylex.props(styles.toneError).className,
plain: undefined,
- success: styles.toneSuccess,
+ success: stylex.props(styles.toneSuccess).className,
};
type SplitAction = Extract<DockAction, { kind: 'merge' | 'autoMerge' | 'updateBranch' }>;
diff --git a/src/features/Conversation/WorkingSidebar/PullRequest/Head.tsx b/src/features/Conversation/WorkingSidebar/PullRequest/Head.tsx
index 34d2f9a72ef..9b66095f3ad 100644
--- a/src/features/Conversation/WorkingSidebar/PullRequest/Head.tsx
+++ b/src/features/Conversation/WorkingSidebar/PullRequest/Head.tsx
@@ -1,77 +1,67 @@
import type { DeviceGitLinkedPullRequest } from '@lobechat/types';
-import { createStaticStyles, Flexbox, Icon } from '@lobehub/ui';
+import { Flexbox, Icon } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import type { ReactNode } from 'react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
+import { sx } from '@/styles/sx';
+
import { rowStyles } from '../Overview/OverviewRow';
import { sectionStyles } from '../Overview/sectionStyles';
import { getDetailVisual } from './prVisual';
-export const headStyles = createStaticStyles(({ css, cssVar }) => ({
- actions: css`
- flex-shrink: 0;
- margin-block-start: -2px;
- `,
- meta: css`
- flex-wrap: wrap;
-
- margin-block-start: 6px;
-
- font-size: 12px;
- line-height: 18px;
- color: ${cssVar.colorTextTertiary};
- `,
- ref: css`
- overflow: hidden;
-
- max-width: 160px;
- padding-block: 1px;
- padding-inline: 6px;
- border-radius: 4px;
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 11px;
- color: ${cssVar.colorTextSecondary};
- text-overflow: ellipsis;
- white-space: nowrap;
-
- background: ${cssVar.colorFillSecondary};
- `,
- refButton: css`
- cursor: pointer;
- display: inline-flex;
- gap: 3px;
- align-items: center;
-
- &:hover {
- color: ${cssVar.colorText};
- background: ${cssVar.colorFillTertiary};
- }
- `,
- root: css`
- padding-block: 10px 8px;
- padding-inline: 8px;
- `,
- stats: css`
- font-variant-numeric: tabular-nums;
- `,
- title: css`
- flex: 1;
-
- min-width: 0;
-
- font-size: 15px;
- font-weight: 600;
- line-height: 22px;
- color: ${cssVar.colorText};
- overflow-wrap: anywhere;
- `,
-}));
+export const headStyles = stylex.create({
+ actions: { flexShrink: 0, marginBlockStart: '-2px' },
+ meta: {
+ flexWrap: 'wrap',
+ marginBlockStart: '6px',
+ fontSize: '12px',
+ lineHeight: '18px',
+ color: cssVar.colorTextTertiary,
+ },
+ ref: {
+ overflow: 'hidden',
+ maxWidth: '160px',
+ paddingBlock: '1px',
+ paddingInline: '6px',
+ borderRadius: '4px',
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '11px',
+ color: cssVar.colorTextSecondary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ backgroundColor: cssVar.colorFillSecondary,
+ backgroundImage: 'none',
+ },
+ // Composed after `ref`: a conditional value replaces the whole property, so the
+ // resting colours are restated here.
+ refButton: {
+ cursor: 'pointer',
+ display: 'inline-flex',
+ gap: '3px',
+ alignItems: 'center',
+ color: { 'default': cssVar.colorTextSecondary, ':hover': cssVar.colorText },
+ backgroundColor: { 'default': cssVar.colorFillSecondary, ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ },
+ root: { paddingBlockStart: '10px', paddingBlockEnd: '8px', paddingInline: '8px' },
+ stats: { fontVariantNumeric: 'tabular-nums' },
+ title: {
+ flex: '1',
+ minWidth: '0',
+ fontSize: '15px',
+ fontWeight: 600,
+ lineHeight: '22px',
+ color: cssVar.colorText,
+ overflowWrap: 'anywhere',
+ },
+});
export const PrTitle = memo<{ number: number; title: string }>(({ number, title }) => (
- <span className={headStyles.title}>
- <span className={rowStyles.num}>#{number}</span>
+ <span {...stylex.props(headStyles.title)}>
+ <span {...stylex.props(rowStyles.num)}>#{number}</span>
{title}
</span>
));
@@ -85,11 +75,10 @@ export const PrStatePill = memo<{
const visual = getDetailVisual(pr);
return (
<span
- className={sectionStyles.pill}
- style={{
+ {...sx(sectionStyles.pill, {
background: `color-mix(in srgb, ${visual.color} 12%, transparent)`,
color: visual.color,
- }}
+ })}
>
<Icon icon={visual.icon} size={12} />
{t(`workingPanel.pr.state.${visual.state}`)}
@@ -106,16 +95,16 @@ interface PrHeadProps {
}
const PrHead = memo<PrHeadProps>(({ actions, meta, title }) => (
- <div className={headStyles.root}>
+ <div {...stylex.props(headStyles.root)}>
<Flexbox horizontal align={'flex-start'} gap={6}>
{title}
{actions && (
- <Flexbox horizontal className={headStyles.actions} gap={2}>
+ <Flexbox horizontal {...stylex.props(headStyles.actions)} gap={2}>
{actions}
</Flexbox>
)}
</Flexbox>
- <Flexbox horizontal align={'center'} className={headStyles.meta} gap={6}>
+ <Flexbox horizontal align={'center'} {...stylex.props(headStyles.meta)} gap={6}>
{meta}
</Flexbox>
</div>
diff --git a/src/features/Conversation/WorkingSidebar/PullRequest/Header.tsx b/src/features/Conversation/WorkingSidebar/PullRequest/Header.tsx
index fef4c4136a5..d3688cd95c7 100644
--- a/src/features/Conversation/WorkingSidebar/PullRequest/Header.tsx
+++ b/src/features/Conversation/WorkingSidebar/PullRequest/Header.tsx
@@ -2,12 +2,12 @@ import type { DeviceGitPullRequestAction, DeviceGitPullRequestDetail } from '@lo
import {
ActionIcon,
copyToClipboard,
- cx,
type DropdownItem,
DropdownMenu,
Icon,
toast,
} from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
import {
ArrowRightIcon,
ChevronDownIcon,
@@ -110,7 +110,7 @@ const Header = memo<HeaderProps>(
meta={
<>
<PrStatePill pr={detail} />
- <span className={headStyles.ref} title={detail.headRefName}>
+ <span {...stylex.props(headStyles.ref)} title={detail.headRefName}>
{detail.headRefName}
</span>
<Icon icon={ArrowRightIcon} size={11} />
@@ -122,7 +122,7 @@ const Header = memo<HeaderProps>(
onOpenChange={setBasePickerOpen}
>
<span
- className={cx(headStyles.ref, headStyles.refButton)}
+ {...stylex.props(headStyles.ref, headStyles.refButton)}
role={'button'}
tabIndex={0}
title={t('workingPanel.pr.header.changeBase')}
@@ -132,16 +132,16 @@ const Header = memo<HeaderProps>(
</span>
</DropdownMenu>
) : (
- <span className={headStyles.ref} title={detail.baseRefName}>
+ <span {...stylex.props(headStyles.ref)} title={detail.baseRefName}>
{detail.baseRefName}
</span>
)}
{activityLoaded && (
<span>Β· {t('workingPanel.pr.header.commits', { count: detail.commits.length })}</span>
)}
- <span className={headStyles.stats}>
- <span className={rowStyles.changeAdditions}>+{detail.additions}</span>{' '}
- <span className={rowStyles.changeDeletions}>βˆ’{detail.deletions}</span>
+ <span {...stylex.props(headStyles.stats)}>
+ <span {...stylex.props(rowStyles.changeAdditions)}>+{detail.additions}</span>{' '}
+ <span {...stylex.props(rowStyles.changeDeletions)}>βˆ’{detail.deletions}</span>
</span>
</>
}
diff --git a/src/features/Conversation/WorkingSidebar/PullRequest/MergeDock.tsx b/src/features/Conversation/WorkingSidebar/PullRequest/MergeDock.tsx
index ec2777a218a..1f42e0e1661 100644
--- a/src/features/Conversation/WorkingSidebar/PullRequest/MergeDock.tsx
+++ b/src/features/Conversation/WorkingSidebar/PullRequest/MergeDock.tsx
@@ -1,11 +1,16 @@
import type { DeviceGitPullRequestAction, DeviceGitPullRequestDetail } from '@lobechat/types';
-import { Button, createStaticStyles, cx, Flexbox, Icon, ScrollArea } from '@lobehub/ui';
+import { Button, Flexbox, Icon, ScrollArea } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { ArrowUpIcon, ChevronRightIcon } from 'lucide-react';
import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import { sx } from '@/styles/sx';
+
import ChecksList from './ChecksList';
import DockActionButton from './DockActionButton';
+import { failedChecksMarker } from './markers.stylex';
import { type DockAction, type MergeDockInput, resolveMergeDock } from './mergeDockData';
import { readMergeMethod, writeMergeMethod } from './mergeMethodStorage';
import { DOCK_ICON, TONE_COLOR, type TranslateKey } from './prVisual';
@@ -20,90 +25,71 @@ const BUSY_MAP: Partial<Record<PullRequestBusy, NonNullable<MergeDockInput['ui']
const UPDATE_BRANCH: DockAction = { kind: 'updateBranch', tone: 'success' };
-const styles = createStaticStyles(({ css, cssVar }) => ({
- actionBar: css`
- flex-wrap: wrap;
- padding-block-start: 10px;
- `,
- checks: css`
- margin-inline-start: 22px;
-
- > summary {
- cursor: pointer;
-
- display: flex;
- gap: 4px;
- align-items: center;
-
- font-size: 12px;
- line-height: 18px;
- color: ${cssVar.colorTextTertiary};
- list-style: none;
-
- &::-webkit-details-marker {
- display: none;
- }
- }
-
- &[open] > summary svg {
- transform: rotate(90deg);
- }
- `,
- checksList: css`
- max-height: min(240px, 35vh);
- `,
- dock: css`
- flex-shrink: 0;
-
- padding-block: 10px 12px;
- padding-inline: 16px;
- border-block-start: 1px solid ${cssVar.colorBorderSecondary};
-
- background: ${cssVar.colorBgContainer};
- `,
- local: css`
- flex-shrink: 0;
-
- padding-block: 10px;
- padding-inline: 16px;
- border-block-start: 1px solid ${cssVar.colorBorderSecondary};
-
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
- `,
- headline: css`
- overflow: hidden;
- flex: 1;
-
- min-width: 0;
-
- font-size: 13px;
- font-weight: 600;
- line-height: 20px;
- color: ${cssVar.colorText};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- headlineWrap: css`
- overflow-wrap: anywhere;
- white-space: normal;
- `,
- icon: css`
- flex-shrink: 0;
- `,
- sub: css`
- padding-inline-start: 22px;
-
- font-size: 12px;
- line-height: 18px;
- color: ${cssVar.colorTextTertiary};
- overflow-wrap: anywhere;
- `,
- trailing: css`
- flex-shrink: 0;
- margin-inline-end: -6px;
- `,
-}));
+const styles = stylex.create({
+ actionBar: { flexWrap: 'wrap', paddingBlockStart: '10px' },
+ checks: { marginInlineStart: '22px' },
+ checksChevron: {
+ transform: {
+ default: null,
+ [stylex.when.ancestor(':is([open])', failedChecksMarker)]: 'rotate(90deg)',
+ },
+ },
+ checksList: { maxHeight: 'min(240px, 35vh)' },
+ checksSummary: {
+ cursor: 'pointer',
+ display: { 'default': 'flex', '::-webkit-details-marker': 'none' },
+ gap: '4px',
+ alignItems: 'center',
+ fontSize: '12px',
+ lineHeight: '18px',
+ color: cssVar.colorTextTertiary,
+ listStyleType: 'none',
+ listStyleImage: 'none',
+ listStylePosition: 'outside',
+ },
+ dock: {
+ flexShrink: 0,
+ paddingBlockStart: '10px',
+ paddingBlockEnd: '12px',
+ paddingInline: '16px',
+ borderBlockStartWidth: '1px',
+ borderBlockStartStyle: 'solid',
+ borderBlockStartColor: cssVar.colorBorderSecondary,
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+ headline: {
+ overflow: 'hidden',
+ flex: '1',
+ minWidth: 0,
+ fontSize: '13px',
+ fontWeight: 600,
+ lineHeight: '20px',
+ color: cssVar.colorText,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ headlineWrap: { overflowWrap: 'anywhere', whiteSpace: 'normal' },
+ icon: { flexShrink: 0 },
+ local: {
+ flexShrink: 0,
+ paddingBlock: '10px',
+ paddingInline: '16px',
+ borderBlockStartWidth: '1px',
+ borderBlockStartStyle: 'solid',
+ borderBlockStartColor: cssVar.colorBorderSecondary,
+ fontSize: '12px',
+ color: cssVar.colorTextSecondary,
+ },
+ sub: {
+ paddingInlineStart: '22px',
+ fontSize: '12px',
+ lineHeight: '18px',
+ color: cssVar.colorTextTertiary,
+ overflowWrap: 'anywhere',
+ },
+ trailing: { flexShrink: 0, marginInlineEnd: '-6px' },
+});
interface MergeDockProps {
busy?: PullRequestBusy;
@@ -145,7 +131,7 @@ const MergeDock = memo<MergeDockProps>(
<Flexbox
horizontal
align={'center'}
- className={styles.local}
+ {...stylex.props(styles.local)}
gap={8}
justify={'space-between'}
>
@@ -162,24 +148,26 @@ const MergeDock = memo<MergeDockProps>(
</Button>
</Flexbox>
)}
- <div className={styles.dock}>
+ <div {...stylex.props(styles.dock)}>
<Flexbox horizontal align={'flex-start'} gap={8}>
<Icon
- className={styles.icon}
color={TONE_COLOR[status.tone]}
icon={DOCK_ICON[status.icon]}
size={14}
spin={status.icon === 'spinner'}
- style={{ marginBlockStart: 3 }}
+ {...sx(styles.icon, { marginBlockStart: 3 })}
/>
<span
- className={cx(styles.headline, isError && styles.headlineWrap)}
- style={isError ? { color: TONE_COLOR.error } : undefined}
+ {...sx(
+ styles.headline,
+ isError && styles.headlineWrap,
+ isError ? { color: TONE_COLOR.error } : undefined,
+ )}
>
{tr(status.labelKey, status.labelParams)}
</span>
{isError && (
- <Flexbox horizontal className={styles.trailing} gap={2}>
+ <Flexbox horizontal className={stylex.props(styles.trailing).className} gap={2}>
<Button size={'small'} type={'text'} onClick={onDismissError}>
{t('workingPanel.pr.dismiss')}
</Button>
@@ -190,7 +178,7 @@ const MergeDock = memo<MergeDockProps>(
)}
{status.key === 'autoMerge' && (
<Button
- className={styles.trailing}
+ className={stylex.props(styles.trailing).className}
disabled={contextLoading}
loading={busy === 'disableAutoMerge'}
size={'small'}
@@ -203,9 +191,9 @@ const MergeDock = memo<MergeDockProps>(
</Flexbox>
{model.reasons.length > 0 &&
(hasFailedChecks ? (
- <details className={styles.checks}>
- <summary>
- <Icon icon={ChevronRightIcon} size={12} />
+ <details {...stylex.props(styles.checks, failedChecksMarker)}>
+ <summary {...stylex.props(styles.checksSummary)}>
+ <Icon {...stylex.props(styles.checksChevron)} icon={ChevronRightIcon} size={12} />
{reasons}
</summary>
<ScrollArea
@@ -214,7 +202,7 @@ const MergeDock = memo<MergeDockProps>(
style={{ marginBlockStart: 6 }}
viewportProps={{
'aria-label': t('workingPanel.pr.section.checks'),
- 'className': styles.checksList,
+ 'className': stylex.props(styles.checksList).className,
'role': 'region',
'tabIndex': 0,
}}
@@ -223,11 +211,13 @@ const MergeDock = memo<MergeDockProps>(
</ScrollArea>
</details>
) : (
- <div className={styles.sub}>{reasons}</div>
+ <div {...stylex.props(styles.sub)}>{reasons}</div>
))}
- {model.hintKey && <div className={styles.sub}>{tr(model.hintKey, model.hintParams)}</div>}
+ {model.hintKey && (
+ <div {...stylex.props(styles.sub)}>{tr(model.hintKey, model.hintParams)}</div>
+ )}
{model.action && (
- <Flexbox horizontal align={'center'} className={styles.actionBar} gap={8}>
+ <Flexbox horizontal align={'center'} {...stylex.props(styles.actionBar)} gap={8}>
{model.showUpdateBranch && (
<DockActionButton
secondary
diff --git a/src/features/Conversation/WorkingSidebar/PullRequest/Sections.tsx b/src/features/Conversation/WorkingSidebar/PullRequest/Sections.tsx
index 59cff66dbaf..8f6b0c2ea22 100644
--- a/src/features/Conversation/WorkingSidebar/PullRequest/Sections.tsx
+++ b/src/features/Conversation/WorkingSidebar/PullRequest/Sections.tsx
@@ -3,16 +3,10 @@ import type {
DeviceGitPullRequestActivity,
DeviceGitPullRequestDetail,
} from '@lobechat/types';
-import {
- Button,
- createStaticStyles,
- cssVar,
- cx,
- Flexbox,
- Icon,
- Markdown,
- Skeleton,
-} from '@lobehub/ui';
+// oxlint-disable-next-line stylex-migration/no-emotion-styles -- Markdown output gets no className
+import { Button, createStaticStyles, Flexbox, Icon, Markdown, Skeleton } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import {
ChevronDownIcon,
ChevronRightIcon,
@@ -23,24 +17,30 @@ import { memo, type ReactNode, useState } from 'react';
import { useTranslation } from 'react-i18next';
import type { GitReplicaReadResult } from '@/store/device';
+import { sx } from '@/styles/sx';
import { ChevronRight, OverviewRow, rowStyles } from '../Overview/OverviewRow';
-import { sectionStyles } from '../Overview/sectionStyles';
+import { sectionProps, sectionStyles } from '../Overview/sectionStyles';
import ActivityTimeline from './ActivityTimeline';
import ChecksList from './ChecksList';
import { timeAgo } from './prVisual';
import type { PullRequestBusy } from './usePullRequestActions';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- body: css`
- overflow: hidden;
-
- min-width: 0;
- padding-block: 2px 6px;
- padding-inline: 8px;
-
- overflow-wrap: anywhere;
+const styles = stylex.create({
+ body: {
+ overflow: 'hidden',
+ minWidth: 0,
+ paddingBlockStart: '2px',
+ paddingBlockEnd: '6px',
+ paddingInline: '8px',
+ overflowWrap: 'anywhere',
+ },
+ header: { cursor: 'pointer', userSelect: 'none', gap: '6px' },
+ sha: { fontFamily: cssVar.fontFamilyCode },
+});
+const fallback = createStaticStyles(({ css }) => ({
+ body: css`
table {
overflow-x: auto;
display: block;
@@ -57,14 +57,6 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
max-width: 100%;
}
`,
- header: css`
- cursor: pointer;
- user-select: none;
- gap: 6px;
- `,
- sha: css`
- font-family: ${cssVar.fontFamilyCode};
- `,
}));
interface SectionProps {
@@ -76,12 +68,12 @@ interface SectionProps {
}
const Section = memo<SectionProps>(({ children, count, onToggle, open = true, title }) => (
- <Flexbox className={sectionStyles.section}>
+ <Flexbox {...sectionProps(true)}>
<Flexbox
horizontal
align={'center'}
role={onToggle ? 'button' : undefined}
- className={cx(
+ {...stylex.props(
sectionStyles.sectionHeader,
sectionStyles.sectionTitle,
onToggle && styles.header,
@@ -90,7 +82,7 @@ const Section = memo<SectionProps>(({ children, count, onToggle, open = true, ti
>
{onToggle && <Icon icon={open ? ChevronDownIcon : ChevronRightIcon} size={12} />}
{title}
- {count !== undefined && <span className={sectionStyles.count}>{count}</span>}
+ {count !== undefined && <span {...stylex.props(sectionStyles.count)}>{count}</span>}
</Flexbox>
{open && children}
</Flexbox>
@@ -160,7 +152,7 @@ const Sections = memo<SectionsProps>(
title={t('workingPanel.pr.section.description')}
onToggle={toggle('description')}
>
- <Markdown className={styles.body} fontSize={13} variant={'chat'}>
+ <Markdown fontSize={13} variant={'chat'} {...sx(styles.body, fallback.body)}>
{detail.body}
</Markdown>
</Section>
@@ -171,8 +163,8 @@ const Sections = memo<SectionsProps>(
value={t('workingPanel.pr.files.openReview')}
trailing={
<>
- <span className={rowStyles.changeAdditions}>+{detail.additions}</span>
- <span className={rowStyles.changeDeletions}>βˆ’{detail.deletions}</span>
+ <span {...stylex.props(rowStyles.changeAdditions)}>+{detail.additions}</span>
+ <span {...stylex.props(rowStyles.changeDeletions)}>βˆ’{detail.deletions}</span>
<ChevronRight />
</>
}
@@ -206,7 +198,7 @@ const Sections = memo<SectionsProps>(
value={commit.message.split('\n')[0]}
trailing={
<>
- <span className={styles.sha}>{commit.sha.slice(0, 7)}</span>
+ <span {...stylex.props(styles.sha)}>{commit.sha.slice(0, 7)}</span>
{timeAgo(commit.committedAt)}
</>
}
diff --git a/src/features/Conversation/WorkingSidebar/PullRequest/Skeleton.tsx b/src/features/Conversation/WorkingSidebar/PullRequest/Skeleton.tsx
index 93d22f4d648..4edd0c0e999 100644
--- a/src/features/Conversation/WorkingSidebar/PullRequest/Skeleton.tsx
+++ b/src/features/Conversation/WorkingSidebar/PullRequest/Skeleton.tsx
@@ -1,34 +1,29 @@
import type { DeviceGitLinkedPullRequest } from '@lobechat/types';
-import { createStaticStyles, Flexbox, Skeleton } from '@lobehub/ui';
+import { Flexbox, Skeleton } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { memo } from 'react';
-import { sectionStyles } from '../Overview/sectionStyles';
+import { sectionProps, sectionStyles } from '../Overview/sectionStyles';
import PrHead, { PrStatePill, PrTitle } from './Head';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- dock: css`
- flex-shrink: 0;
- padding-block: 8px 10px;
- padding-inline: 8px;
- border-block-start: 1px solid ${cssVar.colorBorderSecondary};
- `,
- root: css`
- flex: 1;
- min-height: 0;
- `,
- row: css`
- min-height: 32px;
- padding-block: 5px;
- padding-inline: 8px;
- `,
- sectionBody: css`
- padding-block: 2px 6px;
- padding-inline: 8px;
- `,
-}));
+const styles = stylex.create({
+ dock: {
+ flexShrink: 0,
+ paddingBlockStart: '8px',
+ paddingBlockEnd: '10px',
+ paddingInline: '8px',
+ borderBlockStartWidth: '1px',
+ borderBlockStartStyle: 'solid',
+ borderBlockStartColor: cssVar.colorBorderSecondary,
+ },
+ root: { flex: '1', minHeight: '0' },
+ row: { minHeight: '32px', paddingBlock: '5px', paddingInline: '8px' },
+ sectionBody: { paddingBlockStart: '2px', paddingBlockEnd: '6px', paddingInline: '8px' },
+});
const Row = ({ trailing = 48 }: { trailing?: number }) => (
- <Flexbox horizontal align={'center'} className={styles.row} gap={8}>
+ <Flexbox horizontal align={'center'} className={stylex.props(styles.row).className} gap={8}>
<Skeleton height={14} radius={4} width={14} />
<Skeleton.Text width={'55%'} />
<Skeleton height={12} radius={4} style={{ marginInlineStart: 'auto' }} width={trailing} />
@@ -36,15 +31,15 @@ const Row = ({ trailing = 48 }: { trailing?: number }) => (
);
const SectionTitle = ({ width = 64 }: { width?: number }) => (
- <div className={sectionStyles.sectionHeader}>
+ <div {...stylex.props(sectionStyles.sectionHeader)}>
<Skeleton height={10} radius={4} width={width} />
</div>
);
const PullRequestSkeleton = memo(({ summary }: { summary?: DeviceGitLinkedPullRequest }) => {
return (
- <Flexbox className={styles.root}>
- <Flexbox className={styles.root}>
+ <Flexbox className={stylex.props(styles.root).className}>
+ <Flexbox className={stylex.props(styles.root).className}>
<PrHead
meta={
<>
@@ -65,26 +60,26 @@ const PullRequestSkeleton = memo(({ summary }: { summary?: DeviceGitLinkedPullRe
)
}
/>
- <Flexbox className={sectionStyles.section}>
+ <Flexbox {...sectionProps()}>
<SectionTitle width={72} />
- <div className={styles.sectionBody}>
+ <div {...stylex.props(styles.sectionBody)}>
<Skeleton.Text fontSize={13} rows={3} width={['100%', '88%', '46%']} />
</div>
</Flexbox>
- <Flexbox className={sectionStyles.section}>
+ <Flexbox {...sectionProps()}>
<SectionTitle width={40} />
<Row trailing={72} />
</Flexbox>
- <Flexbox className={sectionStyles.section}>
+ <Flexbox {...sectionProps()}>
<SectionTitle width={56} />
</Flexbox>
- <Flexbox className={sectionStyles.section}>
+ <Flexbox {...sectionProps()}>
<SectionTitle width={52} />
<Row />
<Row />
</Flexbox>
</Flexbox>
- <div className={styles.dock}>
+ <div {...stylex.props(styles.dock)}>
<Row trailing={40} />
<Flexbox
horizontal
diff --git a/src/features/Conversation/WorkingSidebar/PullRequest/index.tsx b/src/features/Conversation/WorkingSidebar/PullRequest/index.tsx
index ea49935dfa1..13451b02b58 100644
--- a/src/features/Conversation/WorkingSidebar/PullRequest/index.tsx
+++ b/src/features/Conversation/WorkingSidebar/PullRequest/index.tsx
@@ -1,5 +1,7 @@
import type { DeviceGitLinkedPullRequest } from '@lobechat/types';
-import { Button, createStaticStyles, cssVar, Empty, Flexbox, Icon, ScrollArea } from '@lobehub/ui';
+import { Button, Empty, Flexbox, Icon, ScrollArea } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { GlobeIcon, RefreshCwIcon, TriangleAlertIcon } from 'lucide-react';
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -13,7 +15,7 @@ import {
} from '@/store/device';
import { OverviewRow } from '../Overview/OverviewRow';
-import { sectionStyles } from '../Overview/sectionStyles';
+import { sectionProps } from '../Overview/sectionStyles';
import { resolvePullRequestActionLock } from './actionLock';
import Header from './Header';
import MergeDock from './MergeDock';
@@ -22,23 +24,12 @@ import Sections from './Sections';
import PullRequestSkeleton from './Skeleton';
import { usePullRequestActions } from './usePullRequestActions';
-const styles = createStaticStyles(({ css }) => ({
- root: css`
- flex: 1;
- min-height: 0;
- `,
- scroll: css`
- overflow: hidden;
- flex: 1;
- min-height: 0;
- `,
- scrollContent: css`
- padding-block: 0 10px;
- `,
- viewport: css`
- overflow-x: hidden;
- `,
-}));
+const styles = stylex.create({
+ root: { flex: '1', minHeight: '0' },
+ scroll: { overflow: 'hidden', flex: '1', minHeight: '0' },
+ scrollContent: { paddingBlockStart: '0', paddingBlockEnd: '10px' },
+ viewport: { overflowX: 'hidden' },
+});
interface PullRequestProps {
active: boolean;
@@ -133,7 +124,7 @@ const PullRequest = memo<PullRequestProps>(
}, [data?.detail, context, activity.data]);
const externalUrl = detail?.url ?? url;
const loadError = (error: unknown, onRetry: () => void) => (
- <Flexbox className={sectionStyles.section}>
+ <Flexbox {...sectionProps()}>
<OverviewRow
danger
icon={TriangleAlertIcon}
@@ -188,13 +179,16 @@ const PullRequest = memo<PullRequestProps>(
: undefined;
return (
- <Flexbox className={styles.root}>
+ <Flexbox className={stylex.props(styles.root).className}>
<ScrollArea
disableContentFit
scrollFade
- className={styles.scroll}
- contentProps={{ className: styles.scrollContent }}
- viewportProps={{ className: styles.viewport, style: { overflowX: 'hidden' } }}
+ className={stylex.props(styles.scroll).className}
+ contentProps={{ className: stylex.props(styles.scrollContent).className }}
+ viewportProps={{
+ className: stylex.props(styles.viewport).className,
+ style: { overflowX: 'hidden' },
+ }}
>
{/* The persisted PR still paints, but stays locked until a live read lands. */}
{refreshFailed &&
diff --git a/src/features/Conversation/WorkingSidebar/PullRequest/markers.stylex.ts b/src/features/Conversation/WorkingSidebar/PullRequest/markers.stylex.ts
new file mode 100644
index 00000000000..a5db2a68e83
--- /dev/null
+++ b/src/features/Conversation/WorkingSidebar/PullRequest/markers.stylex.ts
@@ -0,0 +1,3 @@
+import * as stylex from '@stylexjs/stylex';
+
+export const failedChecksMarker = stylex.defineMarker();
diff --git a/src/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.tsx b/src/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.tsx
index 1d46d324ad3..8c88e93a47a 100644
--- a/src/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.tsx
+++ b/src/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.tsx
@@ -4,19 +4,10 @@ import {
buildAgentSkillIdentifier,
EMPTY_ARRAY,
} from '@lobechat/const';
-import {
- ActionIcon,
- Center,
- confirmModal,
- createStaticStyles,
- cx,
- Empty,
- Flexbox,
- Spin,
- Text,
- toast,
-} from '@lobehub/ui';
+import { ActionIcon, Center, confirmModal, Empty, Flexbox, Spin, Text, toast } from '@lobehub/ui';
import { SkillsIcon } from '@lobehub/ui/icons';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
import type { LucideIcon } from 'lucide-react';
@@ -66,65 +57,38 @@ dayjs.extend(relativeTime);
export type ResourceFilter = 'skills' | 'documents' | 'web';
type DocumentOpenMode = 'portal' | 'route';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- container: css`
- cursor: pointer;
- padding: 12px;
- border-radius: 8px;
- background: ${cssVar.colorFillTertiary};
-
- &:hover {
- background: ${cssVar.colorFillSecondary};
- }
- `,
- containerActive: css`
- background: ${cssVar.colorFillSecondary};
- `,
- description: css`
- font-size: 12px;
- line-height: 1.5;
- color: ${cssVar.colorTextSecondary};
- `,
- meta: css`
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
- `,
- pillActive: css`
- font-weight: 500;
- color: ${cssVar.colorText};
- background: ${cssVar.colorFillSecondary};
-
- &:hover {
- background: ${cssVar.colorFillSecondary};
- }
- `,
- pillTab: css`
- cursor: pointer;
- user-select: none;
-
- padding-block: 4px;
- padding-inline: 12px;
- border-radius: 999px;
-
- font-size: 12px;
- line-height: 1.4;
- color: ${cssVar.colorTextSecondary};
-
- background: transparent;
-
- transition:
- background ${cssVar.motionDurationFast} ${cssVar.motionEaseInOut},
- color ${cssVar.motionDurationFast} ${cssVar.motionEaseInOut};
-
- &:hover {
- color: ${cssVar.colorText};
- background: ${cssVar.colorFillTertiary};
- }
- `,
- title: css`
- font-weight: 500;
- `,
-}));
+const styles = stylex.create({
+ container: {
+ cursor: 'pointer',
+ padding: '12px',
+ borderRadius: '8px',
+ backgroundColor: { 'default': cssVar.colorFillTertiary, ':hover': cssVar.colorFillSecondary },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ },
+ description: { fontSize: '12px', lineHeight: 1.5, color: cssVar.colorTextSecondary },
+ meta: { fontSize: '12px', color: cssVar.colorTextTertiary },
+ pillActive: {
+ fontWeight: 500,
+ color: cssVar.colorText,
+ backgroundColor: { 'default': cssVar.colorFillSecondary, ':hover': cssVar.colorFillSecondary },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ },
+ pillTab: {
+ cursor: 'pointer',
+ userSelect: 'none',
+ paddingBlock: '4px',
+ paddingInline: '12px',
+ borderRadius: '999px',
+ fontSize: '12px',
+ lineHeight: 1.4,
+ color: { 'default': cssVar.colorTextSecondary, ':hover': cssVar.colorText },
+ backgroundColor: { 'default': 'transparent', ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ transition: `background ${cssVar.motionDurationFast} ${cssVar.motionEaseInOut},
+ color ${cssVar.motionDurationFast} ${cssVar.motionEaseInOut}`,
+ },
+ title: { fontWeight: 500 },
+});
const FILTER_OPTIONS = [
{ labelKey: 'workingPanel.resources.filter.skills', value: 'skills' },
@@ -218,14 +182,14 @@ const DocumentItem = memo<DocumentItemProps>(
<Flexbox
horizontal
align={'flex-start'}
- className={`${styles.container} ${isActive ? styles.containerActive : ''}`}
+ className={stylex.props(styles.container).className}
gap={8}
onClick={handleOpen}
>
<IconComponent size={16} style={{ flexShrink: 0, marginTop: 2 }} />
<Flexbox gap={4} style={{ flex: 1, minWidth: 0 }}>
<Flexbox horizontal align={'center'} distribution={'space-between'}>
- <Text ellipsis className={styles.title}>
+ <Text ellipsis className={stylex.props(styles.title).className}>
{title}
</Text>
{!hideDelete && (
@@ -239,11 +203,13 @@ const DocumentItem = memo<DocumentItemProps>(
)}
</Flexbox>
{description && (
- <Text className={styles.description} ellipsis={{ rows: 2 }}>
+ <Text className={stylex.props(styles.description).className} ellipsis={{ rows: 2 }}>
{description}
</Text>
)}
- {updatedAtLabel && <Text className={styles.meta}>{updatedAtLabel}</Text>}
+ {updatedAtLabel && (
+ <Text className={stylex.props(styles.meta).className}>{updatedAtLabel}</Text>
+ )}
</Flexbox>
</Flexbox>
);
@@ -738,7 +704,7 @@ const AgentDocumentsGroup = memo<AgentDocumentsGroupProps>(
return (
<div
aria-selected={active}
- className={cx(styles.pillTab, active && styles.pillActive)}
+ {...stylex.props(styles.pillTab, active && styles.pillActive)}
key={option.value}
role={'tab'}
onClick={() => setFilter(option.value)}
diff --git a/src/features/Conversation/WorkingSidebar/Review/FileItem.tsx b/src/features/Conversation/WorkingSidebar/Review/FileItem.tsx
index e898b09854e..35fc0fd1da2 100644
--- a/src/features/Conversation/WorkingSidebar/Review/FileItem.tsx
+++ b/src/features/Conversation/WorkingSidebar/Review/FileItem.tsx
@@ -6,13 +6,14 @@ import {
ActionIcon,
confirmModal,
copyToClipboard,
- createStaticStyles,
cssVar as themeCssVar,
Flexbox,
PatchDiff,
Skeleton,
toast,
} from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { CopyIcon, LocateFixedIcon, Undo2Icon } from 'lucide-react';
import path from 'path-browserify-esm';
import { memo, type MouseEvent, useCallback, useMemo } from 'react';
@@ -26,108 +27,78 @@ import type { ComposerTarget } from '../../types';
import type { DiffSelectedLineRange } from './selection';
import { buildCodeContextSelection } from './selection';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- additions: css`
- color: ${cssVar.colorSuccess};
- `,
+const styles = stylex.create({
+ additions: { color: cssVar.colorSuccess },
// Hover-revealed row actions, anchored to the right edge with a gradient
// mask that fades in from transparent β†’ row hover-bg so any path/stats
// text behind the icons softly disappears instead of being abruptly
- // overlapped.
- actions: css`
- pointer-events: none;
-
- position: absolute;
- inset-block: 0;
- inset-inline-end: -8px;
-
- align-items: center;
-
- padding-inline: 28px 0;
-
- opacity: 0;
- background:
- linear-gradient(to right, transparent 0, ${cssVar.colorFillTertiary} 28px),
- linear-gradient(to right, transparent 0, ${cssVar.colorBgContainer} 28px);
-
- transition: opacity 0.15s;
-
- [data-review-row]:hover & {
- pointer-events: auto;
- opacity: 1;
- }
- `,
- rowAction: css`
- flex: none;
- color: ${cssVar.colorTextTertiary};
- `,
- revertDanger: css`
- &:hover {
- color: ${cssVar.colorError};
- }
- `,
- deletions: css`
- color: ${cssVar.colorError};
- `,
- pending: css`
- padding-block: 8px;
- padding-inline: 12px;
- `,
- empty: css`
- padding-block: 12px;
- color: ${cssVar.colorTextTertiary};
- text-align: center;
- `,
- dir: css`
- direction: rtl;
-
- /* Only the directory portion shrinks + head-truncates. Short dirs
- sit naturally next to the filename (no awkward right-alignment);
- long dirs collapse leading segments into "…" via the RTL trick. */
- overflow: hidden;
- flex: 0 1 auto;
-
- min-width: 0;
-
- color: ${cssVar.colorTextTertiary};
- text-align: start;
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- fileName: css`
- flex: none;
- color: ${cssVar.colorText};
- white-space: nowrap;
- `,
- header: css`
- position: relative;
-
- display: flex;
- gap: 8px;
- align-items: center;
-
- width: 100%;
- min-width: 0;
-
- font-size: 12px;
- `,
- pathWrapper: css`
- overflow: hidden;
-
- /* Shrink-only (no grow): short paths stay content-sized so stats sit
- right after the filename; long paths still shrink so the dir part
- can head-truncate. */
- display: flex;
- flex: 0 1 auto;
- min-width: 0;
- `,
- stats: css`
- flex: none;
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- font-variant-numeric: tabular-nums;
- `,
-}));
+ // overlapped. The row (FileRow) is the hover marker.
+ actions: {
+ pointerEvents: { default: 'none', [stylex.when.ancestor(':hover')]: 'auto' },
+ position: 'absolute',
+ insetBlock: 0,
+ insetInlineEnd: '-8px',
+ alignItems: 'center',
+ paddingInlineStart: '28px',
+ paddingInlineEnd: 0,
+ opacity: { default: 0, [stylex.when.ancestor(':hover')]: 1 },
+ backgroundImage: `linear-gradient(to right, transparent 0, ${cssVar.colorFillTertiary} 28px), linear-gradient(to right, transparent 0, ${cssVar.colorBgContainer} 28px)`,
+ transition: 'opacity 0.15s',
+ },
+ rowAction: { flex: 'none', color: cssVar.colorTextTertiary },
+ // Composed after `rowAction`: a conditional value replaces the whole property,
+ // so the resting colour is restated here.
+ revertDanger: { color: { 'default': cssVar.colorTextTertiary, ':hover': cssVar.colorError } },
+ deletions: { color: cssVar.colorError },
+ pending: { paddingBlock: '8px', paddingInline: '12px' },
+ empty: {
+ paddingBlock: '12px',
+ color: cssVar.colorTextTertiary,
+ textAlign: 'center',
+ },
+ dir: {
+ direction: 'rtl',
+ // Only the directory portion shrinks + head-truncates. Short dirs
+ // sit naturally next to the filename (no awkward right-alignment);
+ // long dirs collapse leading segments into "…" via the RTL trick.
+ overflow: 'hidden',
+ flexGrow: '0',
+ flexShrink: '1',
+ flexBasis: 'auto',
+ minWidth: 0,
+ color: cssVar.colorTextTertiary,
+ textAlign: 'start',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ fileName: { flex: 'none', color: cssVar.colorText, whiteSpace: 'nowrap' },
+ header: {
+ position: 'relative',
+ display: 'flex',
+ gap: '8px',
+ alignItems: 'center',
+ width: '100%',
+ minWidth: 0,
+ fontSize: '12px',
+ },
+ pathWrapper: {
+ overflow: 'hidden',
+ // Shrink-only (no grow): short paths stay content-sized so stats sit
+ // right after the filename; long paths still shrink so the dir part
+ // can head-truncate.
+ display: 'flex',
+ flexGrow: '0',
+ flexShrink: '1',
+ flexBasis: 'auto',
+ minWidth: 0,
+ },
+ stats: {
+ flex: 'none',
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '12px',
+ fontVariantNumeric: 'tabular-nums',
+ },
+});
const reviewDiffUnsafeCSS = `
:host {
@@ -271,32 +242,32 @@ export const FileItemHeader = memo<FileItemHeaderProps>(
);
return (
- <div className={styles.header}>
- <span className={styles.pathWrapper} title={filePath}>
+ <div {...stylex.props(styles.header)}>
+ <span {...stylex.props(styles.pathWrapper)} title={filePath}>
{!hideDir && dir && (
// bdi keeps the dir's visual order LTR while the span is
// direction: rtl for head-side truncation of leading segments.
- <span className={styles.dir}>
+ <span {...stylex.props(styles.dir)}>
<bdi dir={'ltr'}>{dir}</bdi>
</span>
)}
- <span className={styles.fileName}>{fileName}</span>
+ <span {...stylex.props(styles.fileName)}>{fileName}</span>
</span>
- <span className={styles.stats}>
- {additions > 0 && <span className={styles.additions}>+{additions}</span>}
+ <span {...stylex.props(styles.stats)}>
+ {additions > 0 && <span {...stylex.props(styles.additions)}>+{additions}</span>}
{additions > 0 && deletions > 0 && ' '}
- {deletions > 0 && <span className={styles.deletions}>-{deletions}</span>}
+ {deletions > 0 && <span {...stylex.props(styles.deletions)}>-{deletions}</span>}
</span>
- <Flexbox horizontal align={'center'} className={styles.actions} gap={2}>
+ <Flexbox horizontal align={'center'} {...stylex.props(styles.actions)} gap={2}>
<ActionIcon
- className={styles.rowAction}
+ {...stylex.props(styles.rowAction)}
icon={CopyIcon}
size={'small'}
title={t('workingPanel.review.copyPath')}
onClick={handleCopy}
/>
<ActionIcon
- className={styles.rowAction}
+ {...stylex.props(styles.rowAction)}
data-testid="reveal-in-tree"
icon={LocateFixedIcon}
size={'small'}
@@ -305,7 +276,7 @@ export const FileItemHeader = memo<FileItemHeaderProps>(
/>
{revertContext && (
<ActionIcon
- className={`${styles.rowAction} ${styles.revertDanger}`}
+ {...stylex.props(styles.rowAction, styles.revertDanger)}
data-testid="revert-file"
disabled={revertDisabled}
icon={Undo2Icon}
@@ -405,15 +376,17 @@ const FileItemBody = memo<FileItemBodyProps>(
if (!expanded) return null;
- if (isBinary) return <div className={styles.empty}>{t('workingPanel.review.binary')}</div>;
- if (truncated) return <div className={styles.empty}>{t('workingPanel.review.tooLarge')}</div>;
+ if (isBinary)
+ return <div {...stylex.props(styles.empty)}>{t('workingPanel.review.binary')}</div>;
+ if (truncated)
+ return <div {...stylex.props(styles.empty)}>{t('workingPanel.review.tooLarge')}</div>;
if (!patch && pending)
return (
- <div aria-busy className={styles.pending} data-testid={'review-diff-pending'}>
+ <div aria-busy {...stylex.props(styles.pending)} data-testid={'review-diff-pending'}>
<Skeleton.Text rows={3} width={['80%', '60%', '70%']} />
</div>
);
- if (!patch) return <div className={styles.empty}>{t('workingPanel.review.error')}</div>;
+ if (!patch) return <div {...stylex.props(styles.empty)}>{t('workingPanel.review.error')}</div>;
return (
<PatchDiff
diff --git a/src/features/Conversation/WorkingSidebar/Review/FileRow.tsx b/src/features/Conversation/WorkingSidebar/Review/FileRow.tsx
index 651366262ef..0462be6a1a6 100644
--- a/src/features/Conversation/WorkingSidebar/Review/FileRow.tsx
+++ b/src/features/Conversation/WorkingSidebar/Review/FileRow.tsx
@@ -1,61 +1,60 @@
'use client';
import type { GitWorkingTreePatch } from '@lobechat/electron-client-ipc';
-import { createStaticStyles } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { ChevronRightIcon } from 'lucide-react';
import { AnimatePresence } from 'motion/react';
import * as m from 'motion/react-m';
import { type KeyboardEvent, memo, useCallback } from 'react';
+import { sx } from '@/styles/sx';
+
import type { ComposerTarget } from '../../types';
import FileItemBody, { FileItemHeader } from './FileItem';
import type { ReviewMode } from './useReviewPatches';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- item: css`
- /* Skip layout/paint of off-screen rows. Preserved from the previous
- implementation. */
- content-visibility: auto;
- contain-intrinsic-size: auto 32px;
- flex: none;
-
- /* Every row carries its own top border β€” separates file-from-file AND
- file-from-header without doubling up when a group is collapsed. */
- border-block-start: 1px solid ${cssVar.colorBorderSecondary};
- `,
- row: css`
- cursor: pointer;
- user-select: none;
-
- display: flex;
- gap: 6px;
- align-items: center;
-
- width: 100%;
- padding-block: 5px;
- padding-inline: 10px;
-
- transition: background 0.12s;
-
- &:hover {
- background: ${cssVar.colorFillTertiary};
- }
-
- &:focus-visible {
- outline: 2px solid ${cssVar.colorPrimary};
- outline-offset: -2px;
- }
- `,
- chevron: css`
- flex: none;
- color: ${cssVar.colorTextTertiary};
- transition: transform 0.2s;
-
- &[data-expanded='true'] {
- transform: rotate(90deg);
- }
- `,
-}));
+const styles = stylex.create({
+ item: {
+ // Skip layout/paint of off-screen rows. Preserved from the previous
+ // implementation.
+ contentVisibility: 'auto',
+ containIntrinsicSize: 'auto 32px',
+ flex: 'none',
+ // Every row carries its own top border β€” separates file-from-file AND
+ // file-from-header without doubling up when a group is collapsed. The first
+ // child of the list drops it: the list's own top border is the separator.
+ borderBlockStartWidth: { 'default': '1px', ':first-child': 'medium' },
+ borderBlockStartStyle: { 'default': 'solid', ':first-child': 'none' },
+ borderBlockStartColor: {
+ 'default': cssVar.colorBorderSecondary,
+ ':first-child': 'currentcolor',
+ },
+ },
+ row: {
+ cursor: 'pointer',
+ userSelect: 'none',
+ display: 'flex',
+ gap: '6px',
+ alignItems: 'center',
+ width: '100%',
+ paddingBlock: '5px',
+ paddingInline: '10px',
+ transition: 'background 0.12s',
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ outlineWidth: { 'default': null, ':focus-visible': '2px' },
+ outlineStyle: { 'default': null, ':focus-visible': 'solid' },
+ outlineColor: { 'default': null, ':focus-visible': cssVar.colorPrimary },
+ outlineOffset: { 'default': null, ':focus-visible': '-2px' },
+ },
+ chevron: {
+ flex: 'none',
+ color: cssVar.colorTextTertiary,
+ transition: 'transform 0.2s',
+ transform: { 'default': null, "[data-expanded='true']": 'rotate(90deg)' },
+ },
+});
interface FileRowProps {
composerTarget: ComposerTarget;
@@ -116,19 +115,22 @@ const FileRow = memo<FileRowProps>(
[onToggle],
);
return (
- <div className={styles.item} data-file-key={dataFileKey}>
+ <div {...stylex.props(styles.item)} data-file-key={dataFileKey}>
<div
data-review-row
aria-expanded={expanded}
- className={styles.row}
role={'button'}
- style={indent ? { paddingInlineStart: 10 + indent } : undefined}
+ {...sx(
+ styles.row,
+ stylex.defaultMarker(),
+ indent ? { paddingInlineStart: 10 + indent } : undefined,
+ )}
tabIndex={0}
onClick={onToggle}
onKeyDown={onKeyDown}
>
<ChevronRightIcon
- className={styles.chevron}
+ {...stylex.props(styles.chevron)}
data-expanded={expanded ? 'true' : 'false'}
size={14}
/>
diff --git a/src/features/Conversation/WorkingSidebar/Review/FileTreeNav.tsx b/src/features/Conversation/WorkingSidebar/Review/FileTreeNav.tsx
index 6c827e7151c..57132cf3841 100644
--- a/src/features/Conversation/WorkingSidebar/Review/FileTreeNav.tsx
+++ b/src/features/Conversation/WorkingSidebar/Review/FileTreeNav.tsx
@@ -1,6 +1,7 @@
'use client';
-import { createStaticStyles } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { memo, useMemo } from 'react';
import {
@@ -14,24 +15,23 @@ import { buildReviewTreeNodes, type ReviewTreeData, type ReviewTreeGroup } from
const FILE_TREE_UNSAFE_CSS = `${FOLDER_ICON_CSS}\n${HIDE_POINTER_FOCUS_RING_CSS}`;
-const styles = createStaticStyles(({ css, cssVar }) => ({
- tree: css`
- --trees-bg-override: transparent;
- --trees-border-color-override: transparent;
- --trees-selected-bg-override: ${cssVar.colorFillSecondary};
- --trees-selected-fg-override: ${cssVar.colorText};
- --trees-bg-muted-override: ${cssVar.colorFillTertiary};
- --trees-fg-override: ${cssVar.colorTextSecondary};
- --trees-fg-muted-override: ${cssVar.colorTextSecondary};
- --trees-accent-override: ${cssVar.colorPrimary};
- --trees-padding-inline-override: 0px;
- --trees-font-size-override: 12px;
- --trees-border-radius-override: 6px;
-
- flex: 1;
- min-height: 0;
- `,
-}));
+const styles = stylex.create({
+ tree: {
+ '--trees-bg-override': 'transparent',
+ '--trees-border-color-override': 'transparent',
+ '--trees-selected-bg-override': cssVar.colorFillSecondary,
+ '--trees-selected-fg-override': cssVar.colorText,
+ '--trees-bg-muted-override': cssVar.colorFillTertiary,
+ '--trees-fg-override': cssVar.colorTextSecondary,
+ '--trees-fg-muted-override': cssVar.colorTextSecondary,
+ '--trees-accent-override': cssVar.colorPrimary,
+ '--trees-padding-inline-override': '0px',
+ '--trees-font-size-override': '12px',
+ '--trees-border-radius-override': '6px',
+ 'flex': '1',
+ 'minHeight': '0',
+ },
+});
interface FileTreeNavProps {
/** itemKey of the file whose diff is currently focused β€” highlighted in the tree. */
@@ -69,7 +69,7 @@ const FileTreeNav = memo<FileTreeNavProps>(
);
return (
- <div className={styles.tree} style={treeStyleVars}>
+ <div className={stylex.props(styles.tree).className} style={treeStyleVars}>
<ExplorerTree<ReviewTreeData>
iconsColored
defaultExpandedIds={defaultExpandedIds}
diff --git a/src/features/Conversation/WorkingSidebar/Review/GroupHeader.tsx b/src/features/Conversation/WorkingSidebar/Review/GroupHeader.tsx
index 092c4e9d4ab..9ba8f7810c6 100644
--- a/src/features/Conversation/WorkingSidebar/Review/GroupHeader.tsx
+++ b/src/features/Conversation/WorkingSidebar/Review/GroupHeader.tsx
@@ -1,11 +1,13 @@
'use client';
-import { ActionIcon, createStaticStyles } from '@lobehub/ui';
+import { ActionIcon } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { ChevronRightIcon, FoldVerticalIcon, UnfoldVerticalIcon } from 'lucide-react';
import { type KeyboardEvent, memo, type MouseEvent, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
-const styles = createStaticStyles(({ css, cssVar }) => ({
+const styles = stylex.create({
// Sticky group header β€” appears once per repo (parent + each dirty submodule)
// when the working tree spans multiple repositories. Mirrors WebStorm's
// per-repo grouping: collapse chevron + name + file count + totals + branch
@@ -14,126 +16,107 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
// collapse/expand the group's rows. Top-only border (no bottom border) so
// collapsing a group can't produce a doubled-up line against the next
// header's top border.
- header: css`
- cursor: pointer;
- user-select: none;
-
- position: sticky;
- z-index: 1;
- inset-block-start: 0;
-
- display: flex;
- flex: none;
- gap: 6px;
- align-items: center;
-
- /* Fixed height accommodates the ActionIcon (size='small' is ~24px tall)
- so the header stays the same size whether or not the fold button is
- rendered. Without this, expanding/collapsing a group would jitter the
- sticky header height because the button toggles between rendered and
- not. flex:none keeps the column flex list from compressing the sticky
- header during expand/collapse. padding-inline keeps the left-edge
- alignment with file rows. */
- block-size: 32px;
- padding-inline: 10px;
-
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
-
- background: ${cssVar.colorFillQuaternary};
-
- transition: background 0.12s;
-
- /* Separate non-first groups from the preceding group's last row.
- The first header sits against the list's own top border. */
- &:not(:first-child) {
- border-block-start: 1px solid ${cssVar.colorBorderSecondary};
- }
-
- &:hover {
- background: ${cssVar.colorFillTertiary};
- }
-
- &:focus-visible {
- outline: 2px solid ${cssVar.colorPrimary};
- outline-offset: -2px;
- }
- `,
- chevron: css`
- flex: none;
- color: ${cssVar.colorTextTertiary};
- transition: transform 0.2s;
-
- &[data-expanded='true'] {
- transform: rotate(90deg);
- }
- `,
- meta: css`
- overflow: hidden;
- display: inline-flex;
- flex: 1 1 auto;
- gap: 6px;
- align-items: center;
-
- min-width: 0;
- `,
- name: css`
- overflow: hidden;
- flex: 0 1 auto;
-
- min-width: 0;
-
- font-weight: 600;
- color: ${cssVar.colorText};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- fileCount: css`
- flex-shrink: 0;
- font-variant-numeric: tabular-nums;
- color: ${cssVar.colorTextTertiary};
- `,
- stats: css`
- display: inline-flex;
- flex-shrink: 0;
- gap: 6px;
- align-items: center;
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- font-variant-numeric: tabular-nums;
- `,
- additions: css`
- color: ${cssVar.colorSuccess};
- `,
- deletions: css`
- color: ${cssVar.colorError};
- `,
- branch: css`
- overflow: hidden;
- flex: 0 1 auto;
-
- min-width: 0;
-
- font-family: ${cssVar.fontFamilyCode};
- color: ${cssVar.colorTextTertiary};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
+ header: {
+ cursor: 'pointer',
+ userSelect: 'none',
+ position: 'sticky',
+ zIndex: 1,
+ insetBlockStart: 0,
+ display: 'flex',
+ flex: 'none',
+ gap: '6px',
+ alignItems: 'center',
+ // Fixed height accommodates the ActionIcon (size='small' is ~24px tall)
+ // so the header stays the same size whether or not the fold button is
+ // rendered. Without this, expanding/collapsing a group would jitter the
+ // sticky header height because the button toggles between rendered and
+ // not. flex:none keeps the column flex list from compressing the sticky
+ // header during expand/collapse. padding-inline keeps the left-edge
+ // alignment with file rows.
+ blockSize: '32px',
+ paddingInline: '10px',
+ fontSize: '12px',
+ color: cssVar.colorTextSecondary,
+ transition: 'background 0.12s',
+ backgroundColor: { 'default': cssVar.colorFillQuaternary, ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ // Separate non-first groups from the preceding group's last row.
+ // The first header sits against the list's own top border.
+ borderBlockStartWidth: { 'default': null, ':not(:first-child)': '1px' },
+ borderBlockStartStyle: { 'default': null, ':not(:first-child)': 'solid' },
+ borderBlockStartColor: { 'default': null, ':not(:first-child)': cssVar.colorBorderSecondary },
+ outlineWidth: { 'default': null, ':focus-visible': '2px' },
+ outlineStyle: { 'default': null, ':focus-visible': 'solid' },
+ outlineColor: { 'default': null, ':focus-visible': cssVar.colorPrimary },
+ outlineOffset: { 'default': null, ':focus-visible': '-2px' },
+ },
+ chevron: {
+ flex: 'none',
+ color: cssVar.colorTextTertiary,
+ transition: 'transform 0.2s',
+ transform: { 'default': null, "[data-expanded='true']": 'rotate(90deg)' },
+ },
+ meta: {
+ overflow: 'hidden',
+ display: 'inline-flex',
+ flexGrow: '1',
+ flexShrink: '1',
+ flexBasis: 'auto',
+ gap: '6px',
+ alignItems: 'center',
+ minWidth: 0,
+ },
+ name: {
+ overflow: 'hidden',
+ flexGrow: '0',
+ flexShrink: '1',
+ flexBasis: 'auto',
+ minWidth: 0,
+ fontWeight: 600,
+ color: cssVar.colorText,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ fileCount: {
+ flexShrink: 0,
+ fontVariantNumeric: 'tabular-nums',
+ color: cssVar.colorTextTertiary,
+ },
+ stats: {
+ display: 'inline-flex',
+ flexShrink: 0,
+ gap: '6px',
+ alignItems: 'center',
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '12px',
+ fontVariantNumeric: 'tabular-nums',
+ },
+ additions: { color: cssVar.colorSuccess },
+ deletions: { color: cssVar.colorError },
+ branch: {
+ overflow: 'hidden',
+ flexGrow: '0',
+ flexShrink: '1',
+ flexBasis: 'auto',
+ minWidth: 0,
+ fontFamily: cssVar.fontFamilyCode,
+ color: cssVar.colorTextTertiary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
// Hover-revealed fold-all-diffs button. Uses the standard ActionIcon, so
// hover/focus visuals match the rest of the panel β€” we just gate visibility
// via opacity bound to the parent header's hover/focus-within state.
- foldButton: css`
- margin-inline-start: auto;
- opacity: 0;
- transition: opacity 0.15s;
-
- [data-review-group-header]:hover &,
- [data-review-group-header]:focus-within & {
- opacity: 1;
- }
- `,
-}));
+ foldButton: {
+ marginInlineStart: 'auto',
+ opacity: {
+ default: 0,
+ [stylex.when.ancestor(':hover')]: 1,
+ [stylex.when.ancestor(':focus-within')]: 1,
+ },
+ transition: 'opacity 0.15s',
+ },
+});
export interface GroupHeaderProps {
branch?: string;
@@ -187,31 +170,35 @@ const GroupHeader = memo<GroupHeaderProps>(
return (
<div
aria-expanded={!collapsed}
- className={styles.header}
+ {...stylex.props(styles.header, stylex.defaultMarker())}
data-review-group-header={''}
role={'button'}
tabIndex={0}
onClick={onToggleCollapsed}
onKeyDown={handleKeyDown}
>
- <div className={styles.meta}>
+ <div {...stylex.props(styles.meta)}>
<ChevronRightIcon
- className={styles.chevron}
+ {...stylex.props(styles.chevron)}
data-expanded={collapsed ? 'false' : 'true'}
size={14}
/>
- <span className={styles.name}>{name}</span>
- <span className={styles.fileCount}>
+ <span {...stylex.props(styles.name)}>{name}</span>
+ <span {...stylex.props(styles.fileCount)}>
{t('workingPanel.review.group.fileCount', { count: patchCount })}
</span>
{(totalAdditions > 0 || totalDeletions > 0) && (
- <span className={styles.stats}>
- {totalAdditions > 0 && <span className={styles.additions}>+{totalAdditions}</span>}
- {totalDeletions > 0 && <span className={styles.deletions}>-{totalDeletions}</span>}
+ <span {...stylex.props(styles.stats)}>
+ {totalAdditions > 0 && (
+ <span {...stylex.props(styles.additions)}>+{totalAdditions}</span>
+ )}
+ {totalDeletions > 0 && (
+ <span {...stylex.props(styles.deletions)}>-{totalDeletions}</span>
+ )}
</span>
)}
{branch && (
- <span className={styles.branch} title={branch}>
+ <span {...stylex.props(styles.branch)} title={branch}>
{branch}
</span>
)}
@@ -220,7 +207,7 @@ const GroupHeader = memo<GroupHeaderProps>(
<ActionIcon
aria-label={foldLabel}
aria-pressed={diffsAllExpanded}
- className={styles.foldButton}
+ {...stylex.props(styles.foldButton)}
icon={diffsAllExpanded ? FoldVerticalIcon : UnfoldVerticalIcon}
size={'small'}
title={foldLabel}
diff --git a/src/features/Conversation/WorkingSidebar/Review/index.tsx b/src/features/Conversation/WorkingSidebar/Review/index.tsx
index 13b2a87fe0f..39ad69b9ac4 100644
--- a/src/features/Conversation/WorkingSidebar/Review/index.tsx
+++ b/src/features/Conversation/WorkingSidebar/Review/index.tsx
@@ -4,13 +4,14 @@ import type { GitWorkingTreePatch } from '@lobechat/electron-client-ipc';
import {
ActionIcon,
Center,
- createStaticStyles,
type DropdownItem,
DropdownMenu,
Empty,
Flexbox,
Spin,
} from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import {
ArrowLeftIcon,
ChevronDownIcon,
@@ -33,6 +34,7 @@ import { useTranslation } from 'react-i18next';
import { useLocalStorageState } from '@/hooks/useLocalStorageState';
import { useFetchGitBranch } from '@/store/device';
+import { sx } from '@/styles/sx';
import type { ComposerTarget } from '../../types';
import FileRow from './FileRow';
@@ -77,157 +79,140 @@ interface ReviewProps {
workingDirectory: string;
}
-const styles = createStaticStyles(({ css, cssVar }) => ({
- caret: css`
- flex-shrink: 0;
- color: ${cssVar.colorTextTertiary};
- `,
- totalAdditions: css`
- color: ${cssVar.colorSuccess};
- `,
- totalDeletions: css`
- color: ${cssVar.colorError};
- `,
- totalStats: css`
- display: inline-flex;
- flex-shrink: 0;
- gap: 6px;
- align-items: center;
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- font-variant-numeric: tabular-nums;
- `,
+const styles = stylex.create({
+ caret: { flexShrink: 0, color: cssVar.colorTextTertiary },
+ totalAdditions: { color: cssVar.colorSuccess },
+ totalDeletions: { color: cssVar.colorError },
+ totalStats: {
+ display: 'inline-flex',
+ flexShrink: 0,
+ gap: '6px',
+ alignItems: 'center',
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '12px',
+ fontVariantNumeric: 'tabular-nums',
+ },
// Two-pane body: diff list (left, flexes) + tree-nav rail (right, fixed).
- body: css`
- overflow: hidden;
- min-height: 0;
- `,
- list: css`
- position: relative;
- min-width: 0;
- border-block: 1px solid ${cssVar.colorBorderSecondary};
-
- /* Strip the first visible row's own top border β€” the list's
- border-block-start already provides the separator under the subheader,
- so without this we'd render a doubled-up 2px line at the top. */
- & > :first-child {
- border-block-start: none;
- }
- `,
- treeRail: css`
- flex: none;
-
- width: 240px;
- min-height: 0;
- padding-block: 4px;
- border-block-start: 1px solid ${cssVar.colorBorderSecondary};
- border-inline-start: 1px solid ${cssVar.colorBorderSecondary};
- `,
- arrow: css`
- flex-shrink: 0;
- color: ${cssVar.colorTextTertiary};
- `,
- basePicker: css`
- cursor: pointer;
- user-select: none;
-
- overflow: hidden;
- display: inline-flex;
- flex: 0 1 auto;
- gap: 4px;
- align-items: center;
-
- min-width: 0;
- padding-block: 1px;
- padding-inline: 6px;
- border-radius: 4px;
-
- transition: background 0.15s;
-
- &:hover {
- background: ${cssVar.colorFillTertiary};
- }
- `,
- compareChip: css`
- overflow: hidden;
- display: inline-flex;
- flex: 0 1 auto;
- gap: 6px;
- align-items: center;
-
- min-width: 0;
- `,
- headRefText: css`
- overflow: hidden;
- flex: 0 1 auto;
-
- min-width: 0;
- padding-inline-end: 4px;
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- refName: css`
- overflow: hidden;
- flex: 0 1 auto;
-
- min-width: 0;
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- color: ${cssVar.colorText};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- scopeChip: css`
- cursor: pointer;
- user-select: none;
-
- display: inline-flex;
- flex-shrink: 0;
- gap: 6px;
- align-items: center;
-
- padding-block: 2px;
- padding-inline: 6px;
- border-radius: 4px;
-
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
-
- transition: background 0.15s;
-
- &:hover {
- background: ${cssVar.colorFillTertiary};
- }
- `,
- subheader: css`
- display: flex;
- flex-shrink: 0;
- gap: 8px;
- align-items: center;
- justify-content: space-between;
-
- padding-block: 4px 8px;
- padding-inline: 8px;
- `,
+ body: { overflow: 'hidden', minHeight: 0 },
+ // The first row drops its own top border (see FileRow): the list's
+ // border-block-start already separates it from the subheader.
+ list: {
+ position: 'relative',
+ minWidth: 0,
+ borderBlockWidth: '1px',
+ borderBlockStyle: 'solid',
+ borderBlockColor: cssVar.colorBorderSecondary,
+ },
+ treeRail: {
+ flex: 'none',
+ width: '240px',
+ minHeight: 0,
+ paddingBlock: '4px',
+ borderBlockStartWidth: '1px',
+ borderBlockStartStyle: 'solid',
+ borderBlockStartColor: cssVar.colorBorderSecondary,
+ borderInlineStartWidth: '1px',
+ borderInlineStartStyle: 'solid',
+ borderInlineStartColor: cssVar.colorBorderSecondary,
+ },
+ arrow: { flexShrink: 0, color: cssVar.colorTextTertiary },
+ basePicker: {
+ cursor: 'pointer',
+ userSelect: 'none',
+ overflow: 'hidden',
+ display: 'inline-flex',
+ flexGrow: '0',
+ flexShrink: '1',
+ flexBasis: 'auto',
+ gap: '4px',
+ alignItems: 'center',
+ minWidth: 0,
+ paddingBlock: '1px',
+ paddingInline: '6px',
+ borderRadius: '4px',
+ transition: 'background 0.15s',
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ },
+ compareChip: {
+ overflow: 'hidden',
+ display: 'inline-flex',
+ flexGrow: '0',
+ flexShrink: '1',
+ flexBasis: 'auto',
+ gap: '6px',
+ alignItems: 'center',
+ minWidth: 0,
+ },
+ headRefText: {
+ overflow: 'hidden',
+ flexGrow: '0',
+ flexShrink: '1',
+ flexBasis: 'auto',
+ minWidth: 0,
+ paddingInlineEnd: '4px',
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '12px',
+ color: cssVar.colorTextSecondary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ refName: {
+ overflow: 'hidden',
+ flexGrow: '0',
+ flexShrink: '1',
+ flexBasis: 'auto',
+ minWidth: 0,
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '12px',
+ color: cssVar.colorText,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ scopeChip: {
+ cursor: 'pointer',
+ userSelect: 'none',
+ display: 'inline-flex',
+ flexShrink: 0,
+ gap: '6px',
+ alignItems: 'center',
+ paddingBlock: '2px',
+ paddingInline: '6px',
+ borderRadius: '4px',
+ fontSize: '12px',
+ color: cssVar.colorTextSecondary,
+ transition: 'background 0.15s',
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ },
+ subheader: {
+ display: 'flex',
+ flexShrink: 0,
+ gap: '8px',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ paddingBlockStart: '4px',
+ paddingBlockEnd: '8px',
+ paddingInline: '8px',
+ },
// Empty submodule group β€” pointer-only bump where the submodule's own
// working tree is clean. We still surface the group so the user knows the
// submodule pointer moved, just with a softer "no changes" line instead of
// a list of files.
- groupEmpty: css`
- padding-block: 6px 10px;
- padding-inline: 10px;
- border-block-start: 1px solid ${cssVar.colorBorderSecondary};
-
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
- `,
-}));
+ groupEmpty: {
+ paddingBlockStart: '6px',
+ paddingBlockEnd: '10px',
+ paddingInline: '10px',
+ borderBlockStartWidth: { 'default': '1px', ':first-child': 'medium' },
+ borderBlockStartStyle: { 'default': 'solid', ':first-child': 'none' },
+ borderBlockStartColor: {
+ 'default': cssVar.colorBorderSecondary,
+ ':first-child': 'currentcolor',
+ },
+ fontSize: '12px',
+ color: cssVar.colorTextTertiary,
+ },
+});
const Review = memo<ReviewProps>(
({ active, composerTarget, deviceId, onToggleTree, showTree, workingDirectory }) => {
@@ -519,7 +504,7 @@ const Review = memo<ReviewProps>(
return (
<Flexbox style={{ overflow: 'hidden' }} width={'100%'}>
- <div className={styles.subheader}>
+ <div {...stylex.props(styles.subheader)}>
<Flexbox
horizontal
align={'center'}
@@ -527,42 +512,42 @@ const Review = memo<ReviewProps>(
style={{ flex: '1 1 auto', minWidth: 0, overflow: 'hidden' }}
>
<DropdownMenu items={modeMenuItems} placement={'bottomLeft'}>
- <span className={styles.scopeChip} role={'button'} tabIndex={0}>
+ <span {...stylex.props(styles.scopeChip)} role={'button'} tabIndex={0}>
{mode === 'branch'
? t('workingPanel.review.mode.branch')
: t('workingPanel.review.mode.unstaged')}
- <ChevronDownIcon className={styles.caret} size={12} />
+ <ChevronDownIcon {...stylex.props(styles.caret)} size={12} />
</span>
</DropdownMenu>
{mode === 'branch' && (baseRef || headRef) && (
- <span className={styles.compareChip}>
+ <span {...stylex.props(styles.compareChip)}>
<DropdownMenu
items={baseRefMenuItems}
placement={'bottomLeft'}
onOpenChange={setBasePickerOpen}
>
- <span className={styles.basePicker} role={'button'} tabIndex={0}>
- <span className={styles.refName}>
+ <span {...stylex.props(styles.basePicker)} role={'button'} tabIndex={0}>
+ <span {...stylex.props(styles.refName)}>
{baseRef ?? t('workingPanel.review.baseRef.unresolved')}
</span>
- <ChevronDownIcon className={styles.caret} size={12} />
+ <ChevronDownIcon {...stylex.props(styles.caret)} size={12} />
</span>
</DropdownMenu>
{headRef && (
<>
- <ArrowLeftIcon className={styles.arrow} size={12} />
- <span className={styles.headRefText}>{headRef}</span>
+ <ArrowLeftIcon {...stylex.props(styles.arrow)} size={12} />
+ <span {...stylex.props(styles.headRefText)}>{headRef}</span>
</>
)}
</span>
)}
{(totals.additions > 0 || totals.deletions > 0) && (
- <span className={styles.totalStats}>
+ <span {...stylex.props(styles.totalStats)}>
{totals.additions > 0 && (
- <span className={styles.totalAdditions}>+{totals.additions}</span>
+ <span {...stylex.props(styles.totalAdditions)}>+{totals.additions}</span>
)}
{totals.deletions > 0 && (
- <span className={styles.totalDeletions}>-{totals.deletions}</span>
+ <span {...stylex.props(styles.totalDeletions)}>-{totals.deletions}</span>
)}
</span>
)}
@@ -606,8 +591,8 @@ const Review = memo<ReviewProps>(
<Empty description={emptyText} icon={GitCompareIcon} />
</Center>
) : (
- <Flexbox horizontal className={styles.body} flex={1} width={'100%'}>
- <Flexbox className={styles.list} flex={1} ref={listRef} style={{ overflow: 'auto' }}>
+ <Flexbox horizontal {...stylex.props(styles.body)} flex={1} width={'100%'}>
+ <Flexbox flex={1} ref={listRef} {...sx(styles.list, { overflow: 'auto' })}>
{groups.map((group) => {
const groupTotals = group.patches.reduce(
(acc, p) => {
@@ -652,7 +637,7 @@ const Review = memo<ReviewProps>(
!groupCollapsed &&
!group.isParent &&
group.patches.length === 0 && (
- <div className={styles.groupEmpty}>
+ <div {...stylex.props(styles.groupEmpty)}>
{t('workingPanel.review.group.submoduleClean')}
</div>
)}
@@ -686,7 +671,7 @@ const Review = memo<ReviewProps>(
})}
</Flexbox>
{showTree && (
- <Flexbox className={styles.treeRail}>
+ <Flexbox {...stylex.props(styles.treeRail)}>
<FileTreeNav
activeFileKey={activeFileKey}
groups={groups}
diff --git a/src/features/Conversation/WorkingSidebar/WorksSection/VersionList.tsx b/src/features/Conversation/WorkingSidebar/WorksSection/VersionList.tsx
index 74c42eb165f..4e5cdfd0119 100644
--- a/src/features/Conversation/WorkingSidebar/WorksSection/VersionList.tsx
+++ b/src/features/Conversation/WorkingSidebar/WorksSection/VersionList.tsx
@@ -1,5 +1,7 @@
import type { WorkVersionItem } from '@lobechat/types';
-import { Center, createStaticStyles, Flexbox, Spin, Text } from '@lobehub/ui';
+import { Center, Flexbox, Spin, Text } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -7,32 +9,26 @@ import { formatTaskItemDate } from '@/features/AgentTasks/features/formatTaskIte
import { useWorkStore, workActions, workSelectors } from '@/store/work';
import { computeWorkVersionCostDeltas, formatWorkVersionCost } from '@/utils/workVersionCost';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- context: css`
- flex-shrink: 0;
- color: ${cssVar.colorTextTertiary};
- `,
- error: css`
- padding-block: 8px;
- padding-inline: 36px 8px;
- color: ${cssVar.colorError};
- `,
- versionCost: css`
- color: ${cssVar.colorTextTertiary};
- `,
- versionList: css`
- margin-inline-start: 34px;
- padding-block: 6px 10px;
- border-block-start: 1px solid ${cssVar.colorBorderSecondary};
- `,
- versionRow: css`
- padding-block: 6px;
- font-size: 12px;
- `,
- versionTitle: css`
- color: ${cssVar.colorTextSecondary};
- `,
-}));
+const styles = stylex.create({
+ context: { flexShrink: 0, color: cssVar.colorTextTertiary },
+ error: {
+ paddingBlock: '8px',
+ paddingInlineStart: '36px',
+ paddingInlineEnd: '8px',
+ color: cssVar.colorError,
+ },
+ versionCost: { color: cssVar.colorTextTertiary },
+ versionList: {
+ marginInlineStart: '34px',
+ paddingBlockStart: '6px',
+ paddingBlockEnd: '10px',
+ borderBlockStartWidth: '1px',
+ borderBlockStartStyle: 'solid',
+ borderBlockStartColor: cssVar.colorBorderSecondary,
+ },
+ versionRow: { paddingBlock: '6px', fontSize: '12px' },
+ versionTitle: { color: cssVar.colorTextSecondary },
+});
const EMPTY_VERSIONS: WorkVersionItem[] = [];
@@ -59,12 +55,16 @@ const VersionList = memo<{ workId: string }>(({ workId }) => {
// A failed refresh keeps the settled timeline on screen.
if (stored === undefined && error) {
- return <Text className={styles.error}>{t('workingPanel.works.versionError')}</Text>;
+ return (
+ <Text className={stylex.props(styles.error).className}>
+ {t('workingPanel.works.versionError')}
+ </Text>
+ );
}
if (data.length === 0) {
return (
- <Flexbox className={styles.versionList}>
+ <Flexbox className={stylex.props(styles.versionList).className}>
<Text type={'secondary'}>{t('workingPanel.works.emptyVersions')}</Text>
</Flexbox>
);
@@ -75,7 +75,7 @@ const VersionList = memo<{ workId: string }>(({ workId }) => {
const costDeltas = computeWorkVersionCostDeltas(data);
return (
- <Flexbox className={styles.versionList}>
+ <Flexbox className={stylex.props(styles.versionList).className}>
{data.map((version) => {
const cost = formatWorkVersionCost(costDeltas.get(version.id));
const time = formatTaskItemDate(version.createdAt, {
@@ -85,13 +85,13 @@ const VersionList = memo<{ workId: string }>(({ workId }) => {
});
return (
- <Flexbox className={styles.versionRow} gap={4} key={version.id}>
+ <Flexbox className={stylex.props(styles.versionRow).className} gap={4} key={version.id}>
<Flexbox horizontal align={'center'} gap={8} justify={'space-between'}>
<Flexbox horizontal align={'center'} gap={8} style={{ minWidth: 0 }}>
<Text code fontSize={12}>
v{version.version}
</Text>
- <Text ellipsis className={styles.versionTitle}>
+ <Text ellipsis className={stylex.props(styles.versionTitle).className}>
{t(`workingPanel.works.changeType.${version.changeType}` as never)}
</Text>
</Flexbox>
@@ -99,7 +99,7 @@ const VersionList = memo<{ workId: string }>(({ workId }) => {
{cost && (
<Text
code
- className={styles.versionCost}
+ className={stylex.props(styles.versionCost).className}
fontSize={12}
title={t('workingPanel.works.versionCost', { cost })}
>
@@ -107,7 +107,7 @@ const VersionList = memo<{ workId: string }>(({ workId }) => {
</Text>
)}
{time && (
- <Text className={styles.context} type={'secondary'}>
+ <Text className={stylex.props(styles.context).className} type={'secondary'}>
{time}
</Text>
)}
diff --git a/src/features/Conversation/WorkingSidebar/WorksSection/WorkVersionHistoryCard.tsx b/src/features/Conversation/WorkingSidebar/WorksSection/WorkVersionHistoryCard.tsx
index 601dc261ebb..51f8b42a4b0 100644
--- a/src/features/Conversation/WorkingSidebar/WorksSection/WorkVersionHistoryCard.tsx
+++ b/src/features/Conversation/WorkingSidebar/WorksSection/WorkVersionHistoryCard.tsx
@@ -1,5 +1,7 @@
import type { TaskStatus, WorkListItem } from '@lobechat/types';
-import { createStaticStyles, Flexbox, Text } from '@lobehub/ui';
+import { Flexbox, Text } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { ChevronDownIcon, ChevronRightIcon } from 'lucide-react';
import { memo, useState } from 'react';
@@ -24,36 +26,28 @@ const TASK_STATUS_SET = new Set<TaskStatus>([
const toTaskStatus = (status?: string | null): TaskStatus =>
status && TASK_STATUS_SET.has(status as TaskStatus) ? (status as TaskStatus) : 'backlog';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- context: css`
- flex-shrink: 0;
- color: ${cssVar.colorTextTertiary};
- `,
- header: css`
- cursor: pointer;
- user-select: none;
- padding-block: 10px;
- padding-inline: 8px;
-
- &:hover {
- background: ${cssVar.colorFillQuaternary};
- }
- `,
- title: css`
- min-width: 0;
- font-size: 14px;
- font-weight: 500;
- `,
- toggle: css`
- flex-shrink: 0;
- `,
- workCard: css`
- overflow: hidden;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: 8px;
- background: ${cssVar.colorFillQuaternary};
- `,
-}));
+const styles = stylex.create({
+ context: { flexShrink: 0, color: cssVar.colorTextTertiary },
+ header: {
+ cursor: 'pointer',
+ userSelect: 'none',
+ paddingBlock: '10px',
+ paddingInline: '8px',
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillQuaternary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ },
+ title: { minWidth: '0', fontSize: '14px', fontWeight: 500 },
+ toggle: { flexShrink: 0 },
+ workCard: {
+ overflow: 'hidden',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: '8px',
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+});
const WorkVersionHistoryCard = memo<{ work: WorkListItem }>(({ work }) => {
const [expanded, setExpanded] = useState(false);
@@ -108,30 +102,30 @@ const WorkVersionHistoryCard = memo<{ work: WorkListItem }>(({ work }) => {
})();
return (
- <Flexbox className={styles.workCard}>
+ <Flexbox className={stylex.props(styles.workCard).className}>
<Flexbox
horizontal
align={'center'}
- className={styles.header}
+ className={stylex.props(styles.header).className}
gap={8}
onClick={() => setExpanded((value) => !value)}
>
- <ToggleIcon className={styles.toggle} size={16} />
+ <ToggleIcon className={stylex.props(styles.toggle).className} size={16} />
{work.type === 'task' ? (
<>
<TaskPriorityTag disableDropdown priority={work.task.priority} size={14} />
<TaskStatusTag disableDropdown size={14} status={toTaskStatus(work.task.status)} />
</>
) : (
- <TypeIcon className={styles.context} size={16} />
+ <TypeIcon className={stylex.props(styles.context).className} size={16} />
)}
- <Text className={styles.context} style={{ flexShrink: 0 }}>
+ <Text className={stylex.props(styles.context).className} style={{ flexShrink: 0 }}>
{label}
</Text>
{title && (
<Text
ellipsis
- className={styles.title}
+ className={stylex.props(styles.title).className}
onClick={
handleTitleClick &&
((event) => {
diff --git a/src/features/Conversation/WorkingSidebar/WorksSection/index.tsx b/src/features/Conversation/WorkingSidebar/WorksSection/index.tsx
index a4b86b99542..a1775d5c509 100644
--- a/src/features/Conversation/WorkingSidebar/WorksSection/index.tsx
+++ b/src/features/Conversation/WorkingSidebar/WorksSection/index.tsx
@@ -1,5 +1,7 @@
import type { WorkListItem } from '@lobechat/types';
-import { ActionIcon, Center, createStaticStyles, Empty, Flexbox, Spin } from '@lobehub/ui';
+import { ActionIcon, Center, Empty, Flexbox, Spin } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import isEqual from 'fast-deep-equal';
import { ClipboardListIcon, HistoryIcon, ListIcon } from 'lucide-react';
import { memo, useEffect, useMemo, useRef } from 'react';
@@ -21,23 +23,24 @@ const WORKS_VIEW_MODE_STORAGE_KEY = 'lobechat-working-panel-works-view-mode';
const EMPTY_HISTORY: WorkListItem[] = [];
-const styles = createStaticStyles(({ css, cssVar }) => ({
- container: css`
- min-height: 0;
- padding-block: 8px;
- padding-inline: 8px 12px;
- `,
- modeToolbar: css`
- flex-shrink: 0;
- align-self: flex-end;
- `,
- workCard: css`
- overflow: hidden;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: 8px;
- background: ${cssVar.colorFillQuaternary};
- `,
-}));
+const styles = stylex.create({
+ container: {
+ minHeight: '0',
+ paddingBlock: '8px',
+ paddingInlineStart: '8px',
+ paddingInlineEnd: '12px',
+ },
+ modeToolbar: { flexShrink: 0, alignSelf: 'flex-end' },
+ workCard: {
+ overflow: 'hidden',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: '8px',
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+});
const WorksModeToolbar = memo<{
mode: WorksViewMode;
@@ -46,7 +49,7 @@ const WorksModeToolbar = memo<{
const { t } = useTranslation('chat');
return (
- <Flexbox horizontal className={styles.modeToolbar} gap={4}>
+ <Flexbox horizontal className={stylex.props(styles.modeToolbar).className} gap={4}>
<ActionIcon
active={mode === 'summary'}
icon={ListIcon}
@@ -184,13 +187,17 @@ const WorksSection = memo<WorksSectionProps>(({ active = true }) => {
return mode === 'summary'
? summaryData.map((work) => (
- <WorkSummaryCard className={styles.workCard} item={work} key={work.id} />
+ <WorkSummaryCard
+ className={stylex.props(styles.workCard).className}
+ item={work}
+ key={work.id}
+ />
))
: historyData.map((work) => <WorkVersionHistoryCard key={work.id} work={work} />);
})();
return (
- <Flexbox className={styles.container} flex={1} gap={12}>
+ <Flexbox className={stylex.props(styles.container).className} flex={1} gap={12}>
<WorksModeToolbar mode={mode} setMode={setMode} />
{content}
</Flexbox>
diff --git a/src/features/Conversation/WorkingSidebar/WorkspaceTab.tsx b/src/features/Conversation/WorkingSidebar/WorkspaceTab.tsx
index 0356cd52741..e22c0792bfe 100644
--- a/src/features/Conversation/WorkingSidebar/WorkspaceTab.tsx
+++ b/src/features/Conversation/WorkingSidebar/WorkspaceTab.tsx
@@ -1,11 +1,6 @@
-import {
- type ContextMenuItem,
- ContextMenuTrigger,
- createStaticStyles,
- Icon,
- type IconProps,
- keyframes,
-} from '@lobehub/ui';
+import { type ContextMenuItem, ContextMenuTrigger, Icon, type IconProps } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { PinIcon, XIcon } from 'lucide-react';
import { memo, type MouseEvent, type ReactNode } from 'react';
@@ -19,128 +14,85 @@ const TAB_PADDING = 8;
const CLOSE_INSET = 4;
const CLOSE_SIZE = 16;
-const fadeIn = keyframes`
- from {
- opacity: 0;
- }
-
- to {
- opacity: 1;
- }
-`;
-
-const styles = createStaticStyles(({ css, cssVar }) => ({
- close: css`
- cursor: pointer;
-
- position: absolute;
- inset-block-start: 50%;
- inset-inline-end: ${CLOSE_INSET}px;
- transform: translateY(-50%);
-
- display: grid;
- place-items: center;
-
- width: ${CLOSE_SIZE}px;
- height: ${CLOSE_SIZE}px;
- padding: 0;
- border: none;
- border-radius: 4px;
-
- color: ${cssVar.colorTextTertiary};
-
- background: transparent;
-
- transition:
- color 0.15s,
- background 0.15s;
- animation: ${fadeIn} 0.15s ease-out;
-
- &:hover {
- color: ${cssVar.colorText};
- background: ${cssVar.colorFillSecondary};
- }
-
- @media (prefers-reduced-motion: reduce) {
- animation: none;
- }
- `,
- container: css`
- position: relative;
-
- display: flex;
- flex-shrink: 0;
- align-items: center;
-
- border-radius: 6px;
-
- transition: background 0.15s;
-
- &:hover {
- background: ${cssVar.colorFillSecondary};
- }
- `,
- containerActive: css`
- background: ${cssVar.colorFillTertiary};
- `,
- pinned: css`
- pointer-events: none;
-
- position: absolute;
- inset-block-start: 50%;
- inset-inline-end: 6px;
- transform: translateY(-50%);
-
- display: grid;
- place-items: center;
-
- color: ${cssVar.colorTextSecondary};
- `,
- icon: css`
- display: flex;
- flex-shrink: 0;
- `,
- label: css`
- overflow: hidden;
- min-width: 24px;
- max-width: 160px;
- text-overflow: ellipsis;
- `,
- tab: css`
- cursor: pointer;
-
- padding-block: 4px;
- padding-inline: ${TAB_PADDING}px;
- border: none;
- border-radius: 6px;
-
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
- white-space: nowrap;
-
- background: transparent;
-
- transition: color 0.15s;
-
- &:hover {
- color: ${cssVar.colorText};
- }
-
- /* attribute selector outranks the base class so the active color can't lose
- to stylesheet ordering */
- &[aria-pressed='true'] {
- color: ${cssVar.colorText};
- }
- `,
- tabTrailing: css`
- padding-inline-end: ${TRAILING_SLOT}px;
- `,
- trigger: css`
- display: flex;
- gap: 4px;
- align-items: center;
- `,
-}));
+const fadeIn = stylex.keyframes({ from: { opacity: 0 }, to: { opacity: 1 } });
+
+const styles = stylex.create({
+ close: {
+ cursor: 'pointer',
+ position: 'absolute',
+ insetBlockStart: '50%',
+ insetInlineEnd: CLOSE_INSET,
+ transform: 'translateY(-50%)',
+ display: 'grid',
+ placeItems: 'center',
+ width: CLOSE_SIZE,
+ height: CLOSE_SIZE,
+ padding: 0,
+ borderWidth: 0,
+ borderStyle: 'none',
+ borderRadius: '4px',
+ color: { 'default': cssVar.colorTextTertiary, ':hover': cssVar.colorText },
+ backgroundColor: { 'default': 'transparent', ':hover': cssVar.colorFillSecondary },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ transition: 'color 0.15s, background 0.15s',
+ animationName: { 'default': fadeIn, '@media (prefers-reduced-motion: reduce)': 'none' },
+ animationDuration: { 'default': '0.15s', '@media (prefers-reduced-motion: reduce)': '0s' },
+ animationTimingFunction: {
+ 'default': 'ease-out',
+ '@media (prefers-reduced-motion: reduce)': 'ease',
+ },
+ },
+ container: {
+ position: 'relative',
+ display: 'flex',
+ flexShrink: 0,
+ alignItems: 'center',
+ borderRadius: '6px',
+ transition: 'background 0.15s',
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillSecondary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ },
+ // Composed after `container`: a conditional value replaces the whole property,
+ // so the hover colour is restated here.
+ containerActive: {
+ backgroundColor: { 'default': cssVar.colorFillTertiary, ':hover': cssVar.colorFillSecondary },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ },
+ pinned: {
+ pointerEvents: 'none',
+ position: 'absolute',
+ insetBlockStart: '50%',
+ insetInlineEnd: '6px',
+ transform: 'translateY(-50%)',
+ display: 'grid',
+ placeItems: 'center',
+ color: cssVar.colorTextSecondary,
+ },
+ icon: { display: 'flex', flexShrink: 0 },
+ label: { overflow: 'hidden', minWidth: '24px', maxWidth: '160px', textOverflow: 'ellipsis' },
+ tab: {
+ cursor: 'pointer',
+ paddingBlock: '4px',
+ paddingInline: TAB_PADDING,
+ borderWidth: 0,
+ borderStyle: 'none',
+ borderRadius: '6px',
+ fontSize: '12px',
+ // attribute selector outranks the base class so the active color can't lose
+ // to stylesheet ordering
+ color: {
+ 'default': cssVar.colorTextTertiary,
+ ':hover': cssVar.colorText,
+ "[aria-pressed='true']": cssVar.colorText,
+ },
+ whiteSpace: 'nowrap',
+ backgroundColor: 'transparent',
+ backgroundImage: 'none',
+ transition: 'color 0.15s',
+ },
+ tabTrailing: { paddingInlineEnd: TRAILING_SLOT },
+ trigger: { display: 'flex', gap: '4px', alignItems: 'center' },
+});
interface WorkspaceTabProps {
active: boolean;
@@ -187,26 +139,32 @@ const WorkspaceTab = memo<WorkspaceTabProps>(
const content = (
<div
- className={`${styles.container} ${active ? styles.containerActive : ''}`}
+ {...stylex.props(
+ styles.container,
+ stylex.defaultMarker(),
+ active && styles.containerActive,
+ )}
data-pinned={pinned ? 'true' : undefined}
onAuxClick={handleAuxClick}
onMouseDown={handleMouseDown}
>
<button
aria-pressed={active}
- className={`${styles.tab} ${pinned || showClose ? styles.tabTrailing : ''}`}
+ {...stylex.props(styles.tab, (pinned || showClose) && styles.tabTrailing)}
data-tab-key={tabKey}
title={typeof label === 'string' ? label : undefined}
type="button"
onClick={onSelect}
>
- <span className={styles.trigger}>
- <span className={styles.icon}>{iconNode ?? <Icon icon={icon} size={14} />}</span>
- <span className={styles.label}>{label}</span>
+ <span className={stylex.props(styles.trigger).className}>
+ <span className={stylex.props(styles.icon).className}>
+ {iconNode ?? <Icon icon={icon} size={14} />}
+ </span>
+ <span className={stylex.props(styles.label).className}>{label}</span>
</span>
</button>
{pinned ? (
- <span aria-label={pinnedLabel} className={styles.pinned} role="img">
+ <span aria-label={pinnedLabel} {...stylex.props(styles.pinned)} role="img">
<Icon icon={PinIcon} size={12} />
</span>
) : showClose ? (
@@ -215,7 +173,7 @@ const WorkspaceTab = memo<WorkspaceTabProps>(
<button
data-tab-close
aria-label={closeLabel}
- className={styles.close}
+ {...stylex.props(styles.close)}
type="button"
onClick={onClose}
>
diff --git a/src/features/Conversation/WorkingSidebar/index.tsx b/src/features/Conversation/WorkingSidebar/index.tsx
index a49e1adfa50..429964875d6 100644
--- a/src/features/Conversation/WorkingSidebar/index.tsx
+++ b/src/features/Conversation/WorkingSidebar/index.tsx
@@ -1,14 +1,9 @@
import { getWorkingDirEffectivePath } from '@lobechat/types';
import { nanoid } from '@lobechat/utils';
-import {
- ActionIcon,
- createStaticStyles,
- cssVar,
- DropdownMenu,
- Flexbox,
- Skeleton,
-} from '@lobehub/ui';
+import { ActionIcon, DropdownMenu, Flexbox, Skeleton } from '@lobehub/ui';
import { SkillsIcon } from '@lobehub/ui/icons';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import {
BoxesIcon,
ClipboardListIcon,
@@ -106,89 +101,53 @@ import WorksSection from './WorksSection';
const ParamsSection = lazy(() => import('./ParamsSection'));
-const styles = createStaticStyles(({ css }) => ({
- body: css`
- overflow-y: auto;
- flex: 1;
- min-height: 0;
- `,
- close: css`
- flex-shrink: 0;
- `,
- header: css`
- flex-shrink: 0;
- min-width: 0;
- `,
- pane: css`
- overflow-y: auto;
- flex: 1;
- min-height: 0;
- `,
- paneHidden: css`
- display: none;
- `,
- paramsLoading: css`
- width: 100%;
- padding: 16px;
- `,
- add: css`
- flex-shrink: 0;
- `,
- overviewBody: css`
- overflow-y: auto;
- min-height: 0;
- `,
- overviewPanel: css`
- overflow: hidden;
- display: flex;
- flex-direction: column;
- flex-shrink: 0;
-
- max-height: calc(100% - 32px);
- margin: 16px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: 16px;
-
- background: ${cssVar.colorBgContainer};
- box-shadow: ${cssVar.boxShadowTertiary};
- `,
- overviewSlot: css`
- overflow: hidden;
- display: flex;
- flex-shrink: 0;
- align-items: flex-start;
-
- height: 100%;
-
- @container agent-chat-layout (min-width: 1200px) {
- padding-block-start: 44px;
- }
- `,
- tabs: css`
- overflow-anchor: none;
- scrollbar-width: none;
-
- overflow-x: auto;
- display: flex;
- gap: 4px;
- align-items: center;
-
- min-width: 0;
-
- &::-webkit-scrollbar {
- display: none;
- }
- `,
- /* keeps the add button glued to the last tab while the strip itself scrolls */
- tabsArea: css`
- display: flex;
- flex: 1;
- gap: 4px;
- align-items: center;
-
- min-width: 0;
- `,
-}));
+const styles = stylex.create({
+ body: { overflowY: 'auto', flex: '1', minHeight: '0' },
+ close: { flexShrink: 0 },
+ header: { flexShrink: 0, minWidth: '0' },
+ pane: { overflowY: 'auto', flex: '1', minHeight: '0' },
+ paneHidden: { display: 'none' },
+ paramsLoading: { width: '100%', padding: '16px' },
+ add: { flexShrink: 0 },
+ overviewBody: { overflowY: 'auto', minHeight: '0' },
+ overviewPanel: {
+ overflow: 'hidden',
+ display: 'flex',
+ flexDirection: 'column',
+ flexShrink: 0,
+ maxHeight: 'calc(100% - 32px)',
+ margin: '16px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: '16px',
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ boxShadow: cssVar.boxShadowTertiary,
+ },
+ overviewSlot: {
+ overflow: 'hidden',
+ display: 'flex',
+ flexShrink: 0,
+ alignItems: 'flex-start',
+ height: '100%',
+ paddingBlockStart: {
+ 'default': null,
+ '@container agent-chat-layout (min-width: 1200px)': '44px',
+ },
+ },
+ tabs: {
+ 'overflowAnchor': 'none',
+ 'scrollbarWidth': 'none',
+ 'overflowX': 'auto',
+ 'display': 'flex',
+ 'gap': '4px',
+ 'alignItems': 'center',
+ 'minWidth': '0',
+ '::-webkit-scrollbar': { display: 'none' },
+ },
+ tabsArea: { display: 'flex', flex: '1', gap: '4px', alignItems: 'center', minWidth: '0' },
+});
const REVIEW_TREE_STORAGE_KEY = 'lobechat-review-tree';
const OPEN_TABS_STORAGE_KEY = 'lobechat-working-sidebar-open-tabs-v1';
@@ -893,21 +852,21 @@ const AgentWorkingSidebar = memo<AgentWorkingSidebarProps>(({ availableWidth })
{showWorkingOverview && overviewFits && (
<m.div
animate={{ width: overviewWidth + overviewGutter }}
- className={styles.overviewSlot}
+ {...stylex.props(styles.overviewSlot)}
exit={{ transition: overviewExitTransition, width: 0 }}
initial={{ width: 0 }}
transition={OVERVIEW_TRANSITION}
>
<m.div
animate={{ opacity: 1, x: 0 }}
- className={styles.overviewPanel}
+ className={stylex.props(styles.overviewPanel).className}
exit={{ opacity: 0, transition: overviewExitTransition, x: 12 }}
initial={{ opacity: 0, x: 12 }}
role={'complementary'}
style={{ width: overviewWidth }}
transition={OVERVIEW_TRANSITION}
>
- <Flexbox className={styles.overviewBody}>
+ <Flexbox className={stylex.props(styles.overviewBody).className}>
<Overview
active
agentId={activeAgentId}
@@ -965,14 +924,14 @@ const AgentWorkingSidebar = memo<AgentWorkingSidebarProps>(({ availableWidth })
<Flexbox
horizontal
align={'center'}
- className={styles.header}
+ className={stylex.props(styles.header).className}
gap={4}
height={44}
justify={'space-between'}
paddingInline={4}
>
- <div className={styles.tabsArea}>
- <div className={styles.tabs} ref={tabsRef}>
+ <div {...stylex.props(styles.tabsArea)}>
+ <div {...stylex.props(styles.tabs)} ref={tabsRef}>
{displayedTabs.map((tab, index) => (
<WorkspaceTab
active={activeTab === tab.key}
@@ -1000,7 +959,7 @@ const AgentWorkingSidebar = memo<AgentWorkingSidebarProps>(({ availableWidth })
}}
>
<ActionIcon
- className={styles.add}
+ className={stylex.props(styles.add).className}
icon={PlusIcon}
size={DESKTOP_HEADER_ICON_SMALL_SIZE}
title={t('workingPanel.openMenu.title')}
@@ -1008,20 +967,20 @@ const AgentWorkingSidebar = memo<AgentWorkingSidebarProps>(({ availableWidth })
</DropdownMenu>
</div>
<ActionIcon
- className={styles.close}
+ className={stylex.props(styles.close).className}
icon={PanelRightCloseIcon}
size={DESKTOP_HEADER_ICON_SMALL_SIZE}
onClick={() => toggleRightPanel(false)}
/>
</Flexbox>
- <Flexbox className={styles.body} width={'100%'}>
+ <Flexbox className={stylex.props(styles.body).className} width={'100%'}>
{!contentReady && storedTab !== 'files' && activeTab !== 'files' && (
<DeferredSkeleton />
)}
<FilesPane
active={!!showRightPanel && activeTab === 'files'}
available={filesAvailable}
- className={styles.pane}
+ className={stylex.props(styles.pane).className}
contentReady={contentReady || (activeTab === 'files' && filesAvailable)}
deviceId={filesDeviceId}
directory={filesDirectory}
@@ -1033,15 +992,21 @@ const AgentWorkingSidebar = memo<AgentWorkingSidebarProps>(({ availableWidth })
<>
{commentsAvailable && (
<Flexbox
- className={activeTab === 'comments' ? styles.pane : styles.paneHidden}
style={{ overflow: 'hidden' }}
+ className={
+ stylex.props(activeTab === 'comments' ? styles.pane : styles.paneHidden)
+ .className
+ }
>
<TopicCommentsSidebar />
</Flexbox>
)}
{!!topicId && (
<Activity mode={showRightPanel && activeTab === 'search' ? 'visible' : 'hidden'}>
- <Flexbox className={styles.pane} style={{ overflow: 'hidden' }}>
+ <Flexbox
+ className={stylex.props(styles.pane).className}
+ style={{ overflow: 'hidden' }}
+ >
<TopicSearchPane
active={!!showRightPanel && activeTab === 'search'}
key={topicId}
@@ -1051,9 +1016,14 @@ const AgentWorkingSidebar = memo<AgentWorkingSidebarProps>(({ availableWidth })
</Activity>
)}
{paramsAvailable && activeTab === 'params' && (
- <Flexbox className={styles.pane}>
+ <Flexbox className={stylex.props(styles.pane).className}>
<Suspense
- fallback={<Skeleton.Text className={styles.paramsLoading} rows={6} />}
+ fallback={
+ <Skeleton.Text
+ className={stylex.props(styles.paramsLoading).className}
+ rows={6}
+ />
+ }
>
<ParamsSection />
</Suspense>
@@ -1065,7 +1035,7 @@ const AgentWorkingSidebar = memo<AgentWorkingSidebarProps>(({ availableWidth })
for ~200ms. */}
{reviewAvailable && activeTab === 'review' && retainReview && (
<Activity mode={panelVisible ? 'visible' : 'hidden'}>
- <Flexbox className={styles.pane}>
+ <Flexbox className={stylex.props(styles.pane).className}>
<Review
active={panelVisible}
composerTarget={composerTarget}
@@ -1083,7 +1053,7 @@ const AgentWorkingSidebar = memo<AgentWorkingSidebarProps>(({ availableWidth })
{...pullRequestLink}
active={!!showRightPanel && activeTab === 'pr'}
canShow={overviewFits}
- className={styles.pane}
+ className={stylex.props(styles.pane).className}
deviceId={remoteDeviceId}
pullRequest={pullRequest}
workingDirectory={workingDirectory}
@@ -1112,8 +1082,11 @@ const AgentWorkingSidebar = memo<AgentWorkingSidebarProps>(({ availableWidth })
/>
{extraTabs.map((tab) => (
<Flexbox
- className={activeTab === tab.key ? styles.pane : styles.paneHidden}
key={tab.key}
+ className={
+ stylex.props(activeTab === tab.key ? styles.pane : styles.paneHidden)
+ .className
+ }
>
{tab.pane}
</Flexbox>
@@ -1127,7 +1100,7 @@ const AgentWorkingSidebar = memo<AgentWorkingSidebarProps>(({ availableWidth })
key={resourceTab}
mode={showRightPanel && activeTab === resourceTab ? 'visible' : 'hidden'}
>
- <Flexbox className={styles.pane} width={'100%'}>
+ <Flexbox className={stylex.props(styles.pane).className} width={'100%'}>
<ResourcesSection
deviceId={remoteDeviceId}
enabled={showRightPanel && activeTab === resourceTab}
@@ -1137,7 +1110,7 @@ const AgentWorkingSidebar = memo<AgentWorkingSidebarProps>(({ availableWidth })
</Activity>
))}
<Activity mode={showRightPanel && activeTab === 'works' ? 'visible' : 'hidden'}>
- <Flexbox className={styles.pane}>
+ <Flexbox className={stylex.props(styles.pane).className}>
<WorksSection active={showRightPanel && activeTab === 'works'} />
</Flexbox>
</Activity>
diff --git a/src/features/Conversation/Workspace/index.tsx b/src/features/Conversation/Workspace/index.tsx
index df05bebdde2..27279e00236 100644
--- a/src/features/Conversation/Workspace/index.tsx
+++ b/src/features/Conversation/Workspace/index.tsx
@@ -1,6 +1,7 @@
'use client';
-import { createStaticStyles, Flexbox } from '@lobehub/ui';
+import { Flexbox } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
import { useSize } from 'ahooks';
import { type ReactNode, useRef } from 'react';
@@ -10,16 +11,13 @@ import OverviewSlot from '@/features/Conversation/WorkingSidebar/OverviewSlot';
import HeaderSlot from '@/routes/(main)/agent/(chat)/_layout/HeaderSlot';
import Portal from '@/routes/(main)/agent/features/Portal';
-const styles = createStaticStyles(({ css }) => ({
- // Named container queried by ChatHeader and the list top spacer: when this
- // column is wide enough, the header floats above the full-bleed message
- // stream instead of sitting in flow as a solid bar.
- conversationColumn: css`
- position: relative;
- container-name: agent-chat-layout;
- container-type: inline-size;
- `,
-}));
+const styles = stylex.create({
+ conversationColumn: {
+ position: 'relative',
+ containerName: 'agent-chat-layout',
+ containerType: 'inline-size',
+ },
+});
const ConversationWorkspace = ({
children,
@@ -50,7 +48,7 @@ const ConversationWorkspace = ({
width={'100%'}
>
<Flexbox
- className={styles.conversationColumn}
+ className={stylex.props(styles.conversationColumn).className}
flex={1}
style={{ minHeight: 0, minWidth: 0 }}
>
diff --git a/src/features/Conversation/components/History/index.tsx b/src/features/Conversation/components/History/index.tsx
index 4a5c3fbe0db..91e10006c29 100644
--- a/src/features/Conversation/components/History/index.tsx
+++ b/src/features/Conversation/components/History/index.tsx
@@ -1,4 +1,6 @@
-import { Center, createStaticStyles, cssVar, Flexbox, Icon, Markdown, Text } from '@lobehub/ui';
+import { Center, Flexbox, Icon, Markdown, Text } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { ScrollText } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -10,20 +12,16 @@ import { useAgentStore } from '@/store/agent/store';
import { contextSelectors, dataSelectors, useConversationStore } from '../../store';
import HistoryDivider from './HistoryDivider';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- container: css`
- padding-inline: 12px;
- border-radius: 12px;
- `,
- content: css`
- color: ${cssVar.colorTextDescription};
- `,
- line: css`
- width: 3px;
- height: 100%;
- background: ${cssVar.colorBorder};
- `,
-}));
+const styles = stylex.create({
+ container: { paddingInline: '12px', borderRadius: '12px' },
+ content: { color: cssVar.colorTextDescription },
+ line: {
+ width: '3px',
+ height: '100%',
+ backgroundColor: cssVar.colorBorder,
+ backgroundImage: 'none',
+ },
+});
const History = memo(() => {
const { t } = useTranslation('chat');
@@ -41,7 +39,7 @@ const History = memo(() => {
<Flexbox paddingInline={16} style={{ paddingBottom: 8 }}>
<HistoryDivider enable />
{enableCompressHistory && !!content && (
- <Flexbox className={styles.container} gap={8}>
+ <Flexbox className={stylex.props(styles.container).className} gap={8}>
<Flexbox horizontal align={'flex-start'} gap={8}>
<Center height={20} width={20}>
<Icon icon={ScrollText} size={16} style={{ color: cssVar.colorTextDescription }} />
@@ -55,9 +53,9 @@ const History = memo(() => {
</Flexbox>
<Flexbox horizontal align={'flex-start'} gap={8}>
<Flexbox align={'center'} padding={8} width={20}>
- <div className={styles.line} />
+ <div {...stylex.props(styles.line)} />
</Flexbox>
- <Markdown className={styles.content} variant={'chat'}>
+ <Markdown className={stylex.props(styles.content).className} variant={'chat'}>
{content}
</Markdown>
</Flexbox>
diff --git a/src/features/Conversation/components/PortalResourceCard/index.tsx b/src/features/Conversation/components/PortalResourceCard/index.tsx
index 626a817b941..5bc0b4c1ce9 100644
--- a/src/features/Conversation/components/PortalResourceCard/index.tsx
+++ b/src/features/Conversation/components/PortalResourceCard/index.tsx
@@ -1,100 +1,86 @@
'use client';
-import { Center, createStaticStyles, cx, Flexbox, Icon, Text, Tooltip } from '@lobehub/ui';
+import { Center, Flexbox, Icon, Text, Tooltip } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { FileText } from 'lucide-react';
import type { KeyboardEvent, MouseEvent, ReactNode } from 'react';
import { memo } from 'react';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- actionable: css`
- cursor: pointer;
-
- &:hover {
- background: ${cssVar.colorFillQuaternary};
- }
-
- &:focus-visible {
- outline: 2px solid ${cssVar.colorPrimary};
- outline-offset: 2px;
- }
- `,
- avatar: css`
- flex: none;
- align-self: stretch;
- border-inline-end: 1px solid ${cssVar.colorBorderSecondary};
- background: ${cssVar.colorFillQuaternary};
- `,
- openLabel: css`
- display: flex;
- align-items: center;
-
- height: 28px;
- padding-inline: 12px;
- border: 1px solid ${cssVar.colorBorder};
- border-radius: 6px;
-
- font-size: 13px;
- line-height: 1;
- color: ${cssVar.colorText};
- white-space: nowrap;
-
- background: ${cssVar.colorBgContainer};
- `,
- actionButton: css`
- cursor: pointer;
-
- height: 28px;
- padding-inline: 12px;
- border: 1px solid ${cssVar.colorBorder};
- border-radius: 6px;
-
- font-size: 13px;
- line-height: 1;
- color: ${cssVar.colorText};
- white-space: nowrap;
-
- background: ${cssVar.colorBgContainer};
-
- &:hover {
- background: ${cssVar.colorFillQuaternary};
- }
-
- &:focus-visible {
- outline: 2px solid ${cssVar.colorPrimary};
- outline-offset: 2px;
- }
- `,
- container: css`
- overflow: hidden;
-
- width: 100%;
- height: 64px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: 12px;
-
- color: ${cssVar.colorText};
-
- background: ${cssVar.colorBgContainer};
- `,
- content: css`
- overflow: hidden;
- min-width: 0;
- `,
- desc: css`
- font-size: 12px;
- line-height: 1.3;
- color: ${cssVar.colorTextTertiary};
- `,
- title: css`
- font-weight: 500;
- line-height: 1.35;
- `,
- trigger: css`
- overflow: hidden;
- min-width: 0;
- height: 100%;
- `,
-}));
+import { sx } from '@/styles/sx';
+
+const FOCUS_RING = {
+ outlineWidth: { 'default': null, ':focus-visible': '2px' },
+ outlineStyle: { 'default': null, ':focus-visible': 'solid' },
+ outlineColor: { 'default': null, ':focus-visible': cssVar.colorPrimary },
+ outlineOffset: { 'default': null, ':focus-visible': '2px' },
+} as const;
+
+const styles = stylex.create({
+ actionable: {
+ cursor: 'pointer',
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillQuaternary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ ...FOCUS_RING,
+ },
+ avatar: {
+ flex: 'none',
+ alignSelf: 'stretch',
+ borderInlineEndWidth: '1px',
+ borderInlineEndStyle: 'solid',
+ borderInlineEndColor: cssVar.colorBorderSecondary,
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+ openLabel: {
+ display: 'flex',
+ alignItems: 'center',
+ height: '28px',
+ paddingInline: '12px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorder,
+ borderRadius: '6px',
+ fontSize: '13px',
+ lineHeight: 1,
+ color: cssVar.colorText,
+ whiteSpace: 'nowrap',
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+ actionButton: {
+ cursor: 'pointer',
+ height: '28px',
+ paddingInline: '12px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorder,
+ borderRadius: '6px',
+ fontSize: '13px',
+ lineHeight: 1,
+ color: cssVar.colorText,
+ whiteSpace: 'nowrap',
+ backgroundColor: { 'default': cssVar.colorBgContainer, ':hover': cssVar.colorFillQuaternary },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ ...FOCUS_RING,
+ },
+ container: {
+ overflow: 'hidden',
+ width: '100%',
+ height: '64px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: '12px',
+ color: cssVar.colorText,
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+ content: { overflow: 'hidden', minWidth: 0 },
+ desc: { fontSize: '12px', lineHeight: 1.3, color: cssVar.colorTextTertiary },
+ title: { fontWeight: 500, lineHeight: 1.35 },
+ trigger: { overflow: 'hidden', minWidth: 0, height: '100%' },
+});
export interface PortalResourceCardProps {
className?: string;
@@ -136,33 +122,33 @@ const PortalResourceCard = memo<PortalResourceCardProps>(
// Mirrors the inline artifact card shell, while keeping portal-open behavior owned by callers.
const card = (
- <Flexbox horizontal align={'center'} className={cx(styles.container, className)}>
+ <Flexbox horizontal align={'center'} {...sx(styles.container, className)}>
<Flexbox
horizontal
align={'center'}
- className={cx(styles.trigger, onOpen && styles.actionable)}
+ {...stylex.props(styles.trigger, onOpen && styles.actionable)}
flex={1}
role={onOpen ? 'button' : undefined}
tabIndex={onOpen ? 0 : undefined}
onClick={onOpen}
onKeyDown={onOpen ? handleKeyDown : undefined}
>
- <Center horizontal className={styles.avatar} width={64}>
+ <Center horizontal {...stylex.props(styles.avatar)} width={64}>
{icon ?? <Icon icon={FileText} size={28} />}
</Center>
- <Flexbox className={styles.content} flex={1} gap={4} paddingInline={12}>
- <Text ellipsis className={styles.title}>
+ <Flexbox {...stylex.props(styles.content)} flex={1} gap={4} paddingInline={12}>
+ <Text ellipsis {...stylex.props(styles.title)}>
{title}
</Text>
{description && (
- <Text ellipsis className={styles.desc}>
+ <Text ellipsis {...stylex.props(styles.desc)}>
{description}
</Text>
)}
</Flexbox>
{onOpen && openLabel && (
<Flexbox flex={'none'} style={{ paddingInlineEnd: 10 }}>
- <div aria-hidden className={styles.openLabel}>
+ <div aria-hidden {...stylex.props(styles.openLabel)}>
{openLabel}
</div>
</Flexbox>
@@ -174,14 +160,14 @@ const PortalResourceCard = memo<PortalResourceCardProps>(
<>
{onSecondaryAction ? (
<button
- className={styles.actionButton}
+ {...stylex.props(styles.actionButton)}
type={'button'}
onClick={handleSecondaryActionClick}
>
{secondaryActionLabel}
</button>
) : (
- <div aria-hidden className={styles.openLabel}>
+ <div aria-hidden {...stylex.props(styles.openLabel)}>
{secondaryActionLabel}
</div>
)}
diff --git a/src/features/Conversation/components/Reaction/ReactionDisplay.tsx b/src/features/Conversation/components/Reaction/ReactionDisplay.tsx
index ab841b676e6..60fa7cf8c5f 100644
--- a/src/features/Conversation/components/Reaction/ReactionDisplay.tsx
+++ b/src/features/Conversation/components/Reaction/ReactionDisplay.tsx
@@ -1,48 +1,33 @@
'use client';
import type { EmojiReaction } from '@lobechat/types';
-import { createStaticStyles, cx, Flexbox } from '@lobehub/ui';
+import { Flexbox } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { memo } from 'react';
import { usePermission } from '@/hooks/usePermission';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- active: css`
- background: ${cssVar.colorFillTertiary};
- `,
- container: css`
- display: flex;
- flex-wrap: wrap;
- gap: 4px;
- `,
- count: css`
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
- `,
- reactionTag: css`
- cursor: pointer;
-
- display: inline-flex;
- gap: 4px;
- align-items: center;
-
- height: 28px;
- padding-block: 0;
- padding-inline: 10px;
- border-radius: 14px;
-
- font-size: 14px;
- line-height: 1;
-
- background: ${cssVar.colorFillSecondary};
-
- transition: all 0.2s;
-
- &:hover {
- background: ${cssVar.colorFillTertiary};
- }
- `,
-}));
+const styles = stylex.create({
+ active: { backgroundColor: cssVar.colorFillTertiary, backgroundImage: 'none' },
+ container: { display: 'flex', flexWrap: 'wrap', gap: '4px' },
+ count: { fontSize: '12px', color: cssVar.colorTextSecondary },
+ reactionTag: {
+ cursor: 'pointer',
+ display: 'inline-flex',
+ gap: '4px',
+ alignItems: 'center',
+ height: '28px',
+ paddingBlock: '0',
+ paddingInline: '10px',
+ borderRadius: '14px',
+ fontSize: '14px',
+ lineHeight: 1,
+ backgroundColor: { 'default': cssVar.colorFillSecondary, ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ transition: 'all 0.2s',
+ },
+});
interface ReactionDisplayProps {
/**
@@ -65,16 +50,18 @@ const ReactionDisplay = memo<ReactionDisplayProps>(({ reactions, onReactionClick
if (reactions.length === 0) return null;
return (
- <Flexbox horizontal align={'center'} className={styles.container}>
+ <Flexbox horizontal align={'center'} className={stylex.props(styles.container).className}>
{reactions.map((reaction) => (
<div
- className={cx(styles.reactionTag, isActive?.(reaction.emoji) && styles.active)}
key={reaction.emoji}
style={{ cursor: canEdit ? undefined : 'default' }}
+ className={
+ stylex.props(styles.reactionTag, isActive?.(reaction.emoji) && styles.active).className
+ }
onClick={canEdit ? () => onReactionClick?.(reaction.emoji) : undefined}
>
<span>{reaction.emoji}</span>
- {reaction.count > 1 && <span className={styles.count}>{reaction.count}</span>}
+ {reaction.count > 1 && <span {...stylex.props(styles.count)}>{reaction.count}</span>}
</div>
))}
</Flexbox>
diff --git a/src/features/Conversation/components/Reaction/ReactionPicker.tsx b/src/features/Conversation/components/Reaction/ReactionPicker.tsx
index c7d44208276..cbc20b00fb0 100644
--- a/src/features/Conversation/components/Reaction/ReactionPicker.tsx
+++ b/src/features/Conversation/components/Reaction/ReactionPicker.tsx
@@ -2,7 +2,9 @@
import data from '@emoji-mart/data';
import Picker from '@emoji-mart/react';
-import { ActionIcon, createStaticStyles, Flexbox, Popover, Tooltip, useTheme } from '@lobehub/ui';
+import { ActionIcon, Flexbox, Popover, Tooltip, useTheme } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { PlusIcon, SmilePlus } from 'lucide-react';
import { type FC, memo, type ReactNode, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -16,51 +18,36 @@ import { useConversationStore } from '../../store';
const QUICK_REACTIONS = ['πŸ‘', 'πŸ‘Ž', '❀️', 'πŸ˜„', 'πŸ˜‚', 'πŸ˜…', 'πŸŽ‰', '😒', 'πŸ€”', 'πŸš€'];
-const styles = createStaticStyles(({ css, cssVar }) => ({
- emojiButton: css`
- cursor: pointer;
-
- display: flex;
- align-items: center;
- justify-content: center;
-
- width: 32px;
- height: 32px;
- border-radius: ${cssVar.borderRadius};
-
- font-size: 18px;
-
- transition: all 0.2s;
-
- &:hover {
- transform: scale(1.1);
- background: ${cssVar.colorFillSecondary};
- }
- `,
- moreButton: css`
- cursor: pointer;
-
- display: flex;
- align-items: center;
- justify-content: center;
-
- width: 32px;
- height: 32px;
- border-radius: ${cssVar.borderRadius};
-
- color: ${cssVar.colorTextTertiary};
-
- transition: all 0.2s;
-
- &:hover {
- color: ${cssVar.colorText};
- background: ${cssVar.colorFillSecondary};
- }
- `,
- pickerContainer: css`
- padding: 4px;
- `,
-}));
+const styles = stylex.create({
+ emojiButton: {
+ cursor: 'pointer',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: '32px',
+ height: '32px',
+ borderRadius: cssVar.borderRadius,
+ fontSize: '18px',
+ transition: 'all 0.2s',
+ transform: { 'default': null, ':hover': 'scale(1.1)' },
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillSecondary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ },
+ moreButton: {
+ cursor: 'pointer',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: '32px',
+ height: '32px',
+ borderRadius: cssVar.borderRadius,
+ color: { 'default': cssVar.colorTextTertiary, ':hover': cssVar.colorText },
+ transition: 'all 0.2s',
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillSecondary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ },
+ pickerContainer: { padding: '4px' },
+});
interface ReactionPickerProps {
messageId: string;
@@ -102,13 +89,18 @@ const ReactionPicker: FC<ReactionPickerProps> = memo(({ messageId, trigger }) =>
onEmojiSelect={(emoji: any) => handleSelect(emoji.native)}
/>
) : (
- <Flexbox horizontal className={styles.pickerContainer} gap={4} wrap="wrap">
+ <Flexbox
+ horizontal
+ className={stylex.props(styles.pickerContainer).className}
+ gap={4}
+ wrap="wrap"
+ >
{QUICK_REACTIONS.map((emoji) => (
- <div className={styles.emojiButton} key={emoji} onClick={() => handleSelect(emoji)}>
+ <div {...stylex.props(styles.emojiButton)} key={emoji} onClick={() => handleSelect(emoji)}>
{emoji}
</div>
))}
- <div className={styles.moreButton} onClick={() => setShowFullPicker(true)}>
+ <div {...stylex.props(styles.moreButton)} onClick={() => setShowFullPicker(true)}>
<PlusIcon size={16} />
</div>
</Flexbox>
diff --git a/src/features/Conversation/components/ShareMessageModal/ShareImage/index.tsx b/src/features/Conversation/components/ShareMessageModal/ShareImage/index.tsx
index de408d30290..aafb4372ae7 100644
--- a/src/features/Conversation/components/ShareMessageModal/ShareImage/index.tsx
+++ b/src/features/Conversation/components/ShareMessageModal/ShareImage/index.tsx
@@ -1,6 +1,7 @@
import { agentDisplayName, type UIChatMessage } from '@lobechat/types';
import { Button, Flexbox, Switch, Tabs } from '@lobehub/ui';
import { Form, type FormFieldProps, useForm } from '@lobehub/ui/form';
+import * as stylex from '@stylexjs/stylex';
import { CopyIcon } from 'lucide-react';
import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -107,7 +108,7 @@ const ShareImage = memo<{ message: UIChatMessage; mobile?: boolean; uniqueId?: s
return (
<>
- <Flexbox className={styles.body} gap={16} horizontal={!isMobile}>
+ <Flexbox className={stylex.props(styles.body).className} gap={16} horizontal={!isMobile}>
<Preview
context={context}
title={title}
@@ -115,13 +116,13 @@ const ShareImage = memo<{ message: UIChatMessage; mobile?: boolean; uniqueId?: s
message={message}
previewId={previewId}
/>
- <Flexbox className={styles.sidebar} gap={12}>
+ <Flexbox className={stylex.props(styles.sidebar).className} gap={12}>
<Form form={form} items={settings} itemsType={'flat'} {...FORM_STYLE} />
{!isMobile && button}
</Flexbox>
</Flexbox>
{isMobile && (
- <Flexbox horizontal className={styles.footer} gap={8}>
+ <Flexbox horizontal className={stylex.props(styles.footer).className} gap={8}>
{button}
</Flexbox>
)}
diff --git a/src/features/Conversation/components/ShareMessageModal/ShareText/Preview.tsx b/src/features/Conversation/components/ShareMessageModal/ShareText/Preview.tsx
index 6cf4748adab..020f16e3d05 100644
--- a/src/features/Conversation/components/ShareMessageModal/ShareText/Preview.tsx
+++ b/src/features/Conversation/components/ShareMessageModal/ShareText/Preview.tsx
@@ -1,15 +1,23 @@
-import { Markdown } from '@lobehub/ui';
+import { cx, lobeStaticStylish, Markdown } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
import { memo } from 'react';
import { useIsMobile } from '@/hooks/useIsMobile';
-import { styles } from '../style';
+import { fallback, styles } from '../style';
const Preview = memo<{ content: string }>(({ content }) => {
const isMobile = useIsMobile();
return (
- <div className={styles.preview} style={{ padding: 12 }}>
+ <div
+ style={{ padding: 12 }}
+ className={cx(
+ lobeStaticStylish.noScrollbar,
+ stylex.props(styles.preview).className,
+ fallback.preview,
+ )}
+ >
<Markdown variant={isMobile ? 'chat' : undefined}>{content}</Markdown>
</div>
);
diff --git a/src/features/Conversation/components/ShareMessageModal/ShareText/index.tsx b/src/features/Conversation/components/ShareMessageModal/ShareText/index.tsx
index 15a704cfa32..9addf2cb639 100644
--- a/src/features/Conversation/components/ShareMessageModal/ShareText/index.tsx
+++ b/src/features/Conversation/components/ShareMessageModal/ShareText/index.tsx
@@ -1,5 +1,6 @@
import { type UIChatMessage } from '@lobechat/types';
import { Button, copyToClipboard, Flexbox, toast } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
import isEqual from 'fast-deep-equal';
import { CopyIcon } from 'lucide-react';
import { memo } from 'react';
@@ -59,14 +60,14 @@ const ShareText = memo<ShareTextProps>(({ item }) => {
return (
<>
- <Flexbox className={styles.body} gap={16} horizontal={!isMobile}>
+ <Flexbox className={stylex.props(styles.body).className} gap={16} horizontal={!isMobile}>
<Preview content={content} />
- <Flexbox className={styles.sidebar} gap={12}>
+ <Flexbox className={stylex.props(styles.sidebar).className} gap={12}>
{!isMobile && button}
</Flexbox>
</Flexbox>
{isMobile && (
- <Flexbox horizontal className={styles.footer} gap={8}>
+ <Flexbox horizontal className={stylex.props(styles.footer).className} gap={8}>
{button}
</Flexbox>
)}
diff --git a/src/features/Conversation/components/ShareMessageModal/style.ts b/src/features/Conversation/components/ShareMessageModal/style.ts
index a1b1b91db70..cf3b9e08415 100644
--- a/src/features/Conversation/components/ShareMessageModal/style.ts
+++ b/src/features/Conversation/components/ShareMessageModal/style.ts
@@ -1,57 +1,51 @@
-import { createStaticStyles, cx, lobeStaticStylish, responsive } from '@lobehub/ui';
-
-export const styles = createStaticStyles(({ css, cssVar }) => ({
- body: css`
- ${responsive.sm} {
- padding-block-end: 68px;
- }
- `,
- footer: css`
- ${responsive.sm} {
- position: absolute;
- inset-block-end: 0;
- inset-inline: 0;
-
- width: 100%;
- margin: 0;
- padding: 16px;
-
- background: ${cssVar.colorBgContainer};
- }
- `,
- preview: cx(
- lobeStaticStylish.noScrollbar,
- css`
- overflow: hidden scroll;
-
- width: 100%;
- max-height: 70dvh;
- border: 1px solid ${cssVar.colorBorder};
- border-radius: ${cssVar.borderRadiusLG};
-
- background: ${cssVar.colorBgLayout};
-
- * {
- pointer-events: none;
-
- ::-webkit-scrollbar {
- width: 0 !important;
- height: 0 !important;
- }
- }
-
- ${responsive.sm} {
- max-height: 40dvh;
+// oxlint-disable-next-line stylex-migration/no-emotion-styles -- Markdown output gets no className
+import { createStaticStyles } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import { media } from '@lobehub/ui/stylex/media.stylex';
+import * as stylex from '@stylexjs/stylex';
+
+export const styles = stylex.create({
+ body: {
+ paddingBlockEnd: { default: null, [media.sm]: '68px' },
+ },
+ footer: {
+ position: { default: null, [media.sm]: 'absolute' },
+ insetBlockEnd: { default: null, [media.sm]: 0 },
+ insetInline: { default: null, [media.sm]: 0 },
+ width: { default: null, [media.sm]: '100%' },
+ margin: { default: null, [media.sm]: 0 },
+ padding: { default: null, [media.sm]: '16px' },
+ backgroundColor: { default: null, [media.sm]: cssVar.colorBgContainer },
+ backgroundImage: { default: null, [media.sm]: 'none' },
+ },
+ preview: {
+ overflowX: 'hidden',
+ overflowY: 'scroll',
+ width: '100%',
+ maxHeight: { default: '70dvh', [media.sm]: '40dvh' },
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorder,
+ borderRadius: cssVar.borderRadiusLG,
+ backgroundColor: cssVar.colorBgLayout,
+ backgroundImage: 'none',
+ },
+ sidebar: {
+ flex: { default: 'none', [media.sm]: '1' },
+ width: { default: 'max(240px, 25%)', [media.sm]: 'unset' },
+ marginInline: { default: null, [media.sm]: '-16px' },
+ },
+});
+
+export const fallback = createStaticStyles(({ css }) => ({
+ preview: css`
+ * {
+ pointer-events: none;
+
+ ::-webkit-scrollbar {
+ width: 0 !important;
+ height: 0 !important;
}
- `,
- ),
- sidebar: css`
- flex: none;
- width: max(240px, 25%);
- ${responsive.sm} {
- flex: 1;
- width: unset;
- margin-inline: -16px;
}
`,
}));
diff --git a/src/features/Conversation/components/Thinking/index.tsx b/src/features/Conversation/components/Thinking/index.tsx
index 66fd30cd379..19fde4e09be 100644
--- a/src/features/Conversation/components/Thinking/index.tsx
+++ b/src/features/Conversation/components/Thinking/index.tsx
@@ -1,4 +1,7 @@
-import { Accordion, createStaticStyles, ScrollArea } from '@lobehub/ui';
+// oxlint-disable-next-line stylex-migration/no-emotion-styles -- Markdown output gets no className
+import { Accordion, createStaticStyles, cx, ScrollArea } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import type { CSSProperties, ReactNode, RefObject } from 'react';
import { memo, useEffect, useState } from 'react';
@@ -8,21 +11,26 @@ import { type ChatCitationItem } from '@/types/index';
import Title from './Title';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- contentScroll: css`
- max-height: min(40vh, 320px);
- padding-block-end: 8px;
- padding-inline: 8px;
- color: ${cssVar.colorTextDescription};
+const styles = stylex.create({
+ contentScroll: {
+ maxHeight: 'min(40vh, 320px)',
+ paddingBlockEnd: '8px',
+ paddingInline: '8px',
+ color: cssVar.colorTextDescription,
+ },
+ scrollRoot: {
+ borderRadius: 0,
+ backgroundColor: 'transparent',
+ backgroundImage: 'none',
+ },
+});
+const fallback = createStaticStyles(({ css, cssVar }) => ({
+ contentScroll: css`
article * {
color: ${cssVar.colorTextDescription};
}
`,
- scrollRoot: css`
- border-radius: 0;
- background: transparent;
- `,
}));
interface ThinkingProps {
@@ -60,9 +68,9 @@ const Thinking = memo<ThinkingProps>((props) => {
<ScrollArea
disableContentFit
scrollFade
- className={styles.scrollRoot}
+ className={stylex.props(styles.scrollRoot).className}
viewportProps={{
- className: styles.contentScroll,
+ className: cx(stylex.props(styles.contentScroll).className, fallback.contentScroll),
ref: ref as RefObject<HTMLDivElement>,
onScroll: handleScroll,
}}
diff --git a/src/features/ExplorerTree/documentTreeStyle.test.ts b/src/features/ExplorerTree/documentTreeStyle.test.ts
index f0c95e403a4..4a0664e8c1d 100644
--- a/src/features/ExplorerTree/documentTreeStyle.test.ts
+++ b/src/features/ExplorerTree/documentTreeStyle.test.ts
@@ -85,7 +85,8 @@ describe('code tree call sites', () => {
// They keep their own pre-existing 12px label and pierre's default 30px row
// (no `itemHeight` prop) β€” that is what "ζ–‡δ»Άηš„ι‚£δΈͺ tree ζΈ²ζŸ“δΏη•™εŽŸζ ·" means.
// The document tree's 14px / 36px must never reach them.
- expect(source).toContain('--trees-font-size-override: 12px');
+ // Written as a `stylex.create` custom property key since the StyleX migration.
+ expect(source).toMatch(/['"]?--trees-font-size-override['"]?:\s*['"]?12px/);
expect(source).not.toContain('itemHeight');
},
);