Skip to content

Commit 6671eac

Browse files
committed
Fix: centralize DEBUG_ENABLED for TypeScript code to limit mistakes.
1 parent 09f78c0 commit 6671eac

File tree

4 files changed

+29
-10
lines changed

4 files changed

+29
-10
lines changed

client/src/CodeChatEditor.mts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import "./third-party/wc-mermaid/wc-mermaid";
4848

4949
// #### Local
5050
import { assert } from "./assert.mjs";
51+
import { DEBUG_ENABLED } from "./debug_enabled.mjs";
5152
import {
5253
apply_diff_str,
5354
CodeMirror_load,
@@ -130,9 +131,6 @@ declare global {
130131
// Globals
131132
// -------
132133
//
133-
// True to enable additional debug logging.
134-
export const DEBUG_ENABLED = false;
135-
136134
// The ID of the autosave timer; when this timer expires, the document will be
137135
// autosaved.
138136
let autosaveTimeoutId: null | number = null;

client/src/CodeChatEditorFramework.mts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { show_toast as show_toast_core } from "./show_toast.mjs";
3232

3333
// ### Local
3434
import { assert } from "./assert.mjs";
35+
import { DEBUG_ENABLED, MAX_MESSAGE_LENGTH } from "./debug_enabled.mjs";
3536
import {
3637
CodeChatForWeb,
3738
EditorMessage,
@@ -41,7 +42,6 @@ import {
4142
} from "./shared_types.mjs";
4243
import {
4344
console_log,
44-
DEBUG_ENABLED,
4545
on_error,
4646
on_dom_content_loaded,
4747
} from "./CodeChatEditor.mjs";
@@ -52,8 +52,6 @@ import {
5252
// This code communicates with the CodeChat Editor Server via its websocket
5353
// interface.
5454
//
55-
// The max length of a message to show in the console.
56-
const MAX_MESSAGE_LENGTH = 200;
5755
// The timeout for a websocket `Response`, in ms.
5856
const RESPONSE_TIMEOUT_MS = 15000;
5957

client/src/debug_enabled.mts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (C) 2025 Bryan A. Jones.
2+
//
3+
// This file is part of the CodeChat Editor. The CodeChat Editor is free
4+
// software: you can redistribute it and/or modify it under the terms of the GNU
5+
// General Public License as published by the Free Software Foundation, either
6+
// version 3 of the License, or (at your option) any later version.
7+
//
8+
// The CodeChat Editor is distributed in the hope that it will be useful, but
9+
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10+
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11+
// details.
12+
//
13+
// You should have received a copy of the GNU General Public License along with
14+
// the CodeChat Editor. If not, see
15+
// [http://www.gnu.org/licenses](http://www.gnu.org/licenses).
16+
//
17+
// `debug_enable.mts` -- Configure debug features
18+
// ==============================================
19+
// True to enable additional debug logging.
20+
export const DEBUG_ENABLED = false;
21+
22+
// The max length of a message to show in the console when debug logging is enabled.
23+
export const MAX_MESSAGE_LENGTH = 20000;

extensions/VSCode/src/extension.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ import {
4444
MessageResult,
4545
UpdateMessageContents,
4646
} from "../../../client/src/shared_types.mjs";
47+
import {
48+
DEBUG_ENABLED,
49+
MAX_MESSAGE_LENGTH,
50+
} from "../../../client/src/debug_enabled.mjs";
4751

4852
// Globals
4953
// -------
5054
enum CodeChatEditorClientLocation {
5155
html,
5256
browser,
5357
}
54-
// The max length of a message to show in the console.
55-
const MAX_MESSAGE_LENGTH = 200;
56-
// True to enable additional debug logging.
57-
const DEBUG_ENABLED = true;
5858

5959
// True on Windows, false on OS X / Linux.
6060
const is_windows = process.platform === "win32";

0 commit comments

Comments
 (0)