Skip to content

feat(agents): show last used by/at on card and settings#3302

Open
rafavalls wants to merge 1 commit intomainfrom
rafavalls/agent-last-used-info
Open

feat(agents): show last used by/at on card and settings#3302
rafavalls wants to merge 1 commit intomainfrom
rafavalls/agent-last-used-info

Conversation

@rafavalls
Copy link
Copy Markdown
Collaborator

@rafavalls rafavalls commented May 6, 2026

What is this contribution about?

Surfaces "last used" timestamps for agents on the agent card footer and the agent settings metadata line. Data comes from the most recent thread per agent.

The query lives behind a dedicated read-only tool (VIRTUAL_MCP_LAST_USED_LIST) so it stays off the agent fetch hot path — findById / list on virtual MCPs are unchanged and pay no extra cost.

What changed

Backend

  • New tool VIRTUAL_MCP_LAST_USED_LIST (apps/mesh/src/tools/virtual/last-used-list.ts) — takes { ids: string[] }, returns { items: { id, last_used_at?, last_used_by? }[] }. Registered under the existing Basic Usage capability so all org members can read it.
  • New ThreadStoragePort.findLastUsedByVirtualMcpIds(orgId, ids) (apps/mesh/src/storage/threads.ts) — single DISTINCT ON (virtual_mcp_id) query against threads, ordered by created_at DESC. Lives next to threads since that's the table queried.
  • VirtualMCPEntity schema unchanged — no extra fields on the entity, no extra query when other code paths fetch agents.

SDK

  • New hook useVirtualMCPsLastUsed(ids: string[]) in @decocms/mesh-sdk — returns Map<id, { last_used_at?, last_used_by? }>. Disabled when ids is empty. 30s staleTime.

UI

  • ProjectCard accepts an optional lastUsedAt?: string prop. Shows "Last used X ago" when set, falls back to "Updated X ago" when no thread exists.
  • agents-list.tsx calls the hook once for all visible agents, passes the per-card timestamp down.
  • Agent settings page (virtual-mcp/index.tsx) calls the hook for the single agent. Metadata line shows: [avatar] Creator · Created May 6 · Last used X ago (or "Never used").

How to Test

  1. Open the agents grid — cards for agents with threads show "Last used X ago" in the footer; cards for agents with no threads show "Updated X ago".
  2. Open any agent's settings — the metadata line below the header shows creator + created date + last-used time, or "Never used".
  3. Agent fetch endpoints (COLLECTION_VIRTUAL_MCP_GET, COLLECTION_VIRTUAL_MCP_LIST) are unchanged — the threads query only runs when the UI explicitly calls VIRTUAL_MCP_LAST_USED_LIST.

Migration Notes

No database migrations required. The new tool reads from the existing threads table.

Review Checklist

  • PR title is clear and descriptive
  • Changes are tested and working (`bun test` + `bun run check` pass)
  • No breaking changes
  • Hot-path agent fetches pay no extra cost

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

🧪 Benchmark

Should we run the Virtual MCP strategy benchmark for this PR?

React with 👍 to run the benchmark.

Reaction Action
👍 Run quick benchmark (10 & 128 tools)

Benchmark will run on the next push after you react.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Release Options

Suggested: Minor (2.311.0) — based on feat: prefix

React with an emoji to override the release type:

Reaction Type Next Version
👍 Prerelease 2.310.12-alpha.1
🎉 Patch 2.310.12
❤️ Minor 2.311.0
🚀 Major 3.0.0

Current version: 2.310.11

Note: If multiple reactions exist, the smallest bump wins. If no reactions, the suggested bump is used (default: patch).

@rafavalls rafavalls force-pushed the rafavalls/agent-last-used-info branch from a0f147e to 87863ef Compare May 7, 2026 17:43
@rafavalls rafavalls force-pushed the rafavalls/agent-last-used-info branch from 87863ef to 1f50efb Compare May 8, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant