> For the complete documentation index, see [llms.txt](https://ai-os-and-trend-finder.gitbook.io/ai-os-and-trend-finder-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ai-os-and-trend-finder.gitbook.io/ai-os-and-trend-finder-docs/.spec_system/archive/phases/phase_17/session_02_chat_tab_write.md).

# Session 02: Chat Tab (Write: Send + Image Upload)

**Session ID**: `phase17-session02-chat-tab-write` **Status**: Not Started **Estimated Tasks**: \~16-22 **Estimated Duration**: 3-4 hours

***

## Objective

Add the Chat tab as a modular write feature: a chat surface that sends messages through the already-wired chat endpoint, reads threads from the sessions endpoints, and attaches images via the new confined image-upload endpoint. Source-code anchors are the V23 chat components and image-upload client/handler references listed below.

***

## Scope

### In Scope (MVP)

* Source components (decompose into aios modules): `HermesChat` V23 `agents.hermes.tsx:2114`, `HermesChatActive` `:2141`, `ChatSidebar` `:2825`, `SessionPill` `:3010`, `ChatBubble` `:3100`, `UserAvatar` `:3144`, `HermesAvatar` `:3199`, `ChatTyping` `:3224`, `ChatEmptyState` `:3074`.
* Target: new `AIOS/src/components/hermes/chat/` plus a new `Chat` tab added to `hermes-read-only-page.tsx` (TabsList `:150`, TabsContent `:177-189`).
* **Send (write):** already wired server-side at `hermes-admin-bridge.ts:660` (Write Inventory #1, command-exec, args-array spawn `:696`, binPath verify, timeout, redaction `:27`). Add the client mutation in `use-hermes-admin.ts` (template mutations at `:272/:283/:294`). v2.3 client send `agents.hermes.tsx:2394`.
* **Threads (read):** read via `/__hermes_sessions` + `/__hermes_session` (already wired) through `use-hermes.ts`.
* **Image attach (write):** via the new `/__hermes_image_upload` endpoint (Write Inventory #6: body-size cap, content-type check, confined cache dir), added in Phase 16 Session 02 with its mutation in Phase 16 Session 03. v2.3 client image upload `agents.hermes.tsx:2175`.
* Write affordances disabled with an "admin mode required" hint when the token is absent (demo can never write).

### Out of Scope

* Pantheon/Memory/Mission/Documents/Mnemosyne/Connections surfaces.
* Server endpoint implementation (landed in Phase 16 Session 02).

***

## Prerequisites

* [ ] Phase 16 complete: chat mutation, sessions queries, and image-upload mutation present in the hooks; `/__hermes_image_upload` registered with security tests passing.
* [ ] Phase 17 Session 01 visual shell available.

***

## Deliverables

1. A modular Chat tab under `AIOS/src/components/hermes/chat/` wired into the tabs shell.
2. Client send mutation (through `useHermesAdmin`), thread reads, and image attach through the confined upload endpoint.
3. Mode-matrix coverage and an extension of `hermes-sections.test.tsx` for the new tab.

***

## Success Criteria

* [ ] The Chat tab renders threads, sends messages (admin-gated), and shows typing/empty states.
* [ ] Image attach respects the body-size cap and content-type check and writes only to the confined cache dir.
* [ ] No write occurs without the token; demo mode shows the disabled affordance with the admin-mode hint.
* [ ] Mode matrix renders (demo/live/setup-required/offline/endpoint-error); typecheck, lint, and tests pass.


---

# 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://ai-os-and-trend-finder.gitbook.io/ai-os-and-trend-finder-docs/.spec_system/archive/phases/phase_17/session_02_chat_tab_write.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.
