MCPcopy
hub / github.com/continuedev/continue / useChat

Function useChat

extensions/cli/src/ui/hooks/useChat.ts:48–881  ·  view source on GitHub ↗
({
  assistant,
  model,
  llmApi,
  initialPrompt,
  resume,
  fork,
  additionalRules,
  additionalPrompts,
  onShowConfigSelector,
  onShowModelSelector,
  onShowUpdateSelector,
  onShowMCPSelector,
  onShowSessionSelector,
  onShowJobsSelector,
  onShowExportSelector,
  onClear,
  onRefreshStatic,
  isRemoteMode = false,
  remoteUrl,
  onShowDiff,
  onShowStatusMessage,
}: UseChatProps)

Source from the content-addressed store, hash-verified

46} from "./useChat.types.js";
47
48export function useChat({
49 assistant,
50 model,
51 llmApi,
52 initialPrompt,
53 resume,
54 fork,
55 additionalRules,
56 additionalPrompts,
57 onShowConfigSelector,
58 onShowModelSelector,
59 onShowUpdateSelector,
60 onShowMCPSelector,
61 onShowSessionSelector,
62 onShowJobsSelector,
63 onShowExportSelector,
64 onClear,
65 onRefreshStatic,
66 isRemoteMode = false,
67 remoteUrl,
68 onShowDiff,
69 onShowStatusMessage,
70}: UseChatProps) {
71 const { exit } = useApp();
72
73 // Track service subscription
74 const serviceListenerCleanupRef = useRef<null | (() => void)>(null);
75
76 // Store the current session
77 const [currentSession, setCurrentSession] = useState<Session>(() => {
78 // In remote mode, start with empty session (will be populated by polling)
79 if (isRemoteMode) {
80 return createSession([]);
81 }
82
83 // Fork from an existing session if fork flag is used
84 if (fork) {
85 const { loadSessionById, startNewSession } = require("../../session.js");
86 const sessionToFork = loadSessionById(fork);
87 if (sessionToFork) {
88 return startNewSession(sessionToFork.history);
89 }
90 // If session not found, create a new empty session
91 return createSession([]);
92 }
93
94 // Load previous session if resume flag is used
95 if (resume) {
96 const savedSession = loadSession();
97 if (savedSession) {
98 return savedSession;
99 }
100 }
101
102 // Create new session
103 return createSession([]);
104 });
105

Callers 1

TUIChatFunction · 0.85

Calls 15

createSessionFunction · 0.85
loadSessionByIdFunction · 0.85
startNewSessionFunction · 0.85
loadSessionFunction · 0.85
findCompactionIndexFunction · 0.85
setupRemotePollingFunction · 0.85
initializeHistoryFunction · 0.85
processPromptsFunction · 0.85
errorMethod · 0.80
onMethod · 0.65
offMethod · 0.65
isReadyMethod · 0.45

Tested by

no test coverage detected