@@ -56,12 +56,13 @@ When this is nil, the default of '/workspaces/<repo-name>' is used."
5656(defvar codespaces--validated nil
5757 " Whether the gh CLI has been validated for codespaces access." )
5858
59+ (with-current-buffer (get-buffer-create " *codespaces-output*" )
60+ (special-mode ))
61+
5962(defun codespaces--validate-gh ()
6063 " Validate that `gh' is available and properly configured.
6164This check is performed lazily on first use rather than at setup time."
6265 (unless codespaces--validated
63- (with-current-buffer (get-buffer-create " *codespaces-output*" )
64- (special-mode ))
6566 (unless (executable-find " gh" )
6667 (user-error " Could not find `gh' program in your PATH" ))
6768 (unless (featurep 'json )
@@ -168,15 +169,35 @@ allowing for faster startup. Validation happens lazily on first use."
168169 finally return result))
169170
170171(defun codespaces--send-start-async (cs )
171- " Send an `echo' command to CS over ssh."
172- (codespaces--locally
173- (async-shell-command (format " gh codespace ssh -c %s echo 'Codespace ready.' " (codespaces-space-name cs)))))
172+ " Send an `echo' command to CS over ssh asynchronously."
173+ (let ((display-buffer-alist
174+ (list (cons " \\ *codespaces-output\\ *.*"
175+ (cons #'display-buffer-no-window nil )))))
176+ (message " Activating codespace... Check *codespaces-output* for progress. " )
177+ (async-shell-command
178+ (format " gh codespace ssh -c %s echo 'Codespace ready.' "
179+ (codespaces-space-name cs))
180+ " *codespaces-output*" )
181+ (set-process-sentinel
182+ (get-buffer-process " *codespaces-output*" )
183+ (lambda (_process event )
184+ (if (string-match-p " finished" event)
185+ (message " Codespace ready " )
186+ (user-error
187+ " Command `gh codespace ssh` failed... [See *codespaces-output* buffer for details]" ))))))
174188
175189(defun codespaces--send-start-sync (cs )
176190 " Send an `echo' command to CS over ssh synchronously."
177- (codespaces--locally
178- (shell-command
179- (format " gh codespace ssh -c %s echo 'Codespace ready.' " (codespaces-space-name cs)) (get-buffer shell-command-buffer-name))))
191+ (let ((inhibit-read-only t ))
192+ (codespaces--locally
193+ (let ((status
194+ (shell-command
195+ (format " gh codespace ssh -c %s echo 'Codespace ready.' "
196+ (codespaces-space-name cs))
197+ nil " *codespaces-output*" )))
198+ (unless (zerop status)
199+ (user-error
200+ " Command `gh codespace ssh` failed ... [See *codespaces-output* buffer for details]" ))))))
180201
181202(defun codespaces--send-stop-sync (cs )
182203 " Tell codespaces CS to stop."
0 commit comments