Skip to content

feat(tree): add type-aware field creation in Tree view - #21

Closed
EMTumariscal wants to merge 6 commits into
Flowdesktech:masterfrom
EMTumariscal:feat/add-fields
Closed

EMTumariscal wants to merge 6 commits into
Flowdesktech:masterfrom
EMTumariscal:feat/add-fields

Conversation

@EMTumariscal

Copy link
Copy Markdown
Contributor

Description

Adds intuitive field creation to the Tree view. Hovering a document or a nested Map row reveals an Add (+) button that opens a type-aware Add Field dialog (name + type + value input adapted to the type). On save, the field is written via the existing updateDocument flow and the tree refreshes. Scope is documents plus nested Maps; Array indices are excluded, consistent with the existing field-deletion rule.

Why: adding fields through the JSON view is possible but not intuitive, and the Table view only edits top-level fields. The Tree already models every field (including nested ones) as a node with a docId.field.nested path, so it is the natural place for this.

Type of Change

  • Feature
  • Bug fix
  • Docs
  • Refactor

AI Code Generation

AI-assisted implementation (OpenCode with Muse Spark, orchestrated ODD workflow: delegated writer sub-agent for TD-1/TD-2, human-reviewed). All commits verified with typecheck, tests, scoped lint/format. Native receipt-driven review ran on the slice (medium risk): reviewer raised 3 findings (1 BLOCKER timestamp NaN guard, 2 CRITICAL parent-path fallback and JSON-clone lossiness); the bounded correction fixed 2, the validator rejected it over the remaining BLOCKER, and the BLOCKER was then fixed as ordinary follow-up work. Review ended escalated (terminal stop) — outcome is informational only.

Related Issue

No related issue exists in the tracker; this addresses the maintainer request for intuitive field creation in Tree view.

Technical Context

  • Type system: getValueType/getTypeColor in src/features/collections shared utils (String, Integer, Number, Boolean, Null, Timestamp, GeoPoint, Array, Map, Reference).
  • Dialog conventions reused: MUI Dialog pattern from AddDocumentDialog/EditDialog (Ctrl+Enter, monospace inputs, Type badge); datetime-local input like TreeNodeRow/DatePopover.
  • Plumbing: documentService.prepareAddData (dot-path set, duplicate/empty/dots/Array rejection, structuredClone with JSON fallback) -> TreeContext.onAddField -> CollectionTab -> updateDocument thunk.
  • Follow-up fixes: hardened nested parentPath derivation in TreeNodeRow, invalid-date guard in AddFieldDialog.
  • Work tracking: odd/tasks/tree-add-fields.md (shipped in this PR as the feature record).

Test Environment

  • Hardware/OS: Linux (dev machine)
  • App: Firestudio Electron desktop (UI change, no headless runtime harness)
  • Checks (local, equivalent of CI): pnpm run lint (only 1 pre-existing warning in untouched electron/controllers/firebaseController.js), pnpm run format:check clean, pnpm run typecheck clean, pnpm run test 89/89 passing across 12 files
  • Model/provider: Muse Spark via OpenCode

Evidence

  • pnpm run test: Test Files 12 passed, Tests 89 passed
  • pnpm run typecheck: clean (tsc --noEmit)
  • Scoped ESLint + Prettier on all touched files: clean
  • Commits: 3623546 AddFieldDialog, a22afac add plumbing, faac5e2 review-correction hardening, 0207f8b timestamp guard, plus docs commits

Checklist

  • Ran checks locally (lint / format:check / typecheck / test) — green except one pre-existing lint warning in an untouched file
  • PR is focused: only Tree-view field creation + its feature record (7 files)
  • AI involvement disclosed above
  • No unrelated changes bundled
  • Note: slice is ~596 lines, over the 400-line budget — requesting size:exception (single cohesive feature; splitting dialog vs plumbing would not leave independently shippable slices)

Size

~596 insertions / 1 deletion across 7 files (188 lines are the ODD feature record). Requesting size:exception for a single PR.

@EMTumariscal

Copy link
Copy Markdown
Contributor Author

Superseded by #22 — consolidated PR from EMTumariscal:develop to master bundling this change with its original description preserved. Closing per maintainer request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant