From 500687f8d7d5b87ceb33fd959e545746ec9db1ba Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 16 May 2026 04:01:04 -0500 Subject: refactor(integrations): five hygiene fixes from the module-by-module re-review - markdown-config.el: two related fixes on `markdown-preview'. First, the URL was `https://localhost:8080/imp' but simple-httpd serves plaintext on port 8080 -- the browser hit a TLS handshake against a non-TLS listener and the preview never rendered. Changed to `http://' and switched from `browse-url-generic' to plain `browse-url' so the user's default protocol handler picks the browser. Second, the function used to start the network listener as a side effect of opening a preview; that's split into a separate `cj/markdown-preview-server-start' command and `markdown-preview' now signals a `user-error' (with the recovery command in the message) when the server isn't running. - slack-config.el: wrap the `which-key-add-keymap-based-replacements' call in `with-eval-after-load 'which-key'. Matches the pattern other config modules use and means a slow / missing which-key load won't block requiring slack-config. - ai-vterm.el: pass the inner shell-command-string through `shell-quote-argument' before wrapping in the tmux invocation. The default value with embedded double quotes was safe under the prior literal-single-quote wrap, but a user-customized `cj/ai-vterm-agent-command' containing a single quote silently broke the shell parse. Two existing tests updated to tolerate the post-quote escape shape; new regression test asserts a single-quote-bearing custom command survives. - eshell-config.el: scope the `TERM=xterm-256color' override to eshell-spawned processes only via an `eshell-mode' hook that prepends to a buffer-local `process-environment'. The previous global `setenv' at config-time changed `TERM' for every subsequent `start-process' across the Emacs session, so any subprocess (not just eshell pipelines) inherited `xterm-256color' regardless of whether the receiver could interpret the escapes. --- tests/test-ai-vterm--launch-command.el | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/test-ai-vterm--launch-command.el b/tests/test-ai-vterm--launch-command.el index 7e455a8b..bac36d4e 100644 --- a/tests/test-ai-vterm--launch-command.el +++ b/tests/test-ai-vterm--launch-command.el @@ -55,19 +55,33 @@ (cj/--ai-vterm-launch-command "/code/foo"))))) (ert-deftest test-ai-vterm--launch-command-includes-agent-command () - "Normal: the configured agent command is in the launched shell command." + "Normal: the configured agent command is in the launched shell command. +The inner command is passed through `shell-quote-argument', so spaces +are escaped (`\\\\ ') -- the regex below accepts either form." (let ((cj/ai-vterm-agent-command "agent --some-flag")) (should (string-match-p - "agent --some-flag" + "agent\\(\\\\\\)? --some-flag" (cj/--ai-vterm-launch-command "/code/foo"))))) (ert-deftest test-ai-vterm--launch-command-tails-with-exec-bash () - "Boundary: `exec bash' tails so the tmux window survives the agent exiting." + "Boundary: `exec bash' tails so the tmux window survives the agent exiting. +Accepts the post-`shell-quote-argument' shape (`exec\\\\ bash')." (let ((cj/ai-vterm-agent-command "agent")) (should (string-match-p - "exec bash" + "exec\\(\\\\\\)? bash" (cj/--ai-vterm-launch-command "/code/foo"))))) +(ert-deftest test-ai-vterm--launch-command-survives-single-quote-in-agent () + "Normal: a user-customized agent command containing a single quote +shouldn't break the shell parse. `shell-quote-argument' produces a +valid shell token regardless of the embedded quote shape -- the +escaping is implementation-detail, so we assert the literal words +\"hi\" and \"there\" both appear (the space between them may be +escaped as \\\\ )." + (let ((cj/ai-vterm-agent-command "agent --say 'hi there'")) + (let ((cmd (cj/--ai-vterm-launch-command "/code/foo"))) + (should (string-match-p "hi\\(\\\\\\)? there" cmd))))) + (ert-deftest test-ai-vterm--launch-command-handles-spaces-in-basename () "Boundary: a basename with whitespace becomes hyphenated before quoting." (let ((cj/ai-vterm-agent-command "agent") -- cgit v1.2.3