Elffuss BraidHub

kikocis/continue public

main · 1.6 KiBRawPermalink
1import { createSelector } from "@reduxjs/toolkit";
2import {
3 ComboBoxItem,
4 ComboBoxItemType,
5} from "../../components/mainInput/types";
6import { RootState } from "../store";
7
8export const selectSlashCommandComboBoxInputs = createSelector(
9 [(state: RootState) => state.config.config.slashCommands],
10 (slashCommands) => {
11 return (
12 slashCommands?.map((cmd) => {
13 let content = cmd.prompt;
14
15 // For MCP prompts without content, show that it failed to load
16 if (cmd.source === "mcp-prompt" && !content) {
17 content = "[MCP Prompt - failed to load content during startup]";
18 }
19
20 return {
21 title: cmd.name,
22 description: cmd.description,
23 type: "slashCommand" as ComboBoxItemType,
24 content: content,
25 source: cmd.source,
26 } as ComboBoxItem;
27 }) || []
28 );
29 },
30);
31
32export const selectSlashCommands = createSelector(
33 [(state: RootState) => state.config.config.slashCommands],
34 (slashCommands) => {
35 return slashCommands || [];
36 },
37);
38
39export const selectSubmenuContextProviders = createSelector(
40 [(state: RootState) => state.config.config.contextProviders],
41 (providers) => {
42 return providers?.filter((desc) => desc.type === "submenu") || [];
43 },
44);
45
46export const selectDefaultContextProviders = createSelector(
47 [(state: RootState) => state.config.config.experimental?.defaultContext],
48 (defaultProviders) => {
49 return defaultProviders ?? [];
50 },
51);
52
53export const selectUseActiveFile = createSelector(
54 [(state: RootState) => state.config.config.experimental?.defaultContext],
55 (defaultContext) => defaultContext?.includes("activeFile" as any),
56);