fix: delete+recreate status post, file polling fallback

- StatusBox: delete+recreate instead of PUT to keep post at thread bottom
  (Mattermost clears pin on PUT and doesn't bump edited posts)
- StatusBox: extends EventEmitter, emits 'post-replaced' events
- StatusWatcher: 500ms file polling fallback (fs.watch unreliable on
  Docker bind mounts / overlay fs)
- WatcherManager: handles post-replaced events to update activeBoxes
- SessionMonitor: forgetSession() for idle session re-detection
This commit is contained in:
sol
2026-03-07 19:07:01 +00:00
parent 3a8532bb30
commit bbafdaf2d8
3 changed files with 83 additions and 15 deletions

View File

@@ -282,6 +282,18 @@ async function startDaemon() {
logger.debug({ sessionKey }, 'Session removed from sessions.json');
});
// ---- Post Replaced (delete+recreate) ----
sharedStatusBox.on('post-replaced', (oldPostId, newPostId) => {
// Update activeBoxes to point to new post ID
for (var entry of activeBoxes.entries()) {
if (entry[1].postId === oldPostId) {
entry[1].postId = newPostId;
logger.debug({ sessionKey: entry[0], oldPostId, newPostId }, 'Post replaced (delete+recreate)');
break;
}
}
});
// ---- Session Update (from watcher) ----
watcher.on('session-update', (sessionKey, state) => {
const box = activeBoxes.get(sessionKey);