> For the complete documentation index, see [llms.txt](https://faction-os.gitbook.io/faction-os-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://faction-os.gitbook.io/faction-os-docs/.spec_system/archive/sessions/phase02-session02-cockpit-shell-and-navigation-cohesion/implementation-notes.md).

# Implementation Notes

**Session ID**: `phase02-session02-cockpit-shell-and-navigation-cohesion` **Package**: apps/web **Started**: 2026-05-29 06:55 **Last Updated**: 2026-05-29 07:19

***

## Session Progress

| Metric              | Value     |
| ------------------- | --------- |
| Tasks Completed     | 22 / 22   |
| Estimated Remaining | 3-4 hours |
| Blockers            | 0         |

***

## Baseline Evidence

**Environment verified**:

* [x] Spec system present and state valid
* [x] Package registered: `apps/web`
* [x] Workspace manager available: npm 10.5.1
* [x] Required tools available: node v24.14.0, npm 10.5.1
* [x] Directory structure ready

**Baseline focused shell tests**:

* `npm test -- apps/web/tests/CommandPalette.test.tsx apps/web/tests/keyboardShortcuts.test.ts apps/web/tests/KeyboardShortcutsModal.test.tsx apps/web/tests/useSettingsStore.test.ts apps/web/tests/SettingsScan.test.tsx`
* Result: passed, 5 files, 88 tests.

***

## Open Risk Log

* Title bar crowding can regress tablet layouts if command labels are too wide.
* Overlay state can drift if settings, palette, and shortcut help are controlled by separate local states.
* Global shortcuts can hijack typing targets if new routes bypass existing guards.
* War Room copy must avoid implying live web-to-Worker federation before Phase 05.

***

## Task Log

### 2026-05-29 - Session Start

**Environment verified**:

* [x] Prerequisites confirmed
* [x] Tools available
* [x] Directory structure ready
* [x] Package scope confirmed: `apps/web`

***

### Task T001 - Verify baseline requirements and shell tests

**Started**: 2026-05-29 06:55 **Completed**: 2026-05-29 06:56 **Duration**: 1 minute

**Notes**:

* Confirmed Session 02 package scope and prerequisites from `.spec_system/PRD/phase_02/session_02_cockpit_shell_and_navigation_cohesion.md`.
* Ran existing shell-adjacent test set before editing; all selected tests passed.

**Files Changed**:

* `.spec_system/specs/phase02-session02-cockpit-shell-and-navigation-cohesion/tasks.md` - marked T001 complete and updated progress summary.

***

### Task T002 - Create implementation notes

**Started**: 2026-05-29 06:56 **Completed**: 2026-05-29 06:56 **Duration**: 1 minute

**Notes**:

* Created implementation notes with baseline evidence, test commands, and risk log.
* Recorded package-level environment checks and the focused shell test baseline.

**Files Changed**:

* `.spec_system/specs/phase02-session02-cockpit-shell-and-navigation-cohesion/implementation-notes.md` - added baseline evidence, progress tracking, risk log, and task log.

***

### Task T003 - Create cockpit shell helper

**Started**: 2026-05-29 06:56 **Completed**: 2026-05-29 06:58 **Duration**: 2 minutes

**Notes**:

* Added pure metadata helpers for local-server status, shell actions, cockpit surfaces, and the War Room federation boundary.
* Kept local-first and deferred-state copy in one module for component and test reuse.

**Files Changed**:

* `apps/web/src/lib/cockpitShell.ts` - added status, surface, action, and War Room boundary metadata helpers.
* `.spec_system/specs/phase02-session02-cockpit-shell-and-navigation-cohesion/tasks.md` - marked T003 complete and updated progress summary.

**BQC Fixes**:

* Contract alignment: local-server states now map through a typed helper instead of scattered component copy (`apps/web/src/lib/cockpitShell.ts`).

***

### Task T004 - Test cockpit shell helper

**Started**: 2026-05-29 06:58 **Completed**: 2026-05-29 06:59 **Duration**: 1 minute

**Notes**:

* Added pure tests for local-server status mapping, offline surface state, shell action parity metadata, and War Room boundary copy.
* Ran the new focused test file successfully.

**Files Changed**:

* `apps/web/tests/cockpitShell.test.ts` - added helper coverage for status, surface, action, and War Room metadata.
* `.spec_system/specs/phase02-session02-cockpit-shell-and-navigation-cohesion/tasks.md` - marked T004 complete and updated progress summary.

**Validation**:

* `npm test -- apps/web/tests/cockpitShell.test.ts` - passed, 1 file, 10 tests.

**BQC Fixes**:

* Contract alignment: tests pin helper output for local-first and deferred War Room states (`apps/web/tests/cockpitShell.test.ts`).

***

### Task T005 - Add controlled settings drawer state

**Started**: 2026-05-29 06:59 **Completed**: 2026-05-29 07:00 **Duration**: 1 minute

**Notes**:

* Added `settingsDrawerOpen` and `setSettingsDrawerOpen` as transient Zustand state.
* The persisted snapshot remains limited to durable preferences, so drawer visibility does not survive reloads.

**Files Changed**:

* `apps/web/src/store/useSettingsStore.ts` - added transient settings drawer state and setter.
* `.spec_system/specs/phase02-session02-cockpit-shell-and-navigation-cohesion/tasks.md` - marked T005 complete and updated progress summary.

**BQC Fixes**:

* State freshness on re-entry: drawer open state now has one controlled source of truth and can be reset by shared close paths (`apps/web/src/store/useSettingsStore.ts`).

***

### Task T006 - Refactor SettingsDrawer controlled state

**Started**: 2026-05-29 07:00 **Completed**: 2026-05-29 07:01 **Duration**: 1 minute

**Notes**:

* Replaced drawer-local open state with `settingsDrawerOpen`.
* Kept Escape, outside click, and trigger dismissal behavior, added a backdrop click path, and refreshed notification permission only on drawer re-entry.
* Added unmount cleanup so transient drawer state cannot leak across tests or remounts.

**Files Changed**:

* `apps/web/src/components/SettingsDrawer.tsx` - consumed controlled drawer state, added backdrop dismissal, re-entry refresh, and unmount cleanup.
* `.spec_system/specs/phase02-session02-cockpit-shell-and-navigation-cohesion/tasks.md` - marked T006 complete and updated progress summary.

**Validation**:

* `npm test -- apps/web/tests/SettingsScan.test.tsx apps/web/tests/useSettingsStore.test.ts` - passed, 2 files, 16 tests.

**BQC Fixes**:

* Resource cleanup: unmount closes transient drawer state and removes open-scope event listeners (`apps/web/src/components/SettingsDrawer.tsx`).
* State freshness on re-entry: notification permission is re-read when the drawer opens (`apps/web/src/components/SettingsDrawer.tsx`).

***

### Task T007 - Route settings shortcut through controlled state

**Started**: 2026-05-29 07:01 **Completed**: 2026-05-29 07:02 **Duration**: 1 minute

**Notes**:

* Updated the `s` shortcut action to open the settings drawer through Zustand state instead of clicking a DOM trigger.
* Kept the existing DOM helper exported for compatibility with command-palette wiring until the catalog is aligned.

**Files Changed**:

* `apps/web/src/lib/useKeyboardShortcuts.ts` - routed settings shortcut to `setSettingsDrawerOpen(true)`.
* `.spec_system/specs/phase02-session02-cockpit-shell-and-navigation-cohesion/tasks.md` - marked T007 complete and updated progress summary.

**Validation**:

* `npm test -- apps/web/tests/keyboardShortcuts.test.ts` - passed, 1 file, 41 tests.

**BQC Fixes**:

* Resource cleanup: existing sequence timer cleanup remains scoped to hook unmount while settings opening no longer depends on external DOM state (`apps/web/src/lib/useKeyboardShortcuts.ts`).

***

### Task T008 - Refine responsive layout constraints

**Started**: 2026-05-29 07:02 **Completed**: 2026-05-29 07:02 **Duration**: 1 minute

**Notes**:

* Added tablet-scale three-column layout at `lg` with bounded side rails and desktop rail caps at `2xl`.
* Added `min-h-0`, `min-w-0`, and stable row constraints so rail content scrolls inside its region instead of resizing the shell.

**Files Changed**:

* `apps/web/src/components/Layout.tsx` - updated grid tracks, region constraints, and battlefield frame radius.
* `.spec_system/specs/phase02-session02-cockpit-shell-and-navigation-cohesion/tasks.md` - marked T008 complete and updated progress summary.

**BQC Fixes**:

* Accessibility and platform compliance: layout regions now preserve predictable focus and scroll containers across tablet and desktop sizes (`apps/web/src/components/Layout.tsx`).

***

### Task T009 - Rework TitleBar command strip

**Started**: 2026-05-29 07:02 **Completed**: 2026-05-29 07:05 **Duration**: 3 minutes

**Notes**:

* Rebuilt the title bar as the visible global shell command strip with direct palette, settings, shortcut help, heatmap, standings, leaderboard, tool usage, mission complexity, and trophy room controls.
* Moved the settings trigger out of `SettingsDrawer` so the shell owns the visible entry point.
* Added stable data attributes and accessible labels for pointer, keyboard, and test parity.

**Files Changed**:

* `apps/web/src/components/TitleBar.tsx` - replaced the scrolling status strip with a responsive command/status header.
* `apps/web/src/components/SettingsDrawer.tsx` - removed the fixed floating settings trigger; the TitleBar now supplies `data-settings-trigger`.
* `.spec_system/specs/phase02-session02-cockpit-shell-and-navigation-cohesion/tasks.md` - marked T009 complete and updated progress summary.

**Validation**:

* `npm --workspace apps/web run typecheck` - passed.

**BQC Fixes**:

* Accessibility and platform compliance: all visible shell controls have accessible names and stable trigger attributes (`apps/web/src/components/TitleBar.tsx`).

***

### Task T010 - Add local-server status treatment

**Started**: 2026-05-29 07:02 **Completed**: 2026-05-29 07:05 **Duration**: 3 minutes

**Notes**:

* Wired TitleBar status display through `getLocalServerStatus`.
* Added explicit idle, connecting, connected, disconnected, and no-server visual states without hosted-service claims.

**Files Changed**:

* `apps/web/src/components/TitleBar.tsx` - added local-server status badge, status tone styling, and no-server metadata.
* `.spec_system/specs/phase02-session02-cockpit-shell-and-navigation-cohesion/tasks.md` - marked T010 complete and updated progress summary.

**Validation**:

* `npm --workspace apps/web run typecheck` - passed.

**BQC Fixes**:

* Failure path completeness: disconnected and no-server states now show non-blocking local fallback copy (`apps/web/src/components/TitleBar.tsx`).

***

### Task T011 - Align command catalog to visible surfaces

**Started**: 2026-05-29 07:05 **Completed**: 2026-05-29 07:06 **Duration**: 1 minute

**Notes**:

* Routed the settings command through controlled drawer state to match the TitleBar and shortcut path.
* Kept deferred hosted and Worker federation surfaces out of the command catalog.
* Changed command label truncation to ASCII `...`.

**Files Changed**:

* `apps/web/src/lib/commandPalette.ts` - added controlled settings handler and ASCII label truncation.
* `apps/web/src/components/CommandPalette.tsx` - passed `setSettingsDrawerOpen` into the command catalog.
* `apps/web/tests/commandPaletteRanking.test.ts` - updated handler contract and catalog absence coverage.
* `.spec_system/specs/phase02-session02-cockpit-shell-and-navigation-cohesion/tasks.md` - marked T011 complete and updated progress summary.

**Validation**:

* `npm test -- apps/web/tests/commandPaletteRanking.test.ts apps/web/tests/CommandPalette.test.tsx` - passed, 2 files, 39 tests.

**BQC Fixes**:

* Contract alignment: settings command, settings shortcut, and TitleBar settings button now share the same controlled state (`apps/web/src/lib/commandPalette.ts`).

***

### Task T012 - Update CommandPalette interaction semantics

**Started**: 2026-05-29 07:06 **Completed**: 2026-05-29 07:07 **Duration**: 1 minute

**Notes**:

* Added combobox/listbox active-descendant wiring and active option scroll visibility.
* Added an explicit unavailable command rendering path and a local-only empty-result message.
* Replaced non-ASCII palette glyphs and keyboard footer arrows in the touched component.

**Files Changed**:

* `apps/web/src/components/CommandPalette.tsx` - improved focus, listbox semantics, empty state, unavailable rows, and ASCII display.
* `apps/web/src/lib/commandPalette.ts` - added optional command availability metadata.
* `.spec_system/specs/phase02-session02-cockpit-shell-and-navigation-cohesion/tasks.md` - marked T012 complete and updated progress summary.

**Validation**:

* `npm test -- apps/web/tests/CommandPalette.test.tsx apps/web/tests/commandPaletteRanking.test.ts` - passed, 2 files, 39 tests.

**BQC Fixes**:

* Accessibility and platform compliance: palette input now points to the active result with `aria-activedescendant` and keeps it visible (`apps/web/src/components/CommandPalette.tsx`).

***

### Task T013 - Update keyboard shortcut help semantics

**Started**: 2026-05-29 07:07 **Completed**: 2026-05-29 07:08 **Duration**: 1 minute

**Notes**:

* Updated shortcut descriptions to match controlled settings, replay toggle behavior, and current shell routes.
* Added `aria-describedby` and initial close-button focus for the shortcuts dialog.
* Replaced the close glyph with ASCII text in the touched modal.

**Files Changed**:

* `apps/web/src/lib/useKeyboardShortcuts.ts` - updated help labels for implemented routes.
* `apps/web/src/components/KeyboardShortcutsModal.tsx` - improved dialog description, close focus, and close button display.
* `.spec_system/specs/phase02-session02-cockpit-shell-and-navigation-cohesion/tasks.md` - marked T013 complete and updated progress summary.

**Validation**:

* `npm test -- apps/web/tests/KeyboardShortcutsModal.test.tsx apps/web/tests/keyboardShortcuts.test.ts` - passed, 2 files, 55 tests.

**BQC Fixes**:

* Accessibility and platform compliance: dialog now exposes a description and focuses a stable close control on open (`apps/web/src/components/KeyboardShortcutsModal.tsx`).

***

### Task T014 - Improve first-run FactionPicker context

**Started**: 2026-05-29 07:08 **Completed**: 2026-05-29 07:09 **Duration**: 1 minute

**Notes**:

* Added dialog labeling and description wiring to the first-run faction picker.
* Added local-server status context using the shared cockpit helper and clarified that faction setup does not require a hosted account.

**Files Changed**:

* `apps/web/src/components/FactionPicker.tsx` - added dialog semantics, local status copy, and ASCII local-first text.
* `.spec_system/specs/phase02-session02-cockpit-shell-and-navigation-cohesion/tasks.md` - marked T014 complete and updated progress summary.

**Validation**:

* `npm --workspace apps/web run typecheck` - passed.

**BQC Fixes**:

* Accessibility and platform compliance: first-run picker now has dialog labeling and description linkage (`apps/web/src/components/FactionPicker.tsx`).
* Failure path completeness: no-server/local fallback context is visible before faction selection (`apps/web/src/components/FactionPicker.tsx`).

***

### Task T015 - Rewrite WarRoomPanel as honest stub

**Started**: 2026-05-29 07:09 **Completed**: 2026-05-29 07:10 **Duration**: 1 minute

**Notes**:

* Removed fake room join state and synthetic participant rows.
* Rendered the web panel as a disabled Phase 05 stub that points to the separate Worker backend boundary.

**Files Changed**:

* `apps/web/src/components/WarRoomPanel.tsx` - replaced simulated federation behavior with static separate-surface stub copy and disabled action.
* `.spec_system/specs/phase02-session02-cockpit-shell-and-navigation-cohesion/tasks.md` - marked T015 complete and updated progress summary.

**Validation**:

* `npm --workspace apps/web run typecheck` - passed.

**BQC Fixes**:

* Trust boundary enforcement: the panel no longer implies a live relay or participant transfer path exists in the web package (`apps/web/src/components/WarRoomPanel.tsx`).

***

### Task T016 - Wire shell-level rail state affordances

**Started**: 2026-05-29 07:10 **Completed**: 2026-05-29 07:12 **Duration**: 2 minutes

**Notes**:

* Wrapped mission, notice, roster, scroll, quest, and War Room regions with shell surface metadata.
* Added compact loading, empty, offline, and disconnected state strips driven by local-server status and region counts.
* Extended the helper surface status model with loading and disconnected/error copy.

**Files Changed**:

* `apps/web/src/App.tsx` - added shell surface wrappers, counts, and visible state notes.
* `apps/web/src/lib/cockpitShell.ts` - added loading and disconnected/error surface status metadata.
* `.spec_system/specs/phase02-session02-cockpit-shell-and-navigation-cohesion/tasks.md` - marked T016 complete and updated progress summary.

**Validation**:

* `npm --workspace apps/web run typecheck` - passed.

**BQC Fixes**:

* Failure path completeness: shell regions now show explicit non-blocking loading, empty, offline, and disconnected state copy (`apps/web/src/App.tsx`).

***

### Task T017 - Document web shell behavior

**Started**: 2026-05-29 07:12 **Completed**: 2026-05-29 07:13 **Duration**: 1 minute

**Notes**:

* Documented the TitleBar command strip, local-server status boundary, command/shortcut parity, shell region state wrappers, and War Room stub boundary.

**Files Changed**:

* `apps/web/README_web.md` - added the cockpit shell behavior contract.
* `.spec_system/specs/phase02-session02-cockpit-shell-and-navigation-cohesion/tasks.md` - marked T017 complete and updated progress summary.

**BQC Fixes**:

* Contract alignment: package docs now describe the implemented local-first shell and War Room stub boundary (`apps/web/README_web.md`).

***

### Task T018 - Add cockpit shell component tests

**Started**: 2026-05-29 07:13 **Completed**: 2026-05-29 07:14 **Duration**: 1 minute

**Notes**:

* Added component coverage for visible shell controls, settings/help/palette reachability, no-server/disconnected/loading states, and the War Room stub boundary.
* Mocked only side-effect hooks for sockets, audio, notifications, and replay fragment bootstrapping.

**Files Changed**:

* `apps/web/tests/CockpitShell.test.tsx` - added App-level shell component coverage.
* `.spec_system/specs/phase02-session02-cockpit-shell-and-navigation-cohesion/tasks.md` - marked T018 complete and updated progress summary.

**Validation**:

* `npm test -- apps/web/tests/CockpitShell.test.tsx` - passed, 1 file, 6 tests.

**BQC Fixes**:

* Contract alignment: tests cover pointer reachability, local-server failure states, and War Room stub copy (`apps/web/tests/CockpitShell.test.tsx`).

***

### Task T019 - Extend command palette tests

**Started**: 2026-05-29 07:14 **Completed**: 2026-05-29 07:15 **Duration**: 1 minute

**Notes**:

* Added component assertions that visible shell actions are searchable in the palette.
* Added absence coverage for deferred War Room and Worker federation commands.
* Added controlled drawer state activation coverage for the settings command.

**Files Changed**:

* `apps/web/tests/CommandPalette.test.tsx` - extended component coverage for shell command parity and deferred command absence.
* `.spec_system/specs/phase02-session02-cockpit-shell-and-navigation-cohesion/tasks.md` - marked T019 complete and updated progress summary.

**Validation**:

* `npm test -- apps/web/tests/CommandPalette.test.tsx apps/web/tests/commandPaletteRanking.test.ts` - passed, 2 files, 42 tests.

**BQC Fixes**:

* Contract alignment: palette tests now verify visible shell controls and deferred federation command absence (`apps/web/tests/CommandPalette.test.tsx`).

***

### Task T020 - Extend shortcut and help tests

**Started**: 2026-05-29 07:15 **Completed**: 2026-05-29 07:16 **Duration**: 1 minute

**Notes**:

* Added hook integration coverage for the controlled settings route.
* Verified typing-target guards prevent the settings shortcut from opening while the user is typing.
* Added assertions for updated shortcut help labels.

**Files Changed**:

* `apps/web/tests/keyboardShortcuts.test.ts` - added hook integration and help label coverage.
* `.spec_system/specs/phase02-session02-cockpit-shell-and-navigation-cohesion/tasks.md` - marked T020 complete and updated progress summary.

**Validation**:

* `npm test -- apps/web/tests/keyboardShortcuts.test.ts apps/web/tests/KeyboardShortcutsModal.test.tsx` - passed, 2 files, 58 tests.

**BQC Fixes**:

* Duplicate action prevention: shortcut tests keep single-key settings routing guarded from typing targets (`apps/web/tests/keyboardShortcuts.test.ts`).

***

### Task T021 - Run focused tests and typecheck

**Started**: 2026-05-29 07:16 **Completed**: 2026-05-29 07:17 **Duration**: 1 minute

**Notes**:

* Ran the focused shell/navigation web test set and package typecheck.
* Fixed the existing Settings scan test harness to open the controlled drawer state after the TitleBar took ownership of the visible trigger.

**Files Changed**:

* `apps/web/tests/SettingsScan.test.tsx` - updated the drawer open harness to use controlled state.
* `.spec_system/specs/phase02-session02-cockpit-shell-and-navigation-cohesion/tasks.md` - marked T021 complete and updated progress summary.

**Validation**:

* `npm test -- apps/web/tests/cockpitShell.test.ts apps/web/tests/CockpitShell.test.tsx apps/web/tests/CommandPalette.test.tsx apps/web/tests/commandPaletteRanking.test.ts apps/web/tests/keyboardShortcuts.test.ts apps/web/tests/KeyboardShortcutsModal.test.tsx apps/web/tests/SettingsScan.test.tsx apps/web/tests/useSettingsStore.test.ts` - passed, 8 files, 132 tests.
* `npm --workspace apps/web run typecheck` - passed.

**BQC Fixes**:

* Contract alignment: legacy settings tests now use the same controlled drawer state as the shell (`apps/web/tests/SettingsScan.test.tsx`).

***

### Task T022 - ASCII and viewport smoke validation

**Started**: 2026-05-29 07:17 **Completed**: 2026-05-29 07:19 **Duration**: 2 minutes

**Notes**:

* Normalized touched files to ASCII-only content and re-ran focused tests plus typecheck after the normalization.
* Started the Vite dev server at `http://127.0.0.1:5173/` for browser smoke checks.
* Ran Playwright smoke checks at desktop `1440x900` and tablet `1024x768`.
* Both viewport checks reported all 9 shell control buttons visible, no button overlap, no document horizontal overflow, settings/help/palette reachable, and 5 shell surface state notes visible for local no-server fallback.

**Files Changed**:

* `.spec_system/specs/phase02-session02-cockpit-shell-and-navigation-cohesion/implementation-notes.md` - recorded final validation evidence.
* `.spec_system/specs/phase02-session02-cockpit-shell-and-navigation-cohesion/tasks.md` - marked T022 complete and updated progress summary.

**Validation**:

* `LC_ALL=C rg -n "[^[:ascii:]]" <touched session files>` - passed, no matches.
* `npm test -- apps/web/tests/cockpitShell.test.ts apps/web/tests/CockpitShell.test.tsx apps/web/tests/CommandPalette.test.tsx apps/web/tests/commandPaletteRanking.test.ts apps/web/tests/keyboardShortcuts.test.ts apps/web/tests/KeyboardShortcutsModal.test.tsx apps/web/tests/SettingsScan.test.tsx apps/web/tests/useSettingsStore.test.ts` - passed, 8 files, 132 tests.
* `npm --workspace apps/web run typecheck` - passed.
* Playwright smoke screenshots: `/tmp/factionos-desktop-shell-smoke.png`, `/tmp/factionos-tablet-shell-smoke.png`.

**BQC Fixes**:

* Accessibility and platform compliance: desktop and tablet smoke checks confirmed visible shell controls, dialog reachability, no control overlap, and no horizontal document overflow.

***

## Final Validation Summary

| Check                        | Result                     |
| ---------------------------- | -------------------------- |
| Focused shell tests          | Passed: 8 files, 132 tests |
| Web typecheck                | Passed                     |
| ASCII check on touched files | Passed                     |
| Desktop smoke, 1440x900      | Passed                     |
| Tablet smoke, 1024x768       | Passed                     |
| Blockers                     | 0                          |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://faction-os.gitbook.io/faction-os-docs/.spec_system/archive/sessions/phase02-session02-cockpit-shell-and-navigation-cohesion/implementation-notes.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
