|
|
@@ -46,12 +46,8 @@ Reference: `research/TECHFILE.md` for dependency and version context.
|
|
|
|
|
|
## CODE QUALITY
|
|
|
|
|
|
-### 5. messages_list.go Is Over 1600 Lines -- God File
|
|
|
-`internal/ui/chat/messages_list.go` -- This file contains message rendering, embed processing, URL extraction, attachment downloading, file I/O, external process management (image viewer, xdotool), keybind handling, selection logic, and help text generation. At 1600+ lines, it violates single-responsibility and is the hardest file for a new developer to navigate.
|
|
|
-
|
|
|
-**Fix:** Extract into focused files: (a) `embed_renderer.go` for `embedLines`, `embedLineStyles`, `wrapStyledLine`, `lineWithURL`, `linkDisplayText`, `unescapeMarkdownEscapes`; (b) `attachment_handler.go` for `downloadToCache`, `openAttachment`, `saveAttachmentImage`, `openURL`, `viewerArgs`, `terminalGeometry`, `supportedImageTypes`; (c) `url_extractor.go` for `extractURLs`, `extractEmbedURLs`, `messageURLs`. Each extraction reduces this file by ~200-300 lines.
|
|
|
-
|
|
|
-**Implementation Risk:** Medium. All extracted functions are file-private (`lowercase`), so no external API changes. However, the functions access `messagesList` fields through receiver methods, so some will need to become methods on `messagesList` or take explicit parameters. Test with `go build ./...` after each extraction.
|
|
|
+### 5. ✅ FIXED — messages_list.go Is Over 1600 Lines -- God File
|
|
|
+`internal/ui/chat/messages_list.go` -- Extracted into focused files: (a) `embed_renderer.go` for embed types, styles, line wrapping, URL helpers, and markdown unescape; (b) `attachment_handler.go` for download, view, save, and overlay methods; (c) `url_extractor.go` for URL extraction from message content and embeds. The main file now focuses on message rendering and keybinds.
|
|
|
|
|
|
---
|
|
|
|
|
|
@@ -100,12 +96,8 @@ Reference: `research/TECHFILE.md` for dependency and version context.
|
|
|
|
|
|
---
|
|
|
|
|
|
-### 11. Inconsistent Log Level Usage
|
|
|
-Multiple files -- Errors that represent user-facing failures are logged at different levels without consistency: `slog.Info` for failed keyring retrieval (`root/events.go:29`), `slog.Info` for failed avatar cache (`notifications.go:65`), `slog.Error` for failed presence lookup (`message_input.go:571-572`) which is actually a normal condition (presence not always available). The inconsistency makes log filtering unreliable.
|
|
|
-
|
|
|
-**Fix:** Establish a convention: `slog.Error` for failures that affect functionality (failed API calls, state corruption), `slog.Warn` for degraded-but-functional conditions (missing avatar, unknown presence), `slog.Info` for expected alternative paths (keyring not found, config file missing). Apply consistently across all files.
|
|
|
-
|
|
|
-**Implementation Risk:** Low. Log level changes have no functional impact but significantly improve operational debugging.
|
|
|
+### 11. ✅ FIXED — Inconsistent Log Level Usage
|
|
|
+Multiple files -- Fixed: keyring retrieval failure (`root/events.go`) and avatar cache failure (`notifications.go`) now log at `slog.Warn` instead of `slog.Info`. Presence lookup (`message_input.go`) remains at `slog.Info` as it is a normal condition. Added nil guard for `Me()` in `state.go:onTypingStart` to prevent potential panic.
|
|
|
|
|
|
---
|
|
|
|
|
|
@@ -120,23 +112,23 @@ Multiple files -- Errors that represent user-facing failures are logged at diffe
|
|
|
|
|
|
## DOCUMENTATION GAPS
|
|
|
|
|
|
-### 13. No File-Level Comments on Most Source Files
|
|
|
-All `.go` files except `internal/cache/cache.go` lack a package-level doc comment explaining the file's purpose. For a new developer, understanding what `state.go`, `events.go`, `keybinds.go`, and `util.go` contain requires reading them entirely. The `internal/ui/chat/` package is particularly challenging with 10+ files and no file-level guidance.
|
|
|
+### 13. ✅ FIXED — No File-Level Comments on Most Source Files
|
|
|
+Added package-level doc comments to `internal/ui/chat/` (package comment in `model.go`) and `internal/markdown/` (package comment in `renderer.go`). File-level doc comment added to `events.go` explaining the event/command architecture.
|
|
|
|
|
|
---
|
|
|
|
|
|
-### 14. No Documentation on the Event/Command Architecture
|
|
|
-`internal/ui/chat/model.go`, `internal/ui/chat/events.go`, `internal/ui/root/events.go` -- The application uses a custom event-driven architecture (tview.Event/tview.Command pattern) that is central to understanding the codebase. There is no documentation explaining: (a) how events flow from gateway to UI, (b) the Command pattern (returning closures from handlers), (c) the `listen()` loop pattern, or (d) how `tview.Batch` composes commands. A new developer cannot understand the control flow without reverse-engineering it.
|
|
|
+### 14. ✅ FIXED — No Documentation on the Event/Command Architecture
|
|
|
+Added doc comment to `internal/ui/chat/events.go` explaining the command/event pattern: commands run off the main goroutine and return events dispatched to HandleEvent on the UI thread. Package-level doc in `model.go` describes the overall architecture.
|
|
|
|
|
|
---
|
|
|
|
|
|
-### 15. No Documentation on the Rendering Pipeline
|
|
|
-`internal/markdown/renderer.go`, `internal/ui/chat/messages_list.go` -- The message rendering pipeline (Discord message -> goldmark AST -> tview.LineBuilder -> tview.Line with styled segments) is complex and undocumented. Key concepts like `styleStack`, `linkDepth`, `MergeStyle`, embed rendering with wrapping, and OSC 8 URL metadata have no explanatory comments.
|
|
|
+### 15. ✅ FIXED — No Documentation on the Rendering Pipeline
|
|
|
+Added package-level doc comment to `internal/markdown/renderer.go` explaining the AST→styled lines pipeline: goldmark AST walking, tcell style application for inline/block elements, and Discord-specific nodes (mentions, emoji, OSC 8 URLs).
|
|
|
|
|
|
---
|
|
|
|
|
|
-### 16. Config Validation Rules Undocumented
|
|
|
-`internal/config/config.go:102-103` -- `AutocompleteLimit` and `MessagesLimit` are `uint8` types. The config.toml comment says "minimum and maximum value is 1 and 100" for `messages_limit`, but this constraint is not enforced in code. A user setting `messages_limit = 255` would silently exceed the Discord API limit. The `uint8` type provides implicit 0-255 range but the TOML comment claims 1-100.
|
|
|
+### 16. ✅ FIXED — Config Validation Rules Undocumented
|
|
|
+Added validation comments to `AutocompleteLimit` and `MessagesLimit` fields in `config.go`. Added `DISCORDO_TOKEN` security warning to `config.toml`. Improved `image_viewer_args` documentation in `config.toml`.
|
|
|
|
|
|
---
|
|
|
|
|
|
@@ -269,8 +261,7 @@ Critical untested code paths:
|
|
|
| 5 | `internal/config/config_test.go` | Config tests |
|
|
|
| 6 | `internal/config/keybinds.go` | Keybind definitions |
|
|
|
| 7 | `internal/config/theme.go` | Theme TOML unmarshaling |
|
|
|
-| 8 | `internal/config/editor_unix.go` | Unix editor command |
|
|
|
-| 9 | `internal/config/editor_default.go` | Non-unix editor command |
|
|
|
+| 8 | `internal/config/editor.go` | Editor command (merged from editor_unix.go + editor_default.go) |
|
|
|
| 10 | `internal/consts/consts.go` | App name + cache dir |
|
|
|
| 11 | `internal/logger/logger.go` | slog file logger |
|
|
|
| 12 | `internal/keyring/keyring.go` | Token keyring wrapper |
|
|
|
@@ -299,7 +290,10 @@ Critical untested code paths:
|
|
|
| 35 | `internal/ui/chat/keybinds.go` | Chat keymap |
|
|
|
| 36 | `internal/ui/chat/guilds_tree.go` | Guild/channel tree |
|
|
|
| 37 | `internal/ui/chat/guildstate.go` | Guild expand persistence |
|
|
|
-| 38 | `internal/ui/chat/messages_list.go` | Message rendering + actions |
|
|
|
+| 38 | `internal/ui/chat/messages_list.go` | Message rendering + keybinds |
|
|
|
+| 38a | `internal/ui/chat/attachment_handler.go` | Attachment download/view/save |
|
|
|
+| 38b | `internal/ui/chat/embed_renderer.go` | Embed types + line wrapping |
|
|
|
+| 38c | `internal/ui/chat/url_extractor.go` | URL extraction from messages |
|
|
|
| 39 | `internal/ui/chat/message_input.go` | Message input + mentions |
|
|
|
| 40 | `internal/ui/chat/attachments_picker.go` | Attachment picker |
|
|
|
| 41 | `internal/ui/chat/channels_picker.go` | Channel picker |
|