mirror of
https://github.com/stablyai/orca.git
synced 2026-10-08 08:02:32 +00:00
Add existing workspace migration telemetry (#2359)
Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { eventSchemas } from './telemetry-events'
|
||||
|
||||
describe('add_repo_existing_workspaces_detected schema', () => {
|
||||
it('accepts count-only workspace migration context', () => {
|
||||
const parsed = eventSchemas.add_repo_existing_workspaces_detected.safeParse({
|
||||
source: 'local_folder_picker',
|
||||
existing_workspace_count: 3,
|
||||
existing_linked_workspace_count: 2,
|
||||
main_workspace_count: 1,
|
||||
branch_named_workspace_count: 2,
|
||||
detached_workspace_count: 1,
|
||||
custom_named_workspace_count: 1,
|
||||
sparse_workspace_count: 0,
|
||||
nth_repo_added: 1
|
||||
})
|
||||
expect(parsed.success).toBe(true)
|
||||
})
|
||||
|
||||
it('rejects raw workspace names via .strict()', () => {
|
||||
const parsed = eventSchemas.add_repo_existing_workspaces_detected.safeParse({
|
||||
source: 'local_folder_picker',
|
||||
existing_workspace_count: 1,
|
||||
existing_linked_workspace_count: 0,
|
||||
main_workspace_count: 1,
|
||||
branch_named_workspace_count: 1,
|
||||
detached_workspace_count: 0,
|
||||
custom_named_workspace_count: 0,
|
||||
sparse_workspace_count: 0,
|
||||
nth_repo_added: 1,
|
||||
workspace_names: ['secret-customer-branch']
|
||||
})
|
||||
expect(parsed.success).toBe(false)
|
||||
})
|
||||
|
||||
it('accepts setup start choices with bounded existing-workspace context', () => {
|
||||
for (const action of ['open_existing', 'create_worktree'] as const) {
|
||||
const parsed = eventSchemas.add_repo_setup_step_action.safeParse({
|
||||
action,
|
||||
source: 'ssh_remote_path',
|
||||
existing_workspace_count: 4,
|
||||
existing_linked_workspace_count: 3,
|
||||
nth_repo_added: 1
|
||||
})
|
||||
expect(parsed.success).toBe(true)
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -101,6 +101,15 @@ export const addRepoSetupStepActionSchema = z.enum([
|
||||
])
|
||||
export type AddRepoSetupStepAction = z.infer<typeof addRepoSetupStepActionSchema>
|
||||
|
||||
export const addRepoExistingWorkspaceSourceSchema = z.enum([
|
||||
'local_folder_picker',
|
||||
'runtime_server_path',
|
||||
'ssh_remote_path',
|
||||
'clone_url',
|
||||
'create_project'
|
||||
])
|
||||
export type AddRepoExistingWorkspaceSource = z.infer<typeof addRepoExistingWorkspaceSourceSchema>
|
||||
|
||||
// Deliberately a separate enum from `errorClassSchema` (PTY-spawn taxonomy):
|
||||
// different domain — this one buckets git/filesystem failures thrown by
|
||||
// `createLocalWorktree` / `createRemoteWorktree`. Merging the two would lock
|
||||
@@ -286,8 +295,32 @@ const featureWallTileClickedSchema = z
|
||||
})
|
||||
.strict()
|
||||
|
||||
const existingWorkspaceCountSchema = z.number().int().min(1).max(50)
|
||||
const addRepoExistingWorkspaceContextSchema = {
|
||||
source: addRepoExistingWorkspaceSourceSchema,
|
||||
existing_workspace_count: existingWorkspaceCountSchema,
|
||||
existing_linked_workspace_count: z.number().int().min(0).max(50)
|
||||
} as const
|
||||
|
||||
const addRepoSetupStepActionEventSchema = z
|
||||
.object({ action: addRepoSetupStepActionSchema, nth_repo_added: nthRepoAddedSchema })
|
||||
.object({
|
||||
action: addRepoSetupStepActionSchema,
|
||||
source: addRepoExistingWorkspaceSourceSchema.optional(),
|
||||
existing_workspace_count: existingWorkspaceCountSchema.optional(),
|
||||
existing_linked_workspace_count: z.number().int().min(0).max(50).optional(),
|
||||
nth_repo_added: nthRepoAddedSchema
|
||||
})
|
||||
.strict()
|
||||
const addRepoExistingWorkspacesDetectedSchema = z
|
||||
.object({
|
||||
...addRepoExistingWorkspaceContextSchema,
|
||||
main_workspace_count: z.number().int().min(0).max(50),
|
||||
branch_named_workspace_count: z.number().int().min(0).max(50),
|
||||
detached_workspace_count: z.number().int().min(0).max(50),
|
||||
custom_named_workspace_count: z.number().int().min(0).max(50),
|
||||
sparse_workspace_count: z.number().int().min(0).max(50),
|
||||
nth_repo_added: nthRepoAddedSchema
|
||||
})
|
||||
.strict()
|
||||
|
||||
// Why: same enum-only discipline as `agent_error` — `.strict()` rejects raw
|
||||
@@ -710,6 +743,7 @@ export const eventSchemas = {
|
||||
|
||||
repo_added: repoAddedSchema,
|
||||
add_repo_setup_step_action: addRepoSetupStepActionEventSchema,
|
||||
add_repo_existing_workspaces_detected: addRepoExistingWorkspacesDetectedSchema,
|
||||
workspace_created: workspaceCreatedSchema,
|
||||
workspace_create_failed: workspaceCreateFailedSchema,
|
||||
|
||||
@@ -791,6 +825,7 @@ type _CohortExtendedRoster =
|
||||
| 'app_opened'
|
||||
| 'repo_added'
|
||||
| 'add_repo_setup_step_action'
|
||||
| 'add_repo_existing_workspaces_detected'
|
||||
| 'workspace_created'
|
||||
| 'workspace_create_failed'
|
||||
| 'agent_started'
|
||||
|
||||
Reference in New Issue
Block a user