feat: send test messages during bot connection checks

This commit is contained in:
xmanrui 2026-08-19 03:52:52 +08:00
parent 94da24538f
commit fb61c4235f
78 changed files with 3460 additions and 210 deletions

View file

@ -12,6 +12,10 @@ import {
observeBotWorkspaceRemovals,
validateWorkspacePath,
} from '../src/channels/shared/bot-workspace-store.mjs';
import {
connectionTestTarget,
rememberConnectionTestTarget,
} from '../src/channels/shared/connection-test.mjs';
import {
runWorkspaceCommand,
splitWorkspaceCommandMessage,
@ -70,6 +74,23 @@ test('BotWorkspaceStore uses process.cwd() when a bot has no configured workspac
assert.equal(await store.ensure('bot_cwd'), process.cwd());
});
test('connection test targets survive a new workspace scope for the same bot', async (t) => {
const { path, defaultWorkspace } = await fixture(t);
const workspaces = await new BotWorkspaceStore(path, { defaultWorkspace }).load();
await workspaces.ensure('bot_reconnect');
const state = {};
const harness = {};
const beforeReconnect = createBotWorkspaceScope(harness, {
botId: 'bot_reconnect', workspaces, state,
});
const afterReconnect = createBotWorkspaceScope(harness, {
botId: 'bot_reconnect', workspaces, state,
});
assert.equal(rememberConnectionTestTarget(beforeReconnect.state, { channelId: 'D123' }), true);
assert.deepEqual(connectionTestTarget(afterReconnect.state), { channelId: 'D123' });
});
test('workspace writes roll back updates while committed removals stay retired in memory', async (t) => {
const { root, defaultWorkspace, alternateWorkspace } = await fixture(t);
const storeDirectory = join(root, 'workspace-store');