Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/claw-runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function buildSettings(): AppSettingsV1 {
theme: 'system',
uiFontScale: 0.82,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
provider: defaultModelProviderSettings(),
agents: {
kun: defaultKunRuntimeSettings()
Expand Down
1 change: 1 addition & 0 deletions src/main/claw-schedule-mcp-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function createSettings(patch: Partial<AppSettingsV1['schedule']['internal']> =
theme: 'system',
uiFontScale: 0.82,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
provider: defaultModelProviderSettings(),
agents: {
kun: defaultKunRuntimeSettings()
Expand Down
1 change: 1 addition & 0 deletions src/main/claw-scheduled-task-detector.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function settings(endpointFormat: ModelEndpointFormat): AppSettingsV1 {
theme: 'system',
uiFontScale: 0.82,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
provider,
agents: {
kun: defaultKunRuntimeSettings()
Expand Down
3 changes: 3 additions & 0 deletions src/main/data-migration/application-state-migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export function applyPortableSettingsMigration(
...(typeof value.chatContentMaxWidthPx === 'number'
? { chatContentMaxWidthPx: value.chatContentMaxWidthPx as AppSettingsV1['chatContentMaxWidthPx'] }
: {}),
...(value.composerSendKey === 'enter' || value.composerSendKey === 'shiftEnter'
? { composerSendKey: value.composerSendKey }
: {}),
...(typeof value.cursorSpotlight === 'boolean' ? { cursorSpotlight: value.cursorSpotlight } : {}),
...(typeof value.cursorSpotlightColor === 'string' ? { cursorSpotlightColor: value.cursorSpotlightColor } : {}),
notifications: {
Expand Down
1 change: 1 addition & 0 deletions src/main/data-migration/export-inventory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function settings(workspaceRoot: string, nestedRoot = workspaceRoot): AppSetting
theme: 'dark',
uiFontScale: 1,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
provider: { ...defaultModelProviderSettings(), apiKey: 'must-not-export' },
agents: { kun: { ...defaultKunRuntimeSettings(), runtimeToken: 'must-not-export' } },
workspaceRoot,
Expand Down
1 change: 1 addition & 0 deletions src/main/data-migration/export-inventory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ export function portableSettingsForMigration(settings: AppSettingsV1): Record<st
theme: settings.theme,
uiFontScale: settings.uiFontScale,
chatContentMaxWidthPx: settings.chatContentMaxWidthPx,
composerSendKey: settings.composerSendKey,
cursorSpotlight: settings.cursorSpotlight,
cursorSpotlightColor: settings.cursorSpotlightColor,
notifications: settings.notifications,
Expand Down
1 change: 1 addition & 0 deletions src/main/data-migration/export-orchestrator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function settings(workspaceRoot: string): AppSettingsV1 {
theme: 'system',
uiFontScale: 1,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
provider: defaultModelProviderSettings(),
agents: { kun: defaultKunRuntimeSettings() },
workspaceRoot,
Expand Down
1 change: 1 addition & 0 deletions src/main/execution-settings-consent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function settings(): AppSettingsV1 {
theme: 'system',
uiFontScale: 0.82,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
provider: defaultModelProviderSettings(),
agents: { kun: defaultKunRuntimeSettings() },
workspaceRoot: '/tmp/workspace',
Expand Down
1 change: 1 addition & 0 deletions src/main/ipc/app-ipc-schemas/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,7 @@ const settingsPatchObjectSchema = z.object({
theme: themeSchema.optional(),
uiFontScale: uiFontScaleSchema.optional(),
chatContentMaxWidthPx: chatContentMaxWidthSchema.optional(),
composerSendKey: z.enum(['enter', 'shiftEnter']).optional(),
cursorSpotlight: z.boolean().optional(),
cursorSpotlightColor: hexColorSchema.optional(),
provider: modelProviderPatchSchema.optional(),
Expand Down
1 change: 1 addition & 0 deletions src/main/ipc/register-app-ipc-handlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function settings(): AppSettingsV1 {
theme: 'system',
uiFontScale: 0.82,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
provider: defaultModelProviderSettings(),
agents: {
kun: defaultKunRuntimeSettings()
Expand Down
1 change: 1 addition & 0 deletions src/main/kun-process.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function createSettings(binaryPath: string): AppSettingsV1 {
theme: 'system',
uiFontScale: 0.82,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
provider: defaultModelProviderSettings(),
agents: {
kun: {
Expand Down
3 changes: 2 additions & 1 deletion src/main/kun-regression.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ describe('Kun single-agent regression', () => {
locale: 'en',
theme: 'system',
uiFontScale: 0.82,
chatContentMaxWidthPx: 896,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
provider: defaultModelProviderSettings(),
agents: {
kun: defaultKunRuntimeSettings(19000)
Expand Down
1 change: 1 addition & 0 deletions src/main/runtime-settings-apply-mode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function settings(): AppSettingsV1 {
theme: 'system',
uiFontScale: 0.82,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
provider: defaultModelProviderSettings(),
agents: {
kun: defaultKunRuntimeSettings()
Expand Down
1 change: 1 addition & 0 deletions src/main/runtime/kun-adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function settingsForPort(port: number): AppSettingsV1 {
theme: 'system',
uiFontScale: 0.82,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
provider: defaultModelProviderSettings(),
agents: {
kun: {
Expand Down
3 changes: 2 additions & 1 deletion src/main/runtime/managed-runtime-idle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const settings: AppSettingsV1 = {
locale: 'en',
theme: 'system',
uiFontScale: 0.82,
chatContentMaxWidthPx: 896,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
provider: defaultModelProviderSettings(),
agents: { kun: defaultKunRuntimeSettings() },
workspaceRoot: '/tmp/workspace',
Expand Down
1 change: 1 addition & 0 deletions src/main/schedule-runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ function settingsWith(
theme: 'system',
uiFontScale: 0.82,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
provider: defaultModelProviderSettings(),
agents: {
kun: {
Expand Down
1 change: 1 addition & 0 deletions src/main/services/prompt-optimization-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function createSettings(patch: Partial<AppSettingsV1['agents']['kun']> = {}): Ap
theme: 'system',
uiFontScale: 0.82,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
provider: defaultModelProviderSettings(),
agents: {
kun: {
Expand Down
3 changes: 2 additions & 1 deletion src/main/services/skill-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ describe('skill-service', () => {
locale: 'en',
theme: 'system',
uiFontScale: 0.82,
chatContentMaxWidthPx: 896,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
provider: defaultModelProviderSettings(),
agents: { kun: defaultKunRuntimeSettings() },
workspaceRoot,
Expand Down
1 change: 1 addition & 0 deletions src/main/services/write-inline-completion-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function createSettings(patch: Partial<AppSettingsV1['write']['inlineCompletion'
theme: 'system',
uiFontScale: 0.82,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
provider: defaultModelProviderSettings(),
agents: {
kun: {
Expand Down
2 changes: 2 additions & 0 deletions src/main/settings-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
defaultTerminalSettings,
mergeTerminalSettings,
DEFAULT_CHAT_CONTENT_MAX_WIDTH_PX,
DEFAULT_COMPOSER_SEND_KEY,
DEFAULT_UI_FONT_SCALE,
normalizeAppBehaviorSettings,
normalizeCheckpointCleanupSettings,
Expand Down Expand Up @@ -231,6 +232,7 @@ const defaultSettings = (): AppSettingsV1 => ({
theme: 'system',
uiFontScale: DEFAULT_UI_FONT_SCALE,
chatContentMaxWidthPx: DEFAULT_CHAT_CONTENT_MAX_WIDTH_PX,
composerSendKey: DEFAULT_COMPOSER_SEND_KEY,
cursorSpotlight: true,
cursorSpotlightColor: DEFAULT_CURSOR_SPOTLIGHT_COLOR,
provider: defaultModelProviderSettings(),
Expand Down
1 change: 1 addition & 0 deletions src/main/upstream-models.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function settings(dataDir: string, model = 'settings-model'): AppSettingsV1 {
theme: 'system',
uiFontScale: 0.82,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
provider: {
...provider,
providers: [
Expand Down
1 change: 1 addition & 0 deletions src/main/workflow-runtime.nodes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ function buildSettings(
theme: 'system',
uiFontScale: 0.82,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
provider: defaultModelProviderSettings(),
agents: { kun: { ...defaultKunRuntimeSettings(), model: 'test-model', apiKey: 'test-key' } },
workspaceRoot: workflowWorkspaceRoot,
Expand Down
1 change: 1 addition & 0 deletions src/main/workflow-runtime.run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function settingsWithWorkflows(workflows: WorkflowV1[], modules: WorkflowCustomM
theme: 'system',
uiFontScale: 0.82,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
provider: defaultModelProviderSettings(),
agents: { kun: { ...defaultKunRuntimeSettings(), model: 'test-model', apiKey: 'test-key' } },
workspaceRoot: workflowWorkspaceRoot,
Expand Down
1 change: 1 addition & 0 deletions src/renderer/src/agent/kun-runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function settings(): AppSettingsV1 {
theme: 'system',
uiFontScale: 0.82,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
provider: defaultModelProviderSettings(),
agents: {
kun: defaultKunRuntimeSettings()
Expand Down
1 change: 1 addition & 0 deletions src/renderer/src/agent/runtime-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function settings(apiKey: string): AppSettingsV1 {
theme: 'system',
uiFontScale: 0.82,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
provider: defaultModelProviderSettings(),
agents: {
kun: {
Expand Down
12 changes: 8 additions & 4 deletions src/renderer/src/components/chat/FloatingComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ import {
routeComposerFileDrop,
type ComposerFileDropOptions
} from './composer-file-drop'
import { useComposerSendKeySetting } from '../../lib/composer-send-key-settings'
import { isComposerSendHotkey } from '@shared/app-settings'

export type { ComposerFileReference } from '../../lib/composer-file-references'
export type { ComposerExecutionSettings } from './FloatingComposerExecutionPicker'
Expand Down Expand Up @@ -339,6 +341,7 @@ export function FloatingComposer({
hideBtwCommand = false
}: Props): ReactElement {
const { t, i18n } = useTranslation('common')
const composerSendKey = useComposerSendKeySetting()
const route = useChatStore((s) => s.route)
const workspaceRoot = useChatStore((s) => s.workspaceRoot)
const storeActiveThreadId = useChatStore((s) => s.activeThreadId)
Expand Down Expand Up @@ -540,7 +543,9 @@ export function FloatingComposer({
: t('clawComposerHintNeedsInbound')
: useWorktreePool
? t('composerWorktreeModeHint')
: t('composerShortcut')
: composerSendKey === 'shiftEnter'
? t('composerShortcutShiftEnter')
: t('composerShortcut')
const showTodoProgress = !compact
&& route === 'chat'
&& Boolean(activeThreadId)
Expand Down Expand Up @@ -968,8 +973,7 @@ export function FloatingComposer({
dictationPrimaryActionRef.current = primaryActionDisabled ? null : handlePrimaryAction

const handleComposerKeyDown = (event: ReactKeyboardEvent<HTMLTextAreaElement>): void => {
const sendByEnter =
event.key === 'Enter' && !event.shiftKey && !event.metaKey && !event.ctrlKey
const sendByHotkey = isComposerSendHotkey(event, composerSendKey)
const composing = draft.isComposingEvent(event)

if (fileMentions.handleKeyDown(event, composing)) return
Expand All @@ -987,7 +991,7 @@ export function FloatingComposer({
return
}

if (!sendByEnter || composing) return
if (!sendByHotkey || composing) return

event.preventDefault()
handlePrimaryAction()
Expand Down
1 change: 1 addition & 0 deletions src/renderer/src/components/settings-section-claw.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ function buildSettings(): AppSettingsV1 {
theme: 'system',
uiFontScale: 0.88,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
provider: defaultModelProviderSettings(),
agents: { kun: defaultKunRuntimeSettings() },
workspaceRoot: '/tmp/workspace',
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/src/components/settings-section-general.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ function baseCtx(): Record<string, unknown> {
locale: 'zh',
theme: 'dark',
uiFontScale: 0.88,
chatContentMaxWidthPx: 896,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
workspaceRoot: '~/data/code/python/Kook-Voices',
cursorSpotlight: true,
cursorSpotlightColor: '#3b82f6',
Expand Down
19 changes: 19 additions & 0 deletions src/renderer/src/components/settings-section-general.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
WRITE_INLINE_COMPLETION_MODEL_IDS,
isKunRuntimeInsecure,
normalizeChatContentMaxWidth,
normalizeComposerSendKey,
normalizeUiFontScale
} from '@shared/app-settings'
import type { SkillRootId } from '../lib/skill-root-preference'
Expand Down Expand Up @@ -400,6 +401,24 @@ export function GeneralSettingsSection({ ctx }: { ctx: Record<string, any> }): R
</div>
}
/>
<SettingRow
title={t('composerSendKey')}
description={t('composerSendKeyDesc')}
control={
<select
className={selectControlClass}
value={normalizeComposerSendKey(form.composerSendKey)}
onChange={(e) =>
update({
composerSendKey: normalizeComposerSendKey(e.target.value)
})
}
>
<option value="enter">{t('composerSendKey_enter')}</option>
<option value="shiftEnter">{t('composerSendKey_shiftEnter')}</option>
</select>
}
/>
<SettingRow
title={t('workspaceRoot')}
description={t('workspaceRootDesc')}
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/src/components/settings-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
normalizeWriteSettings,
normalizeTerminalSettings,
normalizeChatContentMaxWidth,
normalizeComposerSendKey,
normalizeUiFontScale,
type AppSettingsPatch,
type AppSettingsV1
Expand Down Expand Up @@ -140,6 +141,7 @@ export function coerceRendererSettings(settings: AppSettingsV1): AppSettingsV1 {
theme,
uiFontScale,
chatContentMaxWidthPx,
composerSendKey: normalizeComposerSendKey(raw.composerSendKey),
cursorSpotlight: raw.cursorSpotlight !== false,
cursorSpotlightColor: normalizeCursorSpotlightColor(raw.cursorSpotlightColor),
provider: normalizeModelProviderSettings(raw.provider),
Expand Down
1 change: 1 addition & 0 deletions src/renderer/src/lib/claw-model-options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function buildSettings(models: string[]): AppSettingsV1 {
theme: 'system',
uiFontScale: 0.88,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
provider,
agents: { kun: defaultKunRuntimeSettings() },
workspaceRoot: '/tmp/workspace',
Expand Down
34 changes: 34 additions & 0 deletions src/renderer/src/lib/composer-send-key-settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { useEffect, useState } from 'react'
import {
DEFAULT_COMPOSER_SEND_KEY,
normalizeComposerSendKey,
type AppSettingsV1,
type ComposerSendKey
} from '@shared/app-settings'
import { SETTINGS_CHANGED_EVENT } from './keyboard-shortcut-settings'

export function useComposerSendKeySetting(): ComposerSendKey {
const [sendKey, setSendKey] = useState<ComposerSendKey>(DEFAULT_COMPOSER_SEND_KEY)

useEffect(() => {
let cancelled = false
const apply = (settings: AppSettingsV1): void => {
if (!cancelled) setSendKey(normalizeComposerSendKey(settings.composerSendKey))
}

if (typeof window.kunGui?.getSettings === 'function') {
void window.kunGui.getSettings().then(apply).catch(() => undefined)
}

const onSettingsChanged = (event: Event): void => {
apply((event as CustomEvent<AppSettingsV1>).detail)
}
window.addEventListener(SETTINGS_CHANGED_EVENT, onSettingsChanged)
return () => {
cancelled = true
window.removeEventListener(SETTINGS_CHANGED_EVENT, onSettingsChanged)
}
}, [])

return sendKey
}
1 change: 1 addition & 0 deletions src/renderer/src/lib/settings-home-paths.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ function settings(): AppSettingsV1 {
theme: 'system',
uiFontScale: 0.82,
chatContentMaxWidthPx: 896,
composerSendKey: 'enter',
cursorSpotlight: true,
provider: defaultModelProviderSettings(),
agents: {
Expand Down
1 change: 1 addition & 0 deletions src/renderer/src/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,7 @@
"autoLabel": "Auto",
"composerHint": "Press Enter to send · Shift+Enter for a new line · AI-generated content, verify before use",
"composerShortcut": "Enter to send · Shift+Enter for newline",
"composerShortcutShiftEnter": "Shift+Enter to send · Enter for newline",
"newline": "newline",
"composerVerifyHint": "AI-generated content, verify before use",
"composerStartHint": "Describe the task, paste code, or ask the agent to work directly in the current workspace.",
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/src/locales/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@
"chatContentMaxWidthWide": "Wide",
"chatContentMaxWidthDecrease": "Decrease conversation text width",
"chatContentMaxWidthIncrease": "Increase conversation text width",
"composerSendKey": "Send shortcut",
"composerSendKeyDesc": "Choose whether Enter or Shift+Enter sends a message; the other inserts a new line.",
"composerSendKey_enter": "Enter to send · Shift+Enter for new line",
"composerSendKey_shiftEnter": "Shift+Enter to send · Enter for new line",
"cursorSpotlight": "Interactive effects",
"cursorSpotlightDesc": "Show a soft cursor-follow spotlight on the title bar and sidebar.",
"cursorSpotlightColor": "Interaction effect color",
Expand Down
Loading
Loading