PURPOSE
Playground tab for artifacts, split by the side prop. LEFT (instance) shows a 2-column grid that grants the artifact at runtime and tiers it up on repeat clicks. RIGHT (base) shows a picker plus a tier-values editor that pushes edits back to artifacts/<id>.ts on disk.
OWNS
- Default export
ArtifactsTab(React component, acceptsTabProps:missionRef,side). - Local state:
instanceOpen,baseOpen,selectedArtifact,grantedTiers(record of artifact id to runtime tier 0..4, default -1). - Local helper
grantArtifact(id)that calls the mission sandbox grant and increments the tracked tier (capped at 4). - Internal types and helpers:
ArtifactDraft,toDraft,useArtifactPanel,ArtifactPanelBody.
READS FROM
../../data/artifacts—ARTIFACT_DEFS,ARTIFACT_MAP,ARTIFACT_TIER_COLOR_BY_IDX,ARTIFACT_TIER_NAMES, typeArtifactDef../PlaygroundShared—Panel,PushButton,BTN_STYLE,LABEL_STYLE,EditableTextRow,EditableNumberRow,useDraft, typeTabProps.missionRef.currentfor the sandbox grant API.
PUSHES TO
../../services/playgroundPush—pushStats({ target: 'artifacts', id, patch: { name, description, tiers } })writes back toartifacts/<id>.ts.missionRef.current?.sandboxGrantArtifact(id)— runtime grant in the live mission.
DOES NOT
- Does not edit the common tier (data tier indices 0..3 map to uncommon..legendary; common is computed at runtime from uncommon and is not editable here).
- Does not persist
grantedTiersacross remounts — it is local UI state only. - Does not validate or reconcile push results beyond returning
r.ok(failures are swallowed in acatchreturningfalse). - Does not render anything when
side === 'base'and noartis resolved fromselectedArtifact.
Signals
isDirtyfromuseDrafttoggles the RESET button visibility in the base editor.grantedTiers[id] >= 0flips the instance button into the active style (colored border, tier label).- Data tier index plus one is used as the runtime tier index for color and name lookup (
runtimeTier = tierIdx + 1). - Number step is
0.01when absolute value is under 1, else1.
Entry points
- Rendered by the playground screen with
side="instance"on the left column andside="base"on the right. TabProps.missionRefmust point at a live mission instance exposingsandboxGrantArtifact.ARTIFACT_DEFS[0].idseedsselectedArtifacton mount.
Pattern notes
- Draft-on-edit, push-on-confirm:
useDraftholds the editable copy of name, description, and tiers;pushStatswrites the patch back to source. useMemowrapstoDraft(art)so the original snapshot changes only when the selected artifact changes.ArtifactPanelBodyis keyed onart.idso switching the picker remounts the editor and resets the draft.- Tier blocks are styled with
borderLeftcolored byARTIFACT_TIER_COLOR_BY_IDX[runtimeTier]and labelledT{runtimeTier} {ARTIFACT_TIER_NAMES[runtimeTier]}. - Tier mutations clone the tiers array and the target tier object before assignment to keep the draft update immutable.
- The split-by-
sidepattern lets one tab component supply two different surfaces in the playground layout.