InvokeAI/invokeai/frontend/web
Mary Hipp Rogers 9d6e4ff1fb
workflow tab (#5680)
* new workflow tab UI - still using shared state with workflow editor tab

* polish workflow details

* remove workflow tab, add edit/view mode to workflow slice and get that working to switch between within editor tab

* UI updates for view/edit mode

* cleanup

* add warning to view mode

* lint

* start with isTouched false

* working on styling mode toggle

* more UX iteration

* lint

* cleanup

* save original field values to state, add indicator if they have been changed and give user choice to reset

* lint

* fix import and commit translation

* dont switch to view mode when loading a workflow

* warns before clearing editor

* use folder icon

* fix(ui): track do not erase value when resetting field value

- When adding an exposed field, we need to add it to originalExposedFieldValues
- When removing an exposed field, we need to remove it from originalExposedFieldValues
- add `useFieldValue` and `useOriginalFieldValue` hooks to encapsulate related logic

* feat(ui): use IconButton for workflow view/edit button

* feat(ui): change icon for new workflow

It was the same as the workflow tab icon, confusing bc you think it's going to somehow take you to the tab.

* feat(ui): use render props for NewWorkflowConfirmationAlertDialog

There was a lot of potentially sensitive logic shared between the new workflow button and menu items. Also, two instances of ConfirmationAlertDialog.

Using a render prop deduplicates the logic & components

* fix(ui): do not mark workflow touched when loading workflow

This was occurring because the `nodesChanged` action is called by reactflow when loading a workflow. Specifically, it calculates and sets the node dimensions as it loads.

The existing logic set `isTouched` whenever this action was called.

The changes reactflow emits have types, and we can use the change types and data to determine if a change should result in the workflow being marked as touched.

* chore(ui): lint

* chore(ui): lint

* delete empty file

---------

Co-authored-by: Mary Hipp <maryhipp@Marys-MacBook-Air.local>
Co-authored-by: psychedelicious <4822129+psychedelicious@users.noreply.github.com>
2024-02-14 09:02:07 -05:00
..
.storybook fix(ui): correct import in ReduxInit 2024-01-28 19:57:53 +11:00
config add UI library to rollup config (#5598) 2024-01-29 13:13:09 -05:00
docs docs(ui): add STATE_MGMT.md 2024-01-29 07:28:20 +11:00
patches feat(ui): patch reselect to use lruMemoize only 2024-01-06 00:03:07 +11:00
public workflow tab (#5680) 2024-02-14 09:02:07 -05:00
scripts chore(ui): format 2024-01-28 19:57:53 +11:00
src workflow tab (#5680) 2024-02-14 09:02:07 -05:00
static/docs feat(ui): update assets 2024-01-12 08:02:59 +11:00
tests Partial migration of UI to nodes API (#3195) 2023-04-22 13:10:20 +10:00
__init__.py Run python black 2023-07-28 09:46:44 -04:00
.eslintignore fix(ui): fix workflow editor model selector, excise ONNX 2024-01-03 13:18:50 +11:00
.eslintrc.js chore(ui): update eslint rules 2024-02-02 00:20:28 +11:00
.gitignore Report ci disk space + minor docker fixes (#5461) 2024-01-10 05:20:26 +00:00
.prettierignore fix(ui): fix workflow editor model selector, excise ONNX 2024-01-03 13:18:50 +11:00
.prettierrc.js chore(ui): use new prettier config 2024-01-28 19:57:53 +11:00
.unimportedrc.json chore(ui): format 2024-01-28 19:57:53 +11:00
index.html feat(ui): update assets 2024-01-12 08:02:59 +11:00
package.json chore(ui): bump @invoke-ai/eslint-config-react 2024-02-02 00:20:28 +11:00
pnpm-lock.yaml chore(ui): bump @invoke-ai/eslint-config-react 2024-02-02 00:20:28 +11:00
README.md docs(ui): update README.md 2024-01-29 07:28:20 +11:00
tsconfig.json feat(ui): migrate to @invoke-ai/ui 2024-01-22 09:37:26 +11:00
tsconfig.node.json chore(ui): format 2024-01-28 19:57:53 +11:00
vite.config.mts chore(ui): bump deps 2024-01-01 08:13:23 -05:00

Invoke UI

Invoke's UI is made possible by many contributors and open-source libraries. Thank you!

Dev environment

Setup

  1. Install node and pnpm.
  2. Run pnpm i to install all packages.

Run in dev mode

  1. From invokeai/frontend/web/, run pnpm dev.
  2. From repo root, run python scripts/invokeai-web.py.
  3. Point your browser to the dev server address, e.g. http://localhost:5173/

Package scripts

  • dev: run the frontend in dev mode, enabling hot reloading
  • build: run all checks (madge, eslint, prettier, tsc) and then build the frontend
  • typegen: generate types from the OpenAPI schema (see Type generation)
  • lint:madge: check frontend for circular dependencies
  • lint:eslint: check frontend for code quality
  • lint:prettier: check frontend for code formatting
  • lint:tsc: check frontend for type issues
  • lint: run all checks concurrently
  • fix: run eslint and prettier, fixing fixable issues

Type generation

We use openapi-typescript to generate types from the app's OpenAPI schema.

The generated types are committed to the repo in schema.ts.

# from the repo root, start the server
python scripts/invokeai-web.py
# from invokeai/frontend/web/, run the script
pnpm typegen

Localization

We use i18next for localization, but translation to languages other than English happens on our Weblate project.

Only the English source strings should be changed on this repo.

VSCode

Example debugger config

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "chrome",
      "request": "launch",
      "name": "Invoke UI",
      "url": "http://localhost:5173",
      "webRoot": "${workspaceFolder}/invokeai/frontend/web",
    },
  ],
}

Remote dev

We've noticed an intermittent timeout issue with the VSCode remote dev port forwarding.

We suggest disabling the editor's port forwarding feature and doing it manually via SSH:

ssh -L 9090:localhost:9090 -L 5173:localhost:5173 user@host

Contributing Guidelines

Thanks for your interest in contributing to the Invoke Web UI!

Please follow these guidelines when contributing.

Check in before investing your time

Please check in before you invest your time on anything besides a trivial fix, in case it conflicts with ongoing work or isn't aligned with the vision for the app.

If a feature request or issue doesn't already exist for the thing you want to work on, please create one.

Ping @psychedelicious on discord in the #frontend-dev channel or in the feature request / issue you want to work on - we're happy chat.

Code conventions

  • This is a fairly complex app with a deep component tree. Please use memoization (useCallback, useMemo, memo) with enthusiasm.
  • If you need to add some global, ephemeral state, please use [nanostores] if possible.
  • Be careful with your redux selectors. If they need to be parameterized, consider creating them inside a useMemo.
  • Feel free to use lodash (via lodash-es) to make the intent of your code clear.
  • Please add comments describing the "why", not the "how" (unless it is really arcane).

Commit format

Please use the conventional commits spec for the web UI, with a scope of "ui":

  • chore(ui): bump deps
  • chore(ui): lint
  • feat(ui): add some cool new feature
  • fix(ui): fix some bug

Submitting a PR

  • Ensure your branch is tidy. Use an interactive rebase to clean up the commit history and reword the commit messages if they are not descriptive.
  • Run pnpm lint. Some issues are auto-fixable with pnpm fix.
  • Fill out the PR form when creating the PR.
    • It doesn't need to be super detailed, but a screenshot or video is nice if you changed something visually.
    • If a section isn't relevant, delete it. There are no UI tests at this time.

Other docs