This commit is contained in:
Tea 2026-07-09 23:21:25 -04:00
parent 88670c679f
commit cc5e262ccb
3 changed files with 18 additions and 7 deletions

21
main.ts
View file

@ -60,6 +60,8 @@ interface SceneState {
timestamp?: string | null; timestamp?: string | null;
your_last_post?: string | null; your_last_post?: string | null;
posted_since_count?: number | null; posted_since_count?: number | null;
initializing?: boolean;
source?: string;
} }
interface SceneQueryResponse { interface SceneQueryResponse {
@ -1116,14 +1118,23 @@ export default class MultimuseObsidian extends Plugin {
// Use replied or is_from_character (API may send either) // Use replied or is_from_character (API may send either)
const repliedRaw = state.replied ?? state.is_from_character; const repliedRaw = state.replied ?? state.is_from_character;
if (repliedRaw === undefined || repliedRaw === null) { if (repliedRaw === undefined || repliedRaw === null) {
console.log(`[MultimuseObsidian] ${file.basename}: state.replied/is_from_character is undefined/null - skipping update`); if (state.initializing) {
console.log(`[MultimuseObsidian] ${file.basename}: API still initializing turn state - skipping update`);
} else {
console.log(`[MultimuseObsidian] ${file.basename}: state.replied/is_from_character is undefined/null - skipping update`);
}
return false; return false;
} }
// Check if the state looks suspicious (e.g., bot couldn't access channel) // Legacy guard for uninitialized in-memory state without thread_tracker anchors.
// If timestamp is null and your_last_post is null, it might indicate the bot couldn't read the channel // thread_tracker responses include DB anchors or source=thread_tracker — trust those.
// In this case, don't update the Replied? field to avoid incorrect updates const fromThreadTracker = state.source === 'thread_tracker';
if (state.timestamp === null && state.your_last_post === null && state.posted_since_count === 0) { if (
!fromThreadTracker &&
state.timestamp === null &&
state.your_last_post === null &&
(state.posted_since_count ?? 0) === 0
) {
console.log(`[MultimuseObsidian] ${file.basename}: State appears invalid (timestamp and your_last_post are null) - likely bot can't access channel. Skipping update to prevent incorrect "Replied?" value.`); console.log(`[MultimuseObsidian] ${file.basename}: State appears invalid (timestamp and your_last_post are null) - likely bot can't access channel. Skipping update to prevent incorrect "Replied?" value.`);
return false; return false;
} }

View file

@ -1,7 +1,7 @@
{ {
"id": "multimuse-tracker", "id": "multimuse-tracker",
"name": "Multimuse Tracker", "name": "Multimuse Tracker",
"version": "1.12.3", "version": "1.12.4",
"minAppVersion": "1.4.0", "minAppVersion": "1.4.0",
"description": "Roleplay sync tool for use with the MultiMuse bot in discord.", "description": "Roleplay sync tool for use with the MultiMuse bot in discord.",
"author": "BackstagePass Group", "author": "BackstagePass Group",

View file

@ -1,6 +1,6 @@
{ {
"name": "multimuse-tracker", "name": "multimuse-tracker",
"version": "1.12.3", "version": "1.12.4",
"description": "MultiMuse bot integration for tracking Discord threads and sending messages as muses", "description": "MultiMuse bot integration for tracking Discord threads and sending messages as muses",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {