@wherever-dev/client 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/CHANGELOG.md +6 -0
- package/README.md +63 -0
- package/dist/client.js +2 -0
- package/dist/client.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.js.map +1 -1
- package/package.json +23 -3
- package/src/client.ts +2 -0
- package/src/types.ts +3 -0
- package/test/agent-pending.test.ts +0 -107
- package/test/chunked-upload.test.ts +0 -483
- package/test/conversation-mode-flag.test.ts +0 -111
- package/test/creating-session-watchdog.test.ts +0 -82
- package/test/folder-conflict-read-only.test.ts +0 -145
- package/test/folder-missing-read-only.test.ts +0 -114
- package/test/harness.ts +0 -133
- package/test/hydration-seam.test.ts +0 -400
- package/test/liveness-probe.test.ts +0 -183
- package/test/message-delivery-confirmation.test.ts +0 -320
- package/test/mid-stream-steer.test.ts +0 -91
- package/test/new-session-clone-progress.test.ts +0 -263
- package/test/optimistic-force-command.test.ts +0 -127
- package/test/queued-steer-restored.test.ts +0 -175
- package/test/reconnect-rejoins-session.test.ts +0 -136
- package/test/restore-panel.test.ts +0 -324
- package/test/resume-keeps-session.test.ts +0 -118
- package/test/session-load-by-id.test.ts +0 -100
- package/test/session-reload.test.ts +0 -82
- package/test/skills-autocomplete.test.ts +0 -113
- package/test/steer-queue-cancel.test.ts +0 -130
- package/test/superseded-connection-key.test.ts +0 -70
- package/test/superseded-session-load.test.ts +0 -180
- package/test/tool-aborted-render.test.ts +0 -170
- package/test/tool-duration-history.test.ts +0 -93
- package/test/tool-duration.test.ts +0 -86
- package/test/tool-interrupted-history.test.ts +0 -294
- package/test/upload-survives-reconnect.test.ts +0 -482
- package/tsconfig.json +0 -16
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import {describe, it, expect, beforeEach, afterEach, vi} from 'vitest';
|
|
2
|
-
import {get} from 'sveltore';
|
|
3
|
-
import {WhereverClient} from '../src/client.js';
|
|
4
|
-
import type {WhereverState} from '../src/types.js';
|
|
5
|
-
import {makeWSFactory} from './harness.js';
|
|
6
|
-
|
|
7
|
-
// A web `!command` / `!!command` (force command) is intercepted by the server
|
|
8
|
-
// and run as a bash tool call; it is NOT echoed back as a user message. Without
|
|
9
|
-
// any local feedback the tool bubble only appeared after a full server
|
|
10
|
-
// round-trip (client -> server -> tool_start -> client), so the command did not
|
|
11
|
-
// show up instantly. The client now renders an OPTIMISTIC bash tool bubble at
|
|
12
|
-
// send time and RECONCILES the server's real tool_start onto it (no duplicate).
|
|
13
|
-
|
|
14
|
-
function setup(ws: ReturnType<typeof makeWSFactory>, isStreaming = false) {
|
|
15
|
-
const client = new WhereverClient({
|
|
16
|
-
host: 'localhost',
|
|
17
|
-
port: 1234,
|
|
18
|
-
secure: false,
|
|
19
|
-
WebSocketCtor: ws.ctor,
|
|
20
|
-
});
|
|
21
|
-
client.connect();
|
|
22
|
-
ws.last().open();
|
|
23
|
-
client.joinSession('/tmp/project/session.jsonl');
|
|
24
|
-
ws.last().receive({
|
|
25
|
-
type: 'session_created',
|
|
26
|
-
sessionId: 'sid-1',
|
|
27
|
-
sessionFile: '/tmp/project/session.jsonl',
|
|
28
|
-
cwd: '/tmp/project',
|
|
29
|
-
model: 'fake:model',
|
|
30
|
-
isStreaming,
|
|
31
|
-
});
|
|
32
|
-
return client;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
describe('optimistic force-command tool bubble', () => {
|
|
36
|
-
let ws: ReturnType<typeof makeWSFactory>;
|
|
37
|
-
let client: WhereverClient;
|
|
38
|
-
const state = () => get<WhereverState>(client.stateStore);
|
|
39
|
-
const tools = () => state().messages.filter((m) => m.role === 'tool');
|
|
40
|
-
|
|
41
|
-
beforeEach(() => {
|
|
42
|
-
vi.useFakeTimers();
|
|
43
|
-
ws = makeWSFactory();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
afterEach(() => {
|
|
47
|
-
client.disconnect(true);
|
|
48
|
-
vi.useRealTimers();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('renders an optimistic bash bubble instantly on a !command (no user echo)', () => {
|
|
52
|
-
client = setup(ws);
|
|
53
|
-
client.sendMessage('!ls -la');
|
|
54
|
-
|
|
55
|
-
const t = tools();
|
|
56
|
-
expect(t.length).toBe(1);
|
|
57
|
-
expect(t[0].toolName).toBe('bash');
|
|
58
|
-
expect(t[0].forceCommand).toBe(true);
|
|
59
|
-
expect(t[0].optimistic).toBe(true);
|
|
60
|
-
expect(t[0].isStreaming).toBe(true);
|
|
61
|
-
expect(t[0].content).toBe('$ bash command="ls -la"');
|
|
62
|
-
// It is NOT a user message (no user echo, no delivery tracking).
|
|
63
|
-
expect(state().messages.some((m) => m.role === 'user')).toBe(false);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('strips the !! prefix for an excluded-from-context command', () => {
|
|
67
|
-
client = setup(ws);
|
|
68
|
-
client.sendMessage('!!git status');
|
|
69
|
-
const t = tools();
|
|
70
|
-
expect(t.length).toBe(1);
|
|
71
|
-
expect(t[0].content).toBe('$ bash command="git status"');
|
|
72
|
-
expect(t[0].optimistic).toBe(true);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('reconciles the server tool_start onto the optimistic bubble (no duplicate)', () => {
|
|
76
|
-
client = setup(ws);
|
|
77
|
-
client.sendMessage('!ls -la');
|
|
78
|
-
expect(tools().length).toBe(1);
|
|
79
|
-
|
|
80
|
-
// The server runs it and emits the real tool_start (forceCommand).
|
|
81
|
-
ws.last().receive({
|
|
82
|
-
type: 'tool_start',
|
|
83
|
-
sessionId: 'sid-1',
|
|
84
|
-
toolName: 'bash',
|
|
85
|
-
args: {command: 'ls -la'},
|
|
86
|
-
forceCommand: true,
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
const t = tools();
|
|
90
|
-
expect(t.length).toBe(1); // reconciled, not duplicated
|
|
91
|
-
expect(t[0].optimistic).toBeFalsy(); // flag cleared
|
|
92
|
-
expect(t[0].forceCommand).toBe(true);
|
|
93
|
-
expect(t[0].isStreaming).toBe(true);
|
|
94
|
-
|
|
95
|
-
// Output then streams and settles onto the SAME bubble.
|
|
96
|
-
ws.last().receive({type: 'tool_update', sessionId: 'sid-1', toolName: 'bash', delta: 'total 0\n'});
|
|
97
|
-
ws.last().receive({
|
|
98
|
-
type: 'tool_end',
|
|
99
|
-
sessionId: 'sid-1',
|
|
100
|
-
toolName: 'bash',
|
|
101
|
-
isError: false,
|
|
102
|
-
result: 'total 0\n',
|
|
103
|
-
forceCommand: true,
|
|
104
|
-
});
|
|
105
|
-
const done = tools();
|
|
106
|
-
expect(done.length).toBe(1);
|
|
107
|
-
expect(done[0].isStreaming).toBe(false);
|
|
108
|
-
expect(done[0].toolOutput).toContain('total 0');
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('does NOT render an optimistic bubble for !sudo (deferred behind a password prompt)', () => {
|
|
112
|
-
client = setup(ws);
|
|
113
|
-
client.sendMessage('!sudo apt update');
|
|
114
|
-
expect(tools().length).toBe(0);
|
|
115
|
-
expect(state().sessionError).toBeNull();
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('an agent-issued bash tool_start still appends its own bubble', () => {
|
|
119
|
-
client = setup(ws);
|
|
120
|
-
// No optimistic bubble exists; a plain agent tool_start (no forceCommand).
|
|
121
|
-
ws.last().receive({type: 'tool_start', sessionId: 'sid-1', toolName: 'bash', args: {command: 'echo hi'}});
|
|
122
|
-
const t = tools();
|
|
123
|
-
expect(t.length).toBe(1);
|
|
124
|
-
expect(t[0].forceCommand).toBeFalsy();
|
|
125
|
-
expect(t[0].optimistic).toBeFalsy();
|
|
126
|
-
});
|
|
127
|
-
});
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import {describe, it, expect, beforeEach, afterEach, vi} from 'vitest';
|
|
2
|
-
import {get} from 'sveltore';
|
|
3
|
-
import {WhereverClient} from '../src/client.js';
|
|
4
|
-
import {makeWSFactory} from './harness.js';
|
|
5
|
-
|
|
6
|
-
// Bug: after a reload, a message queued mid-stream (a STEER) was invisible. The
|
|
7
|
-
// server now snapshots pi's queue on attach (queue_update), but the queued text
|
|
8
|
-
// is NOT in the session file yet, so message_history cannot contain it: with
|
|
9
|
-
// only `pendingSteering` set and no matching message, the UI had nothing to
|
|
10
|
-
// badge and the user's text simply vanished until pi injected it at the next
|
|
11
|
-
// step.
|
|
12
|
-
//
|
|
13
|
-
// Fix: queue_update re-materializes any queued text with no matching user
|
|
14
|
-
// message, so a reloaded client shows the queued messages (badged "Queued") and
|
|
15
|
-
// can still cancel them.
|
|
16
|
-
|
|
17
|
-
function newClient(ws: ReturnType<typeof makeWSFactory>) {
|
|
18
|
-
const client = new WhereverClient({
|
|
19
|
-
host: 'localhost',
|
|
20
|
-
port: 1234,
|
|
21
|
-
secure: false,
|
|
22
|
-
WebSocketCtor: ws.ctor,
|
|
23
|
-
});
|
|
24
|
-
client.connect();
|
|
25
|
-
ws.last().open();
|
|
26
|
-
return client;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function attach(ws: ReturnType<typeof makeWSFactory>, client: WhereverClient) {
|
|
30
|
-
client.joinSession('/tmp/project/session.jsonl');
|
|
31
|
-
ws.last().receive({
|
|
32
|
-
type: 'session_created',
|
|
33
|
-
sessionId: 'sid-1',
|
|
34
|
-
sessionFile: '/tmp/project/session.jsonl',
|
|
35
|
-
cwd: '/tmp/project',
|
|
36
|
-
model: 'fake:model',
|
|
37
|
-
});
|
|
38
|
-
ws.last().receive({
|
|
39
|
-
type: 'message_history',
|
|
40
|
-
sessionId: 'sid-1',
|
|
41
|
-
messages: [{role: 'user', content: 'do the first thing', timestamp: 1}],
|
|
42
|
-
totalCount: 1,
|
|
43
|
-
offset: 0,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
describe('a queued steer is restored into the conversation on reload', () => {
|
|
48
|
-
let ws: ReturnType<typeof makeWSFactory>;
|
|
49
|
-
let client: WhereverClient;
|
|
50
|
-
|
|
51
|
-
beforeEach(() => {
|
|
52
|
-
vi.useFakeTimers();
|
|
53
|
-
ws = makeWSFactory();
|
|
54
|
-
client = newClient(ws);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
afterEach(() => {
|
|
58
|
-
client.disconnect(true);
|
|
59
|
-
vi.useRealTimers();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('renders a queued message the freshly-loaded history does not contain', () => {
|
|
63
|
-
attach(ws, client);
|
|
64
|
-
|
|
65
|
-
ws.last().receive({
|
|
66
|
-
type: 'queue_update',
|
|
67
|
-
sessionId: 'sid-1',
|
|
68
|
-
steering: ['actually do X instead'],
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
const s = get(client.stateStore);
|
|
72
|
-
expect(s.pendingSteering).toEqual(['actually do X instead']);
|
|
73
|
-
const restored = s.messages.filter(
|
|
74
|
-
(m) => m.role === 'user' && m.content === 'actually do X instead',
|
|
75
|
-
);
|
|
76
|
-
expect(restored).toHaveLength(1);
|
|
77
|
-
// It is server-side queued, not an unconfirmed local send: no retry banner.
|
|
78
|
-
expect(restored[0].delivery).toBeUndefined();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('does not duplicate a queued message we sent ourselves this session', () => {
|
|
82
|
-
attach(ws, client);
|
|
83
|
-
client.sendMessage('actually do X instead');
|
|
84
|
-
|
|
85
|
-
ws.last().receive({
|
|
86
|
-
type: 'queue_update',
|
|
87
|
-
sessionId: 'sid-1',
|
|
88
|
-
steering: ['actually do X instead'],
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
const s = get(client.stateStore);
|
|
92
|
-
expect(
|
|
93
|
-
s.messages.filter((m) => m.content === 'actually do X instead'),
|
|
94
|
-
).toHaveLength(1);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('does not duplicate when the queued message is finally delivered', () => {
|
|
98
|
-
attach(ws, client);
|
|
99
|
-
ws.last().receive({
|
|
100
|
-
type: 'queue_update',
|
|
101
|
-
sessionId: 'sid-1',
|
|
102
|
-
steering: ['actually do X instead'],
|
|
103
|
-
});
|
|
104
|
-
// pi injects it: the queue empties and the server echoes the user message.
|
|
105
|
-
ws.last().receive({type: 'queue_update', sessionId: 'sid-1', steering: []});
|
|
106
|
-
ws.last().receive({
|
|
107
|
-
type: 'message_end',
|
|
108
|
-
sessionId: 'sid-1',
|
|
109
|
-
role: 'user',
|
|
110
|
-
content: 'actually do X instead',
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
const s = get(client.stateStore);
|
|
114
|
-
expect(s.pendingSteering).toEqual([]);
|
|
115
|
-
expect(
|
|
116
|
-
s.messages.filter((m) => m.content === 'actually do X instead'),
|
|
117
|
-
).toHaveLength(1);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('restores every queued message, including repeats of the same text', () => {
|
|
121
|
-
attach(ws, client);
|
|
122
|
-
ws.last().receive({
|
|
123
|
-
type: 'queue_update',
|
|
124
|
-
sessionId: 'sid-1',
|
|
125
|
-
steering: ['ping', 'ping'],
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
const s = get(client.stateStore);
|
|
129
|
-
expect(s.messages.filter((m) => m.content === 'ping')).toHaveLength(2);
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('does not duplicate when the OLDER of two queued messages is delivered', () => {
|
|
133
|
-
attach(ws, client);
|
|
134
|
-
ws.last().receive({
|
|
135
|
-
type: 'queue_update',
|
|
136
|
-
sessionId: 'sid-1',
|
|
137
|
-
steering: ['first queued', 'second queued'],
|
|
138
|
-
});
|
|
139
|
-
// pi injects the oldest: the queue drops it and the server echoes it. The
|
|
140
|
-
// echoed message is NOT the last user bubble ('second queued' is), so a
|
|
141
|
-
// naive last-message dedupe would append a duplicate.
|
|
142
|
-
ws.last().receive({
|
|
143
|
-
type: 'queue_update',
|
|
144
|
-
sessionId: 'sid-1',
|
|
145
|
-
steering: ['second queued'],
|
|
146
|
-
});
|
|
147
|
-
ws.last().receive({
|
|
148
|
-
type: 'message_end',
|
|
149
|
-
sessionId: 'sid-1',
|
|
150
|
-
role: 'user',
|
|
151
|
-
content: 'first queued',
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
const s = get(client.stateStore);
|
|
155
|
-
expect(s.messages.filter((m) => m.content === 'first queued')).toHaveLength(1);
|
|
156
|
-
expect(s.messages.filter((m) => m.content === 'second queued')).toHaveLength(1);
|
|
157
|
-
expect(s.pendingSteering).toEqual(['second queued']);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it('leaves an already-restored queue alone on a repeated snapshot', () => {
|
|
161
|
-
attach(ws, client);
|
|
162
|
-
const snapshot = {
|
|
163
|
-
type: 'queue_update',
|
|
164
|
-
sessionId: 'sid-1',
|
|
165
|
-
steering: ['actually do X instead'],
|
|
166
|
-
};
|
|
167
|
-
ws.last().receive(snapshot);
|
|
168
|
-
ws.last().receive(snapshot);
|
|
169
|
-
|
|
170
|
-
const s = get(client.stateStore);
|
|
171
|
-
expect(
|
|
172
|
-
s.messages.filter((m) => m.content === 'actually do X instead'),
|
|
173
|
-
).toHaveLength(1);
|
|
174
|
-
});
|
|
175
|
-
});
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import {describe, it, expect, beforeEach, afterEach, vi} from 'vitest';
|
|
2
|
-
import {get} from 'sveltore';
|
|
3
|
-
import {WhereverClient} from '../src/client.js';
|
|
4
|
-
import {makeWSFactory} from './harness.js';
|
|
5
|
-
|
|
6
|
-
// Bug: after an UNSOLICITED reconnect (the socket dropped on its own -- tab
|
|
7
|
-
// switch, network blip, laptop sleep, half-open reap -- NOT via suspend()), the
|
|
8
|
-
// client reconnected to the relay but did NOT re-issue session_load, so the new
|
|
9
|
-
// socket was attached to NO session server-side. The frontend kept showing the
|
|
10
|
-
// stale conversation (a frozen tool call as the last message, "Abort" disabled)
|
|
11
|
-
// and followed nothing, with no "connecting"/"loading" affordance, while the
|
|
12
|
-
// agent kept running behind the scenes. Only a full reload recovered it.
|
|
13
|
-
//
|
|
14
|
-
// The server is stateless per-connection: every new socket gets a fresh clientId
|
|
15
|
-
// with sessionId=null and the old socket's close removes the client from the
|
|
16
|
-
// pool. So the CLIENT must re-attach by re-issuing session_load on ANY reconnect
|
|
17
|
-
// that still holds an active session -- not only on the suspend/resume path.
|
|
18
|
-
|
|
19
|
-
function createAndLoad(
|
|
20
|
-
ws: ReturnType<typeof makeWSFactory>,
|
|
21
|
-
client: WhereverClient,
|
|
22
|
-
{streaming = false}: {streaming?: boolean} = {},
|
|
23
|
-
) {
|
|
24
|
-
client.joinSession('/tmp/project/session.jsonl');
|
|
25
|
-
ws.last().receive({
|
|
26
|
-
type: 'session_created',
|
|
27
|
-
sessionId: 'sid-1',
|
|
28
|
-
sessionFile: '/tmp/project/session.jsonl',
|
|
29
|
-
cwd: '/tmp/project',
|
|
30
|
-
model: 'fake:model',
|
|
31
|
-
isStreaming: streaming,
|
|
32
|
-
});
|
|
33
|
-
ws.last().receive({
|
|
34
|
-
type: 'message_history',
|
|
35
|
-
sessionId: 'sid-1',
|
|
36
|
-
messages: [{role: 'user', content: 'go build it', timestamp: 1}],
|
|
37
|
-
totalCount: 1,
|
|
38
|
-
offset: 0,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
describe('unsolicited reconnect re-attaches to the active session', () => {
|
|
43
|
-
let ws: ReturnType<typeof makeWSFactory>;
|
|
44
|
-
let client: WhereverClient;
|
|
45
|
-
|
|
46
|
-
beforeEach(() => {
|
|
47
|
-
vi.useFakeTimers();
|
|
48
|
-
ws = makeWSFactory();
|
|
49
|
-
client = new WhereverClient({
|
|
50
|
-
host: 'localhost',
|
|
51
|
-
port: 1234,
|
|
52
|
-
secure: false,
|
|
53
|
-
WebSocketCtor: ws.ctor,
|
|
54
|
-
});
|
|
55
|
-
client.connect();
|
|
56
|
-
ws.last().open();
|
|
57
|
-
createAndLoad(ws, client, {streaming: true});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
afterEach(() => {
|
|
61
|
-
client.disconnect(true);
|
|
62
|
-
vi.useRealTimers();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('re-issues session_load after the socket drops and reconnects', () => {
|
|
66
|
-
const firstWs = ws.last();
|
|
67
|
-
// The socket dies on its own (no suspend). onClose schedules a reconnect.
|
|
68
|
-
firstWs.close();
|
|
69
|
-
|
|
70
|
-
// The reconnect backoff timer fires and opens a brand-new socket.
|
|
71
|
-
vi.advanceTimersByTime(5000);
|
|
72
|
-
const secondWs = ws.last();
|
|
73
|
-
expect(secondWs).not.toBe(firstWs);
|
|
74
|
-
secondWs.open();
|
|
75
|
-
|
|
76
|
-
// The client MUST re-attach to the previously-active session so the live
|
|
77
|
-
// stream resumes; otherwise it is silently detached and frozen.
|
|
78
|
-
const load = secondWs.lastSentOfType('session_load');
|
|
79
|
-
expect(load).toBeTruthy();
|
|
80
|
-
expect(load.sessionFile).toBe('/tmp/project/session.jsonl');
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('shows a resyncing affordance during the reconnect, not a silent frozen view', () => {
|
|
84
|
-
const firstWs = ws.last();
|
|
85
|
-
firstWs.close();
|
|
86
|
-
vi.advanceTimersByTime(5000);
|
|
87
|
-
const secondWs = ws.last();
|
|
88
|
-
secondWs.open();
|
|
89
|
-
|
|
90
|
-
// While re-attaching, resyncing is true (drives the "Reconnecting and
|
|
91
|
-
// syncing session..." banner + blocks sending) and the cached conversation
|
|
92
|
-
// stays visible.
|
|
93
|
-
const s = get(client.stateStore);
|
|
94
|
-
expect(s.resyncing).toBe(true);
|
|
95
|
-
expect(s.activeSessionFile).toBe('/tmp/project/session.jsonl');
|
|
96
|
-
expect(s.messages.length).toBeGreaterThan(0);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('clears resyncing and resumes the stream once fresh history arrives', () => {
|
|
100
|
-
ws.last().close();
|
|
101
|
-
vi.advanceTimersByTime(5000);
|
|
102
|
-
const secondWs = ws.last();
|
|
103
|
-
secondWs.open();
|
|
104
|
-
|
|
105
|
-
secondWs.receive({
|
|
106
|
-
type: 'session_created',
|
|
107
|
-
sessionId: 'sid-1',
|
|
108
|
-
sessionFile: '/tmp/project/session.jsonl',
|
|
109
|
-
cwd: '/tmp/project',
|
|
110
|
-
model: 'fake:model',
|
|
111
|
-
isStreaming: true,
|
|
112
|
-
});
|
|
113
|
-
secondWs.receive({
|
|
114
|
-
type: 'message_history',
|
|
115
|
-
sessionId: 'sid-1',
|
|
116
|
-
messages: [
|
|
117
|
-
{role: 'user', content: 'go build it', timestamp: 1},
|
|
118
|
-
{role: 'assistant', content: 'on it', timestamp: 2},
|
|
119
|
-
],
|
|
120
|
-
totalCount: 2,
|
|
121
|
-
offset: 0,
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
const s = get(client.stateStore);
|
|
125
|
-
expect(s.resyncing).toBe(false);
|
|
126
|
-
expect(s.connected).toBe(true);
|
|
127
|
-
// Re-attach restores the true streaming state from the server, so "Abort"
|
|
128
|
-
// re-enables if the agent is still working (the reported symptom: Abort
|
|
129
|
-
// disabled with a stale tool call as last message).
|
|
130
|
-
expect(s.isStreaming).toBe(true);
|
|
131
|
-
// Live stream is following again: a new event after resync lands.
|
|
132
|
-
secondWs.receive({type: 'agent_end'});
|
|
133
|
-
vi.advanceTimersByTime(400);
|
|
134
|
-
expect(get(client.stateStore).isStreaming).toBe(false);
|
|
135
|
-
});
|
|
136
|
-
});
|