Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/vscode-extension/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#### Fixed

- **Panels in the XR scene no longer show the content behind them.** Opening an element's info card in front of a virtual screen or the guide mixed the text of both: the card skipped the depth test, and the scene draws see-through surfaces in page order rather than by distance, so screens farther away were painted over it. Info cards, the dependency-graph path chip, virtual screens, the guide, the controller panel, the "Virtual screens" list, the comparison card and the evolution overlay now have opaque, depth-tested backings. Clicking an info card no longer passes through it to whatever is behind (it could start a screen share), and a virtual screen's idle message now wraps inside the screen instead of spilling past its edges.
- **XR scenes keep updating after the connection to VS Code drops.** After any network error the scene reconnected with a connection that listened to nothing, so it silently stopped following re-analyses until the page was reloaded. It now reconnects with every handler in place, leaves the browser's own retry alone and backs off up to 30 s when the server is gone. A refresh also no longer breaks the chart's row-limited data source (it was pointed at the page itself), keeps the other parameters of a data URL such as a comparison's revision, and repairs a data URL that had been corrupted to `url: url: ./data.json` at startup. The DOM visualization no longer reloads the page every 3 s while the server is unreachable; it reloads once, when the connection is back.
- **Historical comparison and project evolution no longer refuse a folder opened through a link.** When the analyzed folder was reached through a symbolic link, a junction, or a shortened Windows path (`C:\Users\JOHNDO~1\...`), Code-XR compared it with the repository path Git reports and wrongly concluded the folder was outside the repository, so the Git-based analyses were unavailable. Both paths are now resolved to their real location before they are compared.
- **The installed extension only ever runs the Python analysis scripts it ships with.** If its bundled copy of an analysis script was missing (a damaged or partially deleted install), Code-XR fell back to a developer location two folders above the extension, which in an installed copy is your home folder, and could have run a file found there. That fallback is now limited to development builds; an installed extension reports the missing script instead.
- **The analysis backend loads again on Python 3.8 and 3.9.** One type annotation in the line-metrics module used syntax that only exists from Python 3.10, so on 3.8 or 3.9 every analysis failed as soon as the backend loaded, although the extension asks only for Python 3.7 or newer. The annotation now uses the older spelling; results on newer Python versions are unchanged.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,26 @@
return Array.from(new Set(dataEntities));
}

// Reads the url of a babia-queryjson value in either form: the parsed
// object, or the raw declaration string ("url: ./data.json; ...") that
// getAttribute returns before A-Frame initialised the component. Reading
// the raw string as the url produced "url: url: ./data.json?...", which no
// later refresh could repair; any leaked "url:" prefix is stripped here.
function readQueryJsonUrl(value) {
var raw = '';
if (typeof value === 'string') {
var match = /(?:^|;)\s*url\s*:\s*([^;]*)/.exec(value);
raw = match ? match[1] : '';
} else if (value && typeof value.url === 'string') {
raw = value.url;
}
raw = raw.trim();
while (/^url\s*:/i.test(raw)) {
raw = raw.replace(/^url\s*:\s*/i, '');
}
return raw.trim();
}

async function refreshNormalDataSources(modeRevision) {
var doc = root.document;
if (!doc || modeRevision <= state.lastNormalModeRevision) {
Expand All @@ -83,7 +103,7 @@
if (!current) {
return;
}
var currentUrl = typeof current === 'string' ? current : current.url || '';
var currentUrl = readQueryJsonUrl(current);
if (!currentUrl) {
return;
}
Expand Down
68 changes: 52 additions & 16 deletions apps/vscode-extension/templates/xr/sse/live_sse_fileDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ function liveReloadDebugLog(...args) {

liveReloadDebugLog('Setting up EventSource for HTML live reload...');

const eventSource = new EventSource('/events');
let eventSource = null;
let isXRMode = false;
let hadConnectionError = false;
let reconnectDelayMs = 0;
let reconnectTimer = null;
const RECONNECT_MIN_DELAY_MS = 1000;
const RECONNECT_MAX_DELAY_MS = 30000;

function checkXRMode() {
isXRMode = !!document.querySelector('a-scene');
Expand Down Expand Up @@ -47,21 +52,50 @@ function applyBabiaHtmlComponent(entity, htmlContent, distanceLevels) {

document.addEventListener('DOMContentLoaded', checkXRMode);

eventSource.onopen = function () {
liveReloadDebugLog('HTML EventSource connection established');
liveReloadDebugLog('DOM Visualization live reload ready - file changes will update automatically');
};

eventSource.onerror = function (err) {
console.error('HTML EventSource error:', err);
setTimeout(() => {
liveReloadDebugLog('Attempting to reconnect HTML EventSource...');
eventSource.close();
location.reload();
}, 3000);
};
// Opens the connection and binds every handler to it. An error used to
// reload the page after 3 s whatever happened: with the server down that
// replaced the visualization with the browser's error page, and with
// /events answering 404 the page reloaded forever. Now the browser's own
// retry is left alone, a connection it gave up on is reopened with back-off,
// and the page reloads only once a connection is back after an error (to
// pick up any update missed while it was down).
function connectLiveReload() {
reconnectTimer = null;
const source = new EventSource('/events');
eventSource = source;
source.onopen = function () {
reconnectDelayMs = 0;
liveReloadDebugLog('HTML EventSource connection established');
if (hadConnectionError) {
hadConnectionError = false;
liveReloadDebugLog('Connection restored after an error; reloading to catch up...');
location.reload();
return;
}
liveReloadDebugLog('DOM Visualization live reload ready - file changes will update automatically');
};
source.onerror = function (err) {
if (source !== eventSource) {
return;
}
console.error('HTML EventSource error:', err);
hadConnectionError = true;
if (source.readyState !== 2) {
return;
}
source.close();
if (!reconnectTimer) {
reconnectDelayMs = reconnectDelayMs
? Math.min(RECONNECT_MAX_DELAY_MS, reconnectDelayMs * 2)
: RECONNECT_MIN_DELAY_MS;
reconnectTimer = setTimeout(connectLiveReload, reconnectDelayMs);
}
};
source.addEventListener('message', handleLiveReloadMessage);
return source;
}

eventSource.addEventListener('message', function(event) {
function handleLiveReloadMessage(event) {
try {
const data = JSON.parse(event.data);
liveReloadDebugLog('SSE received:', data);
Expand Down Expand Up @@ -91,7 +125,7 @@ eventSource.addEventListener('message', function(event) {
} catch (error) {
console.error('Error parsing SSE message:', error);
}
});
}

function updateBabiaHtmlComponent(entity, htmlContent) {
try {
Expand All @@ -105,3 +139,5 @@ function updateBabiaHtmlComponent(entity, htmlContent) {
location.reload();
}
}

connectLiveReload();
Loading
Loading