feat: Add message observing status API#89
Conversation
|
The Message model has a session_task_process_status field, which is used to track the processing status of messages:
|
- Query existing session_task_process_status field from messages table
- Map values: success→observed, running→in_process, pending→pending
- Implement Go API endpoint: GET /session/{id}/observing-status
- Add Python SDK method: messages_observing_status()
- Add TypeScript SDK method: messagesObservingStatus()
- Returns counts of observed, in_process, pending messages
Backend (Go):
- Model layer: MessageObservingStatus response type
- Repository layer: Direct query on messages table
- Service layer: Business logic wrapper
- Handler layer: HTTP endpoint with unit tests
- Router: URL registration
- Dependency injection: Full wiring
Python SDK:
- Type: MessageObservingStatus (Pydantic)
- Method: sessions.messages_observing_status()
TypeScript SDK:
- Schema: MessageObservingStatusSchema (Zod)
- Type: MessageObservingStatus
- Method: sessions.messagesObservingStatus()
Tests:
- Handler tests with mocks (all passing)
Note: Uses existing session_task_process_status field. No database migration needed.
989aca8 to
55dd818
Compare
Updated ImplementationChanged the approach how @gus asked: What Changed:
The |
|
I tested in Docker env and tested the endpoints, everythings works as expected |
gusye1234
left a comment
There was a problem hiding this comment.
Let's not introduce a new handler for this api, just use the session handler please.
okey, gonna keep session-related endpoints togerther, will move to method to SessionHandler later this day. but should i keep the service/repo layers separate or consolidate to session service/repo too? yeah forgot to add async version in async_sessions.py ngl missed that. will update and push later this day. thanks |
Oops, miss this. I don't think you need to add new files in modules/repo and modules/model, those are for ORM. You can just simply add this function and the struct in @GenerQAQ , can you look up this PR and back me up? I think we have no need to add new file in /repo and /model in this PR, right? |
|
Agree, and also merge it into the session service/repository to maintain session consistency. @slyt3 |
|
Can you modify the PR's into to dev? |
Yes ofcourse |
Based on review feedback: - Moved method to SessionHandler instead of separate handler - Consolidated into existing session service/repo/model files - Added async Python client method - Deleted all separate message_observing_* files Changes: - Go: Added GetSessionObservingStatus to SessionHandler/Service/Repo - Model: Added MessageObservingStatus struct to session.go - Tests: Added handler tests to session_test.go - Python: Added async version in async_sessions.py
|
Fixed everything, what you asked hope so I didnt miss anything @GenerQAQ @gusye1234 |
GenerQAQ
left a comment
There was a problem hiding this comment.
LGTM! Thank you very much for your submission. There are a few minor issues. Could you please handle them again :)
- fixed aligment in main.go and router.go - updated swagger doc
|
Resolved all formatting and linting issues :) |
Previously overlooked a point, now the API path needs to follow snake_case. |
Oh yea nice catch didnt even noticed |
Fixed API path to use snake_case: |
changed /observing-status -> observing_status - Updated router registration - Updated swagger doc - Updated Python SDK (sync + async) - Updated TS SDK
de73f7f to
1dede2e
Compare
|
fixed in tests too, missed that, sorry |
Summary
Implements API endpoint to return message observing status counts (observed, in_process, pending) for sessions.
Following team feedback, architecture uses a separate
message_observing_trackingtable decoupled from messages table, with foreign key binding for data integrity.API Endpoint:
GET /api/v1/session/{session_id}/observing-statusResponse Example:
{ "observed": 10, "in_process": 5, "pending": 3, "updated_at": "2025-12-17T10:30:00Z" }Why we need this PR?
Users need visibility into message processing status to:
Changes
Backend (Go):
MessageObservingStatus(response),MessageObservingTracking(DB table)/session/{id}/observing-statusPython SDK:
MessageObservingStatus(Pydantic BaseModel)client.sessions.messages_observing_status(session_id)TypeScript SDK:
MessageObservingStatusSchema(Zod validation)MessageObservingStatus(TypeScript interface)client.sessions.messagesObservingStatus(sessionId)Database:
002_create_message_observing_tracking.sqlmessage_observing_trackingwith FK tomessages(id)ON DELETE CASCADEmessage_idandobserving_statusfor query performanceImpact Areas
Which part of Acontext would this feature affect?
Implementation Tasks
Testing
Completed:
Pending:
Note: Awaiting guidance on running migrations in development environment for full integration testing.
Key Files:
src/server/api/go/internal/modules/handler/message_observing_handler.gosrc/server/api/go/internal/modules/repo/message_observing_repo_impl.gosrc/client/acontext-py/src/acontext/resources/sessions.pysrc/client/acontext-ts/src/resources/sessions.tssrc/server/core/migrations/002_create_message_observing_tracking.sqlQuestions for Reviewers