fix: clarify compression elapsed cap

This commit is contained in:
Dennis Soong
2026-05-18 14:22:29 +08:00
parent 516d2a588c
commit d72b3382fd
2 changed files with 29 additions and 5 deletions
+4 -5
View File
@@ -1976,7 +1976,8 @@ function _compressionElapsedStartedAt(state){const n=Number(state&&state.started
function _compressionElapsedLabel(state){
const started=_compressionElapsedStartedAt(state);
if(!started)return'';
const elapsed=Math.min(Math.max(0,(Date.now()/1000)-started),_COMPRESSION_ELAPSED_MAX_SECONDS);
const elapsed=Math.max(0,(Date.now()/1000)-started);
if(elapsed>=_COMPRESSION_ELAPSED_MAX_SECONDS)return '5+ min';
return _formatActiveElapsedTimer(elapsed);
}
function _compressionElapsedExpired(state){const started=_compressionElapsedStartedAt(state);return !!(started&&((Date.now()/1000)-started)>=_COMPRESSION_ELAPSED_MAX_SECONDS);}
@@ -5012,11 +5013,9 @@ function _autoCompressionPreviewText(state){
}
function _autoCompressionDetailText(state){
const running=state&&state.phase==='running';
const detail=_autoCompressionBaseDetail(state);
const base=_autoCompressionBaseDetail(state);
const elapsedLabel=running?_compressionElapsedLabel(state):'';
return running&&elapsedLabel
? `${detail}\nElapsed: ${elapsedLabel}`
: detail;
return elapsedLabel?`Elapsed: ${elapsedLabel}`:base;
}
function _autoCompressionCardsHtml(state){
const running=state&&state.phase==='running';
+25
View File
@@ -96,6 +96,31 @@ def test_auto_compression_running_card_renders_elapsed_timer_and_caps_updates():
assert "_clearCompressionElapsedTimer();" in src
def test_auto_compression_elapsed_cap_uses_non_frozen_label():
src = _read("static/ui.js")
start = src.find("function _compressionElapsedLabel")
assert start != -1, "elapsed label helper not found"
end = src.find("function _compressionElapsedExpired", start)
assert end != -1, "elapsed expiry helper not found after label helper"
helper = src[start:end]
assert "'5+ min'" in helper
assert "elapsed>=_COMPRESSION_ELAPSED_MAX_SECONDS" in helper
assert "return '05:00'" not in helper
def test_auto_compression_running_detail_avoids_duplicate_message_text():
src = _read("static/ui.js")
start = src.find("function _autoCompressionDetailText")
assert start != -1, "auto compression detail helper not found"
end = src.find("function _autoCompressionCardsHtml", start)
assert end != -1, "auto compression card helper not found after detail helper"
helper = src[start:end]
assert "return elapsedLabel?`Elapsed: ${elapsedLabel}`:base;" in helper
assert "${base}\\nElapsed:" not in helper
def test_auto_compression_live_card_keeps_elapsed_state_for_timer_refresh():
src = _read("static/ui.js")
start = src.find("function appendLiveCompressionCard")