fix(12.2): close code-review blockers on uploads, JSON caps, and pivot fill
Keep form save behind in-flight uploads, make retries idempotent via X-Upload-Id, cap remaining JSON bodies, and surface pending pivot type errors instead of zeroing them. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
// writes action results back through patch, which marks the form dirty and
|
||||
// clears that field's errors exactly like typing into it. A form without a
|
||||
// provider (settings pages) gets the defaults of the injecting control.
|
||||
import type { InjectionKey, Ref } from 'vue'
|
||||
import { ref, type InjectionKey, type Ref } from 'vue'
|
||||
import type { FileRoutes } from '../../api/files'
|
||||
import type { AdminRecord } from '../../api/types'
|
||||
|
||||
@@ -46,6 +46,35 @@ export interface FormSession {
|
||||
pendingChanges: Readonly<Ref<number>>
|
||||
/** Goes up after every successful save, so fields can reload their files. */
|
||||
revision: Readonly<Ref<number>>
|
||||
/**
|
||||
* Registers an in-flight upload. Call the returned function in `finally`
|
||||
* when the request reaches a terminal state. The form will not submit
|
||||
* while any upload is still open.
|
||||
*/
|
||||
beginUpload(): () => void
|
||||
/** How many uploads have not yet reached a terminal state. */
|
||||
activeUploads: Readonly<Ref<number>>
|
||||
}
|
||||
|
||||
/** Counter and register/release pair used by record and child forms. */
|
||||
export function createUploadGate(): { activeUploads: Ref<number>; beginUpload: () => () => void } {
|
||||
const activeUploads = ref(0)
|
||||
return {
|
||||
activeUploads,
|
||||
beginUpload() {
|
||||
activeUploads.value++
|
||||
let released = false
|
||||
return () => {
|
||||
if (released) {
|
||||
return
|
||||
}
|
||||
released = true
|
||||
if (activeUploads.value > 0) {
|
||||
activeUploads.value--
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export const FORM_SESSION: InjectionKey<FormSession> = Symbol('summer.form.session')
|
||||
|
||||
Reference in New Issue
Block a user