fix: hide craft-goal starter in VS Code runtime
Omits the craft-goal command from draft starters in VS Code Prevents the starter from being resolved or pinnable in that runtime Keeps non-VS Code behavior unchanged
This commit is contained in:
@@ -7,6 +7,7 @@ import { useSkillsStore } from '@/stores/useSkillsStore';
|
|||||||
import { useProjectsStore } from '@/stores/useProjectsStore';
|
import { useProjectsStore } from '@/stores/useProjectsStore';
|
||||||
import { updateDesktopSettings } from '@/lib/persistence';
|
import { updateDesktopSettings } from '@/lib/persistence';
|
||||||
import { getProjectDraftStarters, saveProjectDraftStarters } from '@/lib/openchamberConfig';
|
import { getProjectDraftStarters, saveProjectDraftStarters } from '@/lib/openchamberConfig';
|
||||||
|
import { isVSCodeRuntime } from '@/lib/desktop';
|
||||||
import type { IconName } from '@/components/icon/icons';
|
import type { IconName } from '@/components/icon/icons';
|
||||||
import {
|
import {
|
||||||
BUILTIN_STARTERS,
|
BUILTIN_STARTERS,
|
||||||
@@ -58,6 +59,7 @@ export type UseDraftStartersResult = {
|
|||||||
|
|
||||||
export function useDraftStarters(): UseDraftStartersResult {
|
export function useDraftStarters(): UseDraftStartersResult {
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
const isVSCode = React.useMemo(() => isVSCodeRuntime(), []);
|
||||||
const globalRaw = useUIStore((s) => s.globalDraftStarters);
|
const globalRaw = useUIStore((s) => s.globalDraftStarters);
|
||||||
const commands = useCommandsStore((s) => s.commands);
|
const commands = useCommandsStore((s) => s.commands);
|
||||||
const skills = useSkillsStore((s) => s.skills);
|
const skills = useSkillsStore((s) => s.skills);
|
||||||
@@ -105,6 +107,7 @@ export function useDraftStarters(): UseDraftStartersResult {
|
|||||||
const skillNames = React.useMemo(() => new Set(skills.map((s) => s.name)), [skills]);
|
const skillNames = React.useMemo(() => new Set(skills.map((s) => s.name)), [skills]);
|
||||||
|
|
||||||
const resolve = React.useCallback((ref: DraftStarterRef, group: StarterGroup): ResolvedStarter | null => {
|
const resolve = React.useCallback((ref: DraftStarterRef, group: StarterGroup): ResolvedStarter | null => {
|
||||||
|
if (isVSCode && ref.type === 'command' && ref.name === 'craft-goal') return null;
|
||||||
if (ref.type === 'command') {
|
if (ref.type === 'command') {
|
||||||
const builtin = getBuiltInStarter(ref.name);
|
const builtin = getBuiltInStarter(ref.name);
|
||||||
if (builtin) {
|
if (builtin) {
|
||||||
@@ -115,7 +118,7 @@ export function useDraftStarters(): UseDraftStartersResult {
|
|||||||
}
|
}
|
||||||
if (!skillNames.has(ref.name)) return null;
|
if (!skillNames.has(ref.name)) return null;
|
||||||
return { id: chipId(group, ref), ref, group, label: normalizeStarterLabel(ref.name), icon: SKILL_FALLBACK_ICON, submitText: `/${ref.name}` };
|
return { id: chipId(group, ref), ref, group, label: normalizeStarterLabel(ref.name), icon: SKILL_FALLBACK_ICON, submitText: `/${ref.name}` };
|
||||||
}, [t, commandNames, skillNames]);
|
}, [t, commandNames, skillNames, isVSCode]);
|
||||||
|
|
||||||
const globalRefs = React.useMemo<readonly DraftStarterRef[]>(
|
const globalRefs = React.useMemo<readonly DraftStarterRef[]>(
|
||||||
() => globalRaw ?? DEFAULT_GLOBAL_STARTERS,
|
() => globalRaw ?? DEFAULT_GLOBAL_STARTERS,
|
||||||
@@ -141,6 +144,7 @@ export function useDraftStarters(): UseDraftStartersResult {
|
|||||||
const pinnable = React.useMemo<PinnableItem[]>(() => {
|
const pinnable = React.useMemo<PinnableItem[]>(() => {
|
||||||
const items: PinnableItem[] = [];
|
const items: PinnableItem[] = [];
|
||||||
for (const b of BUILTIN_STARTERS) {
|
for (const b of BUILTIN_STARTERS) {
|
||||||
|
if (isVSCode && b.name === 'craft-goal') continue;
|
||||||
items.push({ type: 'command', name: b.name, label: t(b.labelKey), icon: b.icon, section: 'built-in', scope: 'user' });
|
items.push({ type: 'command', name: b.name, label: t(b.labelKey), icon: b.icon, section: 'built-in', scope: 'user' });
|
||||||
}
|
}
|
||||||
for (const c of commands) {
|
for (const c of commands) {
|
||||||
@@ -152,7 +156,7 @@ export function useDraftStarters(): UseDraftStartersResult {
|
|||||||
}
|
}
|
||||||
// Only offer items that are not already pinned (removed built-ins reappear here).
|
// Only offer items that are not already pinned (removed built-ins reappear here).
|
||||||
return items.filter((item) => !pinnedKeys.has(`${item.type}:${item.name}`));
|
return items.filter((item) => !pinnedKeys.has(`${item.type}:${item.name}`));
|
||||||
}, [t, commands, skills, pinnedKeys]);
|
}, [t, commands, skills, pinnedKeys, isVSCode]);
|
||||||
|
|
||||||
const persistGlobal = React.useCallback((next: DraftStarterRef[]) => {
|
const persistGlobal = React.useCallback((next: DraftStarterRef[]) => {
|
||||||
useUIStore.getState().setGlobalDraftStarters(next);
|
useUIStore.getState().setGlobalDraftStarters(next);
|
||||||
|
|||||||
Reference in New Issue
Block a user