diff --git a/apps/web/src/components/CommandPalette.tsx b/apps/web/src/components/CommandPalette.tsx index bea303c30b..e8959e5ab0 100644 --- a/apps/web/src/components/CommandPalette.tsx +++ b/apps/web/src/components/CommandPalette.tsx @@ -58,7 +58,11 @@ import { useAtomCommand } from "../state/use-atom-command"; import { useAtomQueryRunner } from "../state/use-atom-query-runner"; import { useEnvironments, usePrimaryEnvironmentId } from "../state/environments"; import { useProjects, useThreadShells } from "../state/entities"; -import { resolveThreadActionProjectRef, startNewThreadFromContext } from "../lib/chatThreadActions"; +import { + resolveSoleNewThreadProjectRef, + resolveThreadActionProjectRef, + startNewThreadFromContext, +} from "../lib/chatThreadActions"; import { appendBrowsePathSegment, canNavigateUp, @@ -1214,13 +1218,7 @@ function OpenCommandPaletteDialog(props: { const activeProjectTitle = projectPickerEntries.find((entry) => entry.isPreferred)?.group.displayName ?? (currentProjectId ? (projectTitleById.get(currentProjectId) ?? null) : null); - // Only meaningful when there is exactly one destination; with several, - // an absent `defaultProjectRef` means "no obvious target" and the user - // should pick from the submenu rather than have one chosen for them. - const soleNewThreadProjectRef = - newThreadProjectTargets.length === 1 && newThreadProjectTargets[0] - ? scopeProjectRef(newThreadProjectTargets[0].environmentId, newThreadProjectTargets[0].id) - : null; + const soleNewThreadProjectRef = resolveSoleNewThreadProjectRef(newThreadProjectTargets); if (activeProjectTitle) { actionItems.push({ diff --git a/apps/web/src/components/SidebarV2.tsx b/apps/web/src/components/SidebarV2.tsx index b3863e5d04..8ed429d037 100644 --- a/apps/web/src/components/SidebarV2.tsx +++ b/apps/web/src/components/SidebarV2.tsx @@ -87,7 +87,10 @@ import { useThreadSelectionStore } from "../threadSelectionStore"; import { useThreadActions } from "../hooks/useThreadActions"; import { useHandleNewThread } from "../hooks/useHandleNewThread"; import { openCommandPalette } from "../commandPaletteBus"; -import { startNewThreadFromContext } from "../lib/chatThreadActions"; +import { + resolveSoleNewThreadProjectRef, + startNewThreadFromContext, +} from "../lib/chatThreadActions"; import { useClientSettings, useUpdateClientSettings } from "../hooks/useSettings"; import { useCopyToClipboard } from "../hooks/useCopyToClipboard"; import { useNowMinute } from "../hooks/useNowMinute"; @@ -2257,17 +2260,11 @@ export default function SidebarV2() { // One project: nothing to pick, create immediately. if (projectGroups.length <= 1) { if (isMobile) setOpenMobile(false); - // `defaultProjectRef` deliberately resolves to workspaces only, so a - // user whose sole project is an agent has none — without this fallback - // `startNewThreadFromContext` returns false and the click does nothing. - const onlyGroup = projectGroups[0]; - const fallbackProjectRef = - newThreadContext.defaultProjectRef ?? - (onlyGroup ? scopeProjectRef(onlyGroup.environmentId, onlyGroup.id) : null); void startNewThreadFromContext({ activeDraftThread: newThreadContext.activeDraftThread, activeThread: newThreadContext.activeThread ?? undefined, - defaultProjectRef: fallbackProjectRef, + defaultProjectRef: + newThreadContext.defaultProjectRef ?? resolveSoleNewThreadProjectRef(projectGroups), handleNewThread: newThreadContext.handleNewThread, }); return; diff --git a/apps/web/src/components/chat/ChatComposer.tsx b/apps/web/src/components/chat/ChatComposer.tsx index a70f7ffd9e..4161b7ff37 100644 --- a/apps/web/src/components/chat/ChatComposer.tsx +++ b/apps/web/src/components/chat/ChatComposer.tsx @@ -909,10 +909,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) // `thread.create` fixes both, and Hermes sets // `requiresNewThreadForModelChange`. A picker there would offer a choice // that cannot be taken, so the chip renders as a static label instead. - const isHomeThread = useMemo( - () => isHomeThreadId(providerStatuses, activeThread?.id), - [activeThread?.id, providerStatuses], - ); + const isHomeThread = isHomeThreadId(providerStatuses, activeThread?.id); const { modelOptions: composerModelOptions, selectedModel } = useEffectiveComposerModelState({ threadRef: composerDraftTarget, diff --git a/apps/web/src/index.css b/apps/web/src/index.css index 44854988d5..b4ca099532 100644 --- a/apps/web/src/index.css +++ b/apps/web/src/index.css @@ -1139,23 +1139,28 @@ label:has(> select#reasoning-effort) select { * while leaving the real heading the largest thing in the block. The first * heading also loses its top margin, since the header rule above it is * already the separation. + * + * The compound `.chat-markdown.…` selector out-specifies the base + * `.chat-markdown h1` rules regardless of source order — both classes land on + * the same root div, so a single-class selector would win or lose purely on + * position in this file. */ -.chat-markdown-notification-body h1 { +.chat-markdown.chat-markdown-notification-body h1 { font-size: 1.0625rem; } -.chat-markdown-notification-body h2 { +.chat-markdown.chat-markdown-notification-body h2 { font-size: 1rem; } -.chat-markdown-notification-body h3, -.chat-markdown-notification-body h4, -.chat-markdown-notification-body h5, -.chat-markdown-notification-body h6 { +.chat-markdown.chat-markdown-notification-body h3, +.chat-markdown.chat-markdown-notification-body h4, +.chat-markdown.chat-markdown-notification-body h5, +.chat-markdown.chat-markdown-notification-body h6 { font-size: 0.875rem; } -.chat-markdown-notification-body > :first-child { +.chat-markdown.chat-markdown-notification-body > :first-child { margin-top: 0; } diff --git a/apps/web/src/lib/chatThreadActions.ts b/apps/web/src/lib/chatThreadActions.ts index 4a150d617e..3a398b40f9 100644 --- a/apps/web/src/lib/chatThreadActions.ts +++ b/apps/web/src/lib/chatThreadActions.ts @@ -48,6 +48,18 @@ export function resolveThreadActionProjectRef( return context.defaultProjectRef; } +// `defaultProjectRef` resolves to workspaces only by design, so a user whose +// sole project is an agent has none — and "new thread" would silently no-op. +// The fallback applies only when there is exactly one destination: with +// several, an absent default means "no obvious target" and the user should +// pick rather than have one chosen for them. +export function resolveSoleNewThreadProjectRef( + targets: ReadonlyArray<{ environmentId: EnvironmentId; id: ProjectId }>, +): ScopedProjectRef | null { + const sole = targets.length === 1 ? targets[0] : undefined; + return sole ? scopeProjectRef(sole.environmentId, sole.id) : null; +} + // New threads inherit only the *project* from the current context. Branch, // worktree, and env mode always come from the user's configured defaults — // carrying them over from the viewed thread meant "new thread" silently