Skip to content

Commit 6009873

Browse files
PaslestrangePascal
andauthored
feat: add HIDE_TOOL_FILE_MESSAGES env var to suppress file edit documents (#82)
Co-authored-by: Pascal <pascal@local>
1 parent a84ce68 commit 6009873

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
@@ -182,6 +182,7 @@ When installed via npm, the configuration wizard handles the initial setup. The
182182
| `SERVICE_MESSAGES_INTERVAL_SEC` | Service messages interval (thinking + tool calls); keep `>=2` to avoid Telegram rate limits, `0` = immediate | No | `5` |
183183
| `HIDE_THINKING_MESSAGES` | Hide `💭 Thinking...` service messages | No | `false` |
184184
| `HIDE_TOOL_CALL_MESSAGES` | Hide tool-call service messages (`💻 bash ...`, `📖 read ...`, etc.) | No | `false` |
185+
| `HIDE_TOOL_FILE_MESSAGES` | Hide file edit documents sent as `.txt` attachments (`edit_*.txt`, `write_*.txt`) | No | `false` |
185186
| `RESPONSE_STREAMING` | Stream assistant replies while they are generated across one or more Telegram messages | No | `true` |
186187
| `MESSAGE_FORMAT_MODE` | Assistant reply formatting mode: `markdown` (Telegram MarkdownV2) or `raw` | No | `markdown` |
187188
| `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
@@ -547,6 +547,10 @@ async function ensureEventSubscription(directory: string): Promise<void> {
547547
return;
548548
}
549549

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

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)