import type { WorkSummary } from '~/features/work/use-work'
import type { Workspace } from '~/features/workspace/types'

import type { WorkspaceSession } from '../use-session'
import type { WorkspaceSessionGroup } from '../use-session-group'

export const workspaceSidebarFixtureNow = 1_784_836_800

export const workspaceFixtures = {
  local: {
    id: 'workspace-cradle',
    name: 'Cradle',
    locator: {
      hostId: 'local',
      path: '/Users/demo/cradle',
      kind: 'project',
    },
    gitIdentity: {
      originUrl: 'https://github.com/wibus-wee/cradle-app.git',
      repoRoot: '/Users/demo/cradle',
      headSha: '0123456789abcdef',
      branch: 'cradle/wt/chat-transcript-storybook',
    },
    identifier: 'local:/Users/demo/cradle',
    availability: 'available',
    multiFolder: false,
    pinned: 1,
    createdAt: workspaceSidebarFixtureNow - 86_400,
    updatedAt: workspaceSidebarFixtureNow - 30,
  },
  missing: {
    id: 'workspace-missing',
    name: 'Archived client project',
    locator: {
      hostId: 'local',
      path: '/Users/demo/archived-client',
      kind: 'project',
    },
    gitIdentity: {
      originUrl: null,
      repoRoot: null,
      headSha: null,
      branch: null,
    },
    identifier: 'local:/Users/demo/archived-client',
    availability: 'missing',
    multiFolder: false,
    pinned: 0,
    createdAt: workspaceSidebarFixtureNow - 172_800,
    updatedAt: workspaceSidebarFixtureNow - 7_200,
  },
  remote: {
    id: 'workspace-remote',
    name: 'Remote release environment',
    locator: {
      hostId: 'remote-host-staging',
      path: '/srv/cradle-release',
      kind: 'project',
    },
    gitIdentity: {
      originUrl: 'https://github.com/wibus-wee/cradle-app.git',
      repoRoot: '/srv/cradle-release',
      headSha: 'fedcba9876543210',
      branch: 'main',
    },
    identifier: 'remote-host-staging:/srv/cradle-release',
    availability: 'remote',
    multiFolder: false,
    pinned: 0,
    createdAt: workspaceSidebarFixtureNow - 43_200,
    updatedAt: workspaceSidebarFixtureNow - 300,
  },
} satisfies Record<string, Workspace>

export const workspaceSessionFixtures = {
  active: {
    id: 'session-active',
    workspaceId: 'workspace-cradle',
    title: 'Refactor workspace sidebar',
    providerTargetId: 'provider-codex',
    agentId: null,
    modelId: 'gpt-5.4',
    linkedIssueId: null,
    sessionGroupId: null,
    runtimeKind: 'codex-app-server',
    status: 'idle',
    pinned: 1,
    archivedAt: null,
    lastReadAt: workspaceSidebarFixtureNow - 30,
    createdAt: workspaceSidebarFixtureNow - 3_600,
    updatedAt: workspaceSidebarFixtureNow - 40,
    latestUserMessageAt: workspaceSidebarFixtureNow - 90,
    latestAssistantMessageAt: workspaceSidebarFixtureNow - 40,
    unread: false,
    listActivityAt: workspaceSidebarFixtureNow - 40,
    origin: 'manual',
    isIsolated: false,
    worktreeId: null,
    worktreeBranch: null,
    execution: { kind: 'local' },
  },
  unread: {
    id: 'session-unread',
    workspaceId: 'workspace-cradle',
    title: 'Review remote host settings',
    providerTargetId: 'provider-claude',
    agentId: null,
    modelId: 'claude-opus-4-1',
    linkedIssueId: null,
    sessionGroupId: null,
    runtimeKind: 'claude-agent-sdk',
    status: 'idle',
    pinned: 0,
    archivedAt: null,
    lastReadAt: workspaceSidebarFixtureNow - 600,
    createdAt: workspaceSidebarFixtureNow - 7_200,
    updatedAt: workspaceSidebarFixtureNow - 120,
    latestUserMessageAt: workspaceSidebarFixtureNow - 500,
    latestAssistantMessageAt: workspaceSidebarFixtureNow - 120,
    unread: true,
    listActivityAt: workspaceSidebarFixtureNow - 120,
    origin: 'manual',
    isIsolated: false,
    worktreeId: null,
    worktreeBranch: null,
    execution: { kind: 'local' },
  },
  running: {
    id: 'session-running',
    workspaceId: 'workspace-cradle',
    title: 'Run the release verification suite',
    providerTargetId: 'provider-codex',
    agentId: null,
    modelId: 'gpt-5.4',
    linkedIssueId: null,
    sessionGroupId: null,
    runtimeKind: 'codex-app-server',
    status: 'streaming',
    pinned: 0,
    archivedAt: null,
    lastReadAt: workspaceSidebarFixtureNow - 60,
    createdAt: workspaceSidebarFixtureNow - 1_800,
    updatedAt: workspaceSidebarFixtureNow - 10,
    latestUserMessageAt: workspaceSidebarFixtureNow - 60,
    latestAssistantMessageAt: workspaceSidebarFixtureNow - 10,
    unread: false,
    listActivityAt: workspaceSidebarFixtureNow - 10,
    origin: 'manual',
    isIsolated: true,
    worktreeId: 'worktree-release',
    worktreeBranch: 'cradle/wt/release',
    execution: { kind: 'local' },
  },
  system: {
    id: 'session-system',
    workspaceId: 'workspace-cradle',
    title: 'Nightly automation report',
    providerTargetId: 'provider-codex',
    agentId: null,
    modelId: 'gpt-5.4',
    linkedIssueId: null,
    sessionGroupId: null,
    runtimeKind: 'codex-app-server',
    status: 'idle',
    pinned: 0,
    archivedAt: null,
    lastReadAt: workspaceSidebarFixtureNow - 3_600,
    createdAt: workspaceSidebarFixtureNow - 86_400,
    updatedAt: workspaceSidebarFixtureNow - 3_600,
    latestUserMessageAt: workspaceSidebarFixtureNow - 3_700,
    latestAssistantMessageAt: workspaceSidebarFixtureNow - 3_600,
    unread: false,
    listActivityAt: workspaceSidebarFixtureNow - 3_600,
    origin: 'automation',
    isIsolated: false,
    worktreeId: null,
    worktreeBranch: null,
    execution: { kind: 'local' },
  },
} satisfies Record<string, WorkspaceSession>

