Commit dc82aeef by 程裕兵

fix(luna-tts): add Luna TTS vote counter, fix Stop button, fix daily limit auto-stop

parent 1abd0ae9
......@@ -332,9 +332,11 @@
}
}
if (!enabled) return; // stopped during listening/matching
if (finalDecision === 'vote_left') {
_updateBanner('🗳️ 投票: 左侧...');
_captureRevealAndVerify(result, 'left');
if (!enabled) return; // stopped before voting
const v = await simulateVote('left');
if (!v.success) { _updateBanner('❌ 投票未确认,刷新重试...'); await delay(3000); location.reload(); return; }
_updateBanner(`🗳️ 投左侧 ✓${finalDecision !== result.decision ? ' [手动]' : ''}`);
......@@ -381,7 +383,8 @@
}
function scheduleNextVote() {
voteTimerId = setTimeout(doVote, 1000); // minimal delay, page naturally loads next audio
if (!enabled) return; // stopped — don't schedule next cycle
voteTimerId = setTimeout(doVote, 1000);
}
// ---- Work/rest cycle ----
......
......@@ -29,6 +29,7 @@
</div>
<div class="row"><span class="label">Server</span><span class="value" id="serverStatus"></span></div>
<div class="row"><span class="label">Luna TTS</span><span class="value" id="lunaVotes">0</span></div>
<div class="row"><span class="label">Today votes</span><span class="value" id="todayVotes">0 / 800</span></div>
<div class="row"><span class="label">Today skips</span><span class="value" id="todaySkips">0</span></div>
......
......@@ -7,6 +7,7 @@ const dot = document.getElementById('dot');
const serverStatus = document.getElementById('serverStatus');
const todayVotes = document.getElementById('todayVotes');
const todaySkips = document.getElementById('todaySkips');
const lunaVotes = document.getElementById('lunaVotes');
const log = document.getElementById('log');
let tabId = null;
......@@ -41,6 +42,7 @@ async function refreshState() {
chrome.runtime.sendMessage({ type: 'get_state' }, (state) => {
updateUI(state);
if (state.today_votes !== undefined) {
lunaVotes.textContent = state.luna_votes || 0;
todayVotes.textContent = `${state.today_votes} / ${state.daily_limit || 800}`;
todaySkips.textContent = state.today_skips || 0;
}
......@@ -91,6 +93,7 @@ chrome.runtime.onMessage.addListener((message) => {
if (message.type === 'from_server') {
const payload = message.payload;
if (payload.stats) {
lunaVotes.textContent = payload.stats.luna_votes || 0;
todayVotes.textContent = `${payload.stats.today_votes} / ${payload.stats.daily_limit}`;
todaySkips.textContent = payload.stats.today_skips;
}
......
......@@ -96,6 +96,7 @@ def main():
today_votes = 0
today_skips = 0
luna_votes = 0
_write_status("ready", f"Models loaded, {today_votes} votes today")
_log_stderr("[host] Ready, waiting for messages...")
......@@ -169,6 +170,10 @@ def main():
today_skips += 1
else:
today_votes += 1
# Count Luna TTS votes (top match from "our" library)
if (decision_obj.action == "vote_left" and left_side.top_library == "our") or \
(decision_obj.action == "vote_right" and right_side.top_library == "our"):
luna_votes += 1
needs_review = (
left_side.our_score >= OUR_THRESHOLD and right_side.our_score >= OUR_THRESHOLD and
......@@ -183,7 +188,7 @@ def main():
"left": {**left_result.to_dict(), "top_match": {"speaker": left_side.top_speaker, "score": left_side.top_score, "library": left_side.top_library}},
"right": {**right_result.to_dict(), "top_match": {"speaker": right_side.top_speaker, "score": right_side.top_score, "library": right_side.top_library}},
},
"stats": {"today_votes": today_votes, "today_skips": today_skips, "daily_limit": DAILY_VOTE_LIMIT},
"stats": {"today_votes": today_votes, "today_skips": today_skips, "luna_votes": luna_votes, "daily_limit": DAILY_VOTE_LIMIT},
}
_write_status("ready", f"Votes: {today_votes}, Skips: {today_skips}")
send_message(response)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment