Skip to content

Commit 537ac89

Browse files
Refactor: remove legacy fallback observer parser from timer_dock and test_frontend
1 parent 734a7b1 commit 537ac89

2 files changed

Lines changed: 1 addition & 63 deletions

File tree

tests/test_frontend.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -164,20 +164,7 @@ test("Null returns --:--", formatTime(null) === "--:--");
164164
// ═══════════════════════════════════════════════════════
165165
// Duration Formatting (from stats dashboard)
166166
// ═══════════════════════════════════════════════════════
167-
section("Dock Fallback State Inference");
168-
169-
function inferFallbackRunning(timerText, sessionText) {
170-
const parts = String(timerText || '').trim().split(':').map(part => parseInt(part, 10));
171-
const currentTime = parts.some(Number.isNaN)
172-
? null
173-
: (parts.length === 2 ? (parts[0] * 60) + parts[1] : parts.length === 3 ? (parts[0] * 3600) + (parts[1] * 60) + parts[2] : null);
174-
return currentTime != null && !!sessionText && !/\bready\b/i.test(sessionText);
175-
}
176-
177-
test("Ready session text is treated as idle", inferFallbackRunning("25:00", "Ready") === false);
178-
test("Focus text is treated as running", inferFallbackRunning("25:00", "Focus Time") === true);
179-
test("Paused focus text is still treated as running state", inferFallbackRunning("25:00", "Focus Time (Paused)") === true);
180-
167+
// ═══════════════════════════════════════════════════════
181168
section("Duration Formatting (JS)");
182169

183170
function formatDuration(seconds) {

timer_dock.html

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,43 +1290,6 @@
12901290
return responseData.inputSettings.text || '';
12911291
}
12921292

1293-
function parseTimerText(timerText) {
1294-
if (!timerText || timerText === '--:--') return null;
1295-
const clean = String(timerText).trim().replace(/^\+/, '');
1296-
const parts = clean.split(':').map(part => parseInt(part, 10));
1297-
if (parts.some(Number.isNaN)) return null;
1298-
if (parts.length === 2) return (parts[0] * 60) + parts[1];
1299-
if (parts.length === 3) return (parts[0] * 3600) + (parts[1] * 60) + parts[2];
1300-
return null;
1301-
}
1302-
1303-
function inferSessionType(messageText) {
1304-
const text = String(messageText || '').toLowerCase();
1305-
if (text.includes('short break')) return 'Short Break';
1306-
if (text.includes('long break')) return 'Long Break';
1307-
if (text.includes('focus')) return 'Focus';
1308-
if (text.includes('countdown')) return 'Countdown';
1309-
if (text.includes('stopwatch')) return 'Stopwatch';
1310-
return '';
1311-
}
1312-
1313-
function parseCountText(countText) {
1314-
const match = String(countText || '').match(/(\d+)\s*\/\s*(\d+)/);
1315-
if (!match) return { completed: 0, goal: 0 };
1316-
return {
1317-
completed: parseInt(match[1], 10) || 0,
1318-
goal: parseInt(match[2], 10) || 0
1319-
};
1320-
}
1321-
1322-
function parseProgressText(progressText) {
1323-
const filled = (String(progressText || '').match(//g) || []).length;
1324-
const empty = (String(progressText || '').match(//g) || []).length;
1325-
const total = filled + empty;
1326-
if (total <= 0) return 0;
1327-
return Math.round((filled / total) * 100);
1328-
}
1329-
13301293
function parseControlBridgeState(controlText) {
13311294
if (!controlText) return null;
13321295

@@ -1339,18 +1302,6 @@
13391302
}
13401303
}
13411304

1342-
function buildFallbackChatStatus(sessionText, timerText, countText, paused) {
1343-
const parts = [];
1344-
if (sessionText) parts.push(String(sessionText).trim());
1345-
if (timerText) parts.push(String(timerText).trim());
1346-
if (countText) parts.push(`(${String(countText).trim()})`);
1347-
let summary = parts.join(' ');
1348-
if (paused && summary && !/\bpaused\b/i.test(summary)) {
1349-
summary += ' [Paused]';
1350-
}
1351-
return summary || '--';
1352-
}
1353-
13541305
async function loadStateViaObsSources() {
13551306
// Read SP Control text source — this contains the full state JSON
13561307
// written by the Lua script every tick via update_control_bridge_state().

0 commit comments

Comments
 (0)