@percena/weft-react 0.1.5-next.1 → 0.1.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.
- package/dist/index.cjs +49 -14
- package/dist/index.js +49 -14
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -4177,8 +4177,19 @@ var TurnCard = React10.memo(function TurnCard2({
|
|
|
4177
4177
|
if (prev.isLastResponse !== next.isLastResponse) return false;
|
|
4178
4178
|
if (prev.displayMode !== next.displayMode) return false;
|
|
4179
4179
|
if (prev.annotationInteractionMode !== next.annotationInteractionMode) return false;
|
|
4180
|
-
if (prev.activities !== next.activities)
|
|
4181
|
-
|
|
4180
|
+
if (prev.activities !== next.activities) {
|
|
4181
|
+
if (prev.activities.length !== next.activities.length) return false;
|
|
4182
|
+
for (let i = 0; i < prev.activities.length; i++) {
|
|
4183
|
+
const pa = prev.activities[i], na = next.activities[i];
|
|
4184
|
+
if (pa.id !== na.id || pa.status !== na.status || pa.content !== na.content) return false;
|
|
4185
|
+
}
|
|
4186
|
+
}
|
|
4187
|
+
if (prev.response !== next.response) {
|
|
4188
|
+
if (!prev.response !== !next.response) return false;
|
|
4189
|
+
if (prev.response && next.response) {
|
|
4190
|
+
if (prev.response.text !== next.response.text || prev.response.isStreaming !== next.response.isStreaming || prev.response.messageId !== next.response.messageId || prev.response.annotations?.length !== next.response.annotations?.length) return false;
|
|
4191
|
+
}
|
|
4192
|
+
}
|
|
4182
4193
|
if (prev.openAnnotationRequest !== next.openAnnotationRequest) return false;
|
|
4183
4194
|
if (prev.hasActiveFollowUpAnnotations !== next.hasActiveFollowUpAnnotations) return false;
|
|
4184
4195
|
return prev.sessionId === next.sessionId && prev.turnId === next.turnId;
|
|
@@ -7292,6 +7303,17 @@ function useAgentChatSession(options) {
|
|
|
7292
7303
|
function useTimelineAgentChatSession(options) {
|
|
7293
7304
|
const { runtime, workspaceId = "local-workspace", workspaceName = "Local Workspace" } = options;
|
|
7294
7305
|
const [timeline, setTimeline] = (0, import_react19.useState)([]);
|
|
7306
|
+
const [sessionState, setSessionState] = (0, import_react19.useState)(() => ({
|
|
7307
|
+
session: {
|
|
7308
|
+
id: runtime.sessionId,
|
|
7309
|
+
workspaceId,
|
|
7310
|
+
workspaceName,
|
|
7311
|
+
lastMessageAt: 0,
|
|
7312
|
+
messages: [],
|
|
7313
|
+
isProcessing: false
|
|
7314
|
+
},
|
|
7315
|
+
streaming: null
|
|
7316
|
+
}));
|
|
7295
7317
|
const [capabilityReport, setCapabilityReport] = (0, import_react19.useState)(null);
|
|
7296
7318
|
const [error, setError] = (0, import_react19.useState)(null);
|
|
7297
7319
|
const [isReconnecting, setIsReconnecting] = (0, import_react19.useState)(false);
|
|
@@ -7302,6 +7324,11 @@ function useTimelineAgentChatSession(options) {
|
|
|
7302
7324
|
const onEvent = (envelope) => {
|
|
7303
7325
|
lastCursorRef.current = { epoch: envelope.epoch, afterSeq: envelope.seq };
|
|
7304
7326
|
setTimeline((current) => mergeTimeline(current, [envelope]));
|
|
7327
|
+
if (isChatTranscriptTimelineEnvelope(envelope)) {
|
|
7328
|
+
setSessionState(
|
|
7329
|
+
(current) => processEvent(current, mapTimelineEnvelopeToProcessorEvent(envelope)).state
|
|
7330
|
+
);
|
|
7331
|
+
}
|
|
7305
7332
|
setIsReconnecting(false);
|
|
7306
7333
|
};
|
|
7307
7334
|
const onError = (err) => {
|
|
@@ -7316,6 +7343,16 @@ function useTimelineAgentChatSession(options) {
|
|
|
7316
7343
|
if (catchupAbort) return;
|
|
7317
7344
|
if (result.items.length > 0) {
|
|
7318
7345
|
setTimeline((current) => mergeTimeline(current, result.items));
|
|
7346
|
+
const chatEvents = result.items.filter(isChatTranscriptTimelineEnvelope).sort((a, b) => a.epoch !== b.epoch ? a.epoch.localeCompare(b.epoch) : a.seq - b.seq);
|
|
7347
|
+
if (chatEvents.length > 0) {
|
|
7348
|
+
setSessionState((current) => {
|
|
7349
|
+
let s = current;
|
|
7350
|
+
for (const env of chatEvents) {
|
|
7351
|
+
s = processEvent(s, mapTimelineEnvelopeToProcessorEvent(env)).state;
|
|
7352
|
+
}
|
|
7353
|
+
return s;
|
|
7354
|
+
});
|
|
7355
|
+
}
|
|
7319
7356
|
}
|
|
7320
7357
|
if (result.hasGap) {
|
|
7321
7358
|
setHasGap(true);
|
|
@@ -7354,25 +7391,23 @@ function useTimelineAgentChatSession(options) {
|
|
|
7354
7391
|
const respondToPermission = (0, import_react19.useCallback)(async (requestId, allowed, remember) => {
|
|
7355
7392
|
await runtime.commands.respondToPermission(requestId, allowed, remember);
|
|
7356
7393
|
}, [runtime]);
|
|
7357
|
-
const
|
|
7358
|
-
() =>
|
|
7359
|
-
|
|
7360
|
-
sessionId: runtime.sessionId,
|
|
7361
|
-
workspaceId,
|
|
7362
|
-
workspaceName,
|
|
7363
|
-
runtimeState: runtime.getState(),
|
|
7364
|
-
capabilityReport,
|
|
7365
|
-
error
|
|
7366
|
-
}),
|
|
7367
|
-
[timeline, runtime, workspaceId, workspaceName, capabilityReport, error]
|
|
7394
|
+
const turns = (0, import_react19.useMemo)(
|
|
7395
|
+
() => groupMessagesByTurn(sessionState.session.messages),
|
|
7396
|
+
[sessionState]
|
|
7368
7397
|
);
|
|
7398
|
+
const runtimeState = runtime.getState();
|
|
7399
|
+
const isRunning = runtimeState.status === "running" || runtimeState.status === "preflighting" || runtimeState.status === "starting" || runtimeState.status === "waiting_for_permission";
|
|
7369
7400
|
const isConnected = runtime.events.isConnected();
|
|
7370
7401
|
return {
|
|
7371
|
-
|
|
7402
|
+
session: sessionState.session,
|
|
7403
|
+
turns,
|
|
7372
7404
|
timeline,
|
|
7405
|
+
isRunning,
|
|
7373
7406
|
isConnected,
|
|
7374
7407
|
isReconnecting,
|
|
7375
7408
|
hasGap,
|
|
7409
|
+
capabilityReport,
|
|
7410
|
+
error,
|
|
7376
7411
|
sendMessage,
|
|
7377
7412
|
abort,
|
|
7378
7413
|
respondToPermission
|
package/dist/index.js
CHANGED
|
@@ -4100,8 +4100,19 @@ var TurnCard = React10.memo(function TurnCard2({
|
|
|
4100
4100
|
if (prev.isLastResponse !== next.isLastResponse) return false;
|
|
4101
4101
|
if (prev.displayMode !== next.displayMode) return false;
|
|
4102
4102
|
if (prev.annotationInteractionMode !== next.annotationInteractionMode) return false;
|
|
4103
|
-
if (prev.activities !== next.activities)
|
|
4104
|
-
|
|
4103
|
+
if (prev.activities !== next.activities) {
|
|
4104
|
+
if (prev.activities.length !== next.activities.length) return false;
|
|
4105
|
+
for (let i = 0; i < prev.activities.length; i++) {
|
|
4106
|
+
const pa = prev.activities[i], na = next.activities[i];
|
|
4107
|
+
if (pa.id !== na.id || pa.status !== na.status || pa.content !== na.content) return false;
|
|
4108
|
+
}
|
|
4109
|
+
}
|
|
4110
|
+
if (prev.response !== next.response) {
|
|
4111
|
+
if (!prev.response !== !next.response) return false;
|
|
4112
|
+
if (prev.response && next.response) {
|
|
4113
|
+
if (prev.response.text !== next.response.text || prev.response.isStreaming !== next.response.isStreaming || prev.response.messageId !== next.response.messageId || prev.response.annotations?.length !== next.response.annotations?.length) return false;
|
|
4114
|
+
}
|
|
4115
|
+
}
|
|
4105
4116
|
if (prev.openAnnotationRequest !== next.openAnnotationRequest) return false;
|
|
4106
4117
|
if (prev.hasActiveFollowUpAnnotations !== next.hasActiveFollowUpAnnotations) return false;
|
|
4107
4118
|
return prev.sessionId === next.sessionId && prev.turnId === next.turnId;
|
|
@@ -7215,6 +7226,17 @@ function useAgentChatSession(options) {
|
|
|
7215
7226
|
function useTimelineAgentChatSession(options) {
|
|
7216
7227
|
const { runtime, workspaceId = "local-workspace", workspaceName = "Local Workspace" } = options;
|
|
7217
7228
|
const [timeline, setTimeline] = useState12([]);
|
|
7229
|
+
const [sessionState, setSessionState] = useState12(() => ({
|
|
7230
|
+
session: {
|
|
7231
|
+
id: runtime.sessionId,
|
|
7232
|
+
workspaceId,
|
|
7233
|
+
workspaceName,
|
|
7234
|
+
lastMessageAt: 0,
|
|
7235
|
+
messages: [],
|
|
7236
|
+
isProcessing: false
|
|
7237
|
+
},
|
|
7238
|
+
streaming: null
|
|
7239
|
+
}));
|
|
7218
7240
|
const [capabilityReport, setCapabilityReport] = useState12(null);
|
|
7219
7241
|
const [error, setError] = useState12(null);
|
|
7220
7242
|
const [isReconnecting, setIsReconnecting] = useState12(false);
|
|
@@ -7225,6 +7247,11 @@ function useTimelineAgentChatSession(options) {
|
|
|
7225
7247
|
const onEvent = (envelope) => {
|
|
7226
7248
|
lastCursorRef.current = { epoch: envelope.epoch, afterSeq: envelope.seq };
|
|
7227
7249
|
setTimeline((current) => mergeTimeline(current, [envelope]));
|
|
7250
|
+
if (isChatTranscriptTimelineEnvelope(envelope)) {
|
|
7251
|
+
setSessionState(
|
|
7252
|
+
(current) => processEvent(current, mapTimelineEnvelopeToProcessorEvent(envelope)).state
|
|
7253
|
+
);
|
|
7254
|
+
}
|
|
7228
7255
|
setIsReconnecting(false);
|
|
7229
7256
|
};
|
|
7230
7257
|
const onError = (err) => {
|
|
@@ -7239,6 +7266,16 @@ function useTimelineAgentChatSession(options) {
|
|
|
7239
7266
|
if (catchupAbort) return;
|
|
7240
7267
|
if (result.items.length > 0) {
|
|
7241
7268
|
setTimeline((current) => mergeTimeline(current, result.items));
|
|
7269
|
+
const chatEvents = result.items.filter(isChatTranscriptTimelineEnvelope).sort((a, b) => a.epoch !== b.epoch ? a.epoch.localeCompare(b.epoch) : a.seq - b.seq);
|
|
7270
|
+
if (chatEvents.length > 0) {
|
|
7271
|
+
setSessionState((current) => {
|
|
7272
|
+
let s = current;
|
|
7273
|
+
for (const env of chatEvents) {
|
|
7274
|
+
s = processEvent(s, mapTimelineEnvelopeToProcessorEvent(env)).state;
|
|
7275
|
+
}
|
|
7276
|
+
return s;
|
|
7277
|
+
});
|
|
7278
|
+
}
|
|
7242
7279
|
}
|
|
7243
7280
|
if (result.hasGap) {
|
|
7244
7281
|
setHasGap(true);
|
|
@@ -7277,25 +7314,23 @@ function useTimelineAgentChatSession(options) {
|
|
|
7277
7314
|
const respondToPermission = useCallback9(async (requestId, allowed, remember) => {
|
|
7278
7315
|
await runtime.commands.respondToPermission(requestId, allowed, remember);
|
|
7279
7316
|
}, [runtime]);
|
|
7280
|
-
const
|
|
7281
|
-
() =>
|
|
7282
|
-
|
|
7283
|
-
sessionId: runtime.sessionId,
|
|
7284
|
-
workspaceId,
|
|
7285
|
-
workspaceName,
|
|
7286
|
-
runtimeState: runtime.getState(),
|
|
7287
|
-
capabilityReport,
|
|
7288
|
-
error
|
|
7289
|
-
}),
|
|
7290
|
-
[timeline, runtime, workspaceId, workspaceName, capabilityReport, error]
|
|
7317
|
+
const turns = useMemo8(
|
|
7318
|
+
() => groupMessagesByTurn(sessionState.session.messages),
|
|
7319
|
+
[sessionState]
|
|
7291
7320
|
);
|
|
7321
|
+
const runtimeState = runtime.getState();
|
|
7322
|
+
const isRunning = runtimeState.status === "running" || runtimeState.status === "preflighting" || runtimeState.status === "starting" || runtimeState.status === "waiting_for_permission";
|
|
7292
7323
|
const isConnected = runtime.events.isConnected();
|
|
7293
7324
|
return {
|
|
7294
|
-
|
|
7325
|
+
session: sessionState.session,
|
|
7326
|
+
turns,
|
|
7295
7327
|
timeline,
|
|
7328
|
+
isRunning,
|
|
7296
7329
|
isConnected,
|
|
7297
7330
|
isReconnecting,
|
|
7298
7331
|
hasGap,
|
|
7332
|
+
capabilityReport,
|
|
7333
|
+
error,
|
|
7299
7334
|
sendMessage,
|
|
7300
7335
|
abort,
|
|
7301
7336
|
respondToPermission
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percena/weft-react",
|
|
3
|
-
"version": "0.1.5
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Weft React — TimelineAgentChatPanel + headless hooks (useAgentSession) with precompiled CSS; no Tailwind setup required in the host",
|
|
6
6
|
"type": "module",
|
|
@@ -47,16 +47,16 @@
|
|
|
47
47
|
"remark-gfm": "^4.0.0",
|
|
48
48
|
"remark-math": "^6.0.0",
|
|
49
49
|
"zod": "^3.0.0",
|
|
50
|
-
"@percena/weft-client": "^0.2.0
|
|
50
|
+
"@percena/weft-client": "^0.2.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@tailwindcss/cli": "^4.0.0",
|
|
54
54
|
"@tailwindcss/typography": "^0.5.16",
|
|
55
55
|
"@types/react": "^19.2.14",
|
|
56
56
|
"tailwindcss": "^4.0.0",
|
|
57
|
-
"@weft/provider-flitro": "0.1.0",
|
|
58
|
-
"@weft/local-chat": "0.1.0",
|
|
59
57
|
"@weft/runtime-core": "0.1.0",
|
|
58
|
+
"@weft/local-chat": "0.1.0",
|
|
59
|
+
"@weft/provider-flitro": "0.1.0",
|
|
60
60
|
"@weft/ui": "0.1.0"
|
|
61
61
|
},
|
|
62
62
|
"keywords": [
|