v1.0.50: add diagnostic logging for the update-refresh flow

No functional change. Adds streamDeck.logger.info() calls at
onPropertyInspectorDidAppear, sendProjectsToPI(), and onSendToPlugin
entry, plus a small on-panel debug trail (property-inspector.html)
that timestamps $PI.onConnected firings, button clicks, poll sends,
and received payloads. v1.0.49's panel-polling fix didn't visibly
work in testing and produced no status text at all on the second
attempt -- need to see the actual event sequence rather than guess
again. Remove once the refresh flow is confirmed working.
This commit is contained in:
pdmarf
2026-09-02 11:46:08 +01:00
parent acf4f98d6b
commit feed18ed0d
6 changed files with 30 additions and 6 deletions
+7 -2
View File
@@ -6438,7 +6438,7 @@ async function stopTimer(token, entryId) {
} }
// src/plugin.ts // src/plugin.ts
var CURRENT_VERSION = "1.0.49"; var CURRENT_VERSION = "1.0.50";
var GITEA_BASE = "https://gitea.pdmarf.co.uk/pdm/stream_deck_notion_timer/raw/branch/stable-rebuild"; var GITEA_BASE = "https://gitea.pdmarf.co.uk/pdm/stream_deck_notion_timer/raw/branch/stable-rebuild";
var SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY----- var SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4= MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4=
@@ -6543,10 +6543,12 @@ function setRunningEntry(entryId, actionId) {
plugin_default.settings.getGlobalSettings().then((stored) => plugin_default.settings.setGlobalSettings({ ...stored, runningEntryId: entryId, runningActionId: actionId })).catch((err) => plugin_default.logger.error("Failed to persist running state:", err)); plugin_default.settings.getGlobalSettings().then((stored) => plugin_default.settings.setGlobalSettings({ ...stored, runningEntryId: entryId, runningActionId: actionId })).catch((err) => plugin_default.logger.error("Failed to persist running state:", err));
} }
async function sendProjectsToPI(tokenOverride) { async function sendProjectsToPI(tokenOverride) {
plugin_default.logger.info(`[diag] sendProjectsToPI called, version=${CURRENT_VERSION}, hasToken=${!!tokenOverride}`);
try { try {
const global = await getGlobal(); const global = await getGlobal();
const token = tokenOverride ?? global.notionToken; const token = tokenOverride ?? global.notionToken;
if (!token) { if (!token) {
plugin_default.logger.info("[diag] sendProjectsToPI: no token, sending error payload");
await plugin_default.ui.sendToPropertyInspector({ event: "projects", data: [], error: "Enter your Notion API token above.", version: CURRENT_VERSION }); await plugin_default.ui.sendToPropertyInspector({ event: "projects", data: [], error: "Enter your Notion API token above.", version: CURRENT_VERSION });
return; return;
} }
@@ -6558,6 +6560,7 @@ async function sendProjectsToPI(tokenOverride) {
}) })
]); ]);
await plugin_default.ui.sendToPropertyInspector({ event: "projects", data: projects, users: usersResult, version: CURRENT_VERSION }); await plugin_default.ui.sendToPropertyInspector({ event: "projects", data: projects, users: usersResult, version: CURRENT_VERSION });
plugin_default.logger.info(`[diag] sendProjectsToPI: sent projects payload, version=${CURRENT_VERSION}`);
} catch (err) { } catch (err) {
plugin_default.logger.error("Failed to fetch projects:", err); plugin_default.logger.error("Failed to fetch projects:", err);
await plugin_default.ui.sendToPropertyInspector({ event: "projects", data: [], error: String(err), version: CURRENT_VERSION }); await plugin_default.ui.sendToPropertyInspector({ event: "projects", data: [], error: String(err), version: CURRENT_VERSION });
@@ -6635,7 +6638,8 @@ var TimerToggle = class extends SingletonAction {
await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]); await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]);
} }
} }
async onPropertyInspectorDidAppear(_ev) { async onPropertyInspectorDidAppear(ev) {
plugin_default.logger.info(`[diag] onPropertyInspectorDidAppear fired for ${ev.action.id}, version=${CURRENT_VERSION}`);
await sendProjectsToPI(); await sendProjectsToPI();
} }
async onKeyDown(ev) { async onKeyDown(ev) {
@@ -6721,6 +6725,7 @@ TimerToggle = __decorateClass([
var timerAction = new TimerToggle(); var timerAction = new TimerToggle();
plugin_default.actions.registerAction(timerAction); plugin_default.actions.registerAction(timerAction);
plugin_default.ui.onSendToPlugin(async (ev) => { plugin_default.ui.onSendToPlugin(async (ev) => {
plugin_default.logger.info(`[diag] onSendToPlugin received event=${ev.payload.event}, version=${CURRENT_VERSION}`);
if (ev.payload.event === "saveSettings" && ev.payload.settings) { if (ev.payload.event === "saveSettings" && ev.payload.settings) {
await ev.action.setSettings(ev.payload.settings); await ev.action.setSettings(ev.payload.settings);
const title = buttonTitle(ev.payload.settings.projectName || ""); const title = buttonTitle(ev.payload.settings.projectName || "");
@@ -1 +1 @@
sѕЈвтЫв��ЭSЋгњЬuс�ЏIs5nВ�6фљбJхыИZЯХh?Ў�ВЊЙШ��ЉLJVН?1 u…o%]¹8®ú~/†l�bßϨRŸ1‚ôŽÜ®¸u»†Í%]çâ4Cñ®¥Ri1ü¢Â×05@KfíÙ#X
@@ -147,6 +147,7 @@
<p id="versionText"></p> <p id="versionText"></p>
<button id="updateBtn">Check for Updates</button> <button id="updateBtn">Check for Updates</button>
<p id="updateStatus"></p> <p id="updateStatus"></p>
<p id="debugText" style="font-size:9px;color:#555;text-align:center;margin-top:4px;white-space:pre-line;"></p>
<script src="libs/constants.js"></script> <script src="libs/constants.js"></script>
<script src="libs/prototypes.js"></script> <script src="libs/prototypes.js"></script>
@@ -176,6 +177,15 @@
el.className = cls || ""; el.className = cls || "";
} }
// TEMP diagnostic trail — remove once the update-refresh flow is confirmed working.
var debugLines = [];
function debugLog(msg) {
var t = new Date().toISOString().slice(11, 19);
debugLines.push(t + " " + msg);
if (debugLines.length > 8) debugLines.shift();
document.getElementById("debugText").textContent = debugLines.join("\n");
}
// The plugin process restarts after an update, and a freshly-restarted // The plugin process restarts after an update, and a freshly-restarted
// process has no way to push to an already-open panel (Stream Deck only // process has no way to push to an already-open panel (Stream Deck only
// tells a plugin a panel is visible via a live didAppear/onSendToPlugin // tells a plugin a panel is visible via a live didAppear/onSendToPlugin
@@ -186,6 +196,7 @@
var token = document.getElementById("notionToken").value.trim(); var token = document.getElementById("notionToken").value.trim();
[1500, 3500, 6000, 9000].forEach(function(delay) { [1500, 3500, 6000, 9000].forEach(function(delay) {
setTimeout(function() { setTimeout(function() {
debugLog("poll: sending refreshProjects (+" + delay + "ms)");
$PI.sendToPlugin({ event: "refreshProjects", token: token }); $PI.sendToPlugin({ event: "refreshProjects", token: token });
}, delay); }, delay);
}); });
@@ -269,6 +280,7 @@
} }
$PI.onConnected(function(jsn) { $PI.onConnected(function(jsn) {
debugLog("$PI.onConnected fired (panel loaded/reloaded)");
currentSettings = jsn.actionInfo.payload.settings || {}; currentSettings = jsn.actionInfo.payload.settings || {};
$PI.getSettings(); $PI.getSettings();
$PI.getGlobalSettings(); $PI.getGlobalSettings();
@@ -277,6 +289,7 @@
document.getElementById("notionToken").addEventListener("input", scheduleCredSave); document.getElementById("notionToken").addEventListener("input", scheduleCredSave);
document.getElementById("userId").addEventListener("change", saveCredentials); document.getElementById("userId").addEventListener("change", saveCredentials);
document.getElementById("updateBtn").addEventListener("click", function() { document.getElementById("updateBtn").addEventListener("click", function() {
debugLog("Check for Updates clicked");
document.getElementById("updateStatus").textContent = ""; document.getElementById("updateStatus").textContent = "";
$PI.sendToPlugin({ event: "checkForUpdates" }); $PI.sendToPlugin({ event: "checkForUpdates" });
pollForVersionRefresh(); pollForVersionRefresh();
@@ -319,6 +332,7 @@
$PI.onSendToPropertyInspector(ACTION_UUID, function(jsn) { $PI.onSendToPropertyInspector(ACTION_UUID, function(jsn) {
var payload = jsn.payload; var payload = jsn.payload;
debugLog("received: " + payload.event + (payload.version ? " v" + payload.version : ""));
if (payload.event === "updateStatus") { if (payload.event === "updateStatus") {
document.getElementById("updateStatus").textContent = payload.message; document.getElementById("updateStatus").textContent = payload.message;
} }
Binary file not shown.
+7 -2
View File
@@ -1,4 +1,4 @@
const CURRENT_VERSION = "1.0.49"; const CURRENT_VERSION = "1.0.50";
const GITEA_BASE = "https://gitea.pdmarf.co.uk/pdm/stream_deck_notion_timer/raw/branch/stable-rebuild"; const GITEA_BASE = "https://gitea.pdmarf.co.uk/pdm/stream_deck_notion_timer/raw/branch/stable-rebuild";
const SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY----- const SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4= MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4=
@@ -140,10 +140,12 @@ function setRunningEntry(entryId: string | null, actionId: string | null): void
} }
async function sendProjectsToPI(tokenOverride?: string): Promise<void> { async function sendProjectsToPI(tokenOverride?: string): Promise<void> {
streamDeck.logger.info(`[diag] sendProjectsToPI called, version=${CURRENT_VERSION}, hasToken=${!!tokenOverride}`);
try { try {
const global = await getGlobal(); const global = await getGlobal();
const token = tokenOverride ?? global.notionToken; const token = tokenOverride ?? global.notionToken;
if (!token) { if (!token) {
streamDeck.logger.info("[diag] sendProjectsToPI: no token, sending error payload");
await streamDeck.ui.sendToPropertyInspector({ event: "projects", data: [], error: "Enter your Notion API token above.", version: CURRENT_VERSION }); await streamDeck.ui.sendToPropertyInspector({ event: "projects", data: [], error: "Enter your Notion API token above.", version: CURRENT_VERSION });
return; return;
} }
@@ -155,6 +157,7 @@ async function sendProjectsToPI(tokenOverride?: string): Promise<void> {
}), }),
]); ]);
await streamDeck.ui.sendToPropertyInspector({ event: "projects", data: projects, users: usersResult, version: CURRENT_VERSION }); await streamDeck.ui.sendToPropertyInspector({ event: "projects", data: projects, users: usersResult, version: CURRENT_VERSION });
streamDeck.logger.info(`[diag] sendProjectsToPI: sent projects payload, version=${CURRENT_VERSION}`);
} catch (err) { } catch (err) {
streamDeck.logger.error("Failed to fetch projects:", err); streamDeck.logger.error("Failed to fetch projects:", err);
await streamDeck.ui.sendToPropertyInspector({ event: "projects", data: [], error: String(err), version: CURRENT_VERSION }); await streamDeck.ui.sendToPropertyInspector({ event: "projects", data: [], error: String(err), version: CURRENT_VERSION });
@@ -240,7 +243,8 @@ class TimerToggle extends SingletonAction<TimerSettings> {
} }
} }
async onPropertyInspectorDidAppear(_ev: PropertyInspectorDidAppearEvent<TimerSettings>): Promise<void> { async onPropertyInspectorDidAppear(ev: PropertyInspectorDidAppearEvent<TimerSettings>): Promise<void> {
streamDeck.logger.info(`[diag] onPropertyInspectorDidAppear fired for ${ev.action.id}, version=${CURRENT_VERSION}`);
await sendProjectsToPI(); await sendProjectsToPI();
} }
@@ -337,6 +341,7 @@ const timerAction = new TimerToggle();
streamDeck.actions.registerAction(timerAction); streamDeck.actions.registerAction(timerAction);
streamDeck.ui.onSendToPlugin<{ event: string; settings?: TimerSettings; token?: string }>(async (ev) => { streamDeck.ui.onSendToPlugin<{ event: string; settings?: TimerSettings; token?: string }>(async (ev) => {
streamDeck.logger.info(`[diag] onSendToPlugin received event=${ev.payload.event}, version=${CURRENT_VERSION}`);
if (ev.payload.event === "saveSettings" && ev.payload.settings) { if (ev.payload.event === "saveSettings" && ev.payload.settings) {
await ev.action.setSettings(ev.payload.settings); await ev.action.setSettings(ev.payload.settings);
const title = buttonTitle(ev.payload.settings.projectName || ""); const title = buttonTitle(ev.payload.settings.projectName || "");
+1 -1
View File
@@ -1 +1 @@
{ "version": "1.0.49" } { "version": "1.0.50" }