mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-06-26 18:26:38 +00:00
Support sending mock status events (#143)
This commit is contained in:
parent
20769b071d
commit
667de1425e
@ -12,6 +12,14 @@ import { disableTelemetry } from '~/lib/hooks/pingTelemetry';
|
|||||||
// Add your mock chat messages here!
|
// Add your mock chat messages here!
|
||||||
const gMockChat: Message[] | undefined = undefined;
|
const gMockChat: Message[] | undefined = undefined;
|
||||||
|
|
||||||
|
// Add any status events to emit here!
|
||||||
|
const gMockStatus: MockChatStatus[] | undefined = undefined;
|
||||||
|
|
||||||
|
interface MockChatStatus {
|
||||||
|
time: string;
|
||||||
|
status: string;
|
||||||
|
}
|
||||||
|
|
||||||
if (gMockChat) {
|
if (gMockChat) {
|
||||||
disableTelemetry();
|
disableTelemetry();
|
||||||
}
|
}
|
||||||
@ -28,6 +36,11 @@ export async function sendChatMessageMocked(callbacks: ChatMessageCallbacks) {
|
|||||||
assert(gMockChat[0].createTime, 'Mock chat first message must have a create time');
|
assert(gMockChat[0].createTime, 'Mock chat first message must have a create time');
|
||||||
let currentTime = Date.parse(gMockChat[0].createTime);
|
let currentTime = Date.parse(gMockChat[0].createTime);
|
||||||
|
|
||||||
|
for (const status of gMockStatus || []) {
|
||||||
|
const delta = Math.max(Date.parse(status.time) - currentTime, 0);
|
||||||
|
waitForTime(delta).then(() => callbacks.onStatus(status.status));
|
||||||
|
}
|
||||||
|
|
||||||
for (const message of gMockChat) {
|
for (const message of gMockChat) {
|
||||||
if (message.role === 'user') {
|
if (message.role === 'user') {
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user