Expose chat tab metadata in connector API

Return the WebUI chat number alongside the honest chat name from chat_get and chats_list. Pass through project metadata so terminal clients can show project-aware context tabs without deriving labels from timestamps or context ids.

Alessandro committed Jun 1, 2026 at 15:06 UTC e6d29938e23195afab1d5f2d10ae6b1305d3d9dc
2 files changed +32 -2
plugins/_a0_connector/api/v1/chat_get.py
+16 -1
@@ -5,6 +5,17 @@ from helpers.api import Request, Response
5 import plugins._a0_connector.api.v1.base as connector_base
6
7
8 +def _project_metadata(context, data: dict[str, object]) -> object:
9 + from helpers import projects
10 +
11 + project_key = getattr(projects, "CONTEXT_DATA_KEY_PROJECT", "project")
12 + return (
13 + data.get(project_key)
14 + or context.get_output_data(project_key)
15 + or context.get_data(project_key)
16 + )
17 +
18 +
19 class ChatGet(connector_base.ProtectedConnectorApiHandler):
20 async def process(self, input: dict, request: Request) -> dict | Response:
21 from agent import AgentContext
@@ -30,14 +41,18 @@ class ChatGet(connector_base.ProtectedConnectorApiHandler):
41
42 context_data = context.output()
43 events, last_sequence = get_context_log_entries(context_id)
44 + project = _project_metadata(context, context_data)
45
46 return {
47 "context_id": context.id,
48 "id": context.id,
37 - "name": context_data.get("name") or context.id,
49 + "name": context_data.get("name") or "",
50 + "no": context_data.get("no", getattr(context, "no", None)),
51 "created_at": context_data.get("created_at"),
52 "last_message": context_data.get("last_message"),
53 "running": context_data.get("running", False),
54 + "project": project,
55 + "project_name": context.get_data("project") or "",
56 "agent_profile": getattr(context.agent0.config, "profile", "default")
57 if context.agent0
58 else "default",
plugins/_a0_connector/api/v1/chats_list.py
+16 -1
@@ -5,6 +5,17 @@ from helpers.api import Request, Response
5 import plugins._a0_connector.api.v1.base as connector_base
6
7
8 +def _project_metadata(context, data: dict[str, object]) -> object:
9 + from helpers import projects
10 +
11 + project_key = getattr(projects, "CONTEXT_DATA_KEY_PROJECT", "project")
12 + return (
13 + data.get(project_key)
14 + or context.get_output_data(project_key)
15 + or context.get_data(project_key)
16 + )
17 +
18 +
19 class ChatsList(connector_base.ProtectedConnectorApiHandler):
20 async def process(self, input: dict, request: Request) -> dict | Response:
21 from agent import AgentContext
@@ -12,13 +23,17 @@ class ChatsList(connector_base.ProtectedConnectorApiHandler):
23 contexts: list[dict[str, object]] = []
24 for context in AgentContext.all():
25 data = context.output()
26 + project = _project_metadata(context, data)
27 contexts.append(
28 {
29 "id": context.id,
18 - "name": data.get("name") or context.name or context.id,
30 + "name": data.get("name") or "",
31 + "no": data.get("no", getattr(context, "no", None)),
32 "created_at": data.get("created_at"),
33 "last_message": data.get("last_message"),
34 "running": data.get("running", False),
35 + "project": project,
36 + "project_name": context.get_data("project") or "",
37 "agent_profile": getattr(context.agent0.config, "profile", "default")
38 if context.agent0
39 else "default",