Fix tool icons#2510
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| 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 |
There was a problem hiding this comment.
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/toolIconsand introduces a newToolIconcomponent that inlines them viavite-plugin-svgr(?react+import.meta.glob), so monochrome icons inheritcurrentColorand adapt to themes; updates Tools, RemoteDeviceConfig, AddToolModal, MessageInput, NewAgent, and SharedAgentCard to use it. - Adds
token_usage.model_idvia Alembic migration0015, extendsTokenUsageRepository.insert()andmodels.py, and stamps_canonical_model_idfromLLMCreator.create_llm()for persistence inapplication/usage.pyandscheduler_worker.py. - Adds
scripts/db/backfill_token_usage_model_id.pyto backfill historicalagent_streamrows byrequest_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.
| """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") |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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: