feat: token usage toggle (setting + /usage command) + timestamp fixes
Token usage display: - Add 'show_token_usage' boolean to settings (default: false, off by default) - Settings panel: checkbox 'Show token usage after responses' - /usage slash command: instant toggle with toast feedback, persists to server, updates checkbox if settings panel is open, re-renders messages - Boot: load show_token_usage alongside send_key on startup - ui.js: gate usage badge on window._showTokenUsage flag Timestamps: - streaming.py: stamp 'timestamp' on every message that lacks one at conversation completion; old messages (no timestamp field) now get a wall-clock time the first time they're touched by a new turn - messages.js: stamp _ts on the last assistant message at done-event time so the time shows immediately on the current turn before next reload - Timestamps already render in the UI (Sprint 14): faint time on each role header line, full opacity on hover, full date in title tooltip
This commit is contained in:
@@ -958,6 +958,8 @@ async function loadSettingsPanel(){
|
||||
// Send key preference
|
||||
const sendKeySel=$('settingsSendKey');
|
||||
if(sendKeySel) sendKeySel.value=settings.send_key||'enter';
|
||||
const showUsageCb=$('settingsShowTokenUsage');
|
||||
if(showUsageCb) showUsageCb.checked=!!settings.show_token_usage;
|
||||
// Password field: always blank (we don't send hash back)
|
||||
const pwField=$('settingsPassword');
|
||||
if(pwField) pwField.value='';
|
||||
@@ -979,16 +981,19 @@ async function saveSettings(){
|
||||
const model=($('settingsModel')||{}).value;
|
||||
const workspace=($('settingsWorkspace')||{}).value;
|
||||
const sendKey=($('settingsSendKey')||{}).value;
|
||||
const showTokenUsage=!!($('settingsShowTokenUsage')||{}).checked;
|
||||
const pw=($('settingsPassword')||{}).value;
|
||||
const body={};
|
||||
if(model) body.default_model=model;
|
||||
if(workspace) body.default_workspace=workspace;
|
||||
if(sendKey) body.send_key=sendKey;
|
||||
body.show_token_usage=showTokenUsage;
|
||||
// Password: only act if the field has content; blank = leave auth unchanged
|
||||
if(pw && pw.trim()){
|
||||
try{
|
||||
await api('/api/settings',{method:'POST',body:JSON.stringify({...body,_set_password:pw.trim()})});
|
||||
window._sendKey=sendKey||'enter';
|
||||
window._showTokenUsage=showTokenUsage;
|
||||
showToast('Settings saved (password set — login now required)');
|
||||
toggleSettings();
|
||||
return;
|
||||
@@ -997,6 +1002,8 @@ async function saveSettings(){
|
||||
try{
|
||||
await api('/api/settings',{method:'POST',body:JSON.stringify(body)});
|
||||
window._sendKey=sendKey||'enter';
|
||||
window._showTokenUsage=showTokenUsage;
|
||||
renderMessages();
|
||||
showToast('Settings saved');
|
||||
toggleSettings();
|
||||
}catch(e){
|
||||
|
||||
Reference in New Issue
Block a user