Skip to content

Commit e217de2

Browse files
fix(frontend): drop unused tool_types_state scaffolding
1 parent 8475dc3 commit e217de2

5 files changed

Lines changed: 3 additions & 30 deletions

File tree

docs/architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ The UI is a **hash-routed** SPA with ES modules under `static/js/`:
106106
- `app.js` — routing and boot
107107
- `projects.js`, `sessions.js`, `search.js`, `export.js` — route handlers
108108
- `render/registry.js`**tool dispatch registry** for session UI: `TOOL_USE_RENDERERS` and `TOOL_RESULT_RENDERERS` map tool name / `result_type` → render function (one module per type under `render/tool_use/` and `render/tool_result/`). Parallels backend `utils/tool_dispatch.py` (backend uses ordered predicates; frontend uses direct key lookup + fallback).
109-
- `static/tool_types.json` — generated manifest of backend tool-use names (`python scripts/gen_tool_types_manifest.py` from `KNOWN_TOOL_TYPES`). Loaded at boot by `render/tool_types_manifest.js`, which cross-checks `TOOL_USE_RENDERERS` and logs `console.warn` on drift.
109+
- `static/tool_types.json` — generated manifest of backend tool-use names (`python scripts/gen_tool_types_manifest.py` from `KNOWN_TOOL_TYPES`). Fetched non-blocking at boot by `render/tool_types_manifest.js` (`void initToolTypesManifest()` in `app.js`), which cross-checks `TOOL_USE_RENDERERS` and logs `console.warn` on drift.
110110
- `shared/markdown.js` — markdown + **DOMPurify** sanitization (do not render raw LLM HTML)
111111
- `shared/state.js`, `shared/utils.js`, `shared/theme.js` — shared UI state and helpers
112112

static/js/render/tool_types_manifest.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { TOOL_USE_RENDERERS } from './registry.js';
2-
import { setManifestToolTypes } from './tool_types_state.js';
32

43
const MANIFEST_URL = '/static/tool_types.json';
54
const MANIFEST_FETCH_TIMEOUT_MS = 5000;
@@ -20,7 +19,6 @@ export async function initToolTypesManifest() {
2019
const data = await res.json();
2120
const types = Array.isArray(data.tool_types) ? data.tool_types : [];
2221
const manifest = new Set(types.filter((t) => typeof t === 'string'));
23-
setManifestToolTypes(manifest);
2422

2523
for (const name of manifest) {
2624
if (!Object.prototype.hasOwnProperty.call(TOOL_USE_RENDERERS, name)) {

static/js/render/tool_types_manifest.test.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
22
import { initToolTypesManifest } from './tool_types_manifest.js';
3-
import { getManifestToolTypes, setManifestToolTypes } from './tool_types_state.js';
43
import { TOOL_USE_RENDERERS } from './registry.js';
54

6-
// Registry drift warnings are asserted here (init-time cross-check only; no per-render warn).
7-
85
describe('initToolTypesManifest', () => {
96
beforeEach(() => {
10-
setManifestToolTypes(null);
117
vi.restoreAllMocks();
128
});
139

1410
afterEach(() => {
15-
setManifestToolTypes(null);
11+
vi.unstubAllGlobals();
1612
});
1713

1814
it('cross-checks manifest against TOOL_USE_RENDERERS and warns on drift', async () => {
@@ -28,7 +24,6 @@ describe('initToolTypesManifest', () => {
2824

2925
await initToolTypesManifest();
3026

31-
expect(getManifestToolTypes()).toEqual(new Set(manifestTypes));
3227
expect(warn).toHaveBeenCalledWith(
3328
'[tool registry] Backend tool type "FutureToolXYZ" has no TOOL_USE_RENDERERS entry',
3429
);
@@ -40,7 +35,6 @@ describe('initToolTypesManifest', () => {
4035

4136
await initToolTypesManifest();
4237

43-
expect(getManifestToolTypes()).toBeNull();
4438
expect(warn).toHaveBeenCalledWith(
4539
'[tool registry] Could not load tool types manifest:',
4640
expect.any(Error),
@@ -66,7 +60,6 @@ describe('initToolTypesManifest', () => {
6660
await vi.advanceTimersByTimeAsync(5000);
6761
await promise;
6862

69-
expect(getManifestToolTypes()).toBeNull();
7063
expect(warn).toHaveBeenCalledWith(
7164
'[tool registry] Could not load /static/tool_types.json: timed out after 5000ms',
7265
);

static/js/render/tool_types_state.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

tests/test_tool_dispatch_sync.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,14 @@ def test_tool_name_literal_matches_known_tool_types() -> None:
137137

138138

139139
def test_frontend_registry_matches_known_tool_types() -> None:
140-
"""``TOOL_USE_RENDERERS`` keys must match ``KNOWN_TOOL_TYPES`` and the manifest."""
140+
"""``TOOL_USE_RENDERERS`` keys must match ``KNOWN_TOOL_TYPES``."""
141141
site = "static/js/render/registry.js (TOOL_USE_RENDERERS)"
142142
try:
143143
actual = _parse_frontend_tool_use_renderers(_FRONTEND_REGISTRY)
144-
manifest = _load_manifest_tool_types(_TOOL_TYPES_MANIFEST)
145144
except ValueError as exc:
146145
pytest.fail(f"{site}: {exc}")
147146
if actual != KNOWN_TOOL_TYPES:
148147
pytest.fail(_format_set_diff(KNOWN_TOOL_TYPES, actual, site))
149-
if actual != manifest:
150-
pytest.fail(_format_set_diff(manifest, actual, site))
151148

152149

153150
def test_known_tool_types_nonempty() -> None:

0 commit comments

Comments
 (0)