MCPcopy Create free account
hub / github.com/code-with-antonio/nightcode / createSession

Function createSession

packages/cli/src/screens/new-session.tsx:42–67  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40
41 let ignore = false;
42 const createSession = async () => {
43 try {
44 const res = await apiClient.sessions.$post({
45 json: {
46 title: state.message.slice(0, 100),
47 },
48 });
49
50 if (ignore) return;
51 if (!res.ok) {
52 throw new Error(await getErrorMessage(res));
53 }
54 const session = await res.json();
55 navigate(
56 `/sessions/${session.id}`,
57 { replace: true, state: { session, initialPrompt: state } }
58 );
59 } catch (error) {
60 if (ignore) return;
61 toast.show({
62 variant: "error",
63 message: error instanceof Error ? error.message : "Failed to create session",
64 });
65 navigate("/", { replace: true });
66 }
67 };
68
69 createSession();
70 return () => {

Callers 1

NewSessionFunction · 0.85

Calls 1

getErrorMessageFunction · 0.90

Tested by

no test coverage detected