Skip to content

Commit c9658a0

Browse files
author
Pascal
committed
feat: add HIDE_TOOL_FILE_MESSAGES env var to suppress file edit documents
Adds a new HIDE_TOOL_FILE_MESSAGES configuration flag that prevents the bot from sending edit_*.txt and write_*.txt code file attachments to Telegram. This is useful for users who find the per-edit document notifications noisy and prefer to rely on the pinned diff summary and streaming text responses instead. - Parse HIDE_TOOL_FILE_MESSAGES in config.ts - Skip enqueueFile in setOnToolFile when flag is true - Update .env.example, README.md, and tests
1 parent 7a8e542 commit c9658a0

5 files changed

Lines changed: 17 additions & 0 deletions

File tree

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ OPENCODE_MODEL_ID=big-pickle
6969
# Hide tool call service messages (default: false)
7070
# HIDE_TOOL_CALL_MESSAGES=false
7171

72+
# Hide tool file edit documents sent as .txt attachments (default: false)
73+
# HIDE_TOOL_FILE_MESSAGES=false
74+
7275
# Assistant message formatting mode (default: markdown)
7376
# markdown = convert assistant replies to Telegram MarkdownV2
7477
# raw = show assistant replies as plain text

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ When installed via npm, the configuration wizard handles the initial setup. The
170170
| `SERVICE_MESSAGES_INTERVAL_SEC` | Service messages interval (thinking + tool calls); keep `>=2` to avoid Telegram rate limits, `0` = immediate | No | `5` |
171171
| `HIDE_THINKING_MESSAGES` | Hide `💭 Thinking...` service messages | No | `false` |
172172
| `HIDE_TOOL_CALL_MESSAGES` | Hide tool-call service messages (`💻 bash ...`, `📖 read ...`, etc.) | No | `false` |
173+
| `HIDE_TOOL_FILE_MESSAGES` | Hide file edit documents sent as `.txt` attachments (`edit_*.txt`, `write_*.txt`) | No | `false` |
173174
| `RESPONSE_STREAMING` | Stream assistant replies while they are generated across one or more Telegram messages | No | `true` |
174175
| `MESSAGE_FORMAT_MODE` | Assistant reply formatting mode: `markdown` (Telegram MarkdownV2) or `raw` | No | `markdown` |
175176
| `CODE_FILE_MAX_SIZE_KB` | Max file size (KB) to send as document | No | `100` |

src/bot/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,10 @@ async function ensureEventSubscription(directory: string): Promise<void> {
546546
return;
547547
}
548548

549+
if (config.bot.hideToolFileMessages) {
550+
return;
551+
}
552+
549553
try {
550554
await toolCallStreamer.breakSession(fileInfo.sessionId, "tool_file_boundary");
551555

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export const config = {
103103
locale: getOptionalLocaleEnvVar("BOT_LOCALE", "en"),
104104
hideThinkingMessages: getOptionalBooleanEnvVar("HIDE_THINKING_MESSAGES", false),
105105
hideToolCallMessages: getOptionalBooleanEnvVar("HIDE_TOOL_CALL_MESSAGES", false),
106+
hideToolFileMessages: getOptionalBooleanEnvVar("HIDE_TOOL_FILE_MESSAGES", false),
106107
messageFormatMode: getOptionalMessageFormatModeEnvVar("MESSAGE_FORMAT_MODE", "markdown"),
107108
},
108109
files: {

tests/config.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,49 @@ describe("config boolean env parsing", () => {
1717
it("uses false defaults for hide service message flags", async () => {
1818
vi.stubEnv("HIDE_THINKING_MESSAGES", "");
1919
vi.stubEnv("HIDE_TOOL_CALL_MESSAGES", "");
20+
vi.stubEnv("HIDE_TOOL_FILE_MESSAGES", "");
2021

2122
const config = await loadConfig();
2223

2324
expect(config.bot.hideThinkingMessages).toBe(false);
2425
expect(config.bot.hideToolCallMessages).toBe(false);
26+
expect(config.bot.hideToolFileMessages).toBe(false);
2527
});
2628

2729
it("parses truthy values for hide service message flags", async () => {
2830
vi.stubEnv("HIDE_THINKING_MESSAGES", "YES");
2931
vi.stubEnv("HIDE_TOOL_CALL_MESSAGES", "1");
32+
vi.stubEnv("HIDE_TOOL_FILE_MESSAGES", "true");
3033

3134
const config = await loadConfig();
3235

3336
expect(config.bot.hideThinkingMessages).toBe(true);
3437
expect(config.bot.hideToolCallMessages).toBe(true);
38+
expect(config.bot.hideToolFileMessages).toBe(true);
3539
});
3640

3741
it("parses falsy values for hide service message flags", async () => {
3842
vi.stubEnv("HIDE_THINKING_MESSAGES", "off");
3943
vi.stubEnv("HIDE_TOOL_CALL_MESSAGES", "0");
44+
vi.stubEnv("HIDE_TOOL_FILE_MESSAGES", "false");
4045

4146
const config = await loadConfig();
4247

4348
expect(config.bot.hideThinkingMessages).toBe(false);
4449
expect(config.bot.hideToolCallMessages).toBe(false);
50+
expect(config.bot.hideToolFileMessages).toBe(false);
4551
});
4652

4753
it("falls back to defaults on invalid values", async () => {
4854
vi.stubEnv("HIDE_THINKING_MESSAGES", "banana");
4955
vi.stubEnv("HIDE_TOOL_CALL_MESSAGES", "nope");
56+
vi.stubEnv("HIDE_TOOL_FILE_MESSAGES", "invalid");
5057

5158
const config = await loadConfig();
5259

5360
expect(config.bot.hideThinkingMessages).toBe(false);
5461
expect(config.bot.hideToolCallMessages).toBe(false);
62+
expect(config.bot.hideToolFileMessages).toBe(false);
5563
});
5664

5765
it("uses markdown as default message format mode", async () => {

0 commit comments

Comments
 (0)