lobehub/src/features/ChatInput/InputEditor/index.tsx

379 lines
13 KiB
TypeScript
Raw Normal View History

import { isDesktop } from '@lobechat/const';
♻️ refactor(desktop): consolidate global shortcuts (LOBE-7181) (#13880) * ♻️ refactor(desktop): consolidate global shortcuts and remove default showApp hotkey - Add desktopGlobalShortcuts.ts as single source for Electron + renderer defaults - Wire ShortcutManager and store to DEFAULT_ELECTRON_DESKTOP_SHORTCUTS - Use DesktopHotkeyId for @shortcut; drop local shortcuts barrel - Stop re-exporting DESKTOP_HOTKEYS_REGISTRATION from hotkeys Fixes LOBE-7181 Made-with: Cursor * ✨ feat(desktop): introduce new stubs for business constants and types - Added `@lobechat/business-const` and `@lobechat/types` packages to support workspace dependency resolution. - Updated `package.json` and `pnpm-workspace.yaml` to include new stubs. - Refactored imports in `index.ts` to utilize the new constants structure. - Enhanced `desktopGlobalShortcuts.ts` with improved type definitions for hotkeys. This change streamlines the management of constants and types across the desktop application. Signed-off-by: Innei <tukon479@gmail.com> * ♻️ refactor(hotkeys): consolidate desktop global shortcut definitions (LOBE-7181) Made-with: Cursor * ✨ feat(session, user): replace direct type imports with constants - Updated session.ts to use constants for session types instead of direct imports from @lobechat/types. - Updated user.ts to use a constant for the default topic display mode, enhancing consistency and maintainability. This change improves code clarity and reduces dependencies on external type definitions. Signed-off-by: Innei <tukon479@gmail.com> --------- Signed-off-by: Innei <tukon479@gmail.com>
2026-04-16 16:32:05 +00:00
import { HotkeyEnum, KeyEnum } from '@lobechat/const/hotkeys';
✨ feat(editor): implement AI input auto-completion (#13458) * ✨ feat: implement AI input auto-completion with ReactAutoCompletePlugin Adds GitHub Copilot-style ghost text completion to the chat input, powered by a configurable system agent (disabled by default). Key changes: - Add `inputCompletion` system agent config (type, default, selector, i18n) - Create `chainInputCompletion` prompt chain (V2 few-shot, benchmarked) - Mount `ReactAutoCompletePlugin` in InputEditor when enabled - Wire `getMessages` through ChatInput store for conversation context - Add settings UI in Service Model page with enable toggle Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✅ test: update systemAgent snapshot for inputCompletion Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 🐛 fix: restrict auto-complete context to visible user/assistant turns Filter getMessages to use displayMessages (active visible thread) instead of dbMessages (raw DB records including tool messages and inactive branches). Also limit to last 10 user/assistant turns to keep payload small and relevant. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: enable input completion by default Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ⚡️ perf: use non-streaming for input completion requests Autocomplete needs the full result before displaying ghost text, so streaming adds unnecessary overhead. Setting stream: false reduces latency by avoiding SSE chunking. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 🐛 fix: revert stream:false for input completion fetchPresetTaskResult uses fetchSSE internally which cannot handle non-streaming JSON responses, causing the editor to freeze after receiving the completion result. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ⚡️ perf: use non-streaming for input completion requests Autocomplete waits for the full result before displaying ghost text. fetchSSE handles non-streaming responses via its fallback path (response.clone().text()), avoiding SSE chunking overhead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ⚡️ perf: skip contextEngineering for input completion Call getChatCompletion directly instead of fetchPresetTaskResult to avoid triggering agentDocument.getDocuments on every autocomplete request. Input completion only needs a simple LLM call with the prompt chain, not the full context engineering pipeline. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ♻️ refactor: revert to fetchPresetTaskResult for input completion Use the standard contextEngineering pipeline. The agentDocument overhead will be addressed separately. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 18:00:18 +00:00
import { chainInputCompletion } from '@lobechat/prompts';
import { isCommandPressed, merge } from '@lobechat/utils';
import { INSERT_MENTION_COMMAND, ReactAutoCompletePlugin, ReactMathPlugin } from '@lobehub/editor';
✨ feat: add slash action tags, topic reference tool, and command bus system (#12860) * ✨ feat: add slash action tags in chat input Made-with: Cursor * ✨ feat: enhance editor with new slash actions and localization updates - Added new slash actions: change tone, condense, expand, polish, rewrite, summarize, and translate. - Updated localization files for English and Chinese to include new action tags and slash commands. - Removed deprecated useSlashItems component and integrated its functionality directly into InputEditor. Signed-off-by: Innei <tukon479@gmail.com> * ✨ feat: add slash placement configuration to chat input components - Introduced `slashPlacement` prop to `ChatInputProvider`, `StoreUpdater`, and `InputEditor` for customizable slash menu positioning. - Updated initial state to include `slashPlacement` with default value 'top'. - Adjusted `ChatInput` and `InputArea` components to utilize the new `slashPlacement` prop. This enhancement allows for better control over the user interface in chat input interactions. Signed-off-by: Innei <tukon479@gmail.com> * ✨ feat: implement command bus for slash action tags processing Add command bus system to parse and execute slash commands (compact context, new topic). Refactor action tag categories from ai/prompt to command/skill. Add useEnabledSkills hook for dynamic skill registration. * feat: compress command Signed-off-by: Innei <tukon479@gmail.com> * refactor: compress Signed-off-by: Innei <tukon479@gmail.com> * fix: skill inject * ✨ feat: slash action tags with context engine integration Made-with: Cursor * ✨ feat: add topic reference builtin tool and server runtime Made-with: Cursor * ✨ feat: add topic mention items and update ReferTopic integration Made-with: Cursor * 🐛 fix: preserve editorData through assistant-group edit flow and update RichTextMessage reactively - EditState now forwards editorData from EditorModal to modifyMessageContent - modifyMessageContent accepts and passes editorData to updateMessageContent - RichTextMessage uses useEditor + effect to update document on content change instead of key-based remount - Refactored RichTextMessage plugins to use shared createChatInputRichPlugins() * ✨ feat(context-engine): add metadata types and update processors/providers Made-with: Cursor * ✨ feat(chat-input): add slash action tags and restore failed input state * 🔧 chore: update package dependencies and enhance Vite configuration - Changed @lobehub/ui dependency to a specific package URL. - Added multiple SPA entry points and layout files to the Vite warmup configuration. - Removed unused monorepo packages from sharedOptimizeDeps and added various dayjs locales for better localization support. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 chore: update @lobehub/ui dependency to version 5.4.0 in package.json Signed-off-by: Innei <tukon479@gmail.com> * 🐛 fix: correct SkillsApiName.runSkill to activateSkill and update trimmed content assertions * 🐛 fix: resolve type errors in context-engine tests and InputEditor slashPlacement * 🐛 fix: update runSkill to activateSkill in conversationLifecycle test * 🐛 fix: avoid regex backtracking in placeholder parser * ✨ feat(localization): add action tags and tooltips for slash commands across multiple languages Signed-off-by: Innei <tukon479@gmail.com> * 🐛 fix: preserve file attachments when /newTopic has no text content * cleanup Signed-off-by: Innei <tukon479@gmail.com> --------- Signed-off-by: Innei <tukon479@gmail.com>
2026-03-13 14:17:36 +00:00
import { Editor, FloatMenu, useEditorState } from '@lobehub/editor/react';
import { combineKeys } from '@lobehub/ui';
import { css, cx } from 'antd-style';
import Fuse from 'fuse.js';
🐛 fix(desktop): repo-type detection for submodule/worktree + chat & sidebar polish (#13978) * 🐛 fix(desktop): detect repo type for submodule and worktree directories Route detectRepoType through resolveGitDir so directories where `.git` is a pointer file (submodules, worktrees) are correctly identified as git/github repos instead of falling back to the plain folder icon. Fixes LOBE-7373 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 🐛 fix(desktop): reprobe repo type for stale recent-dir entries The recents picker rendered `entry.repoType` directly from localStorage, so any submodule/worktree entry cached while `detectRepoType` still returned `undefined` stayed stuck on the folder icon even after the main-process fix. Wrap each row icon in a component that calls `useRepoType`, which re-probes missing entries and backfills the cache. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 🐛 fix(chat-input): clear autocomplete hint on IME start to prevent freeze Dispatch KEY_ESCAPE_COMMAND on compositionstart so the autocomplete plugin removes PlaceholderInline/PlaceholderBlock nodes before the IME begins composing. Composing next to those placeholder nodes caused the editor to freeze during pinyin input with a visible hint. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ♻️ refactor(topic-sidebar): split project grouping into ByProjectMode Extracts project-specific group rendering from ByTimeMode into its own ByProjectMode folder, with a shared GroupedAccordion container. Project groups get a folder-icon column aligned with the topic item layout and a "new topic in {directory}" action. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 🐛 fix(desktop): read config via commondir for linked worktrees `resolveGitDir` returns `.git/worktrees/<name>/` for linked worktrees — that dir has its own `HEAD` but no `config`, so `detectRepoType` still returned `undefined` and worktrees missed the repo icon. Resolve the `commondir` pointer first so `config` is read from the shared gitdir. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-19 15:56:39 +00:00
import { KEY_ESCAPE_COMMAND } from 'lexical';
✨ feat: layout sidebar impl (#13719) * ♻️ Restructure sidebar layout: extract Lobe AI entry, move New Agent button - Extract Lobe AI (InboxItem) from agent list to standalone top entry in sidebar body - Move "New Agent" button from header to below Lobe AI entry - Add "Create" to bottom menu items alongside Community and Resources - Filter hidden items in BottomMenu component Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ✨ Add unified Recents section to home page - New TRPC router `recent.getAll` aggregating topics, documents, files, and tasks - New client service and SWR-based store integration for recents data - Unified Recents component on home page with type-based icons - Items sorted by updatedAt, limited to 10, mixed across all types Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ⚡ Prefetch agent config on hover for faster page loads - Add usePrefetchAgent hook using SWR mutate to warm cache - Trigger prefetch on mouseEnter for sidebar agent items - Reduces or eliminates loading screen when navigating to agent pages Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ✨ Redesign agent homepage with info, recent topics, and tasks - New AgentHome feature replacing the old AgentWelcome component - Agent info section: avatar, name, description, opening questions - Recent Topics: horizontal scrollable cards for agent-specific topics - Tasks section: list with status labels for agent-assigned tasks - Preserve ToolAuthAlert for tool authorization flows Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * fix: common misstakes in layout * chore: add fetch Recents cache * chore: add back createagents * chore: add back lobe ai * feat: add display count * feat: add create agent button * feat: add sidebar section order * chore: move divider * ✨ feat: show current page size in display items submenu Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add sidebar display management with customize sidebar modal - Add "Hide section" and "Customize sidebar" to Recents/Agents dropdown menus - Create CustomizeSidebarModal with eye toggle for section visibility - BottomMenu (Community/Resources) also manageable via modal - Show customize sidebar button in footer when all sections hidden - Add hiddenSidebarSections to store with localStorage persistence - Rename "Display Items" to "Show" in dropdown menus - Add 12px margin between accordion sections and bottom menu - Add i18n keys for en-US and zh-CN Fixes LOBE-6938 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 💄 style: use SlidersHorizontal icon for customize sidebar Replace Settings2/PanelLeft icon with SlidersHorizontal to avoid confusion with the settings gear icon. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 💄 style: refine sidebar customization UX - Move Settings entry from Footer to BottomMenu alongside Community/Resources - Add Settings to Customize sidebar modal with eye toggle - Allow hiding all sections (remove disabled constraint) - Move Customize sidebar button next to help button in Footer - Merge Agent dropdown: group Create items with Category items - Use SlidersHorizontal icon for Customize sidebar Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add recents item actions and "more" drawer - Add inline rename (same as Agent Topic) and delete to Recents items - Topic/document/file support rename + delete, task supports delete only - Add "more" button when items exceed pageSize, opens AllRecentsDrawer - AllRecentsDrawer shows all cached recents from store (up to 50) - Fetch max(pageSize, 50) items to support drawer without extra request Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add create agent/group modal with ChatInput and examples - Add CreateAgentModal using base-ui Modal with ChatInputProvider - Show suggestion examples (agent/group mode) in 2-column grid - Submit triggers sendAsAgent/sendAsGroup to auto-generate via Agent Builder - "Create Blank" button for skipping the prompt - Integrate modal into AgentModalProvider for shared state across sidebar - Wire up AddButton, NewAgentButton, and dropdown menus to open modal Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: optimitic update rename * chore: prefetch agent detail * feat: add recent topic meta data * feat: add recents search * ⚡ perf: optimize recents API with single UNION query and prefetch - Replace 3 separate DB queries with single UNION ALL query (RecentModel) - Add optimistic updates for rename and delete actions - Add hover prefetch for resources (usePrefetchResource) - Add hover prefetch for agent config on topic/task items - Change default pageSize to 5 for both Agents and Recents - Unify delete confirmation messages per item type Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: adjust settings page * chore: optimize side bar * feat: recents support right click * chore: add pin icon to Agents * chore: add custom side bar modal * chore: reserve rencent drawer status * feat: add prefetch route * feat: add LobeAI prefetch * fix: document and task rename and delete operation lost * fix: group route id * fix: lint error --------- Co-authored-by: Claude <noreply@anthropic.com>
2026-04-10 16:13:19 +00:00
import { memo, type ReactNode, useCallback, useEffect, useMemo, useRef } from 'react';
import { useHotkeysContext } from 'react-hotkeys-hook';
import { usePasteFile, useUploadFiles } from '@/components/DragUploadZone';
import { useIMECompositionEvent } from '@/hooks/useIMECompositionEvent';
✨ feat(editor): implement AI input auto-completion (#13458) * ✨ feat: implement AI input auto-completion with ReactAutoCompletePlugin Adds GitHub Copilot-style ghost text completion to the chat input, powered by a configurable system agent (disabled by default). Key changes: - Add `inputCompletion` system agent config (type, default, selector, i18n) - Create `chainInputCompletion` prompt chain (V2 few-shot, benchmarked) - Mount `ReactAutoCompletePlugin` in InputEditor when enabled - Wire `getMessages` through ChatInput store for conversation context - Add settings UI in Service Model page with enable toggle Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✅ test: update systemAgent snapshot for inputCompletion Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 🐛 fix: restrict auto-complete context to visible user/assistant turns Filter getMessages to use displayMessages (active visible thread) instead of dbMessages (raw DB records including tool messages and inactive branches). Also limit to last 10 user/assistant turns to keep payload small and relevant. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: enable input completion by default Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ⚡️ perf: use non-streaming for input completion requests Autocomplete needs the full result before displaying ghost text, so streaming adds unnecessary overhead. Setting stream: false reduces latency by avoiding SSE chunking. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 🐛 fix: revert stream:false for input completion fetchPresetTaskResult uses fetchSSE internally which cannot handle non-streaming JSON responses, causing the editor to freeze after receiving the completion result. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ⚡️ perf: use non-streaming for input completion requests Autocomplete waits for the full result before displaying ghost text. fetchSSE handles non-streaming responses via its fallback path (response.clone().text()), avoiding SSE chunking overhead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ⚡️ perf: skip contextEngineering for input completion Call getChatCompletion directly instead of fetchPresetTaskResult to avoid triggering agentDocument.getDocuments on every autocomplete request. Input completion only needs a simple LLM call with the prompt chain, not the full context engineering pipeline. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ♻️ refactor: revert to fetchPresetTaskResult for input completion Use the standard contextEngineering pipeline. The agentDocument overhead will be addressed separately. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 18:00:18 +00:00
import { chatService } from '@/services/chat';
import { useAgentStore } from '@/store/agent';
import { agentByIdSelectors } from '@/store/agent/selectors';
import { useUserStore } from '@/store/user';
✨ feat(editor): implement AI input auto-completion (#13458) * ✨ feat: implement AI input auto-completion with ReactAutoCompletePlugin Adds GitHub Copilot-style ghost text completion to the chat input, powered by a configurable system agent (disabled by default). Key changes: - Add `inputCompletion` system agent config (type, default, selector, i18n) - Create `chainInputCompletion` prompt chain (V2 few-shot, benchmarked) - Mount `ReactAutoCompletePlugin` in InputEditor when enabled - Wire `getMessages` through ChatInput store for conversation context - Add settings UI in Service Model page with enable toggle Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✅ test: update systemAgent snapshot for inputCompletion Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 🐛 fix: restrict auto-complete context to visible user/assistant turns Filter getMessages to use displayMessages (active visible thread) instead of dbMessages (raw DB records including tool messages and inactive branches). Also limit to last 10 user/assistant turns to keep payload small and relevant. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: enable input completion by default Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ⚡️ perf: use non-streaming for input completion requests Autocomplete needs the full result before displaying ghost text, so streaming adds unnecessary overhead. Setting stream: false reduces latency by avoiding SSE chunking. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 🐛 fix: revert stream:false for input completion fetchPresetTaskResult uses fetchSSE internally which cannot handle non-streaming JSON responses, causing the editor to freeze after receiving the completion result. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ⚡️ perf: use non-streaming for input completion requests Autocomplete waits for the full result before displaying ghost text. fetchSSE handles non-streaming responses via its fallback path (response.clone().text()), avoiding SSE chunking overhead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ⚡️ perf: skip contextEngineering for input completion Call getChatCompletion directly instead of fetchPresetTaskResult to avoid triggering agentDocument.getDocuments on every autocomplete request. Input completion only needs a simple LLM call with the prompt chain, not the full context engineering pipeline. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ♻️ refactor: revert to fetchPresetTaskResult for input completion Use the standard contextEngineering pipeline. The agentDocument overhead will be addressed separately. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 18:00:18 +00:00
import {
labPreferSelectors,
preferenceSelectors,
settingsSelectors,
systemAgentSelectors,
} from '@/store/user/selectors';
import { useAgentId } from '../hooks/useAgentId';
import { useChatInputStore, useStoreApi } from '../store';
import {
INSERT_ACTION_TAG_COMMAND,
type InsertActionTagPayload,
useSlashActionItems,
} from './ActionTag';
import { createMentionMenu } from './MentionMenu';
import type { MentionMenuState } from './MentionMenu/types';
import Placeholder from './Placeholder';
✨ feat: add slash action tags, topic reference tool, and command bus system (#12860) * ✨ feat: add slash action tags in chat input Made-with: Cursor * ✨ feat: enhance editor with new slash actions and localization updates - Added new slash actions: change tone, condense, expand, polish, rewrite, summarize, and translate. - Updated localization files for English and Chinese to include new action tags and slash commands. - Removed deprecated useSlashItems component and integrated its functionality directly into InputEditor. Signed-off-by: Innei <tukon479@gmail.com> * ✨ feat: add slash placement configuration to chat input components - Introduced `slashPlacement` prop to `ChatInputProvider`, `StoreUpdater`, and `InputEditor` for customizable slash menu positioning. - Updated initial state to include `slashPlacement` with default value 'top'. - Adjusted `ChatInput` and `InputArea` components to utilize the new `slashPlacement` prop. This enhancement allows for better control over the user interface in chat input interactions. Signed-off-by: Innei <tukon479@gmail.com> * ✨ feat: implement command bus for slash action tags processing Add command bus system to parse and execute slash commands (compact context, new topic). Refactor action tag categories from ai/prompt to command/skill. Add useEnabledSkills hook for dynamic skill registration. * feat: compress command Signed-off-by: Innei <tukon479@gmail.com> * refactor: compress Signed-off-by: Innei <tukon479@gmail.com> * fix: skill inject * ✨ feat: slash action tags with context engine integration Made-with: Cursor * ✨ feat: add topic reference builtin tool and server runtime Made-with: Cursor * ✨ feat: add topic mention items and update ReferTopic integration Made-with: Cursor * 🐛 fix: preserve editorData through assistant-group edit flow and update RichTextMessage reactively - EditState now forwards editorData from EditorModal to modifyMessageContent - modifyMessageContent accepts and passes editorData to updateMessageContent - RichTextMessage uses useEditor + effect to update document on content change instead of key-based remount - Refactored RichTextMessage plugins to use shared createChatInputRichPlugins() * ✨ feat(context-engine): add metadata types and update processors/providers Made-with: Cursor * ✨ feat(chat-input): add slash action tags and restore failed input state * 🔧 chore: update package dependencies and enhance Vite configuration - Changed @lobehub/ui dependency to a specific package URL. - Added multiple SPA entry points and layout files to the Vite warmup configuration. - Removed unused monorepo packages from sharedOptimizeDeps and added various dayjs locales for better localization support. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 chore: update @lobehub/ui dependency to version 5.4.0 in package.json Signed-off-by: Innei <tukon479@gmail.com> * 🐛 fix: correct SkillsApiName.runSkill to activateSkill and update trimmed content assertions * 🐛 fix: resolve type errors in context-engine tests and InputEditor slashPlacement * 🐛 fix: update runSkill to activateSkill in conversationLifecycle test * 🐛 fix: avoid regex backtracking in placeholder parser * ✨ feat(localization): add action tags and tooltips for slash commands across multiple languages Signed-off-by: Innei <tukon479@gmail.com> * 🐛 fix: preserve file attachments when /newTopic has no text content * cleanup Signed-off-by: Innei <tukon479@gmail.com> --------- Signed-off-by: Innei <tukon479@gmail.com>
2026-03-13 14:17:36 +00:00
import { CHAT_INPUT_EMBED_PLUGINS, createChatInputRichPlugins } from './plugins';
import { INSERT_REFER_TOPIC_COMMAND } from './ReferTopic';
import { useMentionCategories } from './useMentionCategories';
const className = cx(css`
p {
margin-block-end: 0;
}
`);
✨ feat: layout sidebar impl (#13719) * ♻️ Restructure sidebar layout: extract Lobe AI entry, move New Agent button - Extract Lobe AI (InboxItem) from agent list to standalone top entry in sidebar body - Move "New Agent" button from header to below Lobe AI entry - Add "Create" to bottom menu items alongside Community and Resources - Filter hidden items in BottomMenu component Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ✨ Add unified Recents section to home page - New TRPC router `recent.getAll` aggregating topics, documents, files, and tasks - New client service and SWR-based store integration for recents data - Unified Recents component on home page with type-based icons - Items sorted by updatedAt, limited to 10, mixed across all types Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ⚡ Prefetch agent config on hover for faster page loads - Add usePrefetchAgent hook using SWR mutate to warm cache - Trigger prefetch on mouseEnter for sidebar agent items - Reduces or eliminates loading screen when navigating to agent pages Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ✨ Redesign agent homepage with info, recent topics, and tasks - New AgentHome feature replacing the old AgentWelcome component - Agent info section: avatar, name, description, opening questions - Recent Topics: horizontal scrollable cards for agent-specific topics - Tasks section: list with status labels for agent-assigned tasks - Preserve ToolAuthAlert for tool authorization flows Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * fix: common misstakes in layout * chore: add fetch Recents cache * chore: add back createagents * chore: add back lobe ai * feat: add display count * feat: add create agent button * feat: add sidebar section order * chore: move divider * ✨ feat: show current page size in display items submenu Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add sidebar display management with customize sidebar modal - Add "Hide section" and "Customize sidebar" to Recents/Agents dropdown menus - Create CustomizeSidebarModal with eye toggle for section visibility - BottomMenu (Community/Resources) also manageable via modal - Show customize sidebar button in footer when all sections hidden - Add hiddenSidebarSections to store with localStorage persistence - Rename "Display Items" to "Show" in dropdown menus - Add 12px margin between accordion sections and bottom menu - Add i18n keys for en-US and zh-CN Fixes LOBE-6938 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 💄 style: use SlidersHorizontal icon for customize sidebar Replace Settings2/PanelLeft icon with SlidersHorizontal to avoid confusion with the settings gear icon. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 💄 style: refine sidebar customization UX - Move Settings entry from Footer to BottomMenu alongside Community/Resources - Add Settings to Customize sidebar modal with eye toggle - Allow hiding all sections (remove disabled constraint) - Move Customize sidebar button next to help button in Footer - Merge Agent dropdown: group Create items with Category items - Use SlidersHorizontal icon for Customize sidebar Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add recents item actions and "more" drawer - Add inline rename (same as Agent Topic) and delete to Recents items - Topic/document/file support rename + delete, task supports delete only - Add "more" button when items exceed pageSize, opens AllRecentsDrawer - AllRecentsDrawer shows all cached recents from store (up to 50) - Fetch max(pageSize, 50) items to support drawer without extra request Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add create agent/group modal with ChatInput and examples - Add CreateAgentModal using base-ui Modal with ChatInputProvider - Show suggestion examples (agent/group mode) in 2-column grid - Submit triggers sendAsAgent/sendAsGroup to auto-generate via Agent Builder - "Create Blank" button for skipping the prompt - Integrate modal into AgentModalProvider for shared state across sidebar - Wire up AddButton, NewAgentButton, and dropdown menus to open modal Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: optimitic update rename * chore: prefetch agent detail * feat: add recent topic meta data * feat: add recents search * ⚡ perf: optimize recents API with single UNION query and prefetch - Replace 3 separate DB queries with single UNION ALL query (RecentModel) - Add optimistic updates for rename and delete actions - Add hover prefetch for resources (usePrefetchResource) - Add hover prefetch for agent config on topic/task items - Change default pageSize to 5 for both Agents and Recents - Unify delete confirmation messages per item type Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: adjust settings page * chore: optimize side bar * feat: recents support right click * chore: add pin icon to Agents * chore: add custom side bar modal * chore: reserve rencent drawer status * feat: add prefetch route * feat: add LobeAI prefetch * fix: document and task rename and delete operation lost * fix: group route id * fix: lint error --------- Co-authored-by: Claude <noreply@anthropic.com>
2026-04-10 16:13:19 +00:00
const InputEditor = memo<{ defaultRows?: number; placeholder?: ReactNode }>(
({ defaultRows = 2, placeholder }) => {
const [editor, slashMenuRef, send, updateMarkdownContent, expand, slashPlacement] =
useChatInputStore((s) => [
s.editor,
s.slashMenuRef,
s.handleSendButton,
s.updateMarkdownContent,
s.expand,
s.slashPlacement ?? 'top',
]);
const storeApi = useStoreApi();
const state = useEditorState(editor);
const hotkey = useUserStore(settingsSelectors.getHotkeyById(HotkeyEnum.AddUserMessage));
const { enableScope, disableScope } = useHotkeysContext();
const { compositionProps, isComposingRef } = useIMECompositionEvent();
const useCmdEnterToSend = useUserStore(preferenceSelectors.useCmdEnterToSend);
// --- Category-based mention system ---
const categories = useMentionCategories();
const stateRef = useRef<MentionMenuState>({ isSearch: false, matchingString: '' });
const categoriesRef = useRef(categories);
categoriesRef.current = categories;
const allMentionItems = useMemo(() => categories.flatMap((c) => c.items), [categories]);
const fuse = useMemo(
() =>
new Fuse(allMentionItems, {
keys: ['key', 'label', 'metadata.topicTitle'],
threshold: 0.3,
}),
[allMentionItems],
);
const mentionItemsFn = useCallback(
async (
search: { leadOffset: number; matchingString: string; replaceableString: string } | null,
) => {
if (search?.matchingString) {
stateRef.current = { isSearch: true, matchingString: search.matchingString };
return fuse.search(search.matchingString).map((r) => r.item);
}
stateRef.current = { isSearch: false, matchingString: '' };
return [...allMentionItems];
},
[allMentionItems, fuse],
);
const MentionMenuComp = useMemo(() => createMentionMenu(stateRef, categoriesRef), []);
const enableMention = allMentionItems.length > 0;
// Get agent's model info for vision support check and handle paste upload
const agentId = useAgentId();
const model = useAgentStore((s) => agentByIdSelectors.getAgentModelById(agentId)(s));
const provider = useAgentStore((s) => agentByIdSelectors.getAgentModelProviderById(agentId)(s));
const { handleUploadFiles } = useUploadFiles({ model, provider });
// Listen to editor's paste event for file uploads
usePasteFile(editor, handleUploadFiles);
useEffect(() => {
const fn = (e: BeforeUnloadEvent) => {
if (!state.isEmpty) {
// set returnValue to trigger alert modal
// Note: No matter what value is set, the browser will display the standard text
e.returnValue = 'You are typing something, are you sure you want to leave?';
}
};
✨ feat: layout sidebar impl (#13719) * ♻️ Restructure sidebar layout: extract Lobe AI entry, move New Agent button - Extract Lobe AI (InboxItem) from agent list to standalone top entry in sidebar body - Move "New Agent" button from header to below Lobe AI entry - Add "Create" to bottom menu items alongside Community and Resources - Filter hidden items in BottomMenu component Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ✨ Add unified Recents section to home page - New TRPC router `recent.getAll` aggregating topics, documents, files, and tasks - New client service and SWR-based store integration for recents data - Unified Recents component on home page with type-based icons - Items sorted by updatedAt, limited to 10, mixed across all types Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ⚡ Prefetch agent config on hover for faster page loads - Add usePrefetchAgent hook using SWR mutate to warm cache - Trigger prefetch on mouseEnter for sidebar agent items - Reduces or eliminates loading screen when navigating to agent pages Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ✨ Redesign agent homepage with info, recent topics, and tasks - New AgentHome feature replacing the old AgentWelcome component - Agent info section: avatar, name, description, opening questions - Recent Topics: horizontal scrollable cards for agent-specific topics - Tasks section: list with status labels for agent-assigned tasks - Preserve ToolAuthAlert for tool authorization flows Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * fix: common misstakes in layout * chore: add fetch Recents cache * chore: add back createagents * chore: add back lobe ai * feat: add display count * feat: add create agent button * feat: add sidebar section order * chore: move divider * ✨ feat: show current page size in display items submenu Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add sidebar display management with customize sidebar modal - Add "Hide section" and "Customize sidebar" to Recents/Agents dropdown menus - Create CustomizeSidebarModal with eye toggle for section visibility - BottomMenu (Community/Resources) also manageable via modal - Show customize sidebar button in footer when all sections hidden - Add hiddenSidebarSections to store with localStorage persistence - Rename "Display Items" to "Show" in dropdown menus - Add 12px margin between accordion sections and bottom menu - Add i18n keys for en-US and zh-CN Fixes LOBE-6938 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 💄 style: use SlidersHorizontal icon for customize sidebar Replace Settings2/PanelLeft icon with SlidersHorizontal to avoid confusion with the settings gear icon. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 💄 style: refine sidebar customization UX - Move Settings entry from Footer to BottomMenu alongside Community/Resources - Add Settings to Customize sidebar modal with eye toggle - Allow hiding all sections (remove disabled constraint) - Move Customize sidebar button next to help button in Footer - Merge Agent dropdown: group Create items with Category items - Use SlidersHorizontal icon for Customize sidebar Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add recents item actions and "more" drawer - Add inline rename (same as Agent Topic) and delete to Recents items - Topic/document/file support rename + delete, task supports delete only - Add "more" button when items exceed pageSize, opens AllRecentsDrawer - AllRecentsDrawer shows all cached recents from store (up to 50) - Fetch max(pageSize, 50) items to support drawer without extra request Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add create agent/group modal with ChatInput and examples - Add CreateAgentModal using base-ui Modal with ChatInputProvider - Show suggestion examples (agent/group mode) in 2-column grid - Submit triggers sendAsAgent/sendAsGroup to auto-generate via Agent Builder - "Create Blank" button for skipping the prompt - Integrate modal into AgentModalProvider for shared state across sidebar - Wire up AddButton, NewAgentButton, and dropdown menus to open modal Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: optimitic update rename * chore: prefetch agent detail * feat: add recent topic meta data * feat: add recents search * ⚡ perf: optimize recents API with single UNION query and prefetch - Replace 3 separate DB queries with single UNION ALL query (RecentModel) - Add optimistic updates for rename and delete actions - Add hover prefetch for resources (usePrefetchResource) - Add hover prefetch for agent config on topic/task items - Change default pageSize to 5 for both Agents and Recents - Unify delete confirmation messages per item type Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: adjust settings page * chore: optimize side bar * feat: recents support right click * chore: add pin icon to Agents * chore: add custom side bar modal * chore: reserve rencent drawer status * feat: add prefetch route * feat: add LobeAI prefetch * fix: document and task rename and delete operation lost * fix: group route id * fix: lint error --------- Co-authored-by: Claude <noreply@anthropic.com>
2026-04-10 16:13:19 +00:00
window.addEventListener('beforeunload', fn);
return () => {
window.removeEventListener('beforeunload', fn);
};
}, [state.isEmpty]);
const enableRichRender = useUserStore(labPreferSelectors.enableInputMarkdown);
const slashActionItems = useSlashActionItems();
const slashItems = useCallback(
async (
search: { leadOffset: number; matchingString: string; replaceableString: string } | null,
) => {
const actionItems =
typeof slashActionItems === 'function'
? await slashActionItems(search)
: slashActionItems;
return actionItems;
},
[slashActionItems],
);
// --- Auto-completion ---
const inputCompletionConfig = useUserStore(systemAgentSelectors.inputCompletion);
const isAutoCompleteEnabled = inputCompletionConfig.enabled;
const getMessagesRef = useRef(storeApi.getState().getMessages);
useEffect(() => {
return storeApi.subscribe((s) => {
getMessagesRef.current = s.getMessages;
});
✨ feat: layout sidebar impl (#13719) * ♻️ Restructure sidebar layout: extract Lobe AI entry, move New Agent button - Extract Lobe AI (InboxItem) from agent list to standalone top entry in sidebar body - Move "New Agent" button from header to below Lobe AI entry - Add "Create" to bottom menu items alongside Community and Resources - Filter hidden items in BottomMenu component Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ✨ Add unified Recents section to home page - New TRPC router `recent.getAll` aggregating topics, documents, files, and tasks - New client service and SWR-based store integration for recents data - Unified Recents component on home page with type-based icons - Items sorted by updatedAt, limited to 10, mixed across all types Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ⚡ Prefetch agent config on hover for faster page loads - Add usePrefetchAgent hook using SWR mutate to warm cache - Trigger prefetch on mouseEnter for sidebar agent items - Reduces or eliminates loading screen when navigating to agent pages Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ✨ Redesign agent homepage with info, recent topics, and tasks - New AgentHome feature replacing the old AgentWelcome component - Agent info section: avatar, name, description, opening questions - Recent Topics: horizontal scrollable cards for agent-specific topics - Tasks section: list with status labels for agent-assigned tasks - Preserve ToolAuthAlert for tool authorization flows Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * fix: common misstakes in layout * chore: add fetch Recents cache * chore: add back createagents * chore: add back lobe ai * feat: add display count * feat: add create agent button * feat: add sidebar section order * chore: move divider * ✨ feat: show current page size in display items submenu Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add sidebar display management with customize sidebar modal - Add "Hide section" and "Customize sidebar" to Recents/Agents dropdown menus - Create CustomizeSidebarModal with eye toggle for section visibility - BottomMenu (Community/Resources) also manageable via modal - Show customize sidebar button in footer when all sections hidden - Add hiddenSidebarSections to store with localStorage persistence - Rename "Display Items" to "Show" in dropdown menus - Add 12px margin between accordion sections and bottom menu - Add i18n keys for en-US and zh-CN Fixes LOBE-6938 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 💄 style: use SlidersHorizontal icon for customize sidebar Replace Settings2/PanelLeft icon with SlidersHorizontal to avoid confusion with the settings gear icon. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 💄 style: refine sidebar customization UX - Move Settings entry from Footer to BottomMenu alongside Community/Resources - Add Settings to Customize sidebar modal with eye toggle - Allow hiding all sections (remove disabled constraint) - Move Customize sidebar button next to help button in Footer - Merge Agent dropdown: group Create items with Category items - Use SlidersHorizontal icon for Customize sidebar Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add recents item actions and "more" drawer - Add inline rename (same as Agent Topic) and delete to Recents items - Topic/document/file support rename + delete, task supports delete only - Add "more" button when items exceed pageSize, opens AllRecentsDrawer - AllRecentsDrawer shows all cached recents from store (up to 50) - Fetch max(pageSize, 50) items to support drawer without extra request Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add create agent/group modal with ChatInput and examples - Add CreateAgentModal using base-ui Modal with ChatInputProvider - Show suggestion examples (agent/group mode) in 2-column grid - Submit triggers sendAsAgent/sendAsGroup to auto-generate via Agent Builder - "Create Blank" button for skipping the prompt - Integrate modal into AgentModalProvider for shared state across sidebar - Wire up AddButton, NewAgentButton, and dropdown menus to open modal Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: optimitic update rename * chore: prefetch agent detail * feat: add recent topic meta data * feat: add recents search * ⚡ perf: optimize recents API with single UNION query and prefetch - Replace 3 separate DB queries with single UNION ALL query (RecentModel) - Add optimistic updates for rename and delete actions - Add hover prefetch for resources (usePrefetchResource) - Add hover prefetch for agent config on topic/task items - Change default pageSize to 5 for both Agents and Recents - Unify delete confirmation messages per item type Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: adjust settings page * chore: optimize side bar * feat: recents support right click * chore: add pin icon to Agents * chore: add custom side bar modal * chore: reserve rencent drawer status * feat: add prefetch route * feat: add LobeAI prefetch * fix: document and task rename and delete operation lost * fix: group route id * fix: lint error --------- Co-authored-by: Claude <noreply@anthropic.com>
2026-04-10 16:13:19 +00:00
}, [storeApi]);
const handleAutoComplete = useCallback(
async ({
abortSignal,
afterText,
input,
}: {
abortSignal: AbortSignal;
afterText: string;
editor: any;
input: string;
selectionType: string;
}): Promise<string | null> => {
// Skip autocomplete during IME composition (e.g. Chinese input method)
if (isComposingRef.current) return null;
if (!input.trim()) return null;
✨ feat(heterogeneous-agent): git-aware runtime config + topic rename modal + inspectors (#13951) * ✨ feat(cc-desktop): git-aware runtime config + topic rename modal + inspectors Cluster of desktop UX improvements around the Claude Code integration: - CC chat input runtime bar: branch switcher, git status, and a richer working-directory bar powered by a new SystemCtr git API (branch list / current status) and `useGitInfo` hook. - Topic rename: switch to a dedicated RenameModal component; add an auto-rename action in the conversation header menu. - ToolSearch inspector for the CC tool client. - Shared DotsLoading indicator. - Operation slice tidy-ups for CC flows. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ♻️ refactor(types): rename heterogeneous provider type `claudecode` → `claude-code` Align the type literal with the npm/CLI naming convention used elsewhere (@lobechat/builtin-tool-claude-code, claude-code provider id) so the union matches the rest of the codebase. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 💄 style(cc-desktop): polish TodoWrite labels, branch switcher refresh, and chat input affordances - TodoWrite render + inspector: i18n the header label (Todos / Current step / All tasks completed), surface the active step inline as highlighted text, and switch the in-progress accent from primary to info for better contrast. - BranchSwitcher: move the refresh button into the dropdown's section header, switch the search and create-branch inputs to the filled variant, and reuse DropdownMenuItem for the create-branch entry instead of a custom footer chip. - GitStatus: drop the inline refresh affordance (now lives in the switcher), collapse trigger styles, and split the PR badge with its own separator. - WorkingDirectory / WorkingDirectoryBar: tighten paddings and gaps so the runtime config row reads at a consistent height. - InputEditor: skip inline placeholder completion when the cursor is not at end of paragraph — inserting a placeholder mid-text triggered nested editor updates that froze the input. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 🐛 fix(cc-desktop): probe repoType for working dirs not cached in recents GitStatus was gated on the `repoType` stored in `recentDirs`, but legacy string entries and agent-config-driven paths that never went through the folder picker have no cached `repoType`. As a result, branch / PR status silently disappeared for valid git repos until users re-selected the folder. Promote `detectRepoType` to a public IPC method and add a `useRepoType` hook that uses the cached value as a fast path, otherwise probes the filesystem via SWR and backfills the recents entry so subsequent reads hit cache. Both runtime config bars (CC mode + heterogeneous chat input) now resolve `repoType` through the hook. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 💄 style(shared-tool-ui): rework Bash/Grep/Glob inspector rows - RunCommand: terminal-prompt icon + mono command text instead of underline highlight - Grep: split pattern by `|` into mono tag chips - Glob: single mono tag chip matching Grep - Switch rows to baseline alignment so the smaller mono text lines up with the label Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 🐛 fix(DotsLoading): allow optional color in styles params The Required<StyleArgs> generic forced color to string, but it's only defaulted at the CSS level via fallback to token.colorTextSecondary. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-18 10:40:39 +00:00
// Skip when cursor is not at end of paragraph — inserting a placeholder
// mid-text causes nested editor updates that freeze the input
if (afterText.trim()) return null;
✨ feat: layout sidebar impl (#13719) * ♻️ Restructure sidebar layout: extract Lobe AI entry, move New Agent button - Extract Lobe AI (InboxItem) from agent list to standalone top entry in sidebar body - Move "New Agent" button from header to below Lobe AI entry - Add "Create" to bottom menu items alongside Community and Resources - Filter hidden items in BottomMenu component Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ✨ Add unified Recents section to home page - New TRPC router `recent.getAll` aggregating topics, documents, files, and tasks - New client service and SWR-based store integration for recents data - Unified Recents component on home page with type-based icons - Items sorted by updatedAt, limited to 10, mixed across all types Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ⚡ Prefetch agent config on hover for faster page loads - Add usePrefetchAgent hook using SWR mutate to warm cache - Trigger prefetch on mouseEnter for sidebar agent items - Reduces or eliminates loading screen when navigating to agent pages Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ✨ Redesign agent homepage with info, recent topics, and tasks - New AgentHome feature replacing the old AgentWelcome component - Agent info section: avatar, name, description, opening questions - Recent Topics: horizontal scrollable cards for agent-specific topics - Tasks section: list with status labels for agent-assigned tasks - Preserve ToolAuthAlert for tool authorization flows Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * fix: common misstakes in layout * chore: add fetch Recents cache * chore: add back createagents * chore: add back lobe ai * feat: add display count * feat: add create agent button * feat: add sidebar section order * chore: move divider * ✨ feat: show current page size in display items submenu Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add sidebar display management with customize sidebar modal - Add "Hide section" and "Customize sidebar" to Recents/Agents dropdown menus - Create CustomizeSidebarModal with eye toggle for section visibility - BottomMenu (Community/Resources) also manageable via modal - Show customize sidebar button in footer when all sections hidden - Add hiddenSidebarSections to store with localStorage persistence - Rename "Display Items" to "Show" in dropdown menus - Add 12px margin between accordion sections and bottom menu - Add i18n keys for en-US and zh-CN Fixes LOBE-6938 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 💄 style: use SlidersHorizontal icon for customize sidebar Replace Settings2/PanelLeft icon with SlidersHorizontal to avoid confusion with the settings gear icon. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 💄 style: refine sidebar customization UX - Move Settings entry from Footer to BottomMenu alongside Community/Resources - Add Settings to Customize sidebar modal with eye toggle - Allow hiding all sections (remove disabled constraint) - Move Customize sidebar button next to help button in Footer - Merge Agent dropdown: group Create items with Category items - Use SlidersHorizontal icon for Customize sidebar Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add recents item actions and "more" drawer - Add inline rename (same as Agent Topic) and delete to Recents items - Topic/document/file support rename + delete, task supports delete only - Add "more" button when items exceed pageSize, opens AllRecentsDrawer - AllRecentsDrawer shows all cached recents from store (up to 50) - Fetch max(pageSize, 50) items to support drawer without extra request Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add create agent/group modal with ChatInput and examples - Add CreateAgentModal using base-ui Modal with ChatInputProvider - Show suggestion examples (agent/group mode) in 2-column grid - Submit triggers sendAsAgent/sendAsGroup to auto-generate via Agent Builder - "Create Blank" button for skipping the prompt - Integrate modal into AgentModalProvider for shared state across sidebar - Wire up AddButton, NewAgentButton, and dropdown menus to open modal Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: optimitic update rename * chore: prefetch agent detail * feat: add recent topic meta data * feat: add recents search * ⚡ perf: optimize recents API with single UNION query and prefetch - Replace 3 separate DB queries with single UNION ALL query (RecentModel) - Add optimistic updates for rename and delete actions - Add hover prefetch for resources (usePrefetchResource) - Add hover prefetch for agent config on topic/task items - Change default pageSize to 5 for both Agents and Recents - Unify delete confirmation messages per item type Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: adjust settings page * chore: optimize side bar * feat: recents support right click * chore: add pin icon to Agents * chore: add custom side bar modal * chore: reserve rencent drawer status * feat: add prefetch route * feat: add LobeAI prefetch * fix: document and task rename and delete operation lost * fix: group route id * fix: lint error --------- Co-authored-by: Claude <noreply@anthropic.com>
2026-04-10 16:13:19 +00:00
const { enabled: _, ...config } = systemAgentSelectors.inputCompletion(
useUserStore.getState(),
);
const context = getMessagesRef.current?.();
const chainParams = chainInputCompletion(input, afterText, context);
const abortController = new AbortController();
abortSignal.addEventListener('abort', () => abortController.abort());
let result = '';
try {
await chatService.fetchPresetTaskResult({
abortController,
onMessageHandle: (chunk) => {
if (chunk.type === 'text') {
result += chunk.text;
}
},
params: merge(config, chainParams),
});
✨ feat: layout sidebar impl (#13719) * ♻️ Restructure sidebar layout: extract Lobe AI entry, move New Agent button - Extract Lobe AI (InboxItem) from agent list to standalone top entry in sidebar body - Move "New Agent" button from header to below Lobe AI entry - Add "Create" to bottom menu items alongside Community and Resources - Filter hidden items in BottomMenu component Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ✨ Add unified Recents section to home page - New TRPC router `recent.getAll` aggregating topics, documents, files, and tasks - New client service and SWR-based store integration for recents data - Unified Recents component on home page with type-based icons - Items sorted by updatedAt, limited to 10, mixed across all types Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ⚡ Prefetch agent config on hover for faster page loads - Add usePrefetchAgent hook using SWR mutate to warm cache - Trigger prefetch on mouseEnter for sidebar agent items - Reduces or eliminates loading screen when navigating to agent pages Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ✨ Redesign agent homepage with info, recent topics, and tasks - New AgentHome feature replacing the old AgentWelcome component - Agent info section: avatar, name, description, opening questions - Recent Topics: horizontal scrollable cards for agent-specific topics - Tasks section: list with status labels for agent-assigned tasks - Preserve ToolAuthAlert for tool authorization flows Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * fix: common misstakes in layout * chore: add fetch Recents cache * chore: add back createagents * chore: add back lobe ai * feat: add display count * feat: add create agent button * feat: add sidebar section order * chore: move divider * ✨ feat: show current page size in display items submenu Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add sidebar display management with customize sidebar modal - Add "Hide section" and "Customize sidebar" to Recents/Agents dropdown menus - Create CustomizeSidebarModal with eye toggle for section visibility - BottomMenu (Community/Resources) also manageable via modal - Show customize sidebar button in footer when all sections hidden - Add hiddenSidebarSections to store with localStorage persistence - Rename "Display Items" to "Show" in dropdown menus - Add 12px margin between accordion sections and bottom menu - Add i18n keys for en-US and zh-CN Fixes LOBE-6938 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 💄 style: use SlidersHorizontal icon for customize sidebar Replace Settings2/PanelLeft icon with SlidersHorizontal to avoid confusion with the settings gear icon. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 💄 style: refine sidebar customization UX - Move Settings entry from Footer to BottomMenu alongside Community/Resources - Add Settings to Customize sidebar modal with eye toggle - Allow hiding all sections (remove disabled constraint) - Move Customize sidebar button next to help button in Footer - Merge Agent dropdown: group Create items with Category items - Use SlidersHorizontal icon for Customize sidebar Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add recents item actions and "more" drawer - Add inline rename (same as Agent Topic) and delete to Recents items - Topic/document/file support rename + delete, task supports delete only - Add "more" button when items exceed pageSize, opens AllRecentsDrawer - AllRecentsDrawer shows all cached recents from store (up to 50) - Fetch max(pageSize, 50) items to support drawer without extra request Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add create agent/group modal with ChatInput and examples - Add CreateAgentModal using base-ui Modal with ChatInputProvider - Show suggestion examples (agent/group mode) in 2-column grid - Submit triggers sendAsAgent/sendAsGroup to auto-generate via Agent Builder - "Create Blank" button for skipping the prompt - Integrate modal into AgentModalProvider for shared state across sidebar - Wire up AddButton, NewAgentButton, and dropdown menus to open modal Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: optimitic update rename * chore: prefetch agent detail * feat: add recent topic meta data * feat: add recents search * ⚡ perf: optimize recents API with single UNION query and prefetch - Replace 3 separate DB queries with single UNION ALL query (RecentModel) - Add optimistic updates for rename and delete actions - Add hover prefetch for resources (usePrefetchResource) - Add hover prefetch for agent config on topic/task items - Change default pageSize to 5 for both Agents and Recents - Unify delete confirmation messages per item type Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: adjust settings page * chore: optimize side bar * feat: recents support right click * chore: add pin icon to Agents * chore: add custom side bar modal * chore: reserve rencent drawer status * feat: add prefetch route * feat: add LobeAI prefetch * fix: document and task rename and delete operation lost * fix: group route id * fix: lint error --------- Co-authored-by: Claude <noreply@anthropic.com>
2026-04-10 16:13:19 +00:00
} catch {
return null;
}
✨ feat: layout sidebar impl (#13719) * ♻️ Restructure sidebar layout: extract Lobe AI entry, move New Agent button - Extract Lobe AI (InboxItem) from agent list to standalone top entry in sidebar body - Move "New Agent" button from header to below Lobe AI entry - Add "Create" to bottom menu items alongside Community and Resources - Filter hidden items in BottomMenu component Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ✨ Add unified Recents section to home page - New TRPC router `recent.getAll` aggregating topics, documents, files, and tasks - New client service and SWR-based store integration for recents data - Unified Recents component on home page with type-based icons - Items sorted by updatedAt, limited to 10, mixed across all types Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ⚡ Prefetch agent config on hover for faster page loads - Add usePrefetchAgent hook using SWR mutate to warm cache - Trigger prefetch on mouseEnter for sidebar agent items - Reduces or eliminates loading screen when navigating to agent pages Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ✨ Redesign agent homepage with info, recent topics, and tasks - New AgentHome feature replacing the old AgentWelcome component - Agent info section: avatar, name, description, opening questions - Recent Topics: horizontal scrollable cards for agent-specific topics - Tasks section: list with status labels for agent-assigned tasks - Preserve ToolAuthAlert for tool authorization flows Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * fix: common misstakes in layout * chore: add fetch Recents cache * chore: add back createagents * chore: add back lobe ai * feat: add display count * feat: add create agent button * feat: add sidebar section order * chore: move divider * ✨ feat: show current page size in display items submenu Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add sidebar display management with customize sidebar modal - Add "Hide section" and "Customize sidebar" to Recents/Agents dropdown menus - Create CustomizeSidebarModal with eye toggle for section visibility - BottomMenu (Community/Resources) also manageable via modal - Show customize sidebar button in footer when all sections hidden - Add hiddenSidebarSections to store with localStorage persistence - Rename "Display Items" to "Show" in dropdown menus - Add 12px margin between accordion sections and bottom menu - Add i18n keys for en-US and zh-CN Fixes LOBE-6938 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 💄 style: use SlidersHorizontal icon for customize sidebar Replace Settings2/PanelLeft icon with SlidersHorizontal to avoid confusion with the settings gear icon. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 💄 style: refine sidebar customization UX - Move Settings entry from Footer to BottomMenu alongside Community/Resources - Add Settings to Customize sidebar modal with eye toggle - Allow hiding all sections (remove disabled constraint) - Move Customize sidebar button next to help button in Footer - Merge Agent dropdown: group Create items with Category items - Use SlidersHorizontal icon for Customize sidebar Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add recents item actions and "more" drawer - Add inline rename (same as Agent Topic) and delete to Recents items - Topic/document/file support rename + delete, task supports delete only - Add "more" button when items exceed pageSize, opens AllRecentsDrawer - AllRecentsDrawer shows all cached recents from store (up to 50) - Fetch max(pageSize, 50) items to support drawer without extra request Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add create agent/group modal with ChatInput and examples - Add CreateAgentModal using base-ui Modal with ChatInputProvider - Show suggestion examples (agent/group mode) in 2-column grid - Submit triggers sendAsAgent/sendAsGroup to auto-generate via Agent Builder - "Create Blank" button for skipping the prompt - Integrate modal into AgentModalProvider for shared state across sidebar - Wire up AddButton, NewAgentButton, and dropdown menus to open modal Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: optimitic update rename * chore: prefetch agent detail * feat: add recent topic meta data * feat: add recents search * ⚡ perf: optimize recents API with single UNION query and prefetch - Replace 3 separate DB queries with single UNION ALL query (RecentModel) - Add optimistic updates for rename and delete actions - Add hover prefetch for resources (usePrefetchResource) - Add hover prefetch for agent config on topic/task items - Change default pageSize to 5 for both Agents and Recents - Unify delete confirmation messages per item type Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: adjust settings page * chore: optimize side bar * feat: recents support right click * chore: add pin icon to Agents * chore: add custom side bar modal * chore: reserve rencent drawer status * feat: add prefetch route * feat: add LobeAI prefetch * fix: document and task rename and delete operation lost * fix: group route id * fix: lint error --------- Co-authored-by: Claude <noreply@anthropic.com>
2026-04-10 16:13:19 +00:00
if (abortSignal.aborted) return null;
return result.trimEnd() || null;
},
[],
);
const autoCompletePlugin = useMemo(
() =>
isAutoCompleteEnabled
? Editor.withProps(ReactAutoCompletePlugin, {
delay: 600,
onAutoComplete: handleAutoComplete,
})
: null,
[isAutoCompleteEnabled, handleAutoComplete],
);
// --- Stable mentionOption & slashOption to prevent infinite re-render on paste ---
const mentionMarkdownWriter = useCallback((mention: any) => {
if (mention.metadata?.type === 'topic') {
return `<refer_topic name="${mention.metadata.topicTitle}" id="${mention.metadata.topicId}" />`;
}
return `<mention name="${mention.label}" id="${mention.metadata.id}" />`;
}, []);
const mentionOnSelect = useCallback((editor: any, option: any) => {
if (option.metadata?.type === 'topic') {
editor.dispatchCommand(INSERT_REFER_TOPIC_COMMAND, {
topicId: option.metadata.topicId as string,
topicTitle: String(option.metadata.topicTitle ?? option.label),
});
} else if (option.metadata?.type === 'skill' || option.metadata?.type === 'tool') {
const payload: InsertActionTagPayload = {
category: option.metadata.actionCategory as 'skill' | 'tool',
label: String(option.label),
type: String(option.metadata.actionType),
};
editor.dispatchCommand(INSERT_ACTION_TAG_COMMAND, payload);
} else {
editor.dispatchCommand(INSERT_MENTION_COMMAND, {
label: String(option.label),
metadata: option.metadata,
});
}
}, []);
const mentionOption = useMemo(
() =>
enableMention
? {
items: mentionItemsFn,
markdownWriter: mentionMarkdownWriter,
maxLength: 50,
onSelect: mentionOnSelect,
renderComp: MentionMenuComp,
}
: undefined,
[enableMention, mentionItemsFn, mentionMarkdownWriter, mentionOnSelect, MentionMenuComp],
);
const slashOption = useMemo(() => ({ items: slashItems }), [slashItems]);
const richRenderProps = useMemo(() => {
const basePlugins = !enableRichRender
? CHAT_INPUT_EMBED_PLUGINS
: createChatInputRichPlugins({
mathPlugin: Editor.withProps(ReactMathPlugin, {
renderComp: expand
? undefined
: (props) => (
<FloatMenu
{...props}
getPopupContainer={() => (slashMenuRef as any)?.current}
/>
),
}),
});
✨ feat: layout sidebar impl (#13719) * ♻️ Restructure sidebar layout: extract Lobe AI entry, move New Agent button - Extract Lobe AI (InboxItem) from agent list to standalone top entry in sidebar body - Move "New Agent" button from header to below Lobe AI entry - Add "Create" to bottom menu items alongside Community and Resources - Filter hidden items in BottomMenu component Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ✨ Add unified Recents section to home page - New TRPC router `recent.getAll` aggregating topics, documents, files, and tasks - New client service and SWR-based store integration for recents data - Unified Recents component on home page with type-based icons - Items sorted by updatedAt, limited to 10, mixed across all types Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ⚡ Prefetch agent config on hover for faster page loads - Add usePrefetchAgent hook using SWR mutate to warm cache - Trigger prefetch on mouseEnter for sidebar agent items - Reduces or eliminates loading screen when navigating to agent pages Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ✨ Redesign agent homepage with info, recent topics, and tasks - New AgentHome feature replacing the old AgentWelcome component - Agent info section: avatar, name, description, opening questions - Recent Topics: horizontal scrollable cards for agent-specific topics - Tasks section: list with status labels for agent-assigned tasks - Preserve ToolAuthAlert for tool authorization flows Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * fix: common misstakes in layout * chore: add fetch Recents cache * chore: add back createagents * chore: add back lobe ai * feat: add display count * feat: add create agent button * feat: add sidebar section order * chore: move divider * ✨ feat: show current page size in display items submenu Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add sidebar display management with customize sidebar modal - Add "Hide section" and "Customize sidebar" to Recents/Agents dropdown menus - Create CustomizeSidebarModal with eye toggle for section visibility - BottomMenu (Community/Resources) also manageable via modal - Show customize sidebar button in footer when all sections hidden - Add hiddenSidebarSections to store with localStorage persistence - Rename "Display Items" to "Show" in dropdown menus - Add 12px margin between accordion sections and bottom menu - Add i18n keys for en-US and zh-CN Fixes LOBE-6938 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 💄 style: use SlidersHorizontal icon for customize sidebar Replace Settings2/PanelLeft icon with SlidersHorizontal to avoid confusion with the settings gear icon. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 💄 style: refine sidebar customization UX - Move Settings entry from Footer to BottomMenu alongside Community/Resources - Add Settings to Customize sidebar modal with eye toggle - Allow hiding all sections (remove disabled constraint) - Move Customize sidebar button next to help button in Footer - Merge Agent dropdown: group Create items with Category items - Use SlidersHorizontal icon for Customize sidebar Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add recents item actions and "more" drawer - Add inline rename (same as Agent Topic) and delete to Recents items - Topic/document/file support rename + delete, task supports delete only - Add "more" button when items exceed pageSize, opens AllRecentsDrawer - AllRecentsDrawer shows all cached recents from store (up to 50) - Fetch max(pageSize, 50) items to support drawer without extra request Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add create agent/group modal with ChatInput and examples - Add CreateAgentModal using base-ui Modal with ChatInputProvider - Show suggestion examples (agent/group mode) in 2-column grid - Submit triggers sendAsAgent/sendAsGroup to auto-generate via Agent Builder - "Create Blank" button for skipping the prompt - Integrate modal into AgentModalProvider for shared state across sidebar - Wire up AddButton, NewAgentButton, and dropdown menus to open modal Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: optimitic update rename * chore: prefetch agent detail * feat: add recent topic meta data * feat: add recents search * ⚡ perf: optimize recents API with single UNION query and prefetch - Replace 3 separate DB queries with single UNION ALL query (RecentModel) - Add optimistic updates for rename and delete actions - Add hover prefetch for resources (usePrefetchResource) - Add hover prefetch for agent config on topic/task items - Change default pageSize to 5 for both Agents and Recents - Unify delete confirmation messages per item type Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: adjust settings page * chore: optimize side bar * feat: recents support right click * chore: add pin icon to Agents * chore: add custom side bar modal * chore: reserve rencent drawer status * feat: add prefetch route * feat: add LobeAI prefetch * fix: document and task rename and delete operation lost * fix: group route id * fix: lint error --------- Co-authored-by: Claude <noreply@anthropic.com>
2026-04-10 16:13:19 +00:00
const plugins = autoCompletePlugin ? [...basePlugins, autoCompletePlugin] : basePlugins;
return !enableRichRender
? { enablePasteMarkdown: false, markdownOption: false, plugins }
: { plugins };
}, [enableRichRender, expand, slashMenuRef, autoCompletePlugin]);
return (
<Editor
autoFocus
pasteAsPlainText
className={className}
content={''}
editor={editor}
{...{ slashPlacement }}
{...richRenderProps}
mentionOption={mentionOption}
placeholder={placeholder ?? <Placeholder />}
slashOption={slashOption}
type={'text'}
variant={'chat'}
style={{
minHeight: defaultRows > 1 ? defaultRows * 23 : undefined,
}}
onCompositionEnd={({ event }) => compositionProps.onCompositionEnd(event)}
onBlur={() => {
disableScope(HotkeyEnum.AddUserMessage);
}}
onChange={() => {
updateMarkdownContent();
}}
🐛 fix(desktop): repo-type detection for submodule/worktree + chat & sidebar polish (#13978) * 🐛 fix(desktop): detect repo type for submodule and worktree directories Route detectRepoType through resolveGitDir so directories where `.git` is a pointer file (submodules, worktrees) are correctly identified as git/github repos instead of falling back to the plain folder icon. Fixes LOBE-7373 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 🐛 fix(desktop): reprobe repo type for stale recent-dir entries The recents picker rendered `entry.repoType` directly from localStorage, so any submodule/worktree entry cached while `detectRepoType` still returned `undefined` stayed stuck on the folder icon even after the main-process fix. Wrap each row icon in a component that calls `useRepoType`, which re-probes missing entries and backfills the cache. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 🐛 fix(chat-input): clear autocomplete hint on IME start to prevent freeze Dispatch KEY_ESCAPE_COMMAND on compositionstart so the autocomplete plugin removes PlaceholderInline/PlaceholderBlock nodes before the IME begins composing. Composing next to those placeholder nodes caused the editor to freeze during pinyin input with a visible hint. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ♻️ refactor(topic-sidebar): split project grouping into ByProjectMode Extracts project-specific group rendering from ByTimeMode into its own ByProjectMode folder, with a shared GroupedAccordion container. Project groups get a folder-icon column aligned with the topic item layout and a "new topic in {directory}" action. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 🐛 fix(desktop): read config via commondir for linked worktrees `resolveGitDir` returns `.git/worktrees/<name>/` for linked worktrees — that dir has its own `HEAD` but no `config`, so `detectRepoType` still returned `undefined` and worktrees missed the repo icon. Resolve the `commondir` pointer first so `config` is read from the shared gitdir. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-19 15:56:39 +00:00
onCompositionStart={({ event }) => {
compositionProps.onCompositionStart(event);
// Clear autocomplete placeholder nodes before IME composition starts —
// composing next to placeholder inline nodes freezes the editor.
if (isAutoCompleteEnabled) {
editor?.dispatchCommand(
KEY_ESCAPE_COMMAND,
new KeyboardEvent('keydown', { key: 'Escape' }),
);
}
}}
✨ feat: layout sidebar impl (#13719) * ♻️ Restructure sidebar layout: extract Lobe AI entry, move New Agent button - Extract Lobe AI (InboxItem) from agent list to standalone top entry in sidebar body - Move "New Agent" button from header to below Lobe AI entry - Add "Create" to bottom menu items alongside Community and Resources - Filter hidden items in BottomMenu component Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ✨ Add unified Recents section to home page - New TRPC router `recent.getAll` aggregating topics, documents, files, and tasks - New client service and SWR-based store integration for recents data - Unified Recents component on home page with type-based icons - Items sorted by updatedAt, limited to 10, mixed across all types Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ⚡ Prefetch agent config on hover for faster page loads - Add usePrefetchAgent hook using SWR mutate to warm cache - Trigger prefetch on mouseEnter for sidebar agent items - Reduces or eliminates loading screen when navigating to agent pages Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ✨ Redesign agent homepage with info, recent topics, and tasks - New AgentHome feature replacing the old AgentWelcome component - Agent info section: avatar, name, description, opening questions - Recent Topics: horizontal scrollable cards for agent-specific topics - Tasks section: list with status labels for agent-assigned tasks - Preserve ToolAuthAlert for tool authorization flows Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * fix: common misstakes in layout * chore: add fetch Recents cache * chore: add back createagents * chore: add back lobe ai * feat: add display count * feat: add create agent button * feat: add sidebar section order * chore: move divider * ✨ feat: show current page size in display items submenu Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add sidebar display management with customize sidebar modal - Add "Hide section" and "Customize sidebar" to Recents/Agents dropdown menus - Create CustomizeSidebarModal with eye toggle for section visibility - BottomMenu (Community/Resources) also manageable via modal - Show customize sidebar button in footer when all sections hidden - Add hiddenSidebarSections to store with localStorage persistence - Rename "Display Items" to "Show" in dropdown menus - Add 12px margin between accordion sections and bottom menu - Add i18n keys for en-US and zh-CN Fixes LOBE-6938 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 💄 style: use SlidersHorizontal icon for customize sidebar Replace Settings2/PanelLeft icon with SlidersHorizontal to avoid confusion with the settings gear icon. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 💄 style: refine sidebar customization UX - Move Settings entry from Footer to BottomMenu alongside Community/Resources - Add Settings to Customize sidebar modal with eye toggle - Allow hiding all sections (remove disabled constraint) - Move Customize sidebar button next to help button in Footer - Merge Agent dropdown: group Create items with Category items - Use SlidersHorizontal icon for Customize sidebar Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add recents item actions and "more" drawer - Add inline rename (same as Agent Topic) and delete to Recents items - Topic/document/file support rename + delete, task supports delete only - Add "more" button when items exceed pageSize, opens AllRecentsDrawer - AllRecentsDrawer shows all cached recents from store (up to 50) - Fetch max(pageSize, 50) items to support drawer without extra request Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add create agent/group modal with ChatInput and examples - Add CreateAgentModal using base-ui Modal with ChatInputProvider - Show suggestion examples (agent/group mode) in 2-column grid - Submit triggers sendAsAgent/sendAsGroup to auto-generate via Agent Builder - "Create Blank" button for skipping the prompt - Integrate modal into AgentModalProvider for shared state across sidebar - Wire up AddButton, NewAgentButton, and dropdown menus to open modal Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: optimitic update rename * chore: prefetch agent detail * feat: add recent topic meta data * feat: add recents search * ⚡ perf: optimize recents API with single UNION query and prefetch - Replace 3 separate DB queries with single UNION ALL query (RecentModel) - Add optimistic updates for rename and delete actions - Add hover prefetch for resources (usePrefetchResource) - Add hover prefetch for agent config on topic/task items - Change default pageSize to 5 for both Agents and Recents - Unify delete confirmation messages per item type Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: adjust settings page * chore: optimize side bar * feat: recents support right click * chore: add pin icon to Agents * chore: add custom side bar modal * chore: reserve rencent drawer status * feat: add prefetch route * feat: add LobeAI prefetch * fix: document and task rename and delete operation lost * fix: group route id * fix: lint error --------- Co-authored-by: Claude <noreply@anthropic.com>
2026-04-10 16:13:19 +00:00
onContextMenu={async ({ event: e, editor }) => {
if (isDesktop) {
e.preventDefault();
const { electronSystemService } = await import('@/services/electron/system');
const selectionText = editor.getSelectionDocument('markdown') as unknown as string;
await electronSystemService.showContextMenu('editor', {
selectionText: selectionText || undefined,
});
}
✨ feat: layout sidebar impl (#13719) * ♻️ Restructure sidebar layout: extract Lobe AI entry, move New Agent button - Extract Lobe AI (InboxItem) from agent list to standalone top entry in sidebar body - Move "New Agent" button from header to below Lobe AI entry - Add "Create" to bottom menu items alongside Community and Resources - Filter hidden items in BottomMenu component Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ✨ Add unified Recents section to home page - New TRPC router `recent.getAll` aggregating topics, documents, files, and tasks - New client service and SWR-based store integration for recents data - Unified Recents component on home page with type-based icons - Items sorted by updatedAt, limited to 10, mixed across all types Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ⚡ Prefetch agent config on hover for faster page loads - Add usePrefetchAgent hook using SWR mutate to warm cache - Trigger prefetch on mouseEnter for sidebar agent items - Reduces or eliminates loading screen when navigating to agent pages Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ✨ Redesign agent homepage with info, recent topics, and tasks - New AgentHome feature replacing the old AgentWelcome component - Agent info section: avatar, name, description, opening questions - Recent Topics: horizontal scrollable cards for agent-specific topics - Tasks section: list with status labels for agent-assigned tasks - Preserve ToolAuthAlert for tool authorization flows Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * fix: common misstakes in layout * chore: add fetch Recents cache * chore: add back createagents * chore: add back lobe ai * feat: add display count * feat: add create agent button * feat: add sidebar section order * chore: move divider * ✨ feat: show current page size in display items submenu Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add sidebar display management with customize sidebar modal - Add "Hide section" and "Customize sidebar" to Recents/Agents dropdown menus - Create CustomizeSidebarModal with eye toggle for section visibility - BottomMenu (Community/Resources) also manageable via modal - Show customize sidebar button in footer when all sections hidden - Add hiddenSidebarSections to store with localStorage persistence - Rename "Display Items" to "Show" in dropdown menus - Add 12px margin between accordion sections and bottom menu - Add i18n keys for en-US and zh-CN Fixes LOBE-6938 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 💄 style: use SlidersHorizontal icon for customize sidebar Replace Settings2/PanelLeft icon with SlidersHorizontal to avoid confusion with the settings gear icon. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 💄 style: refine sidebar customization UX - Move Settings entry from Footer to BottomMenu alongside Community/Resources - Add Settings to Customize sidebar modal with eye toggle - Allow hiding all sections (remove disabled constraint) - Move Customize sidebar button next to help button in Footer - Merge Agent dropdown: group Create items with Category items - Use SlidersHorizontal icon for Customize sidebar Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add recents item actions and "more" drawer - Add inline rename (same as Agent Topic) and delete to Recents items - Topic/document/file support rename + delete, task supports delete only - Add "more" button when items exceed pageSize, opens AllRecentsDrawer - AllRecentsDrawer shows all cached recents from store (up to 50) - Fetch max(pageSize, 50) items to support drawer without extra request Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add create agent/group modal with ChatInput and examples - Add CreateAgentModal using base-ui Modal with ChatInputProvider - Show suggestion examples (agent/group mode) in 2-column grid - Submit triggers sendAsAgent/sendAsGroup to auto-generate via Agent Builder - "Create Blank" button for skipping the prompt - Integrate modal into AgentModalProvider for shared state across sidebar - Wire up AddButton, NewAgentButton, and dropdown menus to open modal Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: optimitic update rename * chore: prefetch agent detail * feat: add recent topic meta data * feat: add recents search * ⚡ perf: optimize recents API with single UNION query and prefetch - Replace 3 separate DB queries with single UNION ALL query (RecentModel) - Add optimistic updates for rename and delete actions - Add hover prefetch for resources (usePrefetchResource) - Add hover prefetch for agent config on topic/task items - Change default pageSize to 5 for both Agents and Recents - Unify delete confirmation messages per item type Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: adjust settings page * chore: optimize side bar * feat: recents support right click * chore: add pin icon to Agents * chore: add custom side bar modal * chore: reserve rencent drawer status * feat: add prefetch route * feat: add LobeAI prefetch * fix: document and task rename and delete operation lost * fix: group route id * fix: lint error --------- Co-authored-by: Claude <noreply@anthropic.com>
2026-04-10 16:13:19 +00:00
}}
onFocus={() => {
enableScope(HotkeyEnum.AddUserMessage);
}}
onInit={(editor) => {
const saved = storeApi.getState()._savedEditorState;
storeApi.setState({ _savedEditorState: undefined, editor });
if (saved) {
requestAnimationFrame(() => {
editor.setDocument('json', saved);
});
}
✨ feat: layout sidebar impl (#13719) * ♻️ Restructure sidebar layout: extract Lobe AI entry, move New Agent button - Extract Lobe AI (InboxItem) from agent list to standalone top entry in sidebar body - Move "New Agent" button from header to below Lobe AI entry - Add "Create" to bottom menu items alongside Community and Resources - Filter hidden items in BottomMenu component Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ✨ Add unified Recents section to home page - New TRPC router `recent.getAll` aggregating topics, documents, files, and tasks - New client service and SWR-based store integration for recents data - Unified Recents component on home page with type-based icons - Items sorted by updatedAt, limited to 10, mixed across all types Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ⚡ Prefetch agent config on hover for faster page loads - Add usePrefetchAgent hook using SWR mutate to warm cache - Trigger prefetch on mouseEnter for sidebar agent items - Reduces or eliminates loading screen when navigating to agent pages Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ✨ Redesign agent homepage with info, recent topics, and tasks - New AgentHome feature replacing the old AgentWelcome component - Agent info section: avatar, name, description, opening questions - Recent Topics: horizontal scrollable cards for agent-specific topics - Tasks section: list with status labels for agent-assigned tasks - Preserve ToolAuthAlert for tool authorization flows Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * fix: common misstakes in layout * chore: add fetch Recents cache * chore: add back createagents * chore: add back lobe ai * feat: add display count * feat: add create agent button * feat: add sidebar section order * chore: move divider * ✨ feat: show current page size in display items submenu Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add sidebar display management with customize sidebar modal - Add "Hide section" and "Customize sidebar" to Recents/Agents dropdown menus - Create CustomizeSidebarModal with eye toggle for section visibility - BottomMenu (Community/Resources) also manageable via modal - Show customize sidebar button in footer when all sections hidden - Add hiddenSidebarSections to store with localStorage persistence - Rename "Display Items" to "Show" in dropdown menus - Add 12px margin between accordion sections and bottom menu - Add i18n keys for en-US and zh-CN Fixes LOBE-6938 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 💄 style: use SlidersHorizontal icon for customize sidebar Replace Settings2/PanelLeft icon with SlidersHorizontal to avoid confusion with the settings gear icon. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 💄 style: refine sidebar customization UX - Move Settings entry from Footer to BottomMenu alongside Community/Resources - Add Settings to Customize sidebar modal with eye toggle - Allow hiding all sections (remove disabled constraint) - Move Customize sidebar button next to help button in Footer - Merge Agent dropdown: group Create items with Category items - Use SlidersHorizontal icon for Customize sidebar Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add recents item actions and "more" drawer - Add inline rename (same as Agent Topic) and delete to Recents items - Topic/document/file support rename + delete, task supports delete only - Add "more" button when items exceed pageSize, opens AllRecentsDrawer - AllRecentsDrawer shows all cached recents from store (up to 50) - Fetch max(pageSize, 50) items to support drawer without extra request Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add create agent/group modal with ChatInput and examples - Add CreateAgentModal using base-ui Modal with ChatInputProvider - Show suggestion examples (agent/group mode) in 2-column grid - Submit triggers sendAsAgent/sendAsGroup to auto-generate via Agent Builder - "Create Blank" button for skipping the prompt - Integrate modal into AgentModalProvider for shared state across sidebar - Wire up AddButton, NewAgentButton, and dropdown menus to open modal Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: optimitic update rename * chore: prefetch agent detail * feat: add recent topic meta data * feat: add recents search * ⚡ perf: optimize recents API with single UNION query and prefetch - Replace 3 separate DB queries with single UNION ALL query (RecentModel) - Add optimistic updates for rename and delete actions - Add hover prefetch for resources (usePrefetchResource) - Add hover prefetch for agent config on topic/task items - Change default pageSize to 5 for both Agents and Recents - Unify delete confirmation messages per item type Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: adjust settings page * chore: optimize side bar * feat: recents support right click * chore: add pin icon to Agents * chore: add custom side bar modal * chore: reserve rencent drawer status * feat: add prefetch route * feat: add LobeAI prefetch * fix: document and task rename and delete operation lost * fix: group route id * fix: lint error --------- Co-authored-by: Claude <noreply@anthropic.com>
2026-04-10 16:13:19 +00:00
}}
onPressEnter={({ event: e }) => {
if (e.shiftKey || isComposingRef.current) return;
// when user like alt + enter to add ai message
if (e.altKey && hotkey === combineKeys([KeyEnum.Alt, KeyEnum.Enter])) return true;
const commandKey = isCommandPressed(e);
// In fullscreen mode, Enter inserts newline; only Cmd/Ctrl+Enter sends
if (expand) {
if (commandKey) {
send();
return true;
}
return;
}
✨ feat: layout sidebar impl (#13719) * ♻️ Restructure sidebar layout: extract Lobe AI entry, move New Agent button - Extract Lobe AI (InboxItem) from agent list to standalone top entry in sidebar body - Move "New Agent" button from header to below Lobe AI entry - Add "Create" to bottom menu items alongside Community and Resources - Filter hidden items in BottomMenu component Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ✨ Add unified Recents section to home page - New TRPC router `recent.getAll` aggregating topics, documents, files, and tasks - New client service and SWR-based store integration for recents data - Unified Recents component on home page with type-based icons - Items sorted by updatedAt, limited to 10, mixed across all types Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ⚡ Prefetch agent config on hover for faster page loads - Add usePrefetchAgent hook using SWR mutate to warm cache - Trigger prefetch on mouseEnter for sidebar agent items - Reduces or eliminates loading screen when navigating to agent pages Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * ✨ Redesign agent homepage with info, recent topics, and tasks - New AgentHome feature replacing the old AgentWelcome component - Agent info section: avatar, name, description, opening questions - Recent Topics: horizontal scrollable cards for agent-specific topics - Tasks section: list with status labels for agent-assigned tasks - Preserve ToolAuthAlert for tool authorization flows Fixes LOBE-6938 https://claude.ai/code/session_01RtfXck3GUngoLAgP2yHArz * fix: common misstakes in layout * chore: add fetch Recents cache * chore: add back createagents * chore: add back lobe ai * feat: add display count * feat: add create agent button * feat: add sidebar section order * chore: move divider * ✨ feat: show current page size in display items submenu Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add sidebar display management with customize sidebar modal - Add "Hide section" and "Customize sidebar" to Recents/Agents dropdown menus - Create CustomizeSidebarModal with eye toggle for section visibility - BottomMenu (Community/Resources) also manageable via modal - Show customize sidebar button in footer when all sections hidden - Add hiddenSidebarSections to store with localStorage persistence - Rename "Display Items" to "Show" in dropdown menus - Add 12px margin between accordion sections and bottom menu - Add i18n keys for en-US and zh-CN Fixes LOBE-6938 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 💄 style: use SlidersHorizontal icon for customize sidebar Replace Settings2/PanelLeft icon with SlidersHorizontal to avoid confusion with the settings gear icon. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 💄 style: refine sidebar customization UX - Move Settings entry from Footer to BottomMenu alongside Community/Resources - Add Settings to Customize sidebar modal with eye toggle - Allow hiding all sections (remove disabled constraint) - Move Customize sidebar button next to help button in Footer - Merge Agent dropdown: group Create items with Category items - Use SlidersHorizontal icon for Customize sidebar Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add recents item actions and "more" drawer - Add inline rename (same as Agent Topic) and delete to Recents items - Topic/document/file support rename + delete, task supports delete only - Add "more" button when items exceed pageSize, opens AllRecentsDrawer - AllRecentsDrawer shows all cached recents from store (up to 50) - Fetch max(pageSize, 50) items to support drawer without extra request Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ✨ feat: add create agent/group modal with ChatInput and examples - Add CreateAgentModal using base-ui Modal with ChatInputProvider - Show suggestion examples (agent/group mode) in 2-column grid - Submit triggers sendAsAgent/sendAsGroup to auto-generate via Agent Builder - "Create Blank" button for skipping the prompt - Integrate modal into AgentModalProvider for shared state across sidebar - Wire up AddButton, NewAgentButton, and dropdown menus to open modal Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: optimitic update rename * chore: prefetch agent detail * feat: add recent topic meta data * feat: add recents search * ⚡ perf: optimize recents API with single UNION query and prefetch - Replace 3 separate DB queries with single UNION ALL query (RecentModel) - Add optimistic updates for rename and delete actions - Add hover prefetch for resources (usePrefetchResource) - Add hover prefetch for agent config on topic/task items - Change default pageSize to 5 for both Agents and Recents - Unify delete confirmation messages per item type Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: adjust settings page * chore: optimize side bar * feat: recents support right click * chore: add pin icon to Agents * chore: add custom side bar modal * chore: reserve rencent drawer status * feat: add prefetch route * feat: add LobeAI prefetch * fix: document and task rename and delete operation lost * fix: group route id * fix: lint error --------- Co-authored-by: Claude <noreply@anthropic.com>
2026-04-10 16:13:19 +00:00
// when user like cmd + enter to send message
if (useCmdEnterToSend) {
if (commandKey) {
send();
return true;
}
} else {
if (!commandKey) {
send();
return true;
}
}
}}
/>
);
},
);
InputEditor.displayName = 'InputEditor';
export default InputEditor;