Skip to content

Commit 42b0214

Browse files
author
Yingwen Luo
committed
feat: add HIDE_TOOL_FILE_MESSAGES env var to suppress file edit documents (grinev#82)
- Add HIDE_TOOL_FILE_MESSAGES configuration option - When set to true, hides file edit documents sent as .txt attachments - Apply upstream commit 6009873
1 parent 079bc20 commit 42b0214

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ OPENCODE_MODEL_ID=claude-opus-4.6
7070
# Hide tool call service messages (default: false)
7171
# HIDE_TOOL_CALL_MESSAGES=false
7272

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

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ When installed via npm, the configuration wizard handles the initial setup. The
333333
| `SERVICE_MESSAGES_INTERVAL_SEC` | Service messages interval (thinking + tool calls); `>=2` to avoid rate limits, `0` = immediate | No | `5` |
334334
| `HIDE_THINKING_MESSAGES` | Hide `💭 Thinking...` service messages | No | `false` |
335335
| `HIDE_TOOL_CALL_MESSAGES` | Hide tool-call service messages (`💻 bash ...`, `📖 read ...`, etc.) | No | `false` |
336+
| `HIDE_TOOL_FILE_MESSAGES` | Hide file edit documents sent as `.txt` attachments (`edit_*.txt`, `write_*.txt`) | No | `false` |
336337
| `RESPONSE_STREAMING` | Stream assistant replies while generated | No | `true` |
337338
| `RESPONSE_STREAM_THROTTLE_MS` | Stream edit throttle (ms) for updates | No | `500` |
338339
| `MESSAGE_FORMAT_MODE` | Assistant reply formatting: `markdown` (Telegram MarkdownV2) or `raw` | No | `markdown` |

src/bot/index.ts

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

578+
if (config.bot.hideToolFileMessages) {
579+
return;
580+
}
581+
578582
try {
579583
await toolCallStreamer.breakSession(fileInfo.sessionId, "tool_file_boundary");
580584

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)