Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

1.2 KB
Raw Blame
import { describe, expect, it } from 'vitest';

import { pendingInitialMessageHandoff } from './chatInitialMessage';

const candidate = (overrides: Partial<Parameters<typeof pendingInitialMessageHandoff>[0]> = {}) => ({
  handledSessionId: null,
  loadedSessionId: 'ses_1',
  loading: false,
  locationState: { initialMessage: 'hello' },
  routeSurfaceActive: true,
  sessionId: 'ses_1',
  ...overrides,
});

describe('initial chat message handoff', () => {
  it('waits until the retained route is foreground before consuming the message', () => {
    expect(pendingInitialMessageHandoff(candidate({ routeSurfaceActive: false }))).toBeNull();
    expect(pendingInitialMessageHandoff(candidate())).toEqual({
      message: 'hello',
      sessionId: 'ses_1',
    });
  });

  it('requires the matching loaded session and an unhandled message', () => {
    expect(pendingInitialMessageHandoff(candidate({ loading: true }))).toBeNull();
    expect(pendingInitialMessageHandoff(candidate({ loadedSessionId: 'ses_2' }))).toBeNull();
    expect(pendingInitialMessageHandoff(candidate({ handledSessionId: 'ses_1' }))).toBeNull();
    expect(pendingInitialMessageHandoff(candidate({ locationState: null }))).toBeNull();
  });
});