diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatHeader.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatHeader.tsx
index 79cc2fb5f..d3953b9ae 100644
--- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatHeader.tsx
+++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatHeader.tsx
@@ -11,7 +11,7 @@ import { useBlockActions, useChatActions, useCurrentTitle } from "~/modules/ai-c
import { useAIRootState } from "../../store/AIChatContext"
import { ChatHistoryDropdown } from "./ChatHistoryDropdown"
import { ChatMoreDropdown } from "./ChatMoreDropdown"
-import { EditableTitle } from "./EditableTitle"
+import { AIHeaderTitle } from "./EditableTitle"
import { TaskReportDropdown } from "./TaskReportDropdown"
// Base header layout with shared logic inside
@@ -68,7 +68,7 @@ const ChatHeaderLayout = ({
diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatInput.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatInput.tsx
index 96e97011f..d847124f6 100644
--- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatInput.tsx
+++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatInput.tsx
@@ -5,7 +5,6 @@ import { ScrollArea } from "@follow/components/ui/scroll-area/ScrollArea.js"
import { cn, nextFrame, stopPropagation } from "@follow/utils"
import type { VariantProps } from "class-variance-authority"
import { cva } from "class-variance-authority"
-import { noop } from "es-toolkit"
import type { EditorState, LexicalEditor } from "lexical"
import { $getRoot } from "lexical"
import type { Ref } from "react"
@@ -131,6 +130,7 @@ export const ChatInput = memo(
void handleSend()
return true
}
+
return false
},
[handleSend, isProcessing],
@@ -185,11 +185,7 @@ export const ChatInput = memo(
)}
-
+
diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/EditableTitle.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/EditableTitle.tsx
index aad3d4f36..ef00c7cb4 100644
--- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/EditableTitle.tsx
+++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/EditableTitle.tsx
@@ -1,39 +1,186 @@
import { cn } from "@follow/utils/utils"
import type { ButtonHTMLAttributes } from "react"
+import { useCallback, useEffect, useRef, useState } from "react"
-interface EditableTitleProps extends Omit, "type"> {
- title?: string
- placeholder?: string
+import { useChatActions } from "~/modules/ai-chat/store/hooks"
+
+interface TitleInputProps {
+ initialValue: string
+ placeholder: string
+ onSave: (value: string) => Promise
+ onCancel: () => void
}
-export const EditableTitle = function EditableTitle({
+const TitleInput = ({ initialValue, placeholder, onSave, onCancel }: TitleInputProps) => {
+ const [editValue, setEditValue] = useState(initialValue)
+ const [isSaving, setIsSaving] = useState(false)
+ const [saveSuccess, setSaveSuccess] = useState(false)
+ const inputRef = useRef(null)
+
+ // Auto-focus and select input on mount
+ useEffect(() => {
+ if (inputRef.current) {
+ inputRef.current.focus()
+ inputRef.current.select()
+ }
+ }, [])
+
+ const handleSave = useCallback(async () => {
+ if (isSaving) return
+
+ const trimmedValue = editValue.trim()
+
+ // If no changes, just cancel
+ if (trimmedValue === initialValue) {
+ onCancel()
+ return
+ }
+
+ try {
+ setIsSaving(true)
+ await onSave(trimmedValue)
+
+ // Show success feedback briefly
+ setSaveSuccess(true)
+ setTimeout(() => {
+ setSaveSuccess(false)
+ onCancel()
+ }, 500)
+ } catch (error) {
+ console.error("Failed to save title:", error)
+ // Keep in edit mode on error to allow retry
+ setIsSaving(false)
+ }
+ }, [editValue, initialValue, onSave, onCancel, isSaving])
+
+ const handleKeyDown = useCallback(
+ (event: React.KeyboardEvent) => {
+ if (event.key === "Enter") {
+ event.preventDefault()
+ handleSave()
+ } else if (event.key === "Escape") {
+ event.preventDefault()
+ onCancel()
+ }
+ },
+ [handleSave, onCancel],
+ )
+
+ const handleBlur = useCallback(() => {
+ if (!isSaving) {
+ handleSave()
+ }
+ }, [handleSave, isSaving])
+
+ return (
+
+ setEditValue(e.target.value)}
+ onKeyDown={handleKeyDown}
+ onBlur={handleBlur}
+ disabled={isSaving}
+ className={cn(
+ "text-text border-border bg-fill flex-1 truncate rounded-md border px-2 py-1 font-bold outline-none",
+ "focus:border-blue focus:ring-blue focus:ring-1",
+ isSaving && "opacity-50",
+ )}
+ placeholder={placeholder}
+ />
+ {isSaving && (
+
+ )}
+ {saveSuccess && }
+
+ )
+}
+
+interface AIHeaderTitleProps extends Omit, "type"> {
+ title?: string
+ placeholder?: string
+ onTitleSave?: (newTitle: string) => Promise
+}
+
+export const AIHeaderTitle = ({
ref,
title = "",
placeholder = "Untitled Chat",
className,
+ onTitleSave,
...buttonProps
-}: EditableTitleProps & { ref?: React.RefObject }) {
+}: AIHeaderTitleProps & { ref?: React.RefObject }) => {
+ const chatActions = useChatActions()
+ const [isEditing, setIsEditing] = useState(false)
+
const displayTitle = title || placeholder
const { ["aria-label"]: ariaLabelProp, ...restButtonProps } = buttonProps
const ariaLabel = ariaLabelProp ?? displayTitle
+ const handleStartEdit = useCallback((e: React.MouseEvent) => {
+ e.stopPropagation()
+ setIsEditing(true)
+ }, [])
+
+ const handleSave = useCallback(
+ async (newTitle: string) => {
+ if (onTitleSave) {
+ await onTitleSave(newTitle)
+ } else {
+ await chatActions.editChatTitle(newTitle)
+ }
+ },
+ [onTitleSave, chatActions],
+ )
+
+ const handleCancel = useCallback(() => {
+ setIsEditing(false)
+ }, [])
+
return (
-
+
)
}
diff --git a/apps/desktop/layer/renderer/src/modules/app-layout/ai-enhanced-timeline/AIEnhancedTimelineLayout.tsx b/apps/desktop/layer/renderer/src/modules/app-layout/ai-enhanced-timeline/AIEnhancedTimelineLayout.tsx
index 608f8d8c6..76f2ec31a 100644
--- a/apps/desktop/layer/renderer/src/modules/app-layout/ai-enhanced-timeline/AIEnhancedTimelineLayout.tsx
+++ b/apps/desktop/layer/renderer/src/modules/app-layout/ai-enhanced-timeline/AIEnhancedTimelineLayout.tsx
@@ -23,6 +23,7 @@ import { EntrySubscriptionList } from "~/modules/entry-column/EntrySubscriptionL
import { EntryContent } from "~/modules/entry-content/components/entry-content"
import { AIEntryHeader } from "~/modules/entry-content/components/entry-header"
import { AppLayoutGridContainerProvider } from "~/providers/app-grid-layout-container-provider"
+import { MainViewHotkeysProvider } from "~/providers/main-view-hotkeys-provider"
/**
* AIEnhancedTimelineLayout Component
@@ -200,6 +201,7 @@ export const AIEnhancedTimelineLayout = memo(function AIEnhancedTimelineLayout()
+
)
})
diff --git a/apps/desktop/layer/renderer/src/modules/command/hooks/use-command-binding.ts b/apps/desktop/layer/renderer/src/modules/command/hooks/use-command-binding.ts
index fb01b719c..0a6b0b221 100644
--- a/apps/desktop/layer/renderer/src/modules/command/hooks/use-command-binding.ts
+++ b/apps/desktop/layer/renderer/src/modules/command/hooks/use-command-binding.ts
@@ -1,3 +1,4 @@
+import { jotaiStore } from "@follow/utils"
import { getStorageNS } from "@follow/utils/ns"
import { transformShortcut } from "@follow/utils/utils"
import { useAtomValue, useSetAtom } from "jotai"
@@ -105,16 +106,16 @@ type ExtractSetType> = T extends Set ? U : never
export type AllowCustomizeCommandId = ExtractSetType
export type BindingCommandId = keyof typeof defaultCommandShortcuts
+const __commandShortcutAtom = (commandId: BindingCommandId) =>
+ selectAtom(overrideCommandShortcutsAtom, (v) => {
+ return v[commandId] ?? defaultCommandShortcuts[commandId]
+ })
export const useCommandShortcut = (commandId: BindingCommandId): string => {
- return useAtomValue(
- useMemo(
- () =>
- selectAtom(overrideCommandShortcutsAtom, (v) => {
- return v[commandId] ?? defaultCommandShortcuts[commandId]
- }),
- [commandId],
- ),
- )
+ return useAtomValue(useMemo(() => __commandShortcutAtom(commandId), [commandId]))
+}
+
+export const getCommandShortcut = (commandId: BindingCommandId) => {
+ return jotaiStore.get(__commandShortcutAtom(commandId))
}
export const useSetCustomCommandShortcut = () => {
diff --git a/apps/desktop/layer/renderer/src/providers/global-hotkeys-provider.tsx b/apps/desktop/layer/renderer/src/providers/global-hotkeys-provider.tsx
index 52d1fe940..def3a4efd 100644
--- a/apps/desktop/layer/renderer/src/providers/global-hotkeys-provider.tsx
+++ b/apps/desktop/layer/renderer/src/providers/global-hotkeys-provider.tsx
@@ -15,7 +15,7 @@ import { COMMAND_ID } from "~/modules/command/commands/id"
import { useRunCommandFn } from "~/modules/command/hooks/use-command"
import { useCommandBinding, useCommandShortcuts } from "~/modules/command/hooks/use-command-binding"
-const useRegisterGlobalHotkeys = () => {
+const useRegisterAppGlobalHotkeys = () => {
const notInFloatingLayerScope = useGlobalFocusableScopeSelector(
FocusablePresets.isNotFloatingLayerScope,
)
@@ -38,14 +38,9 @@ const useRegisterGlobalHotkeys = () => {
commandId: COMMAND_ID.global.quickSearch,
when: notInFloatingLayerScope,
})
-
- useCommandBinding({
- commandId: COMMAND_ID.global.toggleAIChat,
- when: notInFloatingLayerScope,
- })
}
export const GlobalHotkeysProvider = () => {
- useRegisterGlobalHotkeys()
+ useRegisterAppGlobalHotkeys()
useEventListener("keydown", (e) => {
if (e.key === "Tab") {
nextFrame(() => {
diff --git a/apps/desktop/layer/renderer/src/providers/main-view-hotkeys-provider.tsx b/apps/desktop/layer/renderer/src/providers/main-view-hotkeys-provider.tsx
new file mode 100644
index 000000000..df396c125
--- /dev/null
+++ b/apps/desktop/layer/renderer/src/providers/main-view-hotkeys-provider.tsx
@@ -0,0 +1,18 @@
+import { useGlobalFocusableScopeSelector } from "@follow/components/common/Focusable/hooks.js"
+
+import { FocusablePresets } from "~/components/common/Focusable"
+import { COMMAND_ID } from "~/modules/command/commands/id"
+import { useCommandBinding } from "~/modules/command/hooks/use-command-binding"
+
+export const MainViewHotkeysProvider = () => {
+ const notInFloatingLayerScope = useGlobalFocusableScopeSelector(
+ FocusablePresets.isNotFloatingLayerScope,
+ )
+
+ useCommandBinding({
+ commandId: COMMAND_ID.global.toggleAIChat,
+ when: notInFloatingLayerScope,
+ })
+
+ return null
+}