Skip to content

Fix focus for initial graph load#1480

Merged
aidemsined merged 3 commits into
devfrom
feature/1479-focus-node
May 13, 2026
Merged

Fix focus for initial graph load#1480
aidemsined merged 3 commits into
devfrom
feature/1479-focus-node

Conversation

@aidemsined
Copy link
Copy Markdown
Contributor

closes #1479

Use a lazy initializer for currentOperationId (operationId or first operation id) and remove the earlier precomputed focusNodeId. Compute focusNodeId later: prefer currentOperationId if it's connected, else pick the first connected node, otherwise fall back to operationId or the first operation id or 0. This fixes incorrect initial focus when a provided operationId isn't part of the connected graph and avoids referencing potentially undefined values.
@aidemsined aidemsined changed the title Feature/1479 focus node Fix focus for initial graph load May 13, 2026
@aidemsined aidemsined requested a review from dcblundell May 13, 2026 19:49
Copy link
Copy Markdown
Contributor

@dcblundell dcblundell left a comment

Choose a reason for hiding this comment

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

Seems to work.

@aidemsined aidemsined merged commit 61ff77e into dev May 13, 2026
14 checks passed
@aidemsined aidemsined deleted the feature/1479-focus-node branch May 13, 2026 20:25
@github-actions github-actions Bot mentioned this pull request May 13, 2026
dcblundell added a commit that referenced this pull request May 14, 2026
Automated PR to merge `dev` into `main` after
[v0.85.0](https://github.com/tenstorrent/ttnn-visualizer/releases/tag/v0.85.0)
was published.

**package.json version on `dev`:** 0.85.0

---

## Copilot generated summary

This release (v0.85.0) centres on two major additions: a full **MLIR
graph visualisation** feature built on ReactFlow, and meaningful
hardening of the **file upload and database** layers. It also delivers
targeted UX improvements to the operation graph navigator and a
substantial expansion of test coverage across both frontend and backend.

## Notable Changes

### MLIR Graph Viewer (new feature)
- New `MLIRViewReactFlow` component renders MLIR operation graphs using
`@xyflow/react` and `@dagrejs/dagre` for layout, replacing the removed
`MLIRView` (which depended on `hpcc-js` and `zustand`, now dropped).
- Graph construction split into focused modules: `mlirGraphBuilder`,
`mlirGraphIndexBuilder`, `mlirGraphPartitioner`, `mlirLayoutWorker`, and
`useMlirLayoutWorker` (layout runs off the main thread via a web worker
hook).
- MLIR upload is **disabled in hosted/server mode** as an explicit
security boundary; `MlirProcessingStatus` surfaces async processing
state to users.
- New route (`/mlir`), nav entry, and `MLIR.tsx` route component;
feature is guarded behind a dev-mode flag.
- New test suites (`mlirGraphBuilder.spec`,
`mlirGraphIndexBuilder.spec`, `mlirGraphPartitioner.spec`) with shared
fixture builders and scenario helpers provide thorough coverage of graph
logic.

### File Upload Hardening
- `resolve_folder_name` extracted into a shared helper so both upload
handlers use identical folder-naming logic; fixes broken fallback for
uploaded report names (#1481).
- Malware scanning verified to run on MLIR file uploads; new
`test_file_uploads.py` (~600 lines) covers upload validation end-to-end.
- Input validation tightened; `sanitiseFileName` utility added on the
frontend.

### Database Layer
- **Alembic** introduced for schema migrations (`alembic~=1.18.0`);
`database_migrations.py` and `flask:migrate` npm script orchestrate it;
`alembic.ini` and migration env bundled into package data.
- DB queries refactored to use **column-name access** instead of
positional indices (#1478), eliminating fragile index-dependent row
parsing across `Buffer`, `StackTrace`, and related types.
- Directory existence now ensured before SQLite DB creation, preventing
startup errors.

### Operation Graph Navigation (UX)
- Replaced the "recenter" tooltip with a **Locate button** that
highlights and blinks the current operation node.
- Input/output nodes highlighted relative to the focused operation via a
`NodeRelation` enum; blink animation uses `tinycolor2`-lightened
colours.
- Focus properly initialised on first graph load and preserved during
navigation (#1480, #1473).
- Selected tensor scrolled into view when navigating from the tensor
list (#1476).

### Testing
- `useRemote.spec.tsx` added (124 lines) covering remote hook behaviour.
- `test_queries.py` extended alongside the column-name query refactor.

### Dependencies
- **Added:** `@xyflow/react ^12.10.2`, `@dagrejs/dagre ^3.0.0`,
`@types/dagre ^0.7.54` (frontend); `alembic~=1.18.0` (backend).
- **Removed:** `hpcc-js`, `zustand` (frontend).

## Areas Needing Careful Review
- **Security boundary for MLIR uploads:** confirm the hosted-mode guard
is enforced on every upload path and cannot be bypassed via alternate
routes.
- **Alembic migration bootstrap:** verify the first migration runs
cleanly on existing production databases with varying schema versions.
- **Column-name DB queries:** the refactor touches most query functions;
validate against real report SQLite files, especially older schema
versions.
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.

Operation graph focus node is not in the viewport on load

2 participants