📝 Originally published (in Japanese) at forge.workstyle.tech.

TL;DR The settings screen showed “This section could not be displayed” even though about 1,650 tests passed. An early return before useState broke the order of React hooks. Source string checks and unit tests that did not render the screen could not catch the rendering failure.

TL;DR

The React settings screen failed to open because a useState call came after an early return, breaking the order of hooks. Tests that only checked source strings or didn’t render the screen couldn’t catch the bug. I added linting for the Rules of Hooks and smoke checks that open each settings section.

What Were the 425 Tests Actually Checking?

The 425 assert.match(src, /…/) assertions checked whether the source contained specific strings. Of the 164 test files, 63 read source files.

These tests weren’t useless. They can help catch cases where code that was previously fixed gets changed back. But having a string in the source is different from running the code and confirming it behaves as expected. Even when the source contains the correct line, a problem may still occur when you open the screen.

Other tests checked the inputs and outputs of pure functions, how configuration was assembled, and an LLM (large language model) interface using a fake server. But they didn’t check React rendering, Electron IPC connections, how components worked together, or interactions in the actual app. Electron is the app’s runtime environment; IPC is the communication channel between its components.

Seeing “about 1,650 tests” and assuming that a complete user flow through the UI has been verified would overstate what the tests guarantee.

What Caused the Settings Screen to Fail to Open

The bug was related to the order of React hooks. Hooks are a mechanism for managing state and other values in React components. A useState call came after an early return—that is, code that exits a function partway through when a condition is met—and the screen failed to render.

Because unit tests don’t render React components, they couldn’t detect the broken hook order. I realized that simply adding more tests wouldn’t be enough; we needed another check to cover what tests that don’t render the screen can miss.

How I Verified Hook Ordering with Lint

Linting checks whether code follows a set of rules. I added a lint rule for hook conventions and tested it against the settings screen’s TSX file to confirm that it passed.

I also passed lint a short snippet that deliberately placed useState after an early return and confirmed that it detected the violation. This checked not only that the test passed, but also that it could catch a problem.

A regular function with a hook-like name was incorrectly flagged, so I renamed it. Even after adding a rule, I needed to check how it responded to the code.

How I Checked the Settings Screen with a Smoke Test

Adding lint checks does not confirm that the entire settings screen renders correctly. Errors that occur during rendering need to be checked by opening the screen in the actual app.

To do that, I set up a smoke test that opens each settings section in turn and checks for the message “This section could not be displayed.” A smoke test runs the app to see whether a screen opens. The record from October 7, 2026, shows that all 36 sections opened successfully.

I split the checks by purpose. Source-reading tests check whether specified text is present; hook lint checks whether the rules about hook order are followed; and the smoke test checks whether the settings screen actually opens. I also documented the handoff procedure: after a screen-related change, build the app, restart it, run the smoke test, and then hand it off.

Key takeaways

  • Inspect what each test inputs, runs, and checks, rather than relying on the pass count.
  • Treat assert.match(src, /…/) as a source text check, not a runtime behavior check.
  • Unit tests that do not render the screen may miss UI failures.
  • Verify that the hook lint catches a violation, then open each settings section in a smoke check.