mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
feat(frontend): mobile-friendly config editor with find bar and unsaved-changes guard (#326)
* feat(frontend): mobile-friendly config editor with find bar and unsaved-changes guard * refactor: remove retry-clone flow and share destructive-confirm dialog Backend drops POST /:id/retry-clone and the supporting retryCloneRepo service and claimRepoForRetry query; failed clones now delete the repo row rather than lingering in error state. Frontend extracts ConfirmDestructiveDialog shared by Delete/Discard/UnsavedChanges dialogs, memoizes CodeEditor rows, fixes scroll jump while typing away from the active match, and aligns the responsive breakpoint to 768px.
This commit is contained in:
1 parent
f8e361c0b8
commit
a73ac19bbc
29 files changed
+2032
-356
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { parse as parseJsoncLib, type ParseError } from 'jsonc-parser'
|
||||
import { parse as parseJsoncLib, parseTree, findNodeAtLocation, type ParseError, type JSONPath } from 'jsonc-parser'
|
||||
|
||||
export function parseJsonc<T = unknown>(content: string): T {
|
||||
const errors: ParseError[] = []
|
||||
@@ -40,6 +40,26 @@ function getErrorMessageByCode(error: number): string {
|
||||
8: 'Unexpected end of input',
|
||||
9: 'Invalid comment',
|
||||
}
|
||||
|
||||
|
||||
return errorMessages[error] || 'Invalid JSONC'
|
||||
}
|
||||
|
||||
export function parseJsoncErrorLine(error: unknown): number | null {
|
||||
if (!(error instanceof SyntaxError)) return null
|
||||
const match = error.message.match(/at line (\d+)/)
|
||||
return match ? Number(match[1]) : null
|
||||
}
|
||||
|
||||
export function findJsoncLineForPath(content: string, path: JSONPath): number | null {
|
||||
if (path.length === 0) return null
|
||||
const root = parseTree(content, [], { allowTrailingComma: true, disallowComments: false })
|
||||
if (!root) return null
|
||||
const node = findNodeAtLocation(root, path)
|
||||
if (!node) return null
|
||||
return content.substring(0, node.offset).split('\n').length
|
||||
}
|
||||
|
||||
export function parseJsoncPathSegments(path: string): JSONPath {
|
||||
if (!path || path === 'root') return []
|
||||
return path.split('.').map((segment) => (/^\d+$/.test(segment) ? Number(segment) : segment))
|
||||
}
|
||||
Reference in new issue
Block a user