Skip to content

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

πŸ› fix(chat): show ControlBar git status for worktree topics & add Fable 5 model (#17060)

Arvin Xu3481ac833435
diff --git a/src/features/ChatInput/ControlBar/HeteroModel.tsx b/src/features/ChatInput/ControlBar/HeteroModel.tsx
index 612d762e021..cf724917963 100644
--- a/src/features/ChatInput/ControlBar/HeteroModel.tsx
+++ b/src/features/ChatInput/ControlBar/HeteroModel.tsx
@@ -56,6 +56,7 @@ type HeteroReasoningEffort =
type SelectableHeteroProviderType = 'claude-code' | 'codex';
const CLAUDE_CODE_MODEL_OPTIONS = [
+ { label: 'Fable 5', value: 'fable' },
{ label: 'Opus 4.8', value: 'opus' },
{ label: 'Sonnet 4.6', value: 'sonnet' },
{ label: 'Haiku 4.5', value: 'haiku' },
diff --git a/src/features/ChatInput/ControlBar/WorkingDirectorySection.tsx b/src/features/ChatInput/ControlBar/WorkingDirectorySection.tsx
index 799f79f7bbf..a56f9789ebe 100644
--- a/src/features/ChatInput/ControlBar/WorkingDirectorySection.tsx
+++ b/src/features/ChatInput/ControlBar/WorkingDirectorySection.tsx
@@ -1,15 +1,18 @@
'use client';
import { isDesktop } from '@lobechat/const';
+import { getWorkingDirEffectivePath } from '@lobechat/types';
import { isRecord } from '@lobechat/utils';
import { memo } from 'react';
import SafeBoundary from '@/components/ErrorBoundary';
import { resolveTargetDeviceId } from '@/helpers/agentWorkingDirectory';
-import { getWorkingDirectoryPathString } from '@/helpers/workingDirectoryPath';
+import { getConfigRepoType, getWorkingDirectoryPathString } from '@/helpers/workingDirectoryPath';
import { useEffectiveWorkingDirectory } from '@/hooks/useEffectiveWorkingDirectory';
import { useAgentStore } from '@/store/agent';
import { agentByIdSelectors } from '@/store/agent/selectors';
+import { useChatStore } from '@/store/chat';
+import { topicSelectors } from '@/store/chat/selectors';
import { deviceSelectors, useDeviceStore } from '@/store/device';
import { useElectronStore } from '@/store/electron';
@@ -44,6 +47,22 @@ const WorkingDirectorySectionInner = memo<WorkingDirectorySectionProps>(({ agent
const rawEffectiveWorkingDirectory = useEffectiveWorkingDirectory(agentId);
const effectiveWorkingDirectory = getWorkingDirectoryPathString(rawEffectiveWorkingDirectory);
+ // Live probes (fs / cached device dirs) can't resolve repoType for a worktree
+ // path that was never registered as a device working dir β€” so fall back to the
+ // repoType persisted on the topic (the same snapshot the meta hover card reads).
+ // Without this the whole GitStatus is gated out and branch/worktree/PR chips
+ // vanish even though the topic clearly carries git context.
+ const topicWorkingDirectoryConfig = useChatStore(
+ (s) => topicSelectors.currentTopicMetadata(s)?.workingDirectoryConfig,
+ );
+ // Only trust the persisted config when it actually describes the directory we
+ // resolved β€” the topic override wins in `useEffectiveWorkingDirectory`, so this
+ // holds whenever the config is what produced `effectiveWorkingDirectory`.
+ const topicConfigMatchesEffective =
+ !!effectiveWorkingDirectory &&
+ getWorkingDirEffectivePath(topicWorkingDirectoryConfig) === effectiveWorkingDirectory;
+ const persistedConfig = topicConfigMatchesEffective ? topicWorkingDirectoryConfig : undefined;
+
// Local machine probes the filesystem for repoType; a remote device's repoType
// comes from the cached `workingDirs` entry (we can't probe a remote fs here).
const localRepoType = useRepoType(isLocalDevice ? effectiveWorkingDirectory : undefined);
@@ -51,14 +70,23 @@ const WorkingDirectorySectionInner = memo<WorkingDirectorySectionProps>(({ agent
const currentEntry = effectiveWorkingDirectory
? deviceDirs.find((entry) => getEntryEffectivePath(entry) === effectiveWorkingDirectory)
: undefined;
- const sourceWorkingDirectory =
- (isRecord(currentEntry) ? getWorkingDirectoryPathString(currentEntry.path) : undefined) ??
- effectiveWorkingDirectory;
const remoteRepoType =
currentEntry?.repoType === 'git' || currentEntry?.repoType === 'github'
? currentEntry.repoType
: undefined;
- const repoType = isLocalDevice ? localRepoType : remoteRepoType;
+
+ // The SOURCE repo, not the checkout. A persisted-worktree topic has no matching
+ // `workingDirs` entry (that's exactly why the repoType probe misses), so without
+ // the persisted `config.path` this would collapse to the worktree path β€” and
+ // WorktreeSwitcher commits `sourcePath` as the WorkingDirEntry.path, rewriting
+ // the topic's repo source to the linked worktree and breaking later switches.
+ const sourceWorkingDirectory =
+ (isRecord(currentEntry) ? getWorkingDirectoryPathString(currentEntry.path) : undefined) ??
+ getWorkingDirectoryPathString(persistedConfig?.path) ??
+ effectiveWorkingDirectory;
+
+ const repoType =
+ (isLocalDevice ? localRepoType : remoteRepoType) ?? getConfigRepoType(persistedConfig);
return (
<>
diff --git a/src/helpers/workingDirectoryPath.ts b/src/helpers/workingDirectoryPath.ts
index 18b55cbb78a..f8896b3ae6c 100644
--- a/src/helpers/workingDirectoryPath.ts
+++ b/src/helpers/workingDirectoryPath.ts
@@ -1,5 +1,28 @@
+import type { WorkingDirConfig, WorkingDirRepoType } from '@lobechat/types';
import { pickString } from '@lobechat/utils';
+import { isDesktop } from '@/const/version';
+
+/**
+ * The persisted repo type for a working-dir config, applying the web default:
+ * on web there is no local filesystem to probe, so an unset type on an EXISTING
+ * config is treated as `github` (the only web-supported repo source); on desktop
+ * it stays `undefined` so callers fall back to a live probe.
+ *
+ * No config at all means "nothing was ever persisted" β€” that must stay
+ * `undefined` on every platform, otherwise a web caller would treat any bare
+ * device cwd as a GitHub repo and fire git/PR probes at directories that were
+ * never identified as one.
+ *
+ * Shared by the topic meta hover card and the ControlBar git status so both read
+ * repoType from the same source instead of diverging.
+ */
+export const getConfigRepoType = (config?: WorkingDirConfig): WorkingDirRepoType | undefined => {
+ if (!config) return undefined;
+
+ return config.repoType ?? (isDesktop ? undefined : 'github');
+};
+
export const getWorkingDirectoryPathString = (path: unknown) => {
const value = pickString(path)?.trim();
return value || undefined;
diff --git a/src/routes/(main)/agent/_layout/Sidebar/Topic/List/Item/metaCardData.ts b/src/routes/(main)/agent/_layout/Sidebar/Topic/List/Item/metaCardData.ts
index 0e1450e1c2b..7ec4347f027 100644
--- a/src/routes/(main)/agent/_layout/Sidebar/Topic/List/Item/metaCardData.ts
+++ b/src/routes/(main)/agent/_layout/Sidebar/Topic/List/Item/metaCardData.ts
@@ -7,8 +7,7 @@ import { cssVar } from 'antd-style';
import type { LucideIcon } from 'lucide-react';
import { GitMerge, GitPullRequestArrow, GitPullRequestClosed } from 'lucide-react';
-import { isDesktop } from '@/const/version';
-import { getWorkingDirectoryName } from '@/helpers/workingDirectoryPath';
+import { getConfigRepoType, getWorkingDirectoryName } from '@/helpers/workingDirectoryPath';
export type PullRequestState = 'open' | 'merged' | 'closed';
@@ -58,7 +57,7 @@ export const getTopicMetaCard = (metadata: ChatTopicMetadata | undefined) => {
detached: git.detached,
pullRequest: git.github?.pullRequest ?? undefined,
repoName: sourcePath ? getWorkingDirectoryName(sourcePath) : undefined,
- repoType: config.repoType ?? (isDesktop ? undefined : ('github' as const)),
+ repoType: getConfigRepoType(config),
worktreeName: isWorktree && effectivePath ? getWorkingDirectoryName(effectivePath) : undefined,
};
};