@patimweb/pi-teams 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patimweb/pi-teams",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Microsoft Teams integration for pi coding agent — acts fully as the signed-in user across multiple accounts and tenants: chats, channels, meetings, presence, with configurable guardrails",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -143,12 +143,23 @@ export default function (pi: ExtensionAPI) {
143
143
  /** The watcher running in this session, when listen mode is on. */
144
144
  let watchLoop: WatchLoop | undefined;
145
145
 
146
+ /**
147
+ * The settings the running watcher was started from.
148
+ *
149
+ * Used to tell a real config change from a tool that merely *read* the
150
+ * settings. Restarting resets the watcher's baseline, which discards every
151
+ * chat it has already looked at and swallows whatever arrived just before —
152
+ * so a `teams_watch status` must not be treated like an edit.
153
+ */
154
+ let watchSignature: string | undefined;
155
+
146
156
  /** The last polling error the user was told about, so it is said once. */
147
157
  let reportedWatchError: string | undefined;
148
158
 
149
159
  const stopWatch = () => {
150
160
  watchLoop?.stop();
151
161
  watchLoop = undefined;
162
+ watchSignature = undefined;
152
163
  setActiveWatchLoop(undefined);
153
164
  };
154
165
 
@@ -159,9 +170,15 @@ export default function (pi: ExtensionAPI) {
159
170
  * change cannot leave two pollers running.
160
171
  */
161
172
  const startWatch = (ctx: any) => {
173
+ const conn = refresh();
174
+
175
+ // Already watching this exact configuration: leave the loop alone, so its
176
+ // baseline and its cooldowns survive a look at the status.
177
+ const signature = conn?.watch.enabled ? JSON.stringify(conn.watch) : undefined;
178
+ if (watchSignature !== undefined && signature === watchSignature && watchLoop) return;
179
+
162
180
  stopWatch();
163
181
 
164
- const conn = refresh();
165
182
  if (!conn?.watch.enabled) return;
166
183
 
167
184
  reportedWatchError = undefined;
@@ -182,6 +199,7 @@ export default function (pi: ExtensionAPI) {
182
199
  });
183
200
 
184
201
  watchLoop = loop;
202
+ watchSignature = signature;
185
203
  setActiveWatchLoop(loop);
186
204
  };
187
205
 
@@ -134,6 +134,25 @@ export function teamCandidates(team: TeamSummary): (string | undefined)[] {
134
134
  // Chats
135
135
  // ---------------------------------------------------------------------------
136
136
 
137
+ /**
138
+ * When did this chat last *move*?
139
+ *
140
+ * Deliberately the time of the last **message** rather than Graph's
141
+ * `lastUpdatedDateTime`. That field tracks chat metadata and is badly stale for
142
+ * 1:1 and ad-hoc group chats: measured against a live tenant, a chat whose
143
+ * newest message arrived minutes ago still reported a `lastUpdatedDateTime`
144
+ * from more than a year earlier.
145
+ *
146
+ * Everything that dates a chat depends on this — the chat list order, the
147
+ * inbox window, and the freshness cut-off that decides whether listen mode
148
+ * looks at a chat at all — so a stale value here silently disabled listen mode
149
+ * for exactly the chats people write in. `lastUpdatedDateTime` stays as the
150
+ * fallback for chats Graph returns without a preview.
151
+ */
152
+ function chatActivity(raw: Raw): string | undefined {
153
+ return raw.lastMessagePreview?.createdDateTime ?? raw.lastUpdatedDateTime ?? undefined;
154
+ }
155
+
137
156
  /**
138
157
  * Build a chat summary.
139
158
  *
@@ -162,7 +181,7 @@ export function mapChat(raw: Raw, meId?: string): ChatSummary {
162
181
  topic: raw.topic ?? undefined,
163
182
  label: raw.topic || derived || raw.id || "(chat)",
164
183
  members,
165
- lastUpdated: raw.lastUpdatedDateTime ?? raw.lastMessagePreview?.createdDateTime ?? undefined,
184
+ lastUpdated: chatActivity(raw),
166
185
  lastMessagePreview: preview,
167
186
  lastMessageFrom: mapPerson(raw.lastMessagePreview?.from)?.displayName,
168
187
  webUrl: raw.webUrl ?? undefined,