mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
Retire channels/sessions/messages; A2A becomes primary agent comms (#306)
* feat(a2a): deliver latest incoming message preview into the claim briefing
list_unread_a2a now carries last_message_preview (the latest message from the
OTHER agent, never the agent's own reply), fetched via a correlated subquery in
the same query — no N+1 on the per-verb briefing path.
* feat(a2a): read_a2a verb delivers unread message bodies to the agent
A2AService.get_unread_messages returns the caller's unread INCOMING messages
(never its own sends), marking exactly those rows read atomically so a message
arriving mid-call is preserved. Wired as the read_a2a content verb (route +
do_server tool + granted to every delivery role) — the content-bearing read the
A2A inbox lacked (read_messages only zeroed the counter).
* docs(rag): document read_a2a as the A2A content-read path
* fix(task): backlog activation no longer requires a discussion session
Removes the SessionTaskTable gate in activate() (and its dangling log field),
deletes _inherit_parent_session + its create() call, and drops the now-unused
SessionTaskTable import. Coordination rides task state; the session subsystem is
being retired. Tests updated to the new (no-session) behavior.
* fix(orchestrator): drop session sweep from _run_sweep
Removes the messaging import + sweep_timed_out_sessions call. That import sat
outside the try/except, so once messaging.py is deleted it would have killed the
entire sweep cascade (budget kill-switch, token rollups, retention, image prune,
superseded-PR reconcile). Notification sweep + all maintenance sweeps unchanged.
* release-manager --no-tags read-clone fix
* test: update evidence_repo unit test for a2a last_message_preview
* refactor(gateway): drop session propagation on delegate
Removes propagate_sessions_to_subtask from delegate(), the ChoreographerDeps
messaging field + property, and the ChoreographerDeps messaging arg in deps.py
(ContentActions messaging + import stay until the verbs are removed). Deletes the
propagation test; strips the now-invalid messaging kwarg from ChoreographerDeps
test builders.
* refactor(gateway): remove say/open_session/link_session/channels verbs
Removes the four channel/session verbs across content_actions (impls +
ContentActionsDeps.messaging), do_server (tools + registry), role_config (grants
+ _CHANNEL_DISCOVERY), do.py (routes), schemas/v1/do.py (request models), and
deps.py (MessagingService import + construction). Regenerates the prompt verb
tables. dm/notify/read_messages/read_a2a stay. Tests deleted/updated accordingly.
* uv.lock Upgrade
* refactor: remove conversation RAG indexing; Secretary announces via notification
Drops the CONVERSATIONS index (index_conversation, ConversationsIndexPlugin,
IndexType.CONVERSATIONS enum, IndexConversationParams, mentor.py type-label, the
messaging index hook) and its chunk-table manifest entries. The Secretary's
ANNOUNCE/RELAY_MESSAGE now fan out a BROADCAST notification to every agent's
inbox (NotificationService.broadcast) instead of posting to a dead channel.
* fix(panel): label RAG health error lines by subsystem
A red llm_error (e.g. the glm-5.2:cloud weekly-limit 429) rendered under
the 'Embedding: ok' header with no label, reading as an embedding failure.
Prefix each error line with LLM / Embedding / Vector store.
* refactor: remove channel/message reads from metrics, dashboard, git, events
MetricsService drops get_communication_volume + the MessageTable
message-count in get_agent_metrics (and the now-dead messages_sent_week
field). DashboardService drops get_channel_feeds/_compute_channel_status
and the message read in get_recent_activity (task activity kept);
get_auditor_metrics no longer reports communication_volume.
GitService's two primary-session-id helpers always return None now
(callers already treat None as "no primary session"). events/handlers.py
drops the SESSION_CLOSED/SESSION_TIMEOUT subscriptions + the
handle_session_boundary handler.
Forced follow-on: api/routes/dashboard.py + api/schemas/dashboard.py
dropped the now-dangling live_feeds/ChannelFeed surface and the
/metrics/communication route, which wrapped the removed service calls
directly (mypy would otherwise fail on the missing attributes).
* refactor: delete MessagingService + channel seeding
Edited db/__init__.py and services/__init__.py first (drop the unconditional
Channel/Group/Message/Session table + MessagingService re-exports), then
deleted services/messaging.py, then trimmed db/seed.py to only create_agents
(create_channels/create_channel_memberships/create_initial_messages gone).
Forced expansion: api/routes/{channels,groups,sessions,messages}.py import
roboco.services.messaging directly (not through the package __init__), as
does api/routes/tasks.py (the session-links embed on GET /tasks/{id} and the
GET /{id}/sessions route). Deleting messaging.py without addressing these
breaks `import roboco.api.app` immediately, since app.py eagerly imports all
route modules at startup. Since the 4 CRUD route files are 100%
MessagingService-backed with zero independent logic (and are wholesale
deletes in the plan's later API-routes task anyway), deleted them now +
unmounted from app.py/routes/__init__.py; tasks.py got the same surgical
trim its later task already specified (drop session-links embed +
TaskSessionLinkResponse/TaskResponse.sessions). This pulls a slice of that
later work forward — the routes/schemas for channels/groups/sessions/messages
still need their own pass, but their messaging-coupled parts are gone.
Verified with a full-suite collection sweep (12010 tests collected, zero
import errors) beyond the directly touched test dirs, given the expanded
blast radius.
* refactor: remove channel/session/message models, tables, and channel policy
Models: deleted channel.py/group.py/session.py/messaging.py wholesale
(zero external consumers besides the models/__init__.py re-export).
message.py surgically trimmed: removed MessageCreate (dead) and MessageEdit
(never instantiated; ExtractedMessage.edit_history retyped to
list[dict[str, Any]] to match how it's actually persisted — confirmed
ExtractedMessage was never written to any DB table, so MessageTable's
removal carries no functional risk to the kept extraction pipeline).
base.py: removed SessionStatus + ChannelType, kept MessageType. Also
removed the confirmed-dead channels_read/channels_write fields from
models/agent.py:AgentPermissions and models/dashboard.py:ChannelFeedData.
db/tables.py: deleted ChannelTable/GroupTable/SessionTable/SessionTaskTable/
MessageTable, TaskTable.session_links, and JournalEntryTable.session_id —
cascaded through models/journal.py, services/journal.py, and
api/schemas+routes/journals.py (22 plumbing sites).
foundation/policy/communications.py: removed the ChannelSpec/CHANNELS
catalog + TEAM_SCOPED_ROLES/_CELL_*/_AUDITOR_ONLY helpers, kept the
notification policy (Priority/parse_priority/NOTIFY_SENDER_ROLES/
ACK_REQUIRED_BY_TYPE). enforcement/channel_access.py deleted (confirmed
fully dead in production). agents_config.py: removed CHANNEL_ACCESS
(kept A2A_ALLOWED_PAIRS). seeds/initial_data.py: removed
DEFAULT_CHANNELS/CHANNEL_MEMBERSHIPS/AUDITOR_SILENT_ACCESS + the
never-consumed INITIAL_MESSAGES. config.py: removed
session_idle_timeout_seconds (zero consumers). exceptions.py: removed
dead ChannelError/ChannelAccessDeniedError/SessionClosedError.
Forced expansion beyond the original file list — ChannelType cascaded
into a live, mounted surface the plan didn't trace: agents_config.
CHANNEL_ACCESS -> services/permissions.py's channel-RBAC methods (not
models/permissions.py, which turned out to have no channel code at all)
-> two real endpoints in api/routes/stream.py (GET /permissions,
GET /permissions/channel/{name}) and two dependency factories in
api/deps.py. Removed the channel methods + fields, deleted the
channel-specific stream.py endpoint, deleted require_channel_read/write.
Also deleted api/schemas/{channels,sessions}.py (hard dependency on the
removed enums; already fully dead after the Task 10 route deletions) and
api/schemas/messages.py (a TYPE_CHECKING-only import of the deleted
MessageTable; likewise already fully dead) + its dedicated test file.
Test updates: test_permissions.py -14 channel tests (matches the planned
count exactly), test_communications.py / test_communications_consumers.py
split to keep only notification-policy coverage, test_exceptions.py -9,
test_deps.py -4, plus the journal/stream/foundation-smoke fallout. Also
fixed a pre-existing (Task 7) broken assertion in
test_foundation_phase3_smoke.py that inspected a `say()` method already
removed from ContentActions.
Verified: full-suite collection (11961 tests, zero import errors) and a
complete test run (11567 passed, 394 skipped, 0 failed) in addition to
the targeted suites.
* migration: drop channels/groups/sessions/session_tasks/messages + enum types
alembic/versions/060_drop_messaging.py: drop_column journal_entries.
session_id (sidesteps hardcoding the FK constraint name — verified
empirically against a live migrated DB that it's actually
fk_journal_entries_session_id_sessions, but drop_column doesn't care
either way); drop_table in FK order (messages -> session_tasks ->
sessions -> groups -> channels); DROP TABLE IF EXISTS chunks_conversations
(runtime-provisioned, not alembic-managed, would otherwise orphan); DROP
TYPE IF EXISTS for messagetype/sessionstatus/sessionscope/channeltype
(messagetype's Python enum stays for ExtractedMessage, but the DB type
had zero live columns left once MessageTable was dropped in the prior
commit). downgrade() raises NotImplementedError — one-way removal.
Pruned scripts/reset_runtime_state.sql + .sh: removed the DELETE/COUNT
lines for messages/session_tasks/sessions/groups/channels and the
groups.active_session_id reset block.
Verified end-to-end against a scratch Postgres DB: full migration chain
001->060 applies cleanly, alembic heads shows a single head, all 6 dropped
tables + 4 enum types + the journal_entries.session_id column are
confirmed gone, journal_entries keeps only its journal_id/task_id FKs,
downgrade correctly raises NotImplementedError without corrupting DB
state, and the pruned reset_runtime_state.sql runs clean (no errors)
against a fully-migrated DB.
* refactor(api): remove channel/session/message routes + WS streams
Most of this task's file list was already forced through in earlier
commits (routes/{channels,groups,sessions,messages}.py + app.py/__init__.py
unmounting in the MessagingService-deletion commit; tasks.py's
session-links embed + GET /{id}/sessions + schemas/tasks.py's
TaskResponse.sessions in that same commit; deps.py's require_channel_read/
write + schemas/{channels,sessions}.py in the models/tables commit). This
closes out what was left:
- api/websocket.py: deleted the channel_stream + session_stream routes,
ConnectionManager's channel_connections/session_connections dicts,
connect_channel/connect_session, broadcast_to_channel/broadcast_to_session,
get_channel_subscriber_count, and their cleanup lines in disconnect().
Agent streams, notification streams, and the operator system stream are
untouched.
- api/websocket_bridge.py: deleted _handle_session_event +
_handle_message_event and their SESSION_CREATED/SESSION_CLOSED/
SESSION_TIMEOUT/MESSAGE_SENT subscriptions. The A2A live-view, rate-limit,
usage, agent-lifecycle, and notification bridges are untouched.
- api/schemas/websocket.py: removed NewMessageBroadcast, WSMessageNew,
WSMessageEdit, WSMessageDelete, WSSessionClosed — kept the WSMessage base
class (still subclassed by the kept WSAgentStream/WSNotification) plus
those two.
- api/schemas/groups.py: deleted (already fully orphaned since routes/
groups.py was removed; its GroupResponse/GroupDetailResponse had zero
consumers).
Updated the 5 websocket test files accordingly (removed the channel/
session-specific tests + fixed imports); test_websocket_bridge.py's
registration-coverage test dropped the SESSION_*/MESSAGE_SENT assertions.
Verified: full-suite collection (11943 tests, zero import errors) and a
complete test run (11549 passed, 394 skipped, 0 failed).
* docs: retire channels/sessions/messages from agent-facing docs + CLAUDE.md
Rewrites docs/rag (RAG-indexed) + docs/map + CLAUDE.md to reflect A2A (dm +
read_a2a) as primary agent comms; deletes the channel docs, splits messaging-tools
+ messaging-notification (renamed notification.md), swaps the WS worked example to
A2A_MESSAGE_SENT. _complete_map.md still needs regeneration (generated file).
* refactor(panel): remove Communications surface (channels/sessions)
Deletes the /communications routes, message components, task-detail Sessions tab,
use-channels + channel/session WS hooks, and the channels/sessions/messages/groups
api clients; prunes the Channel/Session/Message/Group types + mock data. (Auditor
live-feeds + dashboard.ts dead-route cleanup is a follow-up.)
* refactor(panel): drop auditor channel-feed + dead communication-metric route
* docs(map): regenerate _complete_map from updated slices
* fix(a2a): reduce get_unread_messages complexity below xenon C + stale comments
Extract the per-conversation unread-counter recompute into _reset_unread_counter
(the CI quality gate flagged get_unread_messages as rank C). Also drop the deleted
open_session from a content_actions comment and reword an evidence_repo docstring
that cited the removed messaging._notify_mentions.
---------
Co-authored-by: Renn F <rennf93@users.noreply.github.com>
This commit is contained in:
@@ -1,147 +0,0 @@
|
||||
import api from "./client";
|
||||
import type { Channel, PaginatedResponse, Group } from "@/types";
|
||||
import { ChannelType } from "@/types";
|
||||
import { isMockMode, mockChannels, mockGroups } from "@/lib/mock-data";
|
||||
|
||||
export interface ChannelFilters {
|
||||
type?: string;
|
||||
is_private?: boolean;
|
||||
}
|
||||
|
||||
export interface ChannelCreate {
|
||||
name: string;
|
||||
slug: string;
|
||||
type?: string;
|
||||
description?: string;
|
||||
topic?: string;
|
||||
is_private?: boolean;
|
||||
}
|
||||
|
||||
export interface ChannelUpdate {
|
||||
name?: string;
|
||||
description?: string;
|
||||
topic?: string;
|
||||
is_archived?: boolean;
|
||||
}
|
||||
|
||||
export const channelsApi = {
|
||||
// List all channels
|
||||
list: async (filters?: ChannelFilters): Promise<Channel[]> => {
|
||||
if (isMockMode()) {
|
||||
let channels = [...mockChannels] as Channel[];
|
||||
if (filters?.type) {
|
||||
channels = channels.filter((c) => c.type === filters.type);
|
||||
}
|
||||
if (filters?.is_private !== undefined) {
|
||||
channels = channels.filter((c) => c.is_private === filters.is_private);
|
||||
}
|
||||
return channels;
|
||||
}
|
||||
const { data } = await api.get<PaginatedResponse<Channel>>("/channels", {
|
||||
params: filters,
|
||||
});
|
||||
return data.items;
|
||||
},
|
||||
|
||||
// Get channel by ID
|
||||
get: async (channelId: string): Promise<Channel> => {
|
||||
if (isMockMode()) {
|
||||
const channel = mockChannels.find((c) => c.id === channelId);
|
||||
if (channel) return channel as Channel;
|
||||
throw new Error("Channel not found");
|
||||
}
|
||||
const { data } = await api.get<Channel>("/channels/" + channelId);
|
||||
return data;
|
||||
},
|
||||
|
||||
// Get channel by slug
|
||||
getBySlug: async (slug: string): Promise<Channel> => {
|
||||
if (isMockMode()) {
|
||||
const channel = mockChannels.find((c) => c.slug === slug);
|
||||
if (channel) return channel as Channel;
|
||||
throw new Error("Channel not found");
|
||||
}
|
||||
// Backend uses query param filter, not path segment
|
||||
const { data } = await api.get<PaginatedResponse<Channel>>("/channels", {
|
||||
params: { slug },
|
||||
});
|
||||
if (!data.items.length) {
|
||||
throw new Error("Channel not found");
|
||||
}
|
||||
return data.items[0];
|
||||
},
|
||||
|
||||
// Get groups for a channel
|
||||
getGroups: async (channelId: string): Promise<Group[]> => {
|
||||
if (isMockMode()) {
|
||||
return mockGroups as Group[];
|
||||
}
|
||||
const { data } = await api.get<Group[]>(
|
||||
"/channels/" + channelId + "/groups",
|
||||
);
|
||||
return data;
|
||||
},
|
||||
|
||||
// Create a new channel (PM/CEO only)
|
||||
create: async (channel: ChannelCreate): Promise<Channel> => {
|
||||
if (isMockMode()) {
|
||||
const newChannel: Channel = {
|
||||
id: `channel-${Date.now()}`,
|
||||
name: channel.name,
|
||||
slug: channel.slug,
|
||||
type: (channel.type as ChannelType) || ChannelType.CELL,
|
||||
description: channel.description || null,
|
||||
topic: channel.topic || null,
|
||||
is_private: channel.is_private || false,
|
||||
is_archived: false,
|
||||
member_count: 0,
|
||||
message_count: 0,
|
||||
group_count: 0,
|
||||
can_write: true,
|
||||
};
|
||||
(mockChannels as Channel[]).push(newChannel);
|
||||
return newChannel;
|
||||
}
|
||||
const { data } = await api.post<Channel>("/channels", channel);
|
||||
return data;
|
||||
},
|
||||
|
||||
// Update a channel (PM/CEO only)
|
||||
update: async (
|
||||
channelId: string,
|
||||
updates: ChannelUpdate,
|
||||
): Promise<Channel> => {
|
||||
if (isMockMode()) {
|
||||
const idx = mockChannels.findIndex((c) => c.id === channelId);
|
||||
if (idx === -1) throw new Error("Channel not found");
|
||||
const updated = { ...mockChannels[idx], ...updates } as Channel;
|
||||
(mockChannels as Channel[])[idx] = updated;
|
||||
return updated;
|
||||
}
|
||||
const { data } = await api.patch<Channel>(
|
||||
"/channels/" + channelId,
|
||||
updates,
|
||||
);
|
||||
return data;
|
||||
},
|
||||
|
||||
// Add a member to a channel (PM/CEO only)
|
||||
addMember: async (channelId: string, agentId: string): Promise<void> => {
|
||||
if (isMockMode()) {
|
||||
return;
|
||||
}
|
||||
await api.post("/channels/" + channelId + "/add-member", {
|
||||
agent_id: agentId,
|
||||
});
|
||||
},
|
||||
|
||||
// Remove a member from a channel (PM/CEO only)
|
||||
removeMember: async (channelId: string, agentId: string): Promise<void> => {
|
||||
if (isMockMode()) {
|
||||
return;
|
||||
}
|
||||
await api.delete("/channels/" + channelId + "/remove-member", {
|
||||
data: { agent_id: agentId },
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -35,7 +35,6 @@ export interface TeamHealth {
|
||||
export interface MetricsSummary {
|
||||
velocity: VelocityMetric;
|
||||
blockers: BlockerMetric;
|
||||
communication: CommunicationMetric;
|
||||
agents: AgentMetric;
|
||||
}
|
||||
|
||||
@@ -51,12 +50,6 @@ export interface BlockerMetric {
|
||||
longest_blocked_hours: number;
|
||||
}
|
||||
|
||||
export interface CommunicationMetric {
|
||||
messages_today: number;
|
||||
active_channels: number;
|
||||
notifications_pending: number;
|
||||
}
|
||||
|
||||
export interface AgentMetric {
|
||||
total_agents: number;
|
||||
running: number;
|
||||
@@ -209,20 +202,6 @@ export const dashboardApi = {
|
||||
return data;
|
||||
},
|
||||
|
||||
getCommunicationMetrics: async (): Promise<CommunicationMetric> => {
|
||||
if (isMockMode()) {
|
||||
return {
|
||||
messages_today: 45,
|
||||
active_channels: 5,
|
||||
notifications_pending: 3,
|
||||
};
|
||||
}
|
||||
const { data } = await api.get<CommunicationMetric>(
|
||||
"/dashboard/metrics/communication",
|
||||
);
|
||||
return data;
|
||||
},
|
||||
|
||||
getHealthMetrics: async () => {
|
||||
if (isMockMode()) {
|
||||
return mockTeamHealth;
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
/**
|
||||
* Groups API Client
|
||||
*
|
||||
* API functions for group management within channels.
|
||||
*/
|
||||
|
||||
import api from "./client";
|
||||
import { isMockMode } from "@/lib/mock-data";
|
||||
import type { Group } from "@/types";
|
||||
|
||||
// =============================================================================
|
||||
// Types
|
||||
// =============================================================================
|
||||
|
||||
export interface GroupCreate {
|
||||
channel_id: string;
|
||||
name: string;
|
||||
hierarchy_level?: number;
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// API Client
|
||||
// =============================================================================
|
||||
|
||||
export const groupsApi = {
|
||||
/**
|
||||
* Create a new group within a channel
|
||||
*/
|
||||
create: async (group: GroupCreate): Promise<Group> => {
|
||||
if (isMockMode()) {
|
||||
return {
|
||||
id: `group-${Date.now()}`,
|
||||
name: group.name,
|
||||
hierarchy_level: group.hierarchy_level ?? 0,
|
||||
is_active: true,
|
||||
total_messages: 0,
|
||||
active_session_id: null,
|
||||
};
|
||||
}
|
||||
const { data } = await api.post<Group>("/groups", group);
|
||||
return data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get a group by ID
|
||||
*/
|
||||
get: async (groupId: string): Promise<Group> => {
|
||||
if (isMockMode()) {
|
||||
return {
|
||||
id: groupId,
|
||||
name: "Mock Group",
|
||||
hierarchy_level: 0,
|
||||
is_active: true,
|
||||
total_messages: 0,
|
||||
active_session_id: null,
|
||||
};
|
||||
}
|
||||
const { data } = await api.get<Group>(`/groups/${groupId}`);
|
||||
return data;
|
||||
},
|
||||
};
|
||||
@@ -2,7 +2,6 @@ export { api, API_URL } from "./client";
|
||||
export { usageApi } from "./usage";
|
||||
export { tasksApi } from "./tasks";
|
||||
export { orchestratorApi } from "./orchestrator";
|
||||
export { channelsApi } from "./channels";
|
||||
export { notificationsApi } from "./notifications";
|
||||
export { dashboardApi } from "./dashboard";
|
||||
export { knowledgeBaseApi } from "./knowledge-base";
|
||||
@@ -12,7 +11,6 @@ export { workSessionsApi } from "./work-sessions";
|
||||
export { gitApi } from "./git";
|
||||
export { a2aApi } from "./a2a";
|
||||
export { streamApi } from "./stream";
|
||||
export { groupsApi } from "./groups";
|
||||
export { settingsApi } from "./settings";
|
||||
export { companyGoalsApi } from "./company-goals";
|
||||
export { releaseApi } from "./release";
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
import api from "./client";
|
||||
import type { Message, MessageType } from "@/types";
|
||||
import {
|
||||
isMockMode,
|
||||
getMockMessages,
|
||||
AGENT_IDS,
|
||||
CHANNEL_IDS,
|
||||
} from "@/lib/mock-data";
|
||||
|
||||
// Store for mock messages (persists during session)
|
||||
let mockMessagesStore: Message[] | null = null;
|
||||
const getMessages = (): Message[] => {
|
||||
if (!mockMessagesStore) {
|
||||
mockMessagesStore = getMockMessages() as Message[];
|
||||
}
|
||||
return mockMessagesStore;
|
||||
};
|
||||
|
||||
export const messagesApi = {
|
||||
// List messages for a session
|
||||
listBySession: async (
|
||||
sessionId: string,
|
||||
limit: number = 50,
|
||||
before?: string,
|
||||
after?: string,
|
||||
): Promise<{ items: Message[]; has_more: boolean }> => {
|
||||
if (isMockMode()) {
|
||||
let messages = getMessages().filter((m) => m.session_id === sessionId);
|
||||
if (before) {
|
||||
messages = messages.filter(
|
||||
(m) => new Date(m.timestamp) < new Date(before),
|
||||
);
|
||||
}
|
||||
if (after) {
|
||||
messages = messages.filter(
|
||||
(m) => new Date(m.timestamp) > new Date(after),
|
||||
);
|
||||
}
|
||||
return {
|
||||
items: messages.slice(0, limit),
|
||||
has_more: messages.length > limit,
|
||||
};
|
||||
}
|
||||
const { data } = await api.get<{ items: Message[]; has_more: boolean }>(
|
||||
"/messages",
|
||||
{
|
||||
params: { session_id: sessionId, limit, before, after },
|
||||
},
|
||||
);
|
||||
return data;
|
||||
},
|
||||
|
||||
// Get message by ID
|
||||
get: async (messageId: string): Promise<Message> => {
|
||||
if (isMockMode()) {
|
||||
const message = getMessages().find((m) => m.id === messageId);
|
||||
if (message) return message;
|
||||
throw new Error("Message not found");
|
||||
}
|
||||
const { data } = await api.get<Message>("/messages/" + messageId);
|
||||
return data;
|
||||
},
|
||||
|
||||
// Send a message
|
||||
send: async (
|
||||
sessionId: string,
|
||||
content: string,
|
||||
type: string = "dialogue",
|
||||
): Promise<Message> => {
|
||||
if (isMockMode()) {
|
||||
const newMessage: Message = {
|
||||
id: `msg-${Date.now()}`,
|
||||
agent_id: AGENT_IDS.ceo,
|
||||
channel_id: CHANNEL_IDS.backendCell,
|
||||
group_id: `msg-${Date.now()}`,
|
||||
session_id: sessionId,
|
||||
type: type as MessageType,
|
||||
content,
|
||||
content_length: content.length,
|
||||
is_reply: false,
|
||||
reply_to: null,
|
||||
mentions: [],
|
||||
task_id: null,
|
||||
commit_ref: null,
|
||||
timestamp: new Date().toISOString(),
|
||||
edited_at: null,
|
||||
was_edited: false,
|
||||
};
|
||||
getMessages().push(newMessage);
|
||||
return newMessage;
|
||||
}
|
||||
const { data } = await api.post<Message>("/messages", {
|
||||
session_id: sessionId,
|
||||
content,
|
||||
type,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
|
||||
// Edit a message
|
||||
edit: async (messageId: string, content: string): Promise<Message> => {
|
||||
if (isMockMode()) {
|
||||
const messages = getMessages();
|
||||
const idx = messages.findIndex((m) => m.id === messageId);
|
||||
if (idx !== -1) {
|
||||
const message = messages[idx];
|
||||
const editedMessage: Message = {
|
||||
...message,
|
||||
content,
|
||||
content_length: content.length,
|
||||
edited_at: new Date().toISOString(),
|
||||
was_edited: true,
|
||||
};
|
||||
messages[idx] = editedMessage;
|
||||
return editedMessage;
|
||||
}
|
||||
throw new Error("Message not found");
|
||||
}
|
||||
const { data } = await api.patch<Message>("/messages/" + messageId, {
|
||||
content,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
|
||||
// Delete a message
|
||||
delete: async (messageId: string): Promise<void> => {
|
||||
if (isMockMode()) {
|
||||
const messages = getMessages();
|
||||
const idx = messages.findIndex((m) => m.id === messageId);
|
||||
if (idx !== -1) messages.splice(idx, 1);
|
||||
return;
|
||||
}
|
||||
await api.delete("/messages/" + messageId);
|
||||
},
|
||||
};
|
||||
@@ -1,146 +0,0 @@
|
||||
import api from "./client";
|
||||
import type { Session } from "@/types";
|
||||
import { SessionStatus, SessionScope } from "@/types";
|
||||
import { isMockMode, mockSessions } from "@/lib/mock-data";
|
||||
|
||||
// Session-Task link response from API
|
||||
export interface SessionTaskLinkResponse {
|
||||
id: string;
|
||||
session_id: string;
|
||||
task_id: string;
|
||||
is_primary: boolean;
|
||||
relationship_type: string;
|
||||
added_at: string;
|
||||
added_by: string | null;
|
||||
}
|
||||
|
||||
export interface SessionCreate {
|
||||
group_id: string;
|
||||
scope?: string;
|
||||
}
|
||||
|
||||
export const sessionsApi = {
|
||||
// List sessions for a group
|
||||
listByGroup: async (
|
||||
groupId: string,
|
||||
limit: number = 50,
|
||||
): Promise<Session[]> => {
|
||||
if (isMockMode()) {
|
||||
return (mockSessions as Session[]).slice(0, limit);
|
||||
}
|
||||
const { data } = await api.get<{ items: Session[]; total: number }>(
|
||||
"/sessions",
|
||||
{
|
||||
params: { group_id: groupId, limit },
|
||||
},
|
||||
);
|
||||
return data.items;
|
||||
},
|
||||
|
||||
// Get session by ID
|
||||
get: async (sessionId: string): Promise<Session> => {
|
||||
if (isMockMode()) {
|
||||
const session = mockSessions.find((s) => s.id === sessionId);
|
||||
if (session) return session as Session;
|
||||
throw new Error("Session not found");
|
||||
}
|
||||
const { data } = await api.get<Session>("/sessions/" + sessionId);
|
||||
return data;
|
||||
},
|
||||
|
||||
// Get sessions linked to a task
|
||||
getForTask: async (taskId: string): Promise<SessionTaskLinkResponse[]> => {
|
||||
if (isMockMode()) {
|
||||
return []; // No mock session-task links
|
||||
}
|
||||
const { data } = await api.get<SessionTaskLinkResponse[]>(
|
||||
"/sessions/for-task/" + taskId,
|
||||
);
|
||||
return data;
|
||||
},
|
||||
|
||||
// Close a session
|
||||
close: async (sessionId: string): Promise<Session> => {
|
||||
if (isMockMode()) {
|
||||
const idx = mockSessions.findIndex((s) => s.id === sessionId);
|
||||
if (idx !== -1) {
|
||||
const session = mockSessions[idx] as Session;
|
||||
const closedSession: Session = {
|
||||
...session,
|
||||
status: "closed" as SessionStatus,
|
||||
closed_at: new Date().toISOString(),
|
||||
};
|
||||
(mockSessions as Session[])[idx] = closedSession;
|
||||
return closedSession;
|
||||
}
|
||||
throw new Error("Session not found");
|
||||
}
|
||||
const { data } = await api.post<Session>(
|
||||
"/sessions/" + sessionId + "/close",
|
||||
);
|
||||
return data;
|
||||
},
|
||||
|
||||
// Link a task to a session (PM only)
|
||||
linkTask: async (
|
||||
sessionId: string,
|
||||
taskId: string,
|
||||
isPrimary: boolean = false,
|
||||
relationshipType: string = "discussion",
|
||||
): Promise<SessionTaskLinkResponse> => {
|
||||
const { data } = await api.post<SessionTaskLinkResponse>(
|
||||
"/sessions/" + sessionId + "/tasks",
|
||||
{
|
||||
task_id: taskId,
|
||||
is_primary: isPrimary,
|
||||
relationship_type: relationshipType,
|
||||
},
|
||||
);
|
||||
return data;
|
||||
},
|
||||
|
||||
// Unlink a task from a session (PM only)
|
||||
unlinkTask: async (sessionId: string, taskId: string): Promise<void> => {
|
||||
await api.delete("/sessions/" + sessionId + "/tasks/" + taskId);
|
||||
},
|
||||
|
||||
// Create a session for tasks (PM only)
|
||||
createForTasks: async (
|
||||
taskIds: string[],
|
||||
channelSlug: string,
|
||||
relationshipType: string = "discussion",
|
||||
): Promise<{ session: Session; links: SessionTaskLinkResponse[] }> => {
|
||||
const { data } = await api.post<{
|
||||
session: Session;
|
||||
links: SessionTaskLinkResponse[];
|
||||
}>("/sessions/for-tasks", {
|
||||
task_ids: taskIds,
|
||||
channel_slug: channelSlug,
|
||||
relationship_type: relationshipType,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
|
||||
// Create a new session directly
|
||||
create: async (session: SessionCreate): Promise<Session> => {
|
||||
if (isMockMode()) {
|
||||
const now = new Date().toISOString();
|
||||
const newSession: Session = {
|
||||
id: `session-${Date.now()}`,
|
||||
group_id: session.group_id,
|
||||
status: SessionStatus.ACTIVE,
|
||||
scope: (session.scope as SessionScope) || SessionScope.CELL,
|
||||
message_count: 0,
|
||||
total_content_length: 0,
|
||||
started_at: now,
|
||||
last_activity_at: now,
|
||||
closed_at: null,
|
||||
task_links: [],
|
||||
};
|
||||
(mockSessions as Session[]).push(newSession);
|
||||
return newSession;
|
||||
}
|
||||
const { data } = await api.post<Session>("/sessions", session);
|
||||
return data;
|
||||
},
|
||||
};
|
||||
@@ -87,7 +87,6 @@ const summaryToTask = (s: TaskSummaryWire): Task => ({
|
||||
quick_context: null,
|
||||
self_verified: false,
|
||||
qa_verified: null,
|
||||
sessions: [],
|
||||
});
|
||||
|
||||
export const tasksApi = {
|
||||
@@ -202,7 +201,6 @@ export const tasksApi = {
|
||||
qa_notes: null,
|
||||
auditor_notes: null,
|
||||
quick_context: null,
|
||||
sessions: [],
|
||||
branch_name: null,
|
||||
pr_number: null,
|
||||
pr_url: null,
|
||||
|
||||
@@ -7,10 +7,6 @@ import {
|
||||
NotificationType,
|
||||
NotificationPriority,
|
||||
JournalEntryType,
|
||||
ChannelType,
|
||||
SessionStatus,
|
||||
SessionScope,
|
||||
MessageType,
|
||||
FlagSeverity,
|
||||
TaskNature,
|
||||
TaskType,
|
||||
@@ -64,17 +60,6 @@ export const PROJECT_IDS = {
|
||||
robocoPanel: "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb",
|
||||
};
|
||||
|
||||
export const CHANNEL_IDS = {
|
||||
backendCell: "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
|
||||
frontendCell: "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb",
|
||||
uxuiCell: "cccccccc-cccc-cccc-cccc-cccccccccccc",
|
||||
devAll: "dddddddd-dddd-dddd-dddd-dddddddddddd",
|
||||
qaAll: "eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee",
|
||||
pmAll: "ffffffff-ffff-ffff-ffff-ffffffffffff",
|
||||
announcements: "00000000-0000-0000-0000-000000000100",
|
||||
allHands: "00000000-0000-0000-0000-000000000101",
|
||||
};
|
||||
|
||||
// Timestamps - computed dynamically to stay relative
|
||||
const getNow = () => new Date();
|
||||
const getMinutesAgo = (mins: number) => new Date(Date.now() - mins * 60 * 1000);
|
||||
@@ -299,7 +284,6 @@ Implement a complete user authentication system including:
|
||||
completed_at: null,
|
||||
self_verified: false,
|
||||
qa_verified: null,
|
||||
sessions: [],
|
||||
branch_name: "feature/TASK-001-user-auth",
|
||||
pr_number: null,
|
||||
pr_url: null,
|
||||
@@ -442,7 +426,6 @@ Implement a complete user authentication system including:
|
||||
completed_at: null,
|
||||
self_verified: false,
|
||||
qa_verified: null,
|
||||
sessions: [],
|
||||
branch_name: null,
|
||||
pr_number: null,
|
||||
pr_url: null,
|
||||
@@ -497,7 +480,6 @@ Pagination should maintain filter state.`,
|
||||
completed_at: null,
|
||||
self_verified: false,
|
||||
qa_verified: null,
|
||||
sessions: [],
|
||||
branch_name: "fix/TASK-003-pagination-bug",
|
||||
pr_number: null,
|
||||
pr_url: null,
|
||||
@@ -548,7 +530,6 @@ The flow should guide new users through:
|
||||
completed_at: hourAgo.toISOString(),
|
||||
self_verified: true,
|
||||
qa_verified: null,
|
||||
sessions: [],
|
||||
branch_name: "feature/TASK-004-onboarding-design",
|
||||
pr_number: 42,
|
||||
pr_url: "https://github.com/roboco/roboco/pull/42",
|
||||
@@ -659,7 +640,6 @@ Reduce response time to < 100ms for all endpoints.`,
|
||||
completed_at: null,
|
||||
self_verified: false,
|
||||
qa_verified: null,
|
||||
sessions: [],
|
||||
branch_name: "perf/TASK-005-db-optimization",
|
||||
pr_number: null,
|
||||
pr_url: null,
|
||||
@@ -718,7 +698,6 @@ Include:
|
||||
completed_at: hourAgo.toISOString(),
|
||||
self_verified: true,
|
||||
qa_verified: true,
|
||||
sessions: [],
|
||||
branch_name: "docs/TASK-006-api-documentation",
|
||||
pr_number: 38,
|
||||
pr_url: "https://github.com/roboco/roboco/pull/38",
|
||||
@@ -930,83 +909,6 @@ export const mockWaitingAgents = [
|
||||
},
|
||||
];
|
||||
|
||||
// =============================================================================
|
||||
// MOCK CHANNELS - Matching backend ChannelResponse schema
|
||||
// =============================================================================
|
||||
|
||||
export const mockChannels = [
|
||||
{
|
||||
id: CHANNEL_IDS.backendCell,
|
||||
name: "Backend Cell",
|
||||
slug: "backend-cell",
|
||||
type: ChannelType.CELL,
|
||||
description: "Backend development team channel",
|
||||
topic: null,
|
||||
member_count: 6,
|
||||
message_count: 150,
|
||||
group_count: 3,
|
||||
is_archived: false,
|
||||
is_private: false,
|
||||
can_write: true,
|
||||
},
|
||||
{
|
||||
id: CHANNEL_IDS.frontendCell,
|
||||
name: "Frontend Cell",
|
||||
slug: "frontend-cell",
|
||||
type: ChannelType.CELL,
|
||||
description: "Frontend development team channel",
|
||||
topic: null,
|
||||
member_count: 6,
|
||||
message_count: 120,
|
||||
group_count: 2,
|
||||
is_archived: false,
|
||||
is_private: false,
|
||||
can_write: true,
|
||||
},
|
||||
{
|
||||
id: CHANNEL_IDS.uxuiCell,
|
||||
name: "UX/UI Cell",
|
||||
slug: "uxui-cell",
|
||||
type: ChannelType.CELL,
|
||||
description: "UX/UI design team channel",
|
||||
topic: null,
|
||||
member_count: 5,
|
||||
message_count: 80,
|
||||
group_count: 2,
|
||||
is_archived: false,
|
||||
is_private: false,
|
||||
can_write: true,
|
||||
},
|
||||
{
|
||||
id: CHANNEL_IDS.devAll,
|
||||
name: "All Developers",
|
||||
slug: "dev-all",
|
||||
type: ChannelType.CROSS_CELL,
|
||||
description: "Cross-cell developer discussion",
|
||||
topic: null,
|
||||
member_count: 10,
|
||||
message_count: 200,
|
||||
group_count: 5,
|
||||
is_archived: false,
|
||||
is_private: false,
|
||||
can_write: true,
|
||||
},
|
||||
{
|
||||
id: CHANNEL_IDS.announcements,
|
||||
name: "Announcements",
|
||||
slug: "announcements",
|
||||
type: ChannelType.SPECIAL,
|
||||
description: "Company-wide announcements",
|
||||
topic: null,
|
||||
member_count: 19,
|
||||
message_count: 25,
|
||||
group_count: 1,
|
||||
is_archived: false,
|
||||
is_private: false,
|
||||
can_write: false,
|
||||
},
|
||||
];
|
||||
|
||||
// =============================================================================
|
||||
// MOCK NOTIFICATIONS - Matching backend NotificationResponse schema
|
||||
// =============================================================================
|
||||
@@ -1215,146 +1117,6 @@ export const mockKanbanDevBoard = {
|
||||
blocked_count: 1,
|
||||
};
|
||||
|
||||
// =============================================================================
|
||||
// MOCK SESSIONS - Matching backend SessionResponse schema
|
||||
// =============================================================================
|
||||
|
||||
export const mockSessions = [
|
||||
{
|
||||
id: mockId(),
|
||||
group_id: mockId(),
|
||||
status: SessionStatus.ACTIVE,
|
||||
scope: SessionScope.TASK,
|
||||
message_count: 25,
|
||||
total_content_length: 5000,
|
||||
started_at: hourAgo.toISOString(),
|
||||
last_activity_at: now.toISOString(),
|
||||
closed_at: null,
|
||||
},
|
||||
{
|
||||
id: mockId(),
|
||||
group_id: mockId(),
|
||||
status: SessionStatus.CLOSED,
|
||||
scope: SessionScope.CELL,
|
||||
message_count: 50,
|
||||
total_content_length: 12000,
|
||||
started_at: dayAgo.toISOString(),
|
||||
last_activity_at: new Date(
|
||||
now.getTime() - 2 * 60 * 60 * 1000,
|
||||
).toISOString(),
|
||||
closed_at: new Date(now.getTime() - 2 * 60 * 60 * 1000).toISOString(),
|
||||
},
|
||||
];
|
||||
|
||||
// =============================================================================
|
||||
// MOCK MESSAGES - Matching backend MessageResponse schema
|
||||
// =============================================================================
|
||||
|
||||
const messageGroupId = mockId();
|
||||
|
||||
// Use getter for fresh timestamps
|
||||
export const getMockMessages = () => [
|
||||
{
|
||||
id: mockId(),
|
||||
agent_id: AGENT_IDS.beDev1,
|
||||
channel_id: CHANNEL_IDS.backendCell,
|
||||
group_id: messageGroupId,
|
||||
session_id: mockSessions[0].id,
|
||||
type: MessageType.DIALOGUE,
|
||||
content:
|
||||
"Just finished the auth service implementation. Ready to start on the API endpoints.",
|
||||
content_length: 78,
|
||||
is_reply: false,
|
||||
reply_to: null,
|
||||
mentions: [],
|
||||
task_id: TASK_IDS.task1,
|
||||
commit_ref: null,
|
||||
timestamp: getMinutesAgo(60).toISOString(),
|
||||
edited_at: null,
|
||||
was_edited: false,
|
||||
},
|
||||
{
|
||||
id: mockId(),
|
||||
agent_id: AGENT_IDS.bePm,
|
||||
channel_id: CHANNEL_IDS.backendCell,
|
||||
group_id: messageGroupId,
|
||||
session_id: mockSessions[0].id,
|
||||
type: MessageType.DECISION,
|
||||
content: "Great progress! Let's prioritize the OAuth integration next.",
|
||||
content_length: 58,
|
||||
is_reply: true,
|
||||
reply_to: null,
|
||||
mentions: [AGENT_IDS.beDev1],
|
||||
task_id: TASK_IDS.task1,
|
||||
commit_ref: null,
|
||||
timestamp: getMinutesAgo(55).toISOString(),
|
||||
edited_at: null,
|
||||
was_edited: false,
|
||||
},
|
||||
{
|
||||
id: mockId(),
|
||||
agent_id: AGENT_IDS.beDev2,
|
||||
channel_id: CHANNEL_IDS.backendCell,
|
||||
group_id: messageGroupId,
|
||||
session_id: mockSessions[0].id,
|
||||
type: MessageType.BLOCKER,
|
||||
content:
|
||||
"I'm blocked on the database optimization task. Need the auth changes to merge first.",
|
||||
content_length: 82,
|
||||
is_reply: false,
|
||||
reply_to: null,
|
||||
mentions: [AGENT_IDS.beDev1],
|
||||
task_id: TASK_IDS.task5,
|
||||
commit_ref: null,
|
||||
timestamp: getMinutesAgo(50).toISOString(),
|
||||
edited_at: null,
|
||||
was_edited: false,
|
||||
},
|
||||
{
|
||||
id: mockId(),
|
||||
agent_id: AGENT_IDS.beDev1,
|
||||
channel_id: CHANNEL_IDS.backendCell,
|
||||
group_id: messageGroupId,
|
||||
session_id: mockSessions[0].id,
|
||||
type: MessageType.TECHNICAL,
|
||||
content: "Commit pushed: feat(auth): add user authentication schema",
|
||||
content_length: 55,
|
||||
is_reply: false,
|
||||
reply_to: null,
|
||||
mentions: [],
|
||||
task_id: TASK_IDS.task1,
|
||||
commit_ref: "abc123def456",
|
||||
timestamp: getMinutesAgo(45).toISOString(),
|
||||
edited_at: null,
|
||||
was_edited: false,
|
||||
},
|
||||
];
|
||||
// Legacy export for backwards compatibility
|
||||
export const mockMessages = getMockMessages();
|
||||
|
||||
// =============================================================================
|
||||
// MOCK GROUPS - Matching backend GroupResponse schema
|
||||
// =============================================================================
|
||||
|
||||
export const mockGroups = [
|
||||
{
|
||||
id: mockId(),
|
||||
name: "General Discussion",
|
||||
hierarchy_level: 0,
|
||||
is_active: true,
|
||||
total_messages: 150,
|
||||
active_session_id: mockSessions[0].id,
|
||||
},
|
||||
{
|
||||
id: mockId(),
|
||||
name: "Tech Talk",
|
||||
hierarchy_level: 1,
|
||||
is_active: true,
|
||||
total_messages: 80,
|
||||
active_session_id: null,
|
||||
},
|
||||
];
|
||||
|
||||
// =============================================================================
|
||||
// MOCK AUDITOR DATA - Matching backend dashboard.py schemas
|
||||
// =============================================================================
|
||||
@@ -1409,29 +1171,6 @@ export const mockAuditorReports = [
|
||||
];
|
||||
|
||||
export const mockAuditorDashboard = {
|
||||
live_feeds: [
|
||||
{
|
||||
id: CHANNEL_IDS.backendCell,
|
||||
name: "Backend Cell",
|
||||
status: "streaming",
|
||||
last_activity: now.toISOString(),
|
||||
message_count_24h: 25,
|
||||
},
|
||||
{
|
||||
id: CHANNEL_IDS.frontendCell,
|
||||
name: "Frontend Cell",
|
||||
status: "idle",
|
||||
last_activity: hourAgo.toISOString(),
|
||||
message_count_24h: 15,
|
||||
},
|
||||
{
|
||||
id: CHANNEL_IDS.uxuiCell,
|
||||
name: "UX/UI Cell",
|
||||
status: "idle",
|
||||
last_activity: dayAgo.toISOString(),
|
||||
message_count_24h: 5,
|
||||
},
|
||||
],
|
||||
flagged_items: mockAuditorFlags,
|
||||
metrics: {
|
||||
total_flags: 2,
|
||||
|
||||
Reference in New Issue
Block a user