@personaai/react 0.8.0 → 0.8.1

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.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  React SDK for [Persona](https://persona.hasanraiyan.me) — hooks and a context provider for building chat UIs against any Persona backend.
4
4
 
5
- > **v0.3.2.** Requires React 18+. Client-side only — never holds a credential.
5
+ > **v0.8.0.** Requires React 18+. Client-side only — never holds a credential.
6
6
 
7
7
  ## Install
8
8
 
@@ -46,15 +46,15 @@ function Chat() {
46
46
 
47
47
  ## Hooks
48
48
 
49
- | Hook | Purpose |
50
- | --------------- | -------------------------------------------------------------------------- |
51
- | `useChat` | Streaming chat — messages, send, stop, reload, interrupts, workspace files |
52
- | `useVoice` | Real-time voice calls (Gemini Live) — start/stop/mute, live transcript, tool calls |
53
- | `useThreads` | Thread CRUD — list, create, delete, rename, reset, archive |
54
- | `useFiles` | Upload management — list, upload, delete |
55
- | `useMemory` | Persistent memory — read, write, delete |
56
- | `useAgents` | Agent discovery — list available agents |
57
- | `useConnection` | Health check — backend connectivity status |
49
+ | Hook | Purpose |
50
+ | --------------- | ----------------------------------------------------------------------------------------------- |
51
+ | `useChat` | Streaming chat — messages, send, stop, reload, interrupts, workspace files, ephemeral new chat |
52
+ | `useVoice` | Real-time voice calls (Gemini Live) — start/stop/mute, live transcript, tool calls |
53
+ | `useThreads` | Thread CRUD — list, create, delete, rename, reset, archive |
54
+ | `useFiles` | Upload management — list, upload, delete |
55
+ | `useMemory` | Persistent memory — read, write, delete |
56
+ | `useAgents` | Agent discovery — list available agents |
57
+ | `useConnection` | Health check — backend connectivity status |
58
58
 
59
59
  ## Voice
60
60
 
@@ -125,6 +125,30 @@ as a text response). Injected messages get a `voice-`-prefixed id. You still cal
125
125
  / `voice.stop()` yourself — `useChat` only owns the transcript-to-feed sync, not the call
126
126
  lifecycle.
127
127
 
128
+ ## Ephemeral new chat (0.8.0+)
129
+
130
+ Create a new chat instantly without minting an empty thread. The real `threadId` is created lazily on the first `sendMessage`.
131
+
132
+ ```tsx
133
+ const [threadId, setThreadId] = useState<string | undefined>()
134
+ const chat = useChat({
135
+ agentId,
136
+ threadId,
137
+ onThreadCreated: (id) => setThreadId(id), // sync sidebar after mint
138
+ })
139
+
140
+ const handleNewChat = () => {
141
+ chat.startNewChat() // clears messages/files/todos, enters ephemeral mode
142
+ setThreadId(undefined)
143
+ }
144
+
145
+ // isEphemeral is true until first send mints
146
+ // chat.currentThreadId reflects the effective id (prop ?? minted)
147
+ await chat.sendMessage("Hello") // auto POST /threads if threadId is undefined
148
+ ```
149
+
150
+ `sendMessage` and `reload` now return `Promise<boolean>` (`true` sent, `false` dropped while streaming). `startNewChat()`, `currentThreadId` and `isEphemeral` are new returns on `useChat`.
151
+
128
152
  ## Devtools
129
153
 
130
154
  Floating panel for local debugging — inspect hooks, messages and threads with zero runtime changes. Dev-only, not bundled to production unless imported.
package/dist/index.cjs CHANGED
@@ -974,6 +974,12 @@ function useChat(options = {}) {
974
974
  }
975
975
  }
976
976
  }
977
+ } else if (event.type === "title") {
978
+ const title = event.title;
979
+ if (typeof title === "string" && title.trim()) {
980
+ chatLogger.info("auto title", { title });
981
+ options.onTitle?.(title);
982
+ }
977
983
  } else if (event.type === "RUN_ERROR") {
978
984
  chatLogger.warn("run error", { message: event.message, code: event.code });
979
985
  chatLogger.error("stream run error", { code: event.code, message: event.message });
@@ -2099,7 +2105,7 @@ function useMcp(options = {}) {
2099
2105
 
2100
2106
  // src/index.ts
2101
2107
  var import_logger2 = require("@personaai/logger");
2102
- var VERSION = "0.8.0";
2108
+ var VERSION = "0.8.1";
2103
2109
  // Annotate the CommonJS export names for ESM import in node:
2104
2110
  0 && (module.exports = {
2105
2111
  PersonaProvider,