dsh-tg-bridge 1.38.4 → 1.38.5

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/docs/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # CHANGELOG — DSH Telegram bridge
2
2
 
3
+ ## 1.38.5
4
+
5
+ - **The settings card opens the thing it names.** A row like «Модель» runs
6
+ `/model`, whose answer is a card with buttons. The press handler kept only the
7
+ text of whatever the command answered, so the model card arrived as a plain
8
+ message: it named the current model and gave no way to change it — the settings
9
+ screen could describe the install but not edit it. A card-shaped answer is now
10
+ sent under the settings card with its keyboard, in the topic it was asked in,
11
+ and a plain answer still comes as one line. `/fallback`, `/permissions`,
12
+ `/preset` and `/cd` sit behind the same door and open the same way.
13
+ - **The last thought of a turn reaches the card.** The progress card re-reads the
14
+ decision trail every three seconds, so a line written in the final seconds —
15
+ "the result is checked", the one that says how the turn ended — landed between
16
+ two ticks and never appeared at all. The card now reads the trail once more
17
+ before it is finished, and only while `/thoughts` is not off.
18
+
3
19
  ## 1.38.4
4
20
 
5
21
  - **A rewind button no longer answers "undefined".** `answerRewindPress()` was
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-tg-bridge",
3
- "version": "1.38.4",
3
+ "version": "1.38.5",
4
4
  "description": "Drive DeepSeek Harness from Telegram: one project, model and session per forum topic",
5
5
  "type": "module",
6
6
  "main": "plugin-bridge.mjs",
@@ -21,7 +21,7 @@ import { DIR } from '../core/paths.mjs';
21
21
  import { maxParallel } from '../turn/queue.mjs';
22
22
  import { commandFor, renderSettingsCard, settingsCurrent } from './settings-card.mjs';
23
23
  import { config, log, saveConfig, saveState, state } from '../core/state.mjs';
24
- import { inlineKeyboard, send, tg, tgFast } from '../chat/telegram.mjs';
24
+ import { inlineKeyboard, send, sendWithMarkup, tg, tgFast } from '../chat/telegram.mjs';
25
25
  import { activeTurns, baseProfileOf } from '../turn/turn.mjs';
26
26
  import { join } from 'node:path';
27
27
 
@@ -92,6 +92,17 @@ export async function handleCardPress(query, ctx) {
92
92
  // in the chat: the one line below is the chat's share of this press. Only a
93
93
  // command that failed says more than that.
94
94
  const replies = [];
95
+ // A command may answer with buttons — `/model` and `/fallback` are cards whose
96
+ // whole point is their keyboard. The adapters below used to keep only the text,
97
+ // so the settings door to the model picker opened onto a message that named the
98
+ // current model and offered no way to change it.
99
+ const cards = [];
100
+ const collect = (text, extra = {}) => {
101
+ const body = String(text ?? '');
102
+ if (extra?.keyboard || extra?.reply_markup) cards.push({ body, extra });
103
+ else replies.push(body);
104
+ return Promise.resolve(0);
105
+ };
95
106
  // A press that fails has to say so: the card is redrawn either way, and a
96
107
  // redraw alone looks exactly like success. The old path hid failures behind a
97
108
  // line the person read as a confirmation.
@@ -113,14 +124,8 @@ export async function handleCardPress(query, ctx) {
113
124
  // and vanish on restart, which is the worst of both answers.
114
125
  saveConfig,
115
126
  log,
116
- send: (text) => {
117
- replies.push(String(text ?? ''));
118
- return Promise.resolve(0);
119
- },
120
- reply: (text) => {
121
- replies.push(String(text ?? ''));
122
- return Promise.resolve(0);
123
- },
127
+ send: collect,
128
+ reply: collect,
124
129
  jobs: () => ({ active: [], queued: 0, max: maxParallel() }),
125
130
  api: tg,
126
131
  sendFile: () => Promise.resolve(0),
@@ -151,6 +156,17 @@ export async function handleCardPress(query, ctx) {
151
156
  // a failure is on the card too, so it is not repeated below it.
152
157
  if (!handled) log(`settings press ${data}: no handler answered`);
153
158
  const notLine = replies.filter(Boolean).filter((r) => r !== wanted.command);
159
+ // A card-shaped answer goes under the settings card, with its buttons: the press
160
+ // asked to go somewhere, and swallowing the keyboard is what made
161
+ // `/settings → Модель` a screen you could read but not act on.
162
+ if (cards.length > 0 && !failed) {
163
+ const card = cards[0];
164
+ await sendWithMarkup(chatId, threadId, card.body, card.extra).catch((error) => {
165
+ log(`settings press ${data}: card with buttons failed (${error.message})`);
166
+ return send(chatId, card.body, threadId).catch(() => {});
167
+ });
168
+ return;
169
+ }
154
170
  if (notLine.length > 0 && !changed && !failed) {
155
171
  await send(chatId, notLine[0], threadId).catch(() => {});
156
172
  }
package/turn/progress.mjs CHANGED
@@ -371,6 +371,21 @@ export async function startProgress(chatId, threadId, lang = config.lang || 'en'
371
371
  async finish(result) {
372
372
  clearTimeout(timer);
373
373
  clearInterval(thoughtTimer);
374
+ // One last read before the card is finished. A thought written in the last
375
+ // seconds of a turn — "the result is checked", usually, the line that matters
376
+ // most — used to land between two ticks of the loop above and never reach the
377
+ // card at all. The trail is written until the turn ends, so the last read has
378
+ // to happen at the end too.
379
+ if (reasoningMode(state, config, panelKey) !== 'off') {
380
+ try {
381
+ const rows = thoughtRows([notes, topicNotes], started);
382
+ const merged = rows.slice(-2).map((row) => row.text);
383
+ if (merged.join('\n') !== thoughts.join('\n')) thoughts = merged;
384
+ } catch {
385
+ // An unreadable file leaves the last known lines in place: the card is
386
+ // worth more than an empty promise of a trail.
387
+ }
388
+ }
374
389
  if (result?.stopped) {
375
390
  // The person pressed Стоп. The card says so in their words, not with a
376
391
  // ⚠️ and not with a retry button: nothing failed, and the session is