-
Notifications
You must be signed in to change notification settings - Fork 0
Add read-only Twister configuration UI #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
oveddan
wants to merge
4
commits into
main
Choose a base branch
from
agent/read-only-ui
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| name: CI | ||
|
|
||
| concurrency: | ||
| group: ci-${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| test: | ||
| timeout-minutes: 15 | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - os: ubuntu-latest | ||
| node: 20 | ||
| - os: ubuntu-latest | ||
| node: 22 | ||
| - os: macos-latest | ||
| node: 20 | ||
| runs-on: ${{ matrix.os }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.node }} | ||
| cache: npm | ||
| - name: Install native MIDI build dependency | ||
| if: runner.os == 'Linux' | ||
| run: sudo apt-get update && sudo apt-get install --yes libasound2-dev | ||
| - run: npm ci | ||
| - run: npm run check | ||
| - name: Pack, clean-install, and smoke-test the CLI | ||
| run: npm run test:package | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| # Read-only UI architecture | ||
|
|
||
| The visual configurator is a small local web application. `mft-config ui` | ||
| starts an HTTP server on `127.0.0.1:4783` and serves dependency-free HTML, CSS, | ||
| and browser JavaScript from `ui/`. The browser never opens MIDI ports. The Node | ||
| server reuses the same exporter and protocol decoder as `mft-config export`. | ||
|
|
||
| ## Hard read-only boundary | ||
|
|
||
| The server imports `RtMidiReadOnlyBackend`, not `RtMidiBackend`. The read-only | ||
| backend has only `discover` and `connect`; it cannot create the separate | ||
| `ConfigurationWriteConnection` required by the applier. Its connection's only | ||
| send method runs every frame through `assertReadOnlyRequest` immediately before | ||
| the native MIDI output call. | ||
|
|
||
| The local HTTP surface is intentionally tiny: | ||
|
|
||
| - `GET /api/devices` sends Universal Identity Request and returns matching | ||
| Twister ports. | ||
| - `POST /api/export` accepts only `{ "deviceIndex": <non-negative integer> }` | ||
| and runs the complete read-only export. | ||
|
|
||
| There are no plan, apply, write, reset, system, or bootloader routes. Unknown | ||
| `/api/*` paths return 404 without opening a MIDI connection. The transport guard | ||
| still blocks a mutating or unknown SysEx frame if one reaches it. Tests assert | ||
| both layers. | ||
|
|
||
| The UI listens on loopback by default. `MFT_CONFIG_UI_HOST` can override the | ||
| host, but exposing a hardware-adjacent local service to a network is not | ||
| recommended. Responses use a same-origin Content Security Policy and do not | ||
| load remote assets. | ||
|
|
||
| ## Browser model | ||
|
|
||
| `ui/app.js` is split into small state, API, validation, and rendering functions. | ||
| It validates imported snapshots before rendering. Imports stay entirely in the | ||
| browser, so offline inspection does not touch MIDI. Downloads serialize the | ||
| exact in-memory snapshot rather than reconstructing configuration fields. | ||
|
|
||
| The grid always renders 16 encoders in physical left-to-right, top-to-bottom | ||
| order. Bank tabs are created from the snapshot, so both four- and eight-bank | ||
| exports use the same rendering path. Each knob persistently shows all three | ||
| stored 7-bit color indices: active, inactive, and detent. Active and inactive | ||
| use the selected Classic or MF64 RGB palette; the indicator-ring detent uses its | ||
| separate red/blue balance. CSS previews are a screen approximation; the numeric | ||
| index displayed in the knob detail is authoritative because hardware LED output | ||
| depends on brightness and diffusion. | ||
|
|
||
| ## Local development | ||
|
|
||
| Install and run all checks: | ||
|
|
||
| ```sh | ||
| npm ci | ||
| npm run check | ||
| npm run test:package | ||
| ``` | ||
|
|
||
| Start the UI through the packaged command path: | ||
|
|
||
| ```sh | ||
| npm run build | ||
| node dist/cli.js ui | ||
| ``` | ||
|
|
||
| Or use the contributor shortcut, which builds first: | ||
|
|
||
| ```sh | ||
| npm run ui | ||
| ``` | ||
|
|
||
| Set a different loopback port when needed: | ||
|
|
||
| ```sh | ||
| MFT_CONFIG_UI_PORT=4784 npm run ui | ||
| ``` | ||
|
|
||
| Then open the printed URL. Exercise device discovery with hardware attached, | ||
| or use **Open JSON snapshot** to test every view offline. Server tests inject a | ||
| fake read-only backend and never require MIDI hardware. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workflow executes
actions/checkout@v4andactions/setup-node@v4rather than immutable commit SHAs, so upstream tag movement can change code executed with repository read access or alter the checkout and toolchain used by subsequent checks.How this was verified: Both executable action references use mutable
@v4tags and the workflow grantscontents: read.Prompt To Fix With AI