generated from AbanteAI/mentat-template-js
-
Notifications
You must be signed in to change notification settings - Fork 1
Add WebSocket echo server and simple frontend UI #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mentatai
wants to merge
7
commits into
main
Choose a base branch
from
mentat-5
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Server:
- Add `ws` dependency
- Attach `WebSocketServer` on path `/ws` to existing Express HTTP server
- Type-safe handlers and basic welcome + echo behavior
- Client:
- Add WebSocket proxy in Vite for `/ws`
- Implement simple WebSocket UI in App:
- Connects automatically
- Input + Send button
- Status indicator and message log
This enables a basic echo experience:
- Frontend connects to `/ws` (proxied in dev, same-origin in prod)
- Server echoes any message back to the client
Mentat precommit script passed. Log: https://qa.mentat.ai/gh/AbanteAI/qa-party/log/24b3f169-bec0-44a3-b7db-8ea4c36ccc44
Co-authored-by: granawkins <[email protected]>
…t server - Install `@types/ws` as devDependency to provide typings for `ws` - Stabilizes dev server so WebSocket connection no longer drops Mentat precommit script passed. Log: https://qa.mentat.ai/gh/AbanteAI/qa-party/log/3dc26dad-dd5f-47ab-85f1-2447b035cb84 Co-authored-by: granawkins <[email protected]>
…roxy conflicts - Server: WebSocketServer now listens on `/socket` - Client: connect to `/socket` - Vite dev proxy updated to forward `/socket` as WebSocket Please refresh the client preview and try again. You should see a stable connection and echoed messages. Mentat precommit script passed. Log: https://qa.mentat.ai/gh/AbanteAI/qa-party/log/45d2ba12-79f3-4528-ab63-e7d4d54a882b Co-authored-by: granawkins <[email protected]>
…t.RawData) Also implemented your requested fallback: - Added HTTP endpoints: - POST `/messages` to submit a message - GET `/messages?sinceId=<n>` to poll for new messages - Client now: - Sends with POST - Polls every 1s for new messages and updates the log Please refresh the preview and try the “Simple Messages (1s polling)” section. Mentat precommit script failed. Log: https://qa.mentat.ai/gh/AbanteAI/qa-party/log/2931512c-7ecd-45cb-a19f-88df908228b2 Co-authored-by: granawkins <[email protected]>
… param) - Remove unused `useRef` import - Use empty catch to satisfy @typescript-eslint/no-unused-vars Mentat precommit script passed. Log: https://qa.mentat.ai/gh/AbanteAI/qa-party/log/a0dbdaf7-a266-409b-b548-18f632143654 Co-authored-by: granawkins <[email protected]>
- Assert section titles separately (Frontend/Backend/Utilities) - Assert details strings exactly (React, Vite, Vitest / Node.js, Express, Jest / TypeScript, ESLint, Prettier) Mentat precommit script passed. Log: https://qa.mentat.ai/gh/AbanteAI/qa-party/log/030115d9-0caf-4042-bf82-abab30dfe1e9 Co-authored-by: granawkins <[email protected]>
…ce writes
- Client:
- Stabilized polling loop (background interval, no re-inits)
- Server:
- Persist messages to repo-level `persist/messages.json` (outside `server` dir)
to avoid `ts-node-dev` watching file writes and restarting the server
- Added `persist/**` to .gitignore
This should stop the page from refreshing every second. Please refresh once and try sending messages again.
Mentat precommit script passed. Log: https://qa.mentat.ai/gh/AbanteAI/qa-party/log/d7d3697e-b412-462a-8e63-deef2e539974
Co-authored-by: granawkins <[email protected]>
Contributor
Author
|
A user interrupted me on my agent page. I'll keep working if there's more activity here. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a basic WebSocket echo server to the Express app and a simple UI in the React client to interact with it.
Server:
WebSocketServeron path/wsto the existing HTTP server@types/wsto ensure stable compilationClient:
/wsWebSocket traffic to the serverwsURL so it works in both dev (via proxy) and production (same-origin)How to test:
Closes #5 (basic WebSocket echo request)
🤖 This PR was created with Mentat. See my steps and cost here ✨