Spaces:
Running
Running
Commit
·
3f44783
1
Parent(s):
69abcd1
Fix reasoning trace preservation in deep links
Browse files- Prevent double-loading samples when URL index parameter is present
- Add reasoning panel expansion state to URL parameters
- Properly restore reasoning state from deep links
- Ensure reasoning traces are parsed correctly on initial load
Fixes issue where reasoning traces were lost when following deep links
to examples with model thinking output.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
js/app.js
CHANGED
|
@@ -84,6 +84,7 @@ document.addEventListener('alpine:init', () => {
|
|
| 84 |
const urlView = urlParams.get('view');
|
| 85 |
const urlDiff = urlParams.get('diff');
|
| 86 |
const urlMarkdown = urlParams.get('markdown');
|
|
|
|
| 87 |
|
| 88 |
// Apply URL parameters if present
|
| 89 |
if (urlDataset) {
|
|
@@ -102,6 +103,10 @@ document.addEventListener('alpine:init', () => {
|
|
| 102 |
this.renderMarkdown = urlMarkdown === 'true';
|
| 103 |
}
|
| 104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
// Apply dark mode from localStorage
|
| 106 |
this.darkMode = localStorage.getItem('darkMode') === 'true';
|
| 107 |
this.$watch('darkMode', value => {
|
|
@@ -116,14 +121,20 @@ document.addEventListener('alpine:init', () => {
|
|
| 116 |
// Setup watchers for URL updates
|
| 117 |
this.initWatchers();
|
| 118 |
|
| 119 |
-
//
|
| 120 |
-
|
|
|
|
|
|
|
|
|
|
| 121 |
|
| 122 |
// Jump to specific index if provided in URL
|
| 123 |
-
if (
|
| 124 |
const index = parseInt(urlIndex);
|
| 125 |
if (!isNaN(index) && index >= 0 && index < this.totalSamples) {
|
| 126 |
await this.loadSample(index);
|
|
|
|
|
|
|
|
|
|
| 127 |
}
|
| 128 |
}
|
| 129 |
},
|
|
@@ -182,7 +193,7 @@ document.addEventListener('alpine:init', () => {
|
|
| 182 |
});
|
| 183 |
},
|
| 184 |
|
| 185 |
-
async loadDataset() {
|
| 186 |
this.loading = true;
|
| 187 |
this.error = null;
|
| 188 |
|
|
@@ -205,9 +216,11 @@ document.addEventListener('alpine:init', () => {
|
|
| 205 |
this.datasetSplit
|
| 206 |
);
|
| 207 |
|
| 208 |
-
// Load first sample
|
| 209 |
-
|
| 210 |
-
|
|
|
|
|
|
|
| 211 |
|
| 212 |
} catch (error) {
|
| 213 |
this.error = error.message;
|
|
@@ -853,6 +866,10 @@ document.addEventListener('alpine:init', () => {
|
|
| 853 |
url.searchParams.set('view', this.activeTab);
|
| 854 |
url.searchParams.set('diff', this.diffMode);
|
| 855 |
url.searchParams.set('markdown', this.renderMarkdown);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 856 |
window.history.replaceState({}, '', url);
|
| 857 |
},
|
| 858 |
|
|
@@ -864,6 +881,10 @@ document.addEventListener('alpine:init', () => {
|
|
| 864 |
url.searchParams.set('view', this.activeTab);
|
| 865 |
url.searchParams.set('diff', this.diffMode);
|
| 866 |
url.searchParams.set('markdown', this.renderMarkdown);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 867 |
|
| 868 |
const shareUrl = url.toString();
|
| 869 |
|
|
@@ -912,6 +933,7 @@ document.addEventListener('alpine:init', () => {
|
|
| 912 |
this.$watch('currentSample', () => this.updateDiff());
|
| 913 |
this.$watch('activeTab', () => this.updateURL());
|
| 914 |
this.$watch('renderMarkdown', () => this.updateURL());
|
|
|
|
| 915 |
}
|
| 916 |
}));
|
| 917 |
});
|
|
|
|
| 84 |
const urlView = urlParams.get('view');
|
| 85 |
const urlDiff = urlParams.get('diff');
|
| 86 |
const urlMarkdown = urlParams.get('markdown');
|
| 87 |
+
const urlReasoning = urlParams.get('reasoning');
|
| 88 |
|
| 89 |
// Apply URL parameters if present
|
| 90 |
if (urlDataset) {
|
|
|
|
| 103 |
this.renderMarkdown = urlMarkdown === 'true';
|
| 104 |
}
|
| 105 |
|
| 106 |
+
if (urlReasoning !== null) {
|
| 107 |
+
this.showReasoning = urlReasoning === 'true';
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
// Apply dark mode from localStorage
|
| 111 |
this.darkMode = localStorage.getItem('darkMode') === 'true';
|
| 112 |
this.$watch('darkMode', value => {
|
|
|
|
| 121 |
// Setup watchers for URL updates
|
| 122 |
this.initWatchers();
|
| 123 |
|
| 124 |
+
// Check if we have a specific index to load
|
| 125 |
+
const hasUrlIndex = urlIndex !== null;
|
| 126 |
+
|
| 127 |
+
// Load initial dataset (skip initial load if we have a URL index)
|
| 128 |
+
await this.loadDataset(hasUrlIndex);
|
| 129 |
|
| 130 |
// Jump to specific index if provided in URL
|
| 131 |
+
if (hasUrlIndex) {
|
| 132 |
const index = parseInt(urlIndex);
|
| 133 |
if (!isNaN(index) && index >= 0 && index < this.totalSamples) {
|
| 134 |
await this.loadSample(index);
|
| 135 |
+
} else {
|
| 136 |
+
// If invalid index, load the first sample
|
| 137 |
+
await this.loadSample(0);
|
| 138 |
}
|
| 139 |
}
|
| 140 |
},
|
|
|
|
| 193 |
});
|
| 194 |
},
|
| 195 |
|
| 196 |
+
async loadDataset(skipInitialLoad = false) {
|
| 197 |
this.loading = true;
|
| 198 |
this.error = null;
|
| 199 |
|
|
|
|
| 216 |
this.datasetSplit
|
| 217 |
);
|
| 218 |
|
| 219 |
+
// Load first sample only if not skipping
|
| 220 |
+
if (!skipInitialLoad) {
|
| 221 |
+
this.currentIndex = 0;
|
| 222 |
+
await this.loadSample(0);
|
| 223 |
+
}
|
| 224 |
|
| 225 |
} catch (error) {
|
| 226 |
this.error = error.message;
|
|
|
|
| 866 |
url.searchParams.set('view', this.activeTab);
|
| 867 |
url.searchParams.set('diff', this.diffMode);
|
| 868 |
url.searchParams.set('markdown', this.renderMarkdown);
|
| 869 |
+
// Only add reasoning parameter if there's a reasoning trace
|
| 870 |
+
if (this.hasReasoningTrace) {
|
| 871 |
+
url.searchParams.set('reasoning', this.showReasoning);
|
| 872 |
+
}
|
| 873 |
window.history.replaceState({}, '', url);
|
| 874 |
},
|
| 875 |
|
|
|
|
| 881 |
url.searchParams.set('view', this.activeTab);
|
| 882 |
url.searchParams.set('diff', this.diffMode);
|
| 883 |
url.searchParams.set('markdown', this.renderMarkdown);
|
| 884 |
+
// Only add reasoning parameter if there's a reasoning trace
|
| 885 |
+
if (this.hasReasoningTrace) {
|
| 886 |
+
url.searchParams.set('reasoning', this.showReasoning);
|
| 887 |
+
}
|
| 888 |
|
| 889 |
const shareUrl = url.toString();
|
| 890 |
|
|
|
|
| 933 |
this.$watch('currentSample', () => this.updateDiff());
|
| 934 |
this.$watch('activeTab', () => this.updateURL());
|
| 935 |
this.$watch('renderMarkdown', () => this.updateURL());
|
| 936 |
+
this.$watch('showReasoning', () => this.updateURL());
|
| 937 |
}
|
| 938 |
}));
|
| 939 |
});
|