@@ -123,8 +123,23 @@ function ReplayForm({
123123} ) {
124124 const navigation = useNavigation ( ) ;
125125 const submit = useSubmit ( ) ;
126+
127+ const [ defaultPayloadJson , setDefaultPayloadJson ] = useState < string > (
128+ replayData . payload ?? startingJson
129+ ) ;
130+ const setPayload = useCallback ( ( code : string ) => {
131+ setDefaultPayloadJson ( code ) ;
132+ } , [ ] ) ;
126133 const currentPayloadJson = useRef < string > ( replayData . payload ?? startingJson ) ;
134+
135+ const [ defaultMetadataJson , setDefaultMetadataJson ] = useState < string > (
136+ replayData . metadata ?? startingJson
137+ ) ;
138+ const setMetadata = useCallback ( ( code : string ) => {
139+ setDefaultMetadataJson ( code ) ;
140+ } , [ ] ) ;
127141 const currentMetadataJson = useRef < string > ( replayData . metadata ?? startingJson ) ;
142+
128143 const formAction = `/resources/taskruns/${ runFriendlyId } /replay` ;
129144
130145 const isSubmitting = navigation . formAction === formAction ;
@@ -227,11 +242,17 @@ function ReplayForm({
227242 < div className = "rounded-smbg-charcoal-900 mb-3 h-full min-h-40 overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-charcoal-600" >
228243 < JSONEditor
229244 autoFocus
230- defaultValue = { currentPayloadJson . current }
245+ defaultValue = { ! tab || tab === "payload" ? defaultPayloadJson : defaultMetadataJson }
231246 readOnly = { false }
232247 basicSetup
233248 onChange = { ( v ) => {
234- currentPayloadJson . current = v ;
249+ if ( ! tab || tab === "payload" ) {
250+ currentPayloadJson . current = v ;
251+ setDefaultPayloadJson ( v ) ;
252+ } else {
253+ currentMetadataJson . current = v ;
254+ setDefaultMetadataJson ( v ) ;
255+ }
235256 } }
236257 height = "100%"
237258 min-height = "100%"
0 commit comments