Function: claude-code-ide-toggle

claude-code-ide-toggle is an interactive and natively compiled function defined in claude-code-ide.el.

Signature

(claude-code-ide-toggle &optional PICK)

Documentation

Toggle the current project's Claude Code windows as a panel.

When any of the project's instances is visible, hide them all and remember the set; otherwise restore the remembered set, falling back to the most recently used instance. With prefix argument PICK, choose a single instance and toggle only its window. Tab-bar tabs keep independent window layouts, so hiding and restoring apply to the current tab only.

Key Bindings

This command is not in any keymaps.

Aliases

claude-code-ide-toggle-window (obsolete since 0.3.0)

Source Code

;; Defined in /nix/store/yjvbhwl7p6zrbw9xlnni7y4hra8sa3pl-emacs-packages-deps/share/emacs/site-lisp/claude-code-ide.el
;;;###autoload
(defun claude-code-ide-toggle (&optional pick)
  "Toggle the current project's Claude Code windows as a panel.
When any of the project's instances is visible, hide them all and
remember the set; otherwise restore the remembered set, falling back
to the most recently used instance.  With prefix argument PICK,
choose a single instance and toggle only its window.
Tab-bar tabs keep independent window layouts, so hiding and restoring
apply to the current tab only."
  (interactive "P")
  (let* ((project-dir (claude-code-ide--get-working-directory))
         (sessions (claude-code-ide-mcp--sessions-for-project project-dir)))
    (unless sessions
      (user-error "No Claude Code session for this project"))
    (if pick
        (when-let* ((session (claude-code-ide--read-project-session
                              "Toggle Claude instance: " project-dir)))
          (claude-code-ide--toggle-existing-window session))
      (let ((visible (claude-code-ide--visible-project-sessions project-dir)))
        (if visible
            (progn
              (claude-code-ide--hidden-panel-set project-dir visible)
              (dolist (session visible)
                (claude-code-ide--toggle-existing-window session))
              ;; Stay silent for a single window, matching the
              ;; single-instance behavior before panels existed
              (when (cdr visible)
                (message "Hid %d Claude Code windows" (length visible))))
          ;; Restore the remembered set (skipping stopped instances),
          ;; else show the most recently used instance
          (let ((restore (or (cl-remove-if-not (lambda (s) (memq s sessions))
                                               (claude-code-ide--hidden-panel-get project-dir))
                             (list (claude-code-ide-mcp--mru-session project-dir)))))
            (claude-code-ide--hidden-panel-set project-dir nil)
            (dolist (session restore)
              (claude-code-ide--toggle-existing-window session))))))))