Polish workspace board resizing and status defaults (#2113)
* Add workspace board live resize behavior * Add workspace board create controls * Hide empty status sidebar sections * Update default workspace status order
This commit is contained in:
+5
-10
@@ -6,16 +6,18 @@ import type {
|
||||
PersistedState,
|
||||
PersistedUIState,
|
||||
RepoHookSettings,
|
||||
StatusBarItem,
|
||||
WorkspaceSessionState,
|
||||
WorktreeCardProperty
|
||||
} from './types'
|
||||
import { DEFAULT_STATUS_BAR_ITEMS } from './status-bar-defaults'
|
||||
import { DEFAULT_TERMINAL_FONT_WEIGHT } from './terminal-fonts'
|
||||
import { getDefaultTerminalQuickCommands } from './terminal-quick-commands'
|
||||
import type { VoiceSettings } from './speech-types'
|
||||
import { cloneDefaultWorkspaceStatuses } from './workspace-statuses'
|
||||
import { TASK_PROVIDERS } from './task-providers'
|
||||
|
||||
export { DEFAULT_STATUS_BAR_ITEMS } from './status-bar-defaults'
|
||||
|
||||
export const SCHEMA_VERSION = 1
|
||||
export const DEFAULT_APP_FONT_FAMILY = 'Geist'
|
||||
|
||||
@@ -95,15 +97,6 @@ export const DEFAULT_WORKTREE_CARD_PROPERTIES: WorktreeCardProperty[] = [
|
||||
'inline-agents'
|
||||
]
|
||||
|
||||
export const DEFAULT_STATUS_BAR_ITEMS: StatusBarItem[] = [
|
||||
'claude',
|
||||
'codex',
|
||||
'gemini',
|
||||
'opencode-go',
|
||||
'ssh',
|
||||
'resource-usage'
|
||||
]
|
||||
|
||||
/** Synthetic worktree id used by the memory collector to bucket PTYs that
|
||||
* are not associated with any worktree. Shared across main and renderer so
|
||||
* the collector and the status-bar popover agree on the sentinel. */
|
||||
@@ -358,7 +351,9 @@ export function getDefaultUIState(): PersistedUIState {
|
||||
workspaceStatuses: cloneDefaultWorkspaceStatuses(),
|
||||
workspaceBoardOpacity: 1,
|
||||
workspaceBoardCompact: false,
|
||||
workspaceBoardColumnWidth: 308,
|
||||
_workspaceStatusesDefaultOrderMigrated: true,
|
||||
_workspaceStatusesDefaultWorkflowMigrated: true,
|
||||
_workspaceStatusesDefaultVisualsMigrated: true,
|
||||
statusBarItems: [...DEFAULT_STATUS_BAR_ITEMS],
|
||||
statusBarVisible: true,
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import type { StatusBarItem } from './types'
|
||||
|
||||
export const DEFAULT_STATUS_BAR_ITEMS: StatusBarItem[] = [
|
||||
'claude',
|
||||
'codex',
|
||||
'gemini',
|
||||
'opencode-go',
|
||||
'ssh',
|
||||
'resource-usage'
|
||||
]
|
||||
@@ -1023,6 +1023,7 @@ export type CreateWorktreeArgs = {
|
||||
linkedPR?: number
|
||||
linkedLinearIssue?: string
|
||||
pushTarget?: GitPushTarget
|
||||
workspaceStatus?: WorkspaceStatus
|
||||
/** Agent selected in the create surface. Omitted for blank-shell creates. */
|
||||
createdWithAgent?: TuiAgent
|
||||
/** Telemetry-only: which UI surface initiated this create. Threaded from
|
||||
@@ -1702,10 +1703,15 @@ export type PersistedUIState = {
|
||||
workspaceStatuses?: WorkspaceStatusDefinition[]
|
||||
workspaceBoardOpacity?: number
|
||||
workspaceBoardCompact?: boolean
|
||||
workspaceBoardColumnWidth?: number
|
||||
/** One-shot migration flag for a short-lived build that persisted the
|
||||
* default workspace statuses in reverse workflow order. Once stamped,
|
||||
* user-authored status ordering is never inferred from IDs/labels again. */
|
||||
_workspaceStatusesDefaultOrderMigrated?: boolean
|
||||
/** One-shot migration flag for the default status workflow order/label:
|
||||
* Done -> In review -> In progress -> Todo. Exact legacy default payloads
|
||||
* migrate; customized statuses are preserved. */
|
||||
_workspaceStatusesDefaultWorkflowMigrated?: boolean
|
||||
/** One-shot migration flag for the old default blue/violet/emerald status
|
||||
* visuals. Once stamped, valid user-authored colors/icons are preserved. */
|
||||
_workspaceStatusesDefaultVisualsMigrated?: boolean
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
const LEGACY_DEFAULT_STATUS_LABELS: Record<string, string> = {
|
||||
todo: 'Todo',
|
||||
'in-progress': 'In progress',
|
||||
'in-review': 'In review',
|
||||
completed: 'Completed'
|
||||
}
|
||||
|
||||
const CONDUCTOR_DEFAULT_STATUS_VISUALS: Record<string, { color: string; icon: string }> = {
|
||||
todo: { color: 'neutral', icon: 'circle' },
|
||||
'in-progress': { color: 'conductor-progress', icon: 'conductor-progress' },
|
||||
'in-review': { color: 'conductor-review', icon: 'conductor-review' },
|
||||
completed: { color: 'conductor-done', icon: 'conductor-done' }
|
||||
}
|
||||
|
||||
const LEGACY_DEFAULT_STATUS_VISUALS: Record<string, { color: string; icon: string }> = {
|
||||
todo: { color: 'neutral', icon: 'circle' },
|
||||
'in-progress': { color: 'blue', icon: 'circle-dot' },
|
||||
'in-review': { color: 'violet', icon: 'git-pull-request' },
|
||||
completed: { color: 'emerald', icon: 'circle-check' }
|
||||
}
|
||||
|
||||
const LEGACY_TODO_FIRST_DEFAULT_STATUS_IDS = [
|
||||
'todo',
|
||||
'in-progress',
|
||||
'in-review',
|
||||
'completed'
|
||||
] as const
|
||||
const WORKFLOW_DEFAULT_STATUS_IDS = ['completed', 'in-review', 'in-progress', 'todo'] as const
|
||||
|
||||
function isLegacyDefaultStatusPayload(
|
||||
value: unknown,
|
||||
orderedIds: readonly string[],
|
||||
visuals: Record<string, { color: string; icon: string }>
|
||||
): boolean {
|
||||
if (!Array.isArray(value) || value.length !== orderedIds.length) {
|
||||
return false
|
||||
}
|
||||
return value.every((rawStatus, index) => {
|
||||
if (!rawStatus || typeof rawStatus !== 'object' || Array.isArray(rawStatus)) {
|
||||
return false
|
||||
}
|
||||
const raw = rawStatus as Record<string, unknown>
|
||||
const expectedId = orderedIds[index]!
|
||||
const expectedVisual = visuals[expectedId]
|
||||
return (
|
||||
Object.keys(raw).length === 4 &&
|
||||
raw.id === expectedId &&
|
||||
raw.label === LEGACY_DEFAULT_STATUS_LABELS[expectedId] &&
|
||||
raw.color === expectedVisual?.color &&
|
||||
raw.icon === expectedVisual?.icon
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
export function isLegacyDefaultWorkflowStatusPayload(value: unknown): boolean {
|
||||
return (
|
||||
isLegacyDefaultStatusPayload(
|
||||
value,
|
||||
LEGACY_TODO_FIRST_DEFAULT_STATUS_IDS,
|
||||
CONDUCTOR_DEFAULT_STATUS_VISUALS
|
||||
) ||
|
||||
isLegacyDefaultStatusPayload(
|
||||
value,
|
||||
LEGACY_TODO_FIRST_DEFAULT_STATUS_IDS,
|
||||
LEGACY_DEFAULT_STATUS_VISUALS
|
||||
) ||
|
||||
isLegacyDefaultStatusPayload(
|
||||
value,
|
||||
WORKFLOW_DEFAULT_STATUS_IDS,
|
||||
CONDUCTOR_DEFAULT_STATUS_VISUALS
|
||||
) ||
|
||||
isLegacyDefaultStatusPayload(value, WORKFLOW_DEFAULT_STATUS_IDS, LEGACY_DEFAULT_STATUS_VISUALS)
|
||||
)
|
||||
}
|
||||
|
||||
export function isKnownBadPRReorderedDefaultStatusPayload(value: unknown): boolean {
|
||||
return isLegacyDefaultStatusPayload(
|
||||
value,
|
||||
WORKFLOW_DEFAULT_STATUS_IDS,
|
||||
CONDUCTOR_DEFAULT_STATUS_VISUALS
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import type { WorkspaceStatusDefinition } from './types'
|
||||
|
||||
export const DEFAULT_STATUS_VISUALS: Record<string, { color: string; icon: string }> = {
|
||||
todo: { color: 'neutral', icon: 'circle' },
|
||||
'in-progress': { color: 'conductor-progress', icon: 'conductor-progress' },
|
||||
'in-review': { color: 'conductor-review', icon: 'conductor-review' },
|
||||
completed: { color: 'conductor-done', icon: 'conductor-done' }
|
||||
}
|
||||
|
||||
export const DEFAULT_WORKSPACE_STATUSES = [
|
||||
{ id: 'completed', label: 'Done', color: 'conductor-done', icon: 'conductor-done' },
|
||||
{ id: 'in-review', label: 'In review', color: 'conductor-review', icon: 'conductor-review' },
|
||||
{
|
||||
id: 'in-progress',
|
||||
label: 'In progress',
|
||||
color: 'conductor-progress',
|
||||
icon: 'conductor-progress'
|
||||
},
|
||||
{ id: 'todo', label: 'Todo', color: 'neutral', icon: 'circle' }
|
||||
] as const satisfies readonly WorkspaceStatusDefinition[]
|
||||
@@ -1,18 +1,47 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
WORKSPACE_BOARD_COLUMN_WIDTH_DEFAULT,
|
||||
WORKSPACE_BOARD_COLUMN_WIDTH_MAX,
|
||||
WORKSPACE_BOARD_COLUMN_WIDTH_MIN,
|
||||
clampWorkspaceBoardColumnWidth,
|
||||
cloneDefaultWorkspaceStatuses,
|
||||
normalizePersistedWorkspaceStatuses,
|
||||
normalizeWorkspaceStatuses
|
||||
} from './workspace-statuses'
|
||||
|
||||
describe('workspace status visuals', () => {
|
||||
it('keeps todo first by default', () => {
|
||||
it('keeps the default workflow order', () => {
|
||||
expect(cloneDefaultWorkspaceStatuses().map((status) => status.id)).toEqual([
|
||||
'todo',
|
||||
'in-progress',
|
||||
'completed',
|
||||
'in-review',
|
||||
'completed'
|
||||
'in-progress',
|
||||
'todo'
|
||||
])
|
||||
expect(cloneDefaultWorkspaceStatuses()[0]).toMatchObject({ id: 'completed', label: 'Done' })
|
||||
})
|
||||
|
||||
it('migrates legacy default statuses to the default workflow order', () => {
|
||||
const statuses = normalizePersistedWorkspaceStatuses(
|
||||
[
|
||||
{ id: 'todo', label: 'Todo', color: 'neutral', icon: 'circle' },
|
||||
{
|
||||
id: 'in-progress',
|
||||
label: 'In progress',
|
||||
color: 'conductor-progress',
|
||||
icon: 'conductor-progress'
|
||||
},
|
||||
{
|
||||
id: 'in-review',
|
||||
label: 'In review',
|
||||
color: 'conductor-review',
|
||||
icon: 'conductor-review'
|
||||
},
|
||||
{ id: 'completed', label: 'Completed', color: 'conductor-done', icon: 'conductor-done' }
|
||||
],
|
||||
{ migrateDefaultWorkflowStatuses: true }
|
||||
)
|
||||
|
||||
expect(statuses).toEqual(cloneDefaultWorkspaceStatuses())
|
||||
})
|
||||
|
||||
it('migrates the old default status visuals without reordering the board', () => {
|
||||
@@ -32,7 +61,12 @@ describe('workspace status visuals', () => {
|
||||
'in-review',
|
||||
'completed'
|
||||
])
|
||||
expect(statuses).toEqual(cloneDefaultWorkspaceStatuses())
|
||||
expect(statuses.map((status) => status.color)).toEqual([
|
||||
'neutral',
|
||||
'conductor-progress',
|
||||
'conductor-review',
|
||||
'conductor-done'
|
||||
])
|
||||
})
|
||||
|
||||
it('preserves explicit status order while migrating default visuals', () => {
|
||||
@@ -58,7 +92,7 @@ describe('workspace status visuals', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('preserves default-label reordered statuses unless the one-shot repair is requested', () => {
|
||||
it('preserves default-label reordered statuses unless a default migration is requested', () => {
|
||||
const statuses = normalizePersistedWorkspaceStatuses([
|
||||
{ id: 'completed', label: 'Completed', color: 'conductor-done', icon: 'conductor-done' },
|
||||
{ id: 'in-review', label: 'In review', color: 'conductor-review', icon: 'conductor-review' },
|
||||
@@ -79,6 +113,30 @@ describe('workspace status visuals', () => {
|
||||
])
|
||||
})
|
||||
|
||||
it('migrates exact reordered default statuses to the new Done label when requested', () => {
|
||||
const statuses = normalizePersistedWorkspaceStatuses(
|
||||
[
|
||||
{ id: 'completed', label: 'Completed', color: 'conductor-done', icon: 'conductor-done' },
|
||||
{
|
||||
id: 'in-review',
|
||||
label: 'In review',
|
||||
color: 'conductor-review',
|
||||
icon: 'conductor-review'
|
||||
},
|
||||
{
|
||||
id: 'in-progress',
|
||||
label: 'In progress',
|
||||
color: 'conductor-progress',
|
||||
icon: 'conductor-progress'
|
||||
},
|
||||
{ id: 'todo', label: 'Todo', color: 'neutral', icon: 'circle' }
|
||||
],
|
||||
{ migrateDefaultWorkflowStatuses: true }
|
||||
)
|
||||
|
||||
expect(statuses).toEqual(cloneDefaultWorkspaceStatuses())
|
||||
})
|
||||
|
||||
it('repairs the exact PR-introduced default status reorder when migration-gated', () => {
|
||||
const statuses = normalizePersistedWorkspaceStatuses(
|
||||
[
|
||||
@@ -184,4 +242,11 @@ describe('workspace status visuals', () => {
|
||||
icon: 'circle-dot'
|
||||
})
|
||||
})
|
||||
|
||||
it('clamps workspace board column widths to resizable bounds', () => {
|
||||
expect(clampWorkspaceBoardColumnWidth(undefined)).toBe(WORKSPACE_BOARD_COLUMN_WIDTH_DEFAULT)
|
||||
expect(clampWorkspaceBoardColumnWidth(100)).toBe(WORKSPACE_BOARD_COLUMN_WIDTH_MIN)
|
||||
expect(clampWorkspaceBoardColumnWidth(321.6)).toBe(322)
|
||||
expect(clampWorkspaceBoardColumnWidth(900)).toBe(WORKSPACE_BOARD_COLUMN_WIDTH_MAX)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,15 +1,27 @@
|
||||
import type { Worktree, WorkspaceStatus, WorkspaceStatusDefinition } from './types'
|
||||
import { DEFAULT_STATUS_VISUALS, DEFAULT_WORKSPACE_STATUSES } from './workspace-status-defaults'
|
||||
import {
|
||||
isKnownBadPRReorderedDefaultStatusPayload,
|
||||
isLegacyDefaultWorkflowStatusPayload
|
||||
} from './workspace-status-default-migration'
|
||||
|
||||
export { DEFAULT_WORKSPACE_STATUSES } from './workspace-status-defaults'
|
||||
|
||||
const WORKSPACE_STATUS_GROUP_PREFIX = 'workspace-status:'
|
||||
const MAX_STATUS_LABEL_LENGTH = 32
|
||||
const MAX_WORKSPACE_STATUSES = 12
|
||||
type WorkspaceStatusNormalizationOptions = {
|
||||
migrateDefaultWorkflowStatuses?: boolean
|
||||
migrateLegacyDefaultStatusVisuals?: boolean
|
||||
}
|
||||
|
||||
export const DEFAULT_WORKSPACE_STATUS_ID: WorkspaceStatus = 'in-progress'
|
||||
export const DEFAULT_WORKSPACE_STATUS_COLOR_ID = 'neutral'
|
||||
export const DEFAULT_WORKSPACE_STATUS_ICON_ID = 'circle-dot'
|
||||
export const WORKSPACE_BOARD_COLUMN_WIDTH_DEFAULT = 308
|
||||
export const WORKSPACE_BOARD_COLUMN_WIDTH_MIN = 220
|
||||
export const WORKSPACE_BOARD_COLUMN_WIDTH_MAX = 520
|
||||
export const WORKSPACE_BOARD_COLUMN_WIDTH_STEP = 20
|
||||
|
||||
export const WORKSPACE_STATUS_COLOR_IDS = [
|
||||
'neutral',
|
||||
@@ -44,25 +56,6 @@ export const WORKSPACE_STATUS_ICON_IDS = [
|
||||
'conductor-progress'
|
||||
] as const
|
||||
|
||||
const DEFAULT_STATUS_VISUALS: Record<string, { color: string; icon: string }> = {
|
||||
todo: { color: 'neutral', icon: 'circle' },
|
||||
'in-progress': { color: 'conductor-progress', icon: 'conductor-progress' },
|
||||
'in-review': { color: 'conductor-review', icon: 'conductor-review' },
|
||||
completed: { color: 'conductor-done', icon: 'conductor-done' }
|
||||
}
|
||||
|
||||
export const DEFAULT_WORKSPACE_STATUSES = [
|
||||
{ id: 'todo', label: 'Todo', color: 'neutral', icon: 'circle' },
|
||||
{
|
||||
id: 'in-progress',
|
||||
label: 'In progress',
|
||||
color: 'conductor-progress',
|
||||
icon: 'conductor-progress'
|
||||
},
|
||||
{ id: 'in-review', label: 'In review', color: 'conductor-review', icon: 'conductor-review' },
|
||||
{ id: 'completed', label: 'Completed', color: 'conductor-done', icon: 'conductor-done' }
|
||||
] as const satisfies readonly WorkspaceStatusDefinition[]
|
||||
|
||||
export function cloneDefaultWorkspaceStatuses(): WorkspaceStatusDefinition[] {
|
||||
return DEFAULT_WORKSPACE_STATUSES.map((status) => ({ ...status }))
|
||||
}
|
||||
@@ -106,7 +99,9 @@ function sanitizeWorkspaceStatusColor(
|
||||
options.migrateLegacyDefaultStatusVisuals === true &&
|
||||
((statusId === 'in-progress' && label === 'In progress' && value === 'blue') ||
|
||||
(statusId === 'in-review' && label === 'In review' && value === 'violet') ||
|
||||
(statusId === 'completed' && label === 'Completed' && value === 'emerald')) &&
|
||||
(statusId === 'completed' &&
|
||||
(label === 'Completed' || label === 'Done') &&
|
||||
value === 'emerald')) &&
|
||||
DEFAULT_STATUS_VISUALS[statusId]
|
||||
) {
|
||||
return DEFAULT_STATUS_VISUALS[statusId]?.color ?? DEFAULT_WORKSPACE_STATUS_COLOR_ID
|
||||
@@ -133,7 +128,9 @@ function sanitizeWorkspaceStatusIcon(
|
||||
label === 'In progress' &&
|
||||
(value === 'circle-dot' || value === 'circle-progress')) ||
|
||||
(statusId === 'in-review' && label === 'In review' && value === 'git-pull-request') ||
|
||||
(statusId === 'completed' && label === 'Completed' && value === 'circle-check')) &&
|
||||
(statusId === 'completed' &&
|
||||
(label === 'Completed' || label === 'Done') &&
|
||||
value === 'circle-check')) &&
|
||||
DEFAULT_STATUS_VISUALS[statusId]
|
||||
) {
|
||||
return DEFAULT_STATUS_VISUALS[statusId]?.icon ?? DEFAULT_WORKSPACE_STATUS_ICON_ID
|
||||
@@ -203,43 +200,20 @@ export function normalizeWorkspaceStatuses(value: unknown): WorkspaceStatusDefin
|
||||
return normalizeWorkspaceStatusesInternal(value, {})
|
||||
}
|
||||
|
||||
const PR_REORDERED_DEFAULT_STATUS_IDS = ['completed', 'in-review', 'in-progress', 'todo'] as const
|
||||
|
||||
const PR_REORDERED_DEFAULT_STATUSES = PR_REORDERED_DEFAULT_STATUS_IDS.map((id) => {
|
||||
const status = DEFAULT_WORKSPACE_STATUSES.find((entry) => entry.id === id)
|
||||
if (!status) {
|
||||
throw new Error(`Missing default workspace status: ${id}`)
|
||||
}
|
||||
return { ...status }
|
||||
})
|
||||
|
||||
function isKnownBadPRReorderedDefaultStatusPayload(value: unknown): boolean {
|
||||
if (!Array.isArray(value) || value.length !== PR_REORDERED_DEFAULT_STATUSES.length) {
|
||||
return false
|
||||
}
|
||||
return value.every((rawStatus, index) => {
|
||||
if (!rawStatus || typeof rawStatus !== 'object' || Array.isArray(rawStatus)) {
|
||||
return false
|
||||
}
|
||||
const raw = rawStatus as Record<string, unknown>
|
||||
const expected = PR_REORDERED_DEFAULT_STATUSES[index]
|
||||
return (
|
||||
Object.keys(raw).length === 4 &&
|
||||
raw.id === expected.id &&
|
||||
raw.label === expected.label &&
|
||||
raw.color === expected.color &&
|
||||
raw.icon === expected.icon
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
export function normalizePersistedWorkspaceStatuses(
|
||||
value: unknown,
|
||||
options: {
|
||||
migrateDefaultWorkflowStatuses?: boolean
|
||||
repairReorderedDefaultStatuses?: boolean
|
||||
migrateLegacyDefaultStatusVisuals?: boolean
|
||||
} = {}
|
||||
): WorkspaceStatusDefinition[] {
|
||||
if (
|
||||
options.migrateDefaultWorkflowStatuses === true &&
|
||||
isLegacyDefaultWorkflowStatusPayload(value)
|
||||
) {
|
||||
return cloneDefaultWorkspaceStatuses()
|
||||
}
|
||||
// Why: this PR briefly wrote the default columns in reverse workflow order.
|
||||
// The repair is one-shot and checks the raw payload, because normalized
|
||||
// IDs/labels are indistinguishable from a user-authored column reorder.
|
||||
@@ -265,6 +239,16 @@ export function normalizeWorkspaceBoardCompact(value: unknown): boolean {
|
||||
return value === true
|
||||
}
|
||||
|
||||
export function clampWorkspaceBoardColumnWidth(value: unknown): number {
|
||||
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
||||
return WORKSPACE_BOARD_COLUMN_WIDTH_DEFAULT
|
||||
}
|
||||
return Math.min(
|
||||
WORKSPACE_BOARD_COLUMN_WIDTH_MAX,
|
||||
Math.max(WORKSPACE_BOARD_COLUMN_WIDTH_MIN, Math.round(value))
|
||||
)
|
||||
}
|
||||
|
||||
export function isWorkspaceStatusId(
|
||||
value: string,
|
||||
statuses: readonly WorkspaceStatusDefinition[]
|
||||
|
||||
Reference in New Issue
Block a user