# Channels - Menu (Step 2 sources, Step 3a preview, Step 3b picker rules)

> Loaded by `channels/SKILL.md` Step 2. The SKILL keeps the step order and the autopilot rule; this file carries the context-source table, the summary-first preview logic, the greyed-out rules and the first-run defaults. Read it before Step 2.

## Step 2  -  Context sources

Automatic. The generator picks the best-available source:

| Source | Available when | Used for |
|---|---|---|
| **Pipeline log** | `$HOME/.claude/logs/multi-agent/<project>/<task-id>/agent-log.md` exists AND matches `jiraId` | "Normal analiz" + "Test senaryoları" content options  -  uses Phase 1/2/4 output verbatim |
| **PR diff** | PR exists, diff fetchable (`gh pr diff` or Bitbucket `/diff?contextLines=5`) | "Auto-diff summary" content option  -  old enrich behavior |
| **Manual message** | `--message` / `--message-file` provided | Replaces both sources  -  user text is canonical |

## Step 3a  -  Work Summary preview (summary-first flow)

**Runs only when** (a) `agent-state.json` exists for the task AND (b) a Work Summary can be generated (same availability rule as the "Yapılan iş özeti" content row). Purpose: give the user an instant "what did this ship?" answer BEFORE they pick channels. They see the outcome first, then decide where to route it  -  instead of the reverse.

```bash
preview=$(bash $HOME/.claude/scripts/render-work-summary.sh "$TASK_ID" 2>/dev/null || true)
[ -n "$preview" ] && {
  printf '%s\n\n' "$preview"
  # Auto-tick workSummary content row when preview was shown.
  # Users can still untick it in 3b if they don't want to re-send the same
  # block to remote channels (useful when preview was enough for a look).
  content_defaults.workSummary=true
}
```

When the preview renders:
- **workSummary** row in 3b is **auto-ticked** (user can still uncheck).
- Previous `prefs.global.reportContent.workSummary` value is respected  -  if the user had explicitly unticked in a prior run, the auto-tick is **suppressed** and the ticked state matches the pref.

When the preview does NOT render (no state, or pref explicitly off at global level with no override):
- Skip 3a silently, go straight to the channels picker. The workSummary row in 3b stays at its pref default (`false`).

After the preview prints, 3b renders the two pickers: **Channels** (PR description, Jira comment, Confluence page, Wiki, Board; each unavailable one greyed with its reason) and **Content** (normal analysis, technical analysis, test scenarios, test run, PR auto-diff, manual note, cost summary, work summary).

**Why auto-tick:** the user just saw the summary and is most likely sending it; the explicit pref still wins.

## Step 3b  -  Channel + content picker

**Greyed-out rules:**
- "Wiki" unselectable unless `state.taskType === "component"` AND `figmaConfig.wiki.enabled === true`. If greyed, show reason: `"(no figma-config or taskType != component)"`.
- "Board" unselectable unless `figmaConfig.board.enabled === true` AND `figmaConfig.board.provider === "github-projects-v2"` AND `figmaConfig.github.projectV2Id` set. If greyed, show reason: `"(no figma-config.board or projectV2Id missing)"`. Default target column: `inReview`.
- "Normal analiz" + "Test senaryoları" unselectable if no pipeline log found. Reason: `"(no pipeline log for PROJ-12345)"`.
- "Teknik analiz" unselectable if no Phase 1 planning log AND no PR diff available. Reason: `"(no technical source  -  need Phase 1 plan or PR diff)"`.
- "Auto-diff" unselectable if no PR found. Reason: `"(no PR linked to this target)"`.
- "Manuel not" always available. "Test Koşumu (Xray)": `channels/test-run.md`.
- "Cost özeti" unselectable if `phase-tracker.sh cost total` prints `-` (no priced token tallies; there is no `status` action) AND no `otel-spans.jsonl` exists for the task. Reason: `"(no tracker data  -  set MULTI_AGENT_OTEL_SPANS=1 or enable token tracking)"`.
- "Yapılan iş özeti" unselectable if no `agent-state.json` exists for the task (post-hoc call with `--branch` + `--base-branch` flags restores partial availability). Reason: `"(no agent-state.json for {taskId})"`. **Auto-ticked** when Step 3a preview was shown  -  user can still uncheck before confirming the menu.

One line above the picker says the report file is written on every run, and where. It is not a row and needs no tick (`channels/report-file.md`). **Zero channels ticked is a valid selection** and means file-only: the bodies are composed and written to disk, and nothing is posted. When no channel is selectable at all, print the greyed rows with their reasons as text and ask only Content.

**Defaults (first run):** PR + Jira ticked, Confluence + Wiki unticked. The report file needs no tick. Content: auto-diff if pipeline log missing; otherwise normal-analiz + test-senaryoları.

Saved to `prefs.global.reportChannels` and `prefs.global.reportContent`  -  next run uses these as defaults.
