mirror of
https://github.com/stablyai/orca.git
synced 2026-09-24 00:02:24 +00:00
* Link Jira issues from workspace create dialog Add Jira issue linking to workspace creation, matching existing GitHub and Linear workflows. Users can paste Jira issue URLs in the smart name field to auto-populate workspace names and link the issue to the created workspace/worktree. Linked Jira issues appear on workspace cards via the new 'jira-issue' card property. Implements cancellable searches and summary reads to prevent stalled requests from blocking the shared Jira pool. Persists paired issue + source context metadata with validation of provider/site identity. Fixes git-username rate-limit handling to reject malformed JSON responses so garbage never becomes branch prefixes. * feat(jira): link issues during workspace creation - Display linked Jira issues on worktree cards - Fetch issue summaries and timestamps via Jira API - Gate Jira linking behind runtime capability check - Preserve user-typed names during async lookups * Enforce git check-ref-format rules in login validation Extend isBranchSafeHostedLogin to reject usernames that git rejects as invalid branch components: trailing dots, consecutive dots, and .lock suffix. Prevents invalid branch names from login usernames. * Enforce filesystem filename cap for branch-safe logins Loose refs store logins as single filenames, so the real constraint is the 255-byte filesystem cap, not git check-ref-format rules. This allows longer provider-agnostic logins while staying platform-safe.
116 lines
4.1 KiB
TypeScript
116 lines
4.1 KiB
TypeScript
import type { FolderWorkspace, FolderWorkspaceLinkedTask, ProjectGroup } from './types'
|
|
import { isTuiAgent } from './tui-agent-config'
|
|
import { normalizeStoredTaskSourceContext } from './task-source-context'
|
|
import { normalizeWorkspaceLinkedItem } from './workspace-linked-item'
|
|
import { isWorkspaceLinkedItemSourceContextMatch } from './workspace-linked-item-source-context'
|
|
|
|
export function normalizeFolderWorkspaceName(
|
|
name: string | null | undefined,
|
|
fallback = 'Untitled workspace'
|
|
): string {
|
|
const trimmed = typeof name === 'string' ? name.trim() : ''
|
|
return trimmed.length > 0 ? trimmed : fallback
|
|
}
|
|
|
|
export function normalizeFolderWorkspaceLinkedTask(
|
|
value: unknown
|
|
): FolderWorkspaceLinkedTask | null {
|
|
return normalizeWorkspaceLinkedItem(value)
|
|
}
|
|
|
|
export function normalizeFolderWorkspaces(
|
|
value: unknown,
|
|
projectGroups: readonly ProjectGroup[]
|
|
): FolderWorkspace[] {
|
|
if (!Array.isArray(value)) {
|
|
return []
|
|
}
|
|
const folderGroups = new Map<string, ProjectGroup>()
|
|
for (const group of projectGroups) {
|
|
if (group.parentPath) {
|
|
folderGroups.set(group.id, group)
|
|
}
|
|
}
|
|
|
|
const workspaces: FolderWorkspace[] = []
|
|
const seen = new Set<string>()
|
|
for (const candidate of value) {
|
|
if (!candidate || typeof candidate !== 'object') {
|
|
continue
|
|
}
|
|
const raw = candidate as Partial<FolderWorkspace>
|
|
if (
|
|
typeof raw.id !== 'string' ||
|
|
raw.id.trim().length === 0 ||
|
|
seen.has(raw.id) ||
|
|
typeof raw.projectGroupId !== 'string' ||
|
|
!folderGroups.has(raw.projectGroupId)
|
|
) {
|
|
continue
|
|
}
|
|
const group = folderGroups.get(raw.projectGroupId)
|
|
const folderPath =
|
|
typeof raw.folderPath === 'string' && raw.folderPath.trim().length > 0
|
|
? raw.folderPath
|
|
: group?.parentPath
|
|
if (!folderPath) {
|
|
continue
|
|
}
|
|
const now = Date.now()
|
|
const linkedTask = normalizeWorkspaceLinkedItem(raw.linkedTask)
|
|
const linkedTaskSourceContext = normalizeStoredTaskSourceContext(raw.linkedTaskSourceContext)
|
|
seen.add(raw.id)
|
|
workspaces.push({
|
|
id: raw.id,
|
|
projectGroupId: raw.projectGroupId,
|
|
name: normalizeFolderWorkspaceName(raw.name),
|
|
folderPath,
|
|
connectionId:
|
|
typeof raw.connectionId === 'string'
|
|
? raw.connectionId
|
|
: raw.connectionId === null
|
|
? null
|
|
: (group?.connectionId ?? null),
|
|
linkedTask,
|
|
linkedTaskSourceContext: isWorkspaceLinkedItemSourceContextMatch(
|
|
linkedTask,
|
|
linkedTaskSourceContext
|
|
)
|
|
? linkedTaskSourceContext
|
|
: null,
|
|
comment: typeof raw.comment === 'string' ? raw.comment : '',
|
|
isArchived: raw.isArchived === true,
|
|
isUnread: raw.isUnread === true,
|
|
isPinned: raw.isPinned === true,
|
|
sortOrder:
|
|
typeof raw.sortOrder === 'number' && Number.isFinite(raw.sortOrder) ? raw.sortOrder : now,
|
|
...(typeof raw.manualOrder === 'number' && Number.isFinite(raw.manualOrder)
|
|
? { manualOrder: raw.manualOrder }
|
|
: {}),
|
|
...(typeof raw.workspaceStatus === 'string' && raw.workspaceStatus.trim().length > 0
|
|
? { workspaceStatus: raw.workspaceStatus }
|
|
: {}),
|
|
...(isTuiAgent(raw.createdWithAgent) ? { createdWithAgent: raw.createdWithAgent } : {}),
|
|
...(raw.pendingFirstAgentMessageRename === true
|
|
? { pendingFirstAgentMessageRename: true }
|
|
: {}),
|
|
...(typeof raw.firstAgentMessageRenameError === 'string'
|
|
? { firstAgentMessageRenameError: raw.firstAgentMessageRenameError }
|
|
: raw.firstAgentMessageRenameError === null
|
|
? { firstAgentMessageRenameError: null }
|
|
: {}),
|
|
lastActivityAt:
|
|
typeof raw.lastActivityAt === 'number' && Number.isFinite(raw.lastActivityAt)
|
|
? raw.lastActivityAt
|
|
: 0,
|
|
createdAt:
|
|
typeof raw.createdAt === 'number' && Number.isFinite(raw.createdAt) ? raw.createdAt : now,
|
|
updatedAt:
|
|
typeof raw.updatedAt === 'number' && Number.isFinite(raw.updatedAt) ? raw.updatedAt : now
|
|
})
|
|
}
|
|
return workspaces.sort(
|
|
(left, right) => right.sortOrder - left.sortOrder || left.name.localeCompare(right.name)
|
|
)
|
|
}
|