[State namespaces]

AXIS persistence keys, SuperChart migration, pluginsConfig, editor docs, library IDB, and URL hash state.

State namespaces

AXIS persistence is multi-homed: layout/config in localStorage, script library in IndexedDB (or remotes), ephemeral run data in memory, optional URL hash for shareable slices.

Abstract

NamespaceMediumPurpose
pynescript.axis.v1localStorageApp shell state
pynescript.axis.editor.doclocalStorageEditor document backup
pynescript.axis.storageIndexedDBLocal library
pynescript.axis.library.v1localStorage fallbackLibrary if no IDB
pynescript.axis.library.draftlocalStorageDraft buffer
Plugin install listlocalStorageURL plugins restore
store.bars / lastRun / logsmemorySession only

Contract / product identifiers (not storage keys):

pynescript.axis.plugins.v1   # conceptual plugin contract id
pynescript-superchart        # CF project id (infra)

Conceptual model

App state key pynescript.axis.v1

Solid store (frontend/src/store/index.ts):

Persisted (representative):

  • Market: symbol, interval, exchange, source, engine, endpoint
  • activePlugins { source, stream, engine, storage }
  • pluginsConfig
  • Layout: theme, editor, watchlist, panel open/width/height
  • panes, scripts (indicator list metadata)
  • live.streamId (and related live flags carefully)
  • drawings (user annotations)
  • Flat mirrors: source / engine aligned via setActivePlugin

Explicitly omitted on persist:

  • bars
  • lastRun
  • logs

Debounced write (~200ms).

Legacy migration

Read order:

  1. pynescript.axis.v1
  2. else pynescript.superchart.v2
  3. else pynescript.superchart.v1

On legacy hit: copy forward into AXIS key. Editor doc migrates similarly from pynescript.superchart.editor.doc.

Legacy vanilla state.js uses the same STORAGE_KEY constant for the pre-Solid shell.

pluginsConfig

Map of configuration objects. Preferred keys:

`${kind}:${id}`   e.g. storage:cloud, storage:git, engine:server

Bare ids may still be read for compatibility (cloud, git). Values feed configSchema resolution inside plugins.

Sensitive fields: apiKey, git token — browser-local; treat profile as secret store.

Editor document

KeyRole
pynescript.axis.editor.docDraft / shared doc
Bridge messagesPopout synchronization

Popout mode uses editor-bridge + shared storage so detached windows share source without re-fetching library.

Local library IDB

ConstantValue
DB namepynescript.axis.storage
Version1
Storesscripts, kv

Migration flags (pynescript.axis.library.migrated) prevent re-import loops from SuperChart library keys:

  • pynescript.superchart.library.v1
  • pynescript.axis.library.legacy

Cloud / git (remote namespaces)

Not browser keys—server-side partitions:

BackendPartitioning
cloudHash of API key on Worker; D1 table or memory
gitowner/repo@branch + basePath

Revisions: cloud may expose revision / If-Match; git uses blob SHAs via forge APIs.

URL hash state (legacy helper)

frontend/src/state-hash.js (legacy state path):

FeatureDetail
Keyssymbol, interval, engine, source, stream, timeRange
Scriptbase64 in hash if short
Cap~2000 chars
APIapplyHashState, pushHashState, watchHashState

Solid-first product may not wire this by default; treat as optional share mechanism. Prefer library export + recipe docs for durable shares.

Invariants

  1. Migration is read-repair to AXIS keys.
  2. Never persist full OHLCV in axis.v1.
  3. setActivePlugin keeps flat fields coherent.
  4. Logs panel open state forced closed on hydrate (noise control).
  5. Drawing tool resets to cursor on hydrate; geometries restore.

Failure modes

IssueEffectMitigation
QuotaExceededpersist no-opExport library; shrink drawings
Poisoned JSONload defaultsSecurity tests; clear key
Split profiles“missing” librarySame browser profile
Stale activePlugins idmissing pluginFall back / reselect built-in

Internals

PathRole
frontend/src/store/index.tsSolid persistence
frontend/src/store/types.tsAppState
frontend/src/state.jsLegacy state
frontend/src/state-hash.jsHash sync
frontend/src/storage/local.tsIDB library
frontend/src/plugins/loader.tsInstalled plugin list

See also