@unikode/cli 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +41 -33
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -140724,7 +140724,10 @@ function Docs() {
140724
140724
  }
140725
140725
 
140726
140726
  // src/screens/new-session.tsx
140727
- var import_react38 = __toESM(require_react(), 1);
140727
+ var import_react39 = __toESM(require_react(), 1);
140728
+
140729
+ // src/components/session-shell.tsx
140730
+ var import_react37 = __toESM(require_react(), 1);
140728
140731
 
140729
140732
  // src/components/spinner.tsx
140730
140733
  function Spinner({ mode = Mode.BUILD }) {
@@ -140745,6 +140748,11 @@ function SessionShell({
140745
140748
  interruptible = false
140746
140749
  }) {
140747
140750
  const { mode } = usePromptConfig();
140751
+ const cleanChildren = import_react37.Children.toArray(children).filter((child) => {
140752
+ if (typeof child === "string" && !child.trim())
140753
+ return false;
140754
+ return true;
140755
+ });
140748
140756
  return /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
140749
140757
  flexDirection: "column",
140750
140758
  flexGrow: 1,
@@ -140760,7 +140768,7 @@ function SessionShell({
140760
140768
  stickyScroll: true,
140761
140769
  stickyStart: "bottom",
140762
140770
  children: /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
140763
- children
140771
+ children: cleanChildren
140764
140772
  }, undefined, false, undefined, this)
140765
140773
  }, undefined, false, undefined, this),
140766
140774
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
@@ -140972,12 +140980,12 @@ function prettyMilliseconds(milliseconds, options) {
140972
140980
  }
140973
140981
 
140974
140982
  // src/components/messages/question-message.tsx
140975
- var import_react37 = __toESM(require_react(), 1);
140983
+ var import_react38 = __toESM(require_react(), 1);
140976
140984
  function QuestionMessage({ prompt, onSubmit }) {
140977
140985
  const { colors } = useTheme();
140978
- const inputRef = import_react37.useRef(null);
140979
- const [answerText, setAnswerText] = import_react37.useState("");
140980
- const handleSubmit = import_react37.useCallback(() => {
140986
+ const inputRef = import_react38.useRef(null);
140987
+ const [answerText, setAnswerText] = import_react38.useState("");
140988
+ const handleSubmit = import_react38.useCallback(() => {
140981
140989
  if (!prompt.isActive) {
140982
140990
  return;
140983
140991
  }
@@ -141252,17 +141260,17 @@ function NewSession() {
141252
141260
  const navigate = useNavigate();
141253
141261
  const location = useLocation();
141254
141262
  const toast = useToast();
141255
- const hasStartedRef = import_react38.useRef(false);
141256
- const state = import_react38.useMemo(() => {
141263
+ const hasStartedRef = import_react39.useRef(false);
141264
+ const state = import_react39.useMemo(() => {
141257
141265
  const parsed = newSessionStateSchema.safeParse(location.state);
141258
141266
  return parsed.success ? parsed.data : null;
141259
141267
  }, [location.state]);
141260
- import_react38.useEffect(() => {
141268
+ import_react39.useEffect(() => {
141261
141269
  if (!state) {
141262
141270
  navigate("/", { replace: true });
141263
141271
  }
141264
141272
  }, [state, navigate]);
141265
- import_react38.useEffect(() => {
141273
+ import_react39.useEffect(() => {
141266
141274
  if (!state || hasStartedRef.current)
141267
141275
  return;
141268
141276
  hasStartedRef.current = true;
@@ -141310,19 +141318,19 @@ function NewSession() {
141310
141318
  }
141311
141319
 
141312
141320
  // src/screens/session.tsx
141313
- var import_react47 = __toESM(require_react(), 1);
141321
+ var import_react48 = __toESM(require_react(), 1);
141314
141322
 
141315
141323
  // src/hooks/use-chat.ts
141316
- var import_react45 = __toESM(require_react(), 1);
141324
+ var import_react46 = __toESM(require_react(), 1);
141317
141325
 
141318
141326
  // ../../node_modules/.bun/@ai-sdk+react@4.0.23+38ec045d21336c81/node_modules/@ai-sdk/react/dist/index.js
141319
- var import_react39 = __toESM(require_react(), 1);
141320
141327
  var import_react40 = __toESM(require_react(), 1);
141321
- var import_throttleit = __toESM(require_throttleit(), 1);
141322
141328
  var import_react41 = __toESM(require_react(), 1);
141329
+ var import_throttleit = __toESM(require_throttleit(), 1);
141323
141330
  var import_react42 = __toESM(require_react(), 1);
141324
141331
  var import_react43 = __toESM(require_react(), 1);
141325
141332
  var import_react44 = __toESM(require_react(), 1);
141333
+ var import_react45 = __toESM(require_react(), 1);
141326
141334
  var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
141327
141335
  var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
141328
141336
  var __accessCheck = (obj, member, msg) => {
@@ -141461,7 +141469,7 @@ function useChat({
141461
141469
  ...options
141462
141470
  } = {}) {
141463
141471
  const throttleWaitMs = throttle2 != null ? throttle2 : experimental_throttle;
141464
- const latestRef = import_react40.useRef({});
141472
+ const latestRef = import_react41.useRef({});
141465
141473
  if (!("chat" in options)) {
141466
141474
  latestRef.current = {
141467
141475
  onToolCall: options.onToolCall,
@@ -141504,22 +141512,22 @@ function useChat({
141504
141512
  return (_c = (_b17 = (_a24 = latestRef.current).sendAutomaticallyWhen) == null ? undefined : _b17.call(_a24, arg)) != null ? _c : false;
141505
141513
  }
141506
141514
  };
141507
- const chatRef = import_react40.useRef("chat" in options ? options.chat : new Chat(chatOptions));
141515
+ const chatRef = import_react41.useRef("chat" in options ? options.chat : new Chat(chatOptions));
141508
141516
  const shouldRecreateChat = "chat" in options && options.chat !== chatRef.current || "id" in options && options.id != null && chatRef.current.id !== options.id;
141509
141517
  if (shouldRecreateChat) {
141510
141518
  chatRef.current = "chat" in options ? options.chat : new Chat(chatOptions);
141511
141519
  }
141512
- const subscribeToMessages = import_react40.useCallback((update) => chatRef.current["~registerMessagesCallback"](update, throttleWaitMs), [throttleWaitMs, chatRef.current.id]);
141513
- const messages = import_react40.useSyncExternalStore(subscribeToMessages, () => chatRef.current.messages, () => chatRef.current.messages);
141514
- const status = import_react40.useSyncExternalStore(chatRef.current["~registerStatusCallback"], () => chatRef.current.status, () => chatRef.current.status);
141515
- const error51 = import_react40.useSyncExternalStore(chatRef.current["~registerErrorCallback"], () => chatRef.current.error, () => chatRef.current.error);
141516
- const setMessages = import_react40.useCallback((messagesParam) => {
141520
+ const subscribeToMessages = import_react41.useCallback((update) => chatRef.current["~registerMessagesCallback"](update, throttleWaitMs), [throttleWaitMs, chatRef.current.id]);
141521
+ const messages = import_react41.useSyncExternalStore(subscribeToMessages, () => chatRef.current.messages, () => chatRef.current.messages);
141522
+ const status = import_react41.useSyncExternalStore(chatRef.current["~registerStatusCallback"], () => chatRef.current.status, () => chatRef.current.status);
141523
+ const error51 = import_react41.useSyncExternalStore(chatRef.current["~registerErrorCallback"], () => chatRef.current.error, () => chatRef.current.error);
141524
+ const setMessages = import_react41.useCallback((messagesParam) => {
141517
141525
  if (typeof messagesParam === "function") {
141518
141526
  messagesParam = messagesParam(chatRef.current.messages);
141519
141527
  }
141520
141528
  chatRef.current.messages = messagesParam;
141521
141529
  }, [chatRef]);
141522
- import_react40.useEffect(() => {
141530
+ import_react41.useEffect(() => {
141523
141531
  if (resume) {
141524
141532
  chatRef.current.resumeStream();
141525
141533
  }
@@ -146363,8 +146371,8 @@ ${outline.join(`
146363
146371
 
146364
146372
  // src/hooks/use-chat.ts
146365
146373
  function useChat2(sessionId, initialMessages) {
146366
- const [questionPrompts, setQuestionPrompts] = import_react45.useState([]);
146367
- const transport = import_react45.useMemo(() => {
146374
+ const [questionPrompts, setQuestionPrompts] = import_react46.useState([]);
146375
+ const transport = import_react46.useMemo(() => {
146368
146376
  return new DefaultChatTransport2({
146369
146377
  api: apiClient.chat.$url().toString(),
146370
146378
  headers() {
@@ -146389,10 +146397,10 @@ function useChat2(sessionId, initialMessages) {
146389
146397
  }
146390
146398
  });
146391
146399
  }, [sessionId]);
146392
- const deactivateQuestionPrompts = import_react45.useCallback(() => {
146400
+ const deactivateQuestionPrompts = import_react46.useCallback(() => {
146393
146401
  setQuestionPrompts((prompts) => prompts.map((prompt) => ({ ...prompt, isActive: false })));
146394
146402
  }, []);
146395
- const submitQuestionAnswer = import_react45.useCallback((promptId, answerText) => {
146403
+ const submitQuestionAnswer = import_react46.useCallback((promptId, answerText) => {
146396
146404
  const prompt = questionPrompts.find((entry) => entry.id === promptId);
146397
146405
  if (!prompt) {
146398
146406
  return;
@@ -146495,7 +146503,7 @@ function ChatMessage({
146495
146503
  }, undefined, false, undefined, this);
146496
146504
  }
146497
146505
  function SessionChat({ session, initialPrompt }) {
146498
- const [initialMessages] = import_react47.useState(() => session.messages);
146506
+ const [initialMessages] = import_react48.useState(() => session.messages);
146499
146507
  const {
146500
146508
  messages,
146501
146509
  status,
@@ -146507,10 +146515,10 @@ function SessionChat({ session, initialPrompt }) {
146507
146515
  submitQuestionAnswer,
146508
146516
  deactivateQuestionPrompts
146509
146517
  } = useChat2(session.id, initialMessages);
146510
- const hasSubmittedInitialPromptRef = import_react47.useRef(false);
146518
+ const hasSubmittedInitialPromptRef = import_react48.useRef(false);
146511
146519
  const { mode, model } = usePromptConfig();
146512
146520
  const { isTopLayer } = useKeyboardLayer();
146513
- import_react47.useEffect(() => {
146521
+ import_react48.useEffect(() => {
146514
146522
  return () => {
146515
146523
  abort();
146516
146524
  };
@@ -146521,7 +146529,7 @@ function SessionChat({ session, initialPrompt }) {
146521
146529
  interrupt();
146522
146530
  }
146523
146531
  });
146524
- import_react47.useEffect(() => {
146532
+ import_react48.useEffect(() => {
146525
146533
  if (!initialPrompt || hasSubmittedInitialPromptRef.current)
146526
146534
  return;
146527
146535
  hasSubmittedInitialPromptRef.current = true;
@@ -146555,12 +146563,12 @@ function Session() {
146555
146563
  const location = useLocation();
146556
146564
  const navigate = useNavigate();
146557
146565
  const toast = useToast();
146558
- const prefetched = import_react47.useMemo(() => {
146566
+ const prefetched = import_react48.useMemo(() => {
146559
146567
  const parsed = sessionLocationSchema.safeParse(location.state);
146560
146568
  return parsed.success ? parsed.data : null;
146561
146569
  }, [location.state]);
146562
- const [session, setSession] = import_react47.useState(prefetched?.session ?? null);
146563
- import_react47.useEffect(() => {
146570
+ const [session, setSession] = import_react48.useState(prefetched?.session ?? null);
146571
+ import_react48.useEffect(() => {
146564
146572
  if (prefetched?.session)
146565
146573
  return;
146566
146574
  setSession(null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unikode/cli",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {