Spaces:
Running
Running
Add error handling for tool usage and update evidence display logic
Browse files- TODO.md +3 -1
- app.py +6 -0
- ui/static/js/game_logic.js +31 -20
TODO.md
CHANGED
|
@@ -3,4 +3,6 @@
|
|
| 3 |
- pre-generate suspects cartoony potraits
|
| 4 |
- find the texture missing
|
| 5 |
- remove scroll bars
|
| 6 |
-
- players can't know there's more suspects down the list as we removed the scroll bar, can you scroll a bit down by default to show there's more cards down
|
|
|
|
|
|
|
|
|
| 3 |
- pre-generate suspects cartoony potraits
|
| 4 |
- find the texture missing
|
| 5 |
- remove scroll bars
|
| 6 |
+
- players can't know there's more suspects down the list as we removed the scroll bar, can you scroll a bit down by default to show there's more cards down
|
| 7 |
+
- sound/music
|
| 8 |
+
- eleven labs tts/voice
|
app.py
CHANGED
|
@@ -106,6 +106,12 @@ class GameSession:
|
|
| 106 |
|
| 107 |
result = self.game.use_tool(tool_name, **kwargs)
|
| 108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
# Format the result nicely
|
| 110 |
evidence_data = format_tool_response(tool_name, arg, result, self.game.scenario)
|
| 111 |
|
|
|
|
| 106 |
|
| 107 |
result = self.game.use_tool(tool_name, **kwargs)
|
| 108 |
|
| 109 |
+
if "error" in result:
|
| 110 |
+
return {
|
| 111 |
+
"action": "tool_error",
|
| 112 |
+
"data": {"message": result["error"]}
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
# Format the result nicely
|
| 116 |
evidence_data = format_tool_response(tool_name, arg, result, self.game.scenario)
|
| 117 |
|
ui/static/js/game_logic.js
CHANGED
|
@@ -56,6 +56,9 @@ function handleServerMessage(message) {
|
|
| 56 |
case 'add_evidence':
|
| 57 |
addEvidenceToBoard(data);
|
| 58 |
break;
|
|
|
|
|
|
|
|
|
|
| 59 |
case 'update_status':
|
| 60 |
updateStatus(data);
|
| 61 |
break;
|
|
@@ -223,27 +226,34 @@ function addEvidenceToBoard(evidenceData) {
|
|
| 223 |
const board = document.getElementById('evidence-board');
|
| 224 |
|
| 225 |
// Grouping Logic
|
|
|
|
|
|
|
| 226 |
if (evidenceData.suspect_id) {
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 247 |
}
|
| 248 |
|
| 249 |
const item = document.createElement('div');
|
|
@@ -256,6 +266,7 @@ function addEvidenceToBoard(evidenceData) {
|
|
| 256 |
|
| 257 |
if (evidenceData.type === 'file') {
|
| 258 |
item.classList.add('case-file');
|
|
|
|
| 259 |
item.innerHTML = evidenceData.description;
|
| 260 |
} else {
|
| 261 |
// Standard Card Format
|
|
|
|
| 56 |
case 'add_evidence':
|
| 57 |
addEvidenceToBoard(data);
|
| 58 |
break;
|
| 59 |
+
case 'tool_error':
|
| 60 |
+
showNotification("β " + data.message);
|
| 61 |
+
break;
|
| 62 |
case 'update_status':
|
| 63 |
updateStatus(data);
|
| 64 |
break;
|
|
|
|
| 226 |
const board = document.getElementById('evidence-board');
|
| 227 |
|
| 228 |
// Grouping Logic
|
| 229 |
+
let targetCard = null;
|
| 230 |
+
|
| 231 |
if (evidenceData.suspect_id) {
|
| 232 |
+
// Per-suspect evidence
|
| 233 |
+
targetCard = document.querySelector(`.evidence-item[data-suspect-id="${evidenceData.suspect_id}"]`);
|
| 234 |
+
} else if (evidenceData.type !== 'file') {
|
| 235 |
+
// General evidence (e.g. footage) -> goes to Case File
|
| 236 |
+
targetCard = document.querySelector(`.evidence-item[data-case-file="true"]`);
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
if (targetCard) {
|
| 240 |
+
const contentDiv = targetCard.querySelector('.evidence-content') || targetCard; // Case file might not have .evidence-content wrapper
|
| 241 |
+
|
| 242 |
+
const newEntry = document.createElement('div');
|
| 243 |
+
newEntry.style.marginTop = "10px";
|
| 244 |
+
newEntry.style.borderTop = "1px dashed #888";
|
| 245 |
+
newEntry.style.paddingTop = "5px";
|
| 246 |
+
newEntry.innerHTML = `
|
| 247 |
+
<div style="font-size:0.9em; font-weight:bold; color:#555;">${evidenceData.title}</div>
|
| 248 |
+
${evidenceData.html_content || evidenceData.description}
|
| 249 |
+
`;
|
| 250 |
+
contentDiv.appendChild(newEntry);
|
| 251 |
+
|
| 252 |
+
// Flash effect
|
| 253 |
+
targetCard.style.backgroundColor = "#fff";
|
| 254 |
+
setTimeout(() => targetCard.style.backgroundColor = evidenceData.suspect_id ? "var(--paper-color)" : "#e8dcc8", 300);
|
| 255 |
+
|
| 256 |
+
return;
|
| 257 |
}
|
| 258 |
|
| 259 |
const item = document.createElement('div');
|
|
|
|
| 266 |
|
| 267 |
if (evidenceData.type === 'file') {
|
| 268 |
item.classList.add('case-file');
|
| 269 |
+
item.dataset.caseFile = "true";
|
| 270 |
item.innerHTML = evidenceData.description;
|
| 271 |
} else {
|
| 272 |
// Standard Card Format
|