Skip to content

Fix tool icons#2510

Merged
dartpain merged 2 commits into
mainfrom
fix-tool-icons
May 29, 2026
Merged

Fix tool icons#2510
dartpain merged 2 commits into
mainfrom
fix-tool-icons

Conversation

@dartpain
Copy link
Copy Markdown
Contributor

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

  • Why was this change needed? (You can also link to an open issue here)

  • Other information:

@dartpain dartpain requested a review from Copilot May 29, 2026 08:05
@vercel
Copy link
Copy Markdown

vercel Bot commented May 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nextra-docsgpt Building Building Preview, Comment May 29, 2026 8:05am
oss-docsgpt Ready Ready Preview, Comment May 29, 2026 8:05am

Request Review

from alembic import op


revision: str = "0015_token_usage_model_id"


revision: str = "0015_token_usage_model_id"
down_revision: Union[str, None] = "0014_device_token_hash_index"

revision: str = "0015_token_usage_model_id"
down_revision: Union[str, None] = "0014_device_token_hash_index"
branch_labels: Union[str, Sequence[str], None] = None
revision: str = "0015_token_usage_model_id"
down_revision: Union[str, None] = "0014_device_token_hash_index"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Despite the title "Fix tool icons", this PR bundles two largely independent changes: a frontend tool-icon refactor and a backend addition of per-call model attribution on token_usage rows.

Changes:

  • Moves tool SVGs into frontend/src/assets/toolIcons and introduces a new ToolIcon component that inlines them via vite-plugin-svgr (?react + import.meta.glob), so monochrome icons inherit currentColor and adapt to themes; updates Tools, RemoteDeviceConfig, AddToolModal, MessageInput, NewAgent, and SharedAgentCard to use it.
  • Adds token_usage.model_id via Alembic migration 0015, extends TokenUsageRepository.insert() and models.py, and stamps _canonical_model_id from LLMCreator.create_llm() for persistence in application/usage.py and scheduler_worker.py.
  • Adds scripts/db/backfill_token_usage_model_id.py to backfill historical agent_stream rows by request_id/agent+nearest-message, plus new repository tests for the model_id column.

Reviewed changes

Copilot reviewed 15 out of 35 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
frontend/src/components/ToolIcon.tsx New component mapping tool_<name>.svg to React components via SVGR glob.
frontend/src/vite-env.d.ts Adds vite-plugin-svgr/client reference.
frontend/src/assets/toolIcons/*.svg Tool SVGs moved from public/ and recolored to currentColor where appropriate.
frontend/public/toolIcons/*.svg Deleted public copies of tool SVGs.
frontend/src/settings/Tools.tsx, RemoteDeviceConfig.tsx, modals/AddToolModal.tsx, agents/SharedAgentCard.tsx Replace <img src="/toolIcons/..."> with <ToolIcon />.
frontend/src/components/MessageInput.tsx, agents/NewAgent.tsx Pass <ToolIcon /> React node as MultiSelectPopoverItem.icon instead of a URL string.
application/alembic/versions/0015_token_usage_model_id.py Adds token_usage.model_id column and partial index.
application/storage/db/models.py Mirrors new model_id column in SQLAlchemy table.
application/storage/db/repositories/token_usage.py insert() now accepts and persists model_id.
application/llm/llm_creator.py Stamps _canonical_model_id on the LLM instance after construction.
application/usage.py Forwards _canonical_model_id to the token_usage insert.
application/api/user/scheduler_worker.py Persists model_id=outcome.get("model_id") for scheduled runs.
scripts/db/backfill_token_usage_model_id.py New tier-1/tier-2 backfill with dry-run default and --window-minutes.
tests/storage/db/repositories/test_token_usage.py Adds tests for persisting/null-defaulting model_id.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +34
"""0015 token_usage model_id — record which model each call ran under.

Adds ``token_usage.model_id`` (canonical id: catalog name for built-ins,
UUID for BYOM) so analytics can group spend by model. The partial index
mirrors ``token_usage_request_id_idx`` — it excludes the NULL rows that
pre-date the column.

Revision ID: 0015_token_usage_model_id
Revises: 0014_device_token_hash_index
"""

from typing import Sequence, Union

from alembic import op


revision: str = "0015_token_usage_model_id"
down_revision: Union[str, None] = "0014_device_token_hash_index"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
op.execute("ALTER TABLE token_usage ADD COLUMN model_id TEXT;")
op.execute(
'CREATE INDEX token_usage_model_ts_idx '
'ON token_usage (model_id, "timestamp" DESC) '
"WHERE model_id IS NOT NULL;"
)


def downgrade() -> None:
op.execute("DROP INDEX IF EXISTS token_usage_model_ts_idx;")
op.execute("ALTER TABLE token_usage DROP COLUMN IF EXISTS model_id;")
"""
)

_COUNT_NULL = text("SELECT count(*) FROM token_usage WHERE model_id IS NULL")
@dartpain dartpain merged commit 666db29 into main May 29, 2026
19 checks passed
@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.44%. Comparing base (9b8fe2d) to head (55974b8).
⚠️ Report is 51 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2510      +/-   ##
==========================================
- Coverage   91.34%   89.44%   -1.90%     
==========================================
  Files         248      288      +40     
  Lines       20709    25526    +4817     
==========================================
+ Hits        18916    22832    +3916     
- Misses       1793     2694     +901     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants