fix(chat): restore history on Turnstile verification
Turnstile callback unconditionally showed the greeting message, wiping session history for returning visitors who hadn't verified yet. Callback now uses the same restoreOrGreet pattern as neuronDemoToggle: replays prior messages if session.messages is non-empty, else shows the greeting once and marks session.greeted. Also extracts the gallery voting inline script (a49ca0a129e8.js) as a side effect of re-running extract-js.py. Chat JS rebuilds to de72b8b61d75.js.
This commit is contained in:
@@ -261,7 +261,18 @@ CHAT_HTML_AND_JS = r"""
|
||||
if (gate) gate.style.display = 'none';
|
||||
if (msgs) msgs.style.display = 'flex';
|
||||
if (inputRow) inputRow.style.display = 'flex';
|
||||
addMsg('ai', 'Hey. What is on your mind?', true);
|
||||
if (session.messages && session.messages.length > 0) {
|
||||
session.messages.forEach(function(m) { addMsg(m.role, m.text, true); });
|
||||
var remaining = MAX - msgCount;
|
||||
if (remaining <= 0) {
|
||||
var input = document.getElementById('neuron-demo-text');
|
||||
if (input) { input.disabled = true; input.placeholder = 'Interaction limit reached'; }
|
||||
}
|
||||
} else if (!session.greeted) {
|
||||
addMsg('ai', 'Hey. What is on your mind?', true);
|
||||
session.greeted = true;
|
||||
try { localStorage.setItem('neuron_demo_session', JSON.stringify(session)); } catch(e) {}
|
||||
}
|
||||
updateCountdown();
|
||||
var inp = document.getElementById('neuron-demo-text');
|
||||
if (inp) inp.focus();
|
||||
@@ -435,7 +446,7 @@ CHAT_HTML_AND_JS = r"""
|
||||
# with our new inline content + script. extract-js will then re-extract this
|
||||
# fresh inline block to a content-hashed asset on the next build.
|
||||
|
||||
OLD_LINE = '<script src=\\"/assets/js/fc247ef45b1d.js\\" defer></script>'
|
||||
OLD_LINE = '<script src=\\"/assets/js/de72b8b61d75.js\\" defer></script>'
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
Reference in New Issue
Block a user