#Dock

Dock ช่วยให้คุณเพิ่มตัวควบคุมเทอร์มินัลและเบราว์เซอร์ไปยังแถบด้านขวาได้ ตัวควบคุมเทอร์มินัลเรียกใช้คำสั่งในส่วนที่ใช้ Ghostty เป็นฐาน ส่วนตัวควบคุมเบราว์เซอร์ฝังหน้าเว็บ ใช้สำหรับ feed, logs, queues, git status, dev servers, dashboards หรือหน้าอ้างอิงที่ทีมอยากให้อยู่ข้าง workspace ทุกอัน

#การตั้งค่า

cmux ค้นหาการตั้งค่า Dock ตามลำดับนี้:

  1. .cmux/dock.json สำหรับ repo ปัจจุบัน โปรเจกต์แม่ที่ใกล้ที่สุด และไดเรกทอรีโปรเจกต์ที่ซ้อนอยู่
  2. ~/.config/cmux/dock.json สำหรับ Dock เริ่มต้นส่วนตัวของคุณ หรือเมื่อไม่มี repo
ถ้ามีทั้ง config ของโปรเจกต์และ config แบบ global ระบบจะใช้ config ของโปรเจกต์ก่อน config ของโปรเจกต์ที่ซ้อนอยู่จะมีผลกับ tree ไดเรกทอรีของมัน ถ้าไม่มี config ของโปรเจกต์ Dock จะใช้ config แบบ global ถ้าไม่มีไฟล์ใดเลย Dock จะเปิดแบบว่าง
การตั้งค่า Dock ของโปรเจกต์สามารถเริ่มคำสั่งได้ cmux จะขอให้คุณ trust การตั้งค่าโปรเจกต์ก่อนเปิดคอนโทรล

#ตัวอย่าง dock.json

ไฟล์ Dock คือ JSON object ที่มี controls array ให้ commit controls ของโปรเจกต์ไว้ใน .cmux/dock.json เมื่อต้องการให้เพื่อนร่วมทีมใช้ Dock เดียวกัน แทนที่ command ตัวอย่างด้วยเครื่องมือที่ repo ของคุณมีจริง

.cmux/dock.json
{
  "controls": [
    {
      "id": "git",
      "title": "Git",
      "command": "lazygit",
      "height": 300
    },
    {
      "id": "logs",
      "title": "Logs",
      "command": "tail -f ./logs/development.log",
      "cwd": "."
    },
    {
      "id": "feed",
      "title": "Feed",
      "command": "cmux feed tui --opentui",
      "height": 320
    },
    {
      "id": "dashboard",
      "title": "Dashboard",
      "type": "browser",
      "url": "http://127.0.0.1:8877/sidebar",
      "chrome": false
    }
  ]
}

#ฟิลด์

ฟิลด์คำอธิบาย
idตัวระบุที่เสถียรและไม่ซ้ำสำหรับคอนโทรล ควรสั้นและไม่ใช้ซ้ำกับคำสั่งอื่น
titleป้ายชื่อที่แสดงในหัว Dock
commandคำสั่งที่จะเรียกใช้ในเทอร์มินัล Dock จำเป็นสำหรับตัวควบคุมเทอร์มินัลและเริ่มทำงานใน login shell
typeประเภทตัวควบคุม (ไม่บังคับ): terminal (ค่าเริ่มต้น) หรือ browser
urlหน้าที่จะเปิด จำเป็นสำหรับตัวควบคุมเบราว์เซอร์
chromeการแสดงส่วนควบคุมเบราว์เซอร์ (ไม่บังคับ) ค่าเริ่มต้นคือ true; false จะซ่อนแถบที่อยู่และแถบเครื่องมือ ทำให้ “โฟกัสแถบที่อยู่” ไม่มีผลในบานหน้าต่างนั้น และยังใช้ cmux browser goto/reload ได้
cwdไดเรกทอรีทำงานเสริม เส้นทางแบบ relative จะอิงจาก project root สำหรับ project config หรือจาก home directory สำหรับ global config
heightความสูงของตัวควบคุม (ไม่บังคับ) ตัวควบคุมที่ไม่มี height จะแบ่งพื้นที่ที่เหลือร่วมกัน
envตัวแปรสภาพแวดล้อมเสริมที่ส่งให้เฉพาะคอนโทรลนั้น

#แชร์กับทีม

Dock ถูกออกแบบมาให้แชร์ผ่าน source control เมื่อคำสั่งเป็นของ repo

  • ใส่คอนโทรลเฉพาะ repo ไว้ใน .cmux/dock.json แล้ว commit ไฟล์นั้น
  • ใส่ controls ส่วนตัวไว้ใน ~/.config/cmux/dock.json โดยเฉพาะเมื่ออยู่นอก repo และอย่านำไฟล์นี้เข้า source control ที่ใช้ร่วมกัน
  • อย่าใส่ secrets ใน dock.json ให้อ่าน secrets จาก shell, ไฟล์ env ในเครื่อง หรือเครื่องมือพัฒนาที่มีอยู่

#ให้ agent ตั้งค่าให้

ใช้ prompt นี้เมื่อต้องการให้ coding agent สร้าง Dock controls โดย prompt จะบอกให้ agent รัน `cmux docs dock`, ตรวจดูโปรเจกต์ และถามก่อนเดา

Agent prompt
Set up cmux Dock controls for the current context.

First, learn the feature before editing:
1. Run `cmux docs dock` if the cmux CLI is available. If it is not, read https://cmux.com/docs/dock.
2. Inspect the repository or current directory to understand the project type, scripts, package manager, dev servers, logs, task runners, test commands, and any existing TUI tools.
3. If the desired Dock is ambiguous, ask the user what they want monitored or controlled before writing files.

Dock is cmux's right-sidebar terminal and browser control area. A Dock config is JSON with a top-level `controls` array. Terminal controls run commands in Ghostty-backed sections using the user's login shell; browser controls embed URLs. Controls are useful for project dashboards, git/status views, dev server or build status, test watchers, log tails, queues, local services, or fixed web dashboards.

Choose where to write the config:
- In a repository or project directory, create or edit `.cmux/dock.json` so teammates can share it.
- For a personal default outside a repo, create or edit `~/.config/cmux/dock.json`.
- If both exist, project `.cmux/dock.json` is more specific for that project. Nested project configs apply to that directory tree; use the nearest relevant project config instead of writing unrelated controls globally.
- If there is no repo and no clear project root, use the global config only after confirming the user wants a personal Dock.

Schema:
{
  "controls": [
    {
      "id": "short-stable-id",
      "title": "Human label",
      "command": "safe command to run",
      "cwd": "optional/path",
      "height": 220,
      "env": { "NAME": "value" }
    },
    {
      "id": "dashboard",
      "title": "Dashboard",
      "type": "browser",
      "url": "http://127.0.0.1:3000",
      "chrome": false
    }
  ]
}

Rules:
- Keep ids stable, lowercase, and unique.
- `type` is optional: `terminal` is the default, or use `browser`.
- Terminal controls require `command`; browser controls require `url`.
- Browser controls default to `chrome: true`. Set `chrome: false` to hide browser chrome, including the address bar and toolbar; Focus Address Bar then does nothing for that pane, while `cmux browser goto` and `cmux browser reload` remain available.
- Use `cwd` for subdirectories; relative paths resolve from the config base.
- Use `height` only when a control needs a fixed amount of vertical space.
- Use `env` only for non-secret values needed by one control.
- Do not put secrets, tokens, or machine-specific private paths in a shared project config.
- Prefer commands that are safe to start repeatedly and make sense in a terminal.
- Do not invent unavailable scripts. Read package files, Makefiles, Procfiles, README docs, config files, and existing tooling first.
- Keep shared project Docks portable for teammates. Put personal or machine-specific controls in the global Dock.

Deliverable:
- Create or update the appropriate dock.json.
- Preserve existing useful controls unless the user asked to replace them.
- Validate that the JSON parses.
- Summarize what each control does and any commands the user should review before trusting the Dock config.