export const workspaceSessionGroupFixtures = {
  active: {
    id: 'session-group-active',
    workspaceId: workspaceFixtures.local.id,
    title: 'Architecture follow-ups',
    description: null,
    linkedIssueId: null,
    status: 'active',
    configJson: '{}',
    archivedAt: null,
    createdAt: workspaceSidebarFixtureNow - 7_200,
    updatedAt: workspaceSidebarFixtureNow - 30,
    sessionCount: 2,
    statusAggregate: 'idle',
    latestActivityAt: workspaceSidebarFixtureNow - 30,
  },
  review: {
    id: 'session-group-review',
    workspaceId: workspaceFixtures.local.id,
    title: 'Release review',
    description: null,
    linkedIssueId: null,
    status: 'active',
    configJson: '{}',
    archivedAt: null,
    createdAt: workspaceSidebarFixtureNow - 14_400,
    updatedAt: workspaceSidebarFixtureNow - 300,
    sessionCount: 3,
    statusAggregate: 'streaming',
    latestActivityAt: workspaceSidebarFixtureNow - 300,
  },
} satisfies Record<string, WorkspaceSessionGroup>

export const workspaceWorkFixture = {
  id: 'work-sidebar-refactor',
  title: 'Fixture-driven sidebar architecture',
  objective: 'Extract the workspace sidebar rendering seam.',
  linkedIssueId: null,
  handoffTitle: null,
  handoffSummary: null,
  handoffTestPlan: null,
  preparedAt: null,
  lastSubmittedAt: null,
  closedAt: null,
  archivedAt: null,
  createdAt: workspaceSidebarFixtureNow - 7_200,
  updatedAt: workspaceSidebarFixtureNow - 30,
  workspaceId: 'workspace-cradle',
  primarySessionId: workspaceSessionFixtures.active.id,
  activity: 'waiting',
  pullRequest: {
    owner: 'wibus-wee',
    repo: 'cradle-app',
    number: 71,
    url: 'https://github.com/wibus-wee/cradle-app/pull/71',
    title: 'Fixture-driven Storybook view architecture',
    isDraft: true,
    state: 'open',
    merged: false,
    headRef: 'cradle/wt/chat-transcript-storybook',
    baseRef: 'main',
    headSha: '0123456789abcdef',
    createdAt: workspaceSidebarFixtureNow - 7_000,
    updatedAt: workspaceSidebarFixtureNow - 30,
  },
} satisfies WorkSummary
