Skip to main content

Not every state value belongs in Bitfield. Put state in Bitfield when it coordinates packages. Keep hover, menu, drag, focus, and draft UI details private.

A sidebar has hover state, an editor has unsaved text, a file tree has a selected file, and an assistant panel needs the selected file for context. These are not the same kind of state.The split is simple: Bitfield carries product facts that multiple packages need, while components keep visual-only details close to where they happen.

The rule

Traditional mistake

This turns visual noise into product state. It creates unnecessary churn and makes the product harder to reason about.

Bitfield shape

Private UI state stays private.Shared product state becomes Bitfield state:

The decision table

Four decisions in real product code

Hovered row

Traditional over-globalized answer

Keep hover local

The hover is not a product fact. It is only a visual detail for the current surface.

Open command menu

Traditional over-globalized answer

Keep menu state local

Keep it private unless another package has a real product reason to observe it.

Selected file

Traditional under-shared answer

Better answer when editor, assistant panel, breadcrumbs, and command palette need it:
That value coordinates packages, so it should not be trapped inside one component.

Draft text

Traditional over-shared answer

Keep draft text local

Only promote it when the draft becomes product data, such as a saved message, note, command, or package record.

Promotion rules

What this prevents

React is one adapter example. Swift view state, Kotlin state, terminal prompt state, and future shell state follow the same rule: visual-only state stays near the UI that uses it.

Review checklist

Full before and after

Traditional feature request

“When the user clicks a file row, highlight it, open it in the editor, and show the assistant panel context.”

Bad implementation

This gets both decisions backwards. Hover is visual-only but became global. Selected file coordinates packages but stayed trapped in one component.

Put each value where its readers are

Then the click path updates the public selected-file fact through the package’s public files and names. The editor and assistant panel read that fact. The hover remains private.The rule is not “local state bad” or “Bitfield state good.” The rule is: put each value where its readers are.

Review check

Before adding state, classify it:

Next

Last modified on May 10, 2026