aws-samples / aws-samples/agents4energy
Remove the /chat page (direct HarnessChatTransport surface)
- Dominant language
- TypeScript
- Stars
- 48
- Forks
- 68
- PR merge metrics
- No merged PRs in 30d
Description
## Background
The repo currently has two chat surfaces:
- **`/chat`** (`web/app/(with-auth)/chat/page.tsx`) — uses `HarnessChatTransport` (`web/lib/agentcore-transport.ts`) to `POST /harnesses/invoke` directly from the browser and decode the binary AWS event stream client-side (`web/lib/aws-event-stream.ts`). Each browser tab owns its own HTTP connection to the harness; there's no fan-out, so this surface fundamentally can't support multiple clients watching the same session (see #168).
- **`/chat-handler`** (`web/app/(with-auth)/chat-handler/page.tsx`) — routes through AG-UI events over AppSync (`invokeHandler` mutation + `onAgentEvent` subscription), which already supports N concurrent subscribers per `sessionId`.
Per discussion in #168, `/chat-handler`'s AppSync-based architecture is the one being extended (multi-site session viewing, late-joiner replay), and the direct-harness `/chat` surface is redundant now that `/chat-handler` covers the same functionality plus more. Keeping both increases maintenance surface for no benefit.
## Scope
- [ ] Remove `web/app/(with-auth)/chat/` (`page.tsx`, `use-agents.ts`, `use-chat-session.ts`, `use-initial-messages.ts` — note `use-initial-messages.ts` is currently imported by `chat-handler/page.tsx` too, so it needs to move rather than just delete)
- [ ] Update `web/app/page.tsx` — currently `redirect("/chat")`; point it at `/chat-handler` (or wherever agent selection lands)
- [ ] Remove/replace `web/lib/agentcore-transport.ts` and `web/lib/aws-event-stream.ts` if nothing else uses them (confirm no other consumers first)
- [ ] Remove `web/e2e/chat.spec.ts`, keep `web/e2e/chat-handler.spec.ts` as the canonical chat e2e test
- [ ] Check whether `invoke-agent` Lambda (`web/amplify/functions/invoke-agent/`) and its wiring in `agentConfig.schema.ts` / `backend.ts` are only used by `/chat` — if so, remove them too; if `agents` page or agent-config admin flow depends on them independently, keep and note the dependency
- [ ] Update docs referencing `/chat` / `HarnessChatTransport`: `docs/architecture.md`, `docs/agentic-architecture.md`, `docs/agentcore-transport-investigation.md`, `docs/ai-sdk-chatbot.md`, `docs/ag-ui-handler-pattern.md`, `docs/github-integration.md`, `docs/e2e-testing.md`
- [ ] Update `AGENTS.md`/`CLAUDE.md` if they reference `/chat` specifically (they don't currently, just noting for completeness)
## Open question
Does the `MyHarness` AgentCore resource (`agent/default/app/MyHarness/harness.json`) itself become unused once `/chat` and its Lambda invocation path are gone, or is it still needed for something else (e.g. `scripts/invoke.ts` CLI testing)? Worth confirming before deleting harness config, since `agentcore.json` treats renames/removals as destroy+recreate.
Filed per request in https://github.com/waltmayf/agentcore-amplify-fullstack/issues/66#issuecomment-4905628663.
---
*Imported from `waltmayf/agentcore-amplify-fullstack`#67 — originally filed by @app/github-actions on 2026-07-07. Migrated to open-source repo; cross-references updated post-import.*
Contributor guide
Research direction
Start with web/app/(with-auth)/chat/, web/app/page.tsx, and web/app/(with-auth)/chat-handler/page.tsx; search for consumers of the listed transports, stream utilities, hooks, and invoke-agent wiring. Run the chat-handler and existing relevant tests, including web/e2e/chat-handler.spec.ts. Done means /chat is removed, the root route reaches the canonical surface, obsolete code and docs are updated, and MyHarness is retained or removed based on confirmed consumers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- backend-api-design, documentation, full-stack
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100