@@ -180,17 +180,19 @@ function renderSideBySideJson(comparison, localJson, remoteJson ) {
180180 <div class="json-compare">
181181
182182 <div>
183- <b>Local</b>
184-
185- ${ comparison . localError ? `<div class="json-error">${ comparison . localError } </div>` : '' }
183+ <div class="compare-pane-title">
184+ <b>Local</b>
185+ ${ renderPayloadBadge ( localJson ) }
186+ </div>
186187
187188 ${ renderAlignedJson ( comparison . local , localJson ) }
188189 </div>
189190
190191 <div>
191- <b>Remote</b>
192-
193- ${ comparison . remoteError ? `<div class="json-error">${ comparison . remoteError } </div>` : '' }
192+ <div class="compare-pane-title">
193+ <b>Remote</b>
194+ ${ renderPayloadBadge ( remoteJson ) }
195+ </div>
194196
195197 ${ renderAlignedJson ( comparison . remote , remoteJson ) }
196198 </div>
@@ -199,6 +201,49 @@ function renderSideBySideJson(comparison, localJson, remoteJson ) {
199201 ` ;
200202}
201203
204+ function renderPayloadBadge ( value ) {
205+
206+ const payloadType = getPayloadType ( value ) ;
207+
208+ return `<span class="code-badge ${ payloadType . className } ">${ payloadType . label } </span>` ;
209+ }
210+
211+ function getPayloadType ( value ) {
212+
213+ if ( ! value || ! value . trim ( ) ) {
214+ return {
215+ label : 'Empty' ,
216+ className : 'payload-empty'
217+ } ;
218+ }
219+
220+ try {
221+ JSON . parse ( value ) ;
222+
223+ return {
224+ label : 'JSON' ,
225+ className : 'payload-json'
226+ } ;
227+ } catch {
228+ return looksLikeJson ( value )
229+ ? {
230+ label : 'Invalid JSON' ,
231+ className : 'payload-invalid-json'
232+ }
233+ : {
234+ label : 'Plain Text' ,
235+ className : 'payload-text'
236+ } ;
237+ }
238+ }
239+
240+ function looksLikeJson ( value ) {
241+
242+ const trimmed = value . trimStart ( ) ;
243+
244+ return trimmed . startsWith ( '{' ) || trimmed . startsWith ( '[' ) ;
245+ }
246+
202247function renderAccordionSection ( title , content , expanded = false , changes = 0 ) {
203248 return `
204249 <div class="accordion-section">
@@ -211,7 +256,7 @@ function renderAccordionSection(title, content, expanded = false, changes = 0) {
211256
212257 <div class="accordion-meta">
213258
214- ${ changes > 0 ? `<span class="diff-badge">${ changes } </span>` : '' }
259+ ${ changes > 0 ? `<span class="code-badge diff-badge">${ changes } </span>` : '' }
215260
216261 <span class="accordion-toggle">
217262 ${ expanded ? '-' : '+' }
@@ -288,4 +333,4 @@ function escapeHtml(value) {
288333 . replace ( / > / g, '>' )
289334 . replace ( / " / g, '"' )
290335 . replace ( / ' / g, ''' ) ;
291- }
336+ }
0 commit comments