feat: add server restart coordination and health status tracking (#300)

* feat: add server restart coordination and health status tracking

* refactor: consolidate server restart logic, extract hooks, remove dead code
This commit is contained in:
Chris Scott authored and GitHub committed 2026-06-30 18:20:54 -04:00
1 parent 68cd6b5a0b
commit 217f5bd989
19 files changed
+802 -259

No files matched your search

+46
View File
@@ -137,3 +137,49 @@ export function getErrorMessage(error: OpenCodeError | undefined | null): string
const parsed = parseOpenCodeError(error)
return parsed ? `${parsed.title}: ${parsed.message}` : ''
}
/**
* Extracts a human-readable message from a Manager REST API error, handling
* both {@link FetchError} and axios-style `{ response: { data } }` shapes,
* including OpenCode config validation issues and removed fields.
*/
export function getOpenCodeApiErrorMessage(error: unknown, fallback: string): string {
if (error instanceof FetchError) {
let message = error.detail || error.message || fallback
if (error.validationIssues && error.validationIssues.length > 0) {
const issues = error.validationIssues
.map((issue) => `${issue.path}: ${issue.message}`)
.join('; ')
message = `Validation failed: ${issues}`
}
if (error.removedFields && error.removedFields.length > 0) {
message += ` (removed invalid fields: ${error.removedFields.join(', ')})`
}
return message
}
if (error && typeof error === 'object' && 'response' in error) {
const response = (error as { response?: { data?: { details?: string; error?: string; validationIssues?: Array<{ path: string; message: string }>; removedFields?: string[] } } }).response
const data = response?.data
let message = data?.details || data?.error || fallback
if (data?.validationIssues && data.validationIssues.length > 0) {
const issues = data.validationIssues
.map((issue) => `${issue.path}: ${issue.message}`)
.join('; ')
message = `Validation failed: ${issues}`
}
if (data?.removedFields && data.removedFields.length > 0) {
message += ` (removed invalid fields: ${data.removedFields.join(', ')})`
}
return message
}
return fallback
}