Skip to content

Conversation

@buckhalt
Copy link
Member

@buckhalt buckhalt commented Jan 15, 2026

Refactor how variables are accessed in the family tree interface. Remove hardcoded keys, and correctly get the variable names from the stage config and codebook.

Todo:

  • Update protocol-validation package to get change to sex variables once it's released
  • Verify that updating the package resolves lint/type issues

Copilot summary:
This pull request refactors how variable names for key node and edge attributes (such as name and sex) are determined and accessed throughout the Family Tree Census interface. Instead of hardcoding attribute names like "name" and "sex", the code now dynamically retrieves the correct variable names from the stage configuration and codebook using new selector utilities. This makes the system more flexible and robust to protocol changes, and ensures consistent handling of node and edge data.

Dynamic variable name handling for node and edge attributes:

  • Replaced hardcoded references to "name" and "sex" attributes with selectors (getNameVariable, getNodeSexVariable, getEgoSexVariable) that dynamically determine the correct variable names from the stage config and codebook in all major components (FamilyTreeProvider, FamilyTreeNodeForm, FamilyTreeShells, CensusForm). [1] [2] [3] [4] [5]

  • Updated all logic for reading, writing, and displaying node and edge attributes to use these dynamic variable names, including node creation, form processing, shell hydration, and edge identification. [1] [2] [3] [4] [5] [6]

New and improved selector utilities:

  • Added utility selectors in nodeUtils.ts for retrieving name and sex variable names for ego and alters, and for finding the correct name variable using heuristics from the codebook (getNameVariableFromCodebook). [1] [2] [3]

Component and form logic updates:

  • Refactored form logic in CensusForm and FamilyTreeNodeForm to consistently use the new selectors for variable names, ensuring correct reading and writing of node attributes regardless of protocol configuration. [1] [2] [3] [4] [5]

Propagating variable name changes throughout the interface:

  • Ensured that variable name changes are propagated through all relevant hooks, callbacks, and effect dependencies in components, preventing stale or incorrect attribute references. [1] [2] [3] [4] [5] [6]

This refactor makes the Family Tree Census interface much more adaptable to protocol changes and reduces the risk of bugs caused by mismatched or hardcoded variable names.

@vercel
Copy link

vercel bot commented Jan 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
fresco-sandbox Ready Ready Preview, Comment Jan 20, 2026 7:55pm
fresco-storybook Ready Ready Preview, Comment Jan 20, 2026 7:55pm

Request Review

@buckhalt buckhalt requested a review from Copilot January 15, 2026 22:16
@netlify
Copy link

netlify bot commented Jan 15, 2026

Deploy Preview for fresco-preview ready!

Name Link
🔨 Latest commit 4654fb0
🔍 Latest deploy log https://app.netlify.com/projects/fresco-preview/deploys/696fdd35b189d60008b82da1
😎 Deploy Preview https://deploy-preview-590--fresco-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link

github-actions bot commented Jan 15, 2026

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request refactors the Family Tree Census interface to dynamically retrieve variable names for key node and edge attributes from the stage configuration and codebook, eliminating hardcoded attribute references like "name", "sex", and "relationship". The refactor introduces new selector utilities and consistently applies them throughout the interface, making the system more flexible and adaptable to protocol changes.

Changes:

  • Introduced new selector utilities (getNameVariable, getEgoSexVariable, getNodeSexVariable) to dynamically determine variable names from configuration
  • Replaced hardcoded attribute key references with dynamic lookups in all Family Tree components
  • Added getNameVariableFromCodebook utility function implementing the node labeling heuristics

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/interviewer/utils/getNodeLabelAttribute.ts Extracted codebook-only name variable lookup logic into new getNameVariableFromCodebook function
lib/interviewer/containers/Interfaces/FamilyTreeCensus/utils/nodeUtils.ts Added selectors for ego sex, node sex, and name variables with appropriate documentation
lib/interviewer/containers/Interfaces/FamilyTreeCensus/components/FamilyTreeShells.tsx Updated to use dynamic variable names for node name and edge relationship attributes during hydration
lib/interviewer/containers/Interfaces/FamilyTreeCensus/components/FamilyTreeNodeForm.tsx Refactored form logic to dynamically reference name and sex variables throughout node creation and updates
lib/interviewer/containers/Interfaces/FamilyTreeCensus/components/CensusForm.tsx Updated to use getEgoSexVariable instead of getSexVariable for ego attribute access
lib/interviewer/containers/Interfaces/FamilyTreeCensus/FamilyTreeProvider.tsx Updated initialization logic to use dynamic variable names when reading node and edge attributes
lib/interviewer/containers/Interfaces/FamilyTreeCensus/FamilyTreeCensus.tsx Updated edge identification to use dynamic relationship variable
Comments suppressed due to low confidence (1)

lib/interviewer/utils/getNodeLabelAttribute.ts:37

  • Corrected spelling of 'cas' to 'cast'.
      // If not encrypted, check for a valid value that can be cas to a string

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

buckhalt and others added 2 commits January 16, 2026 09:29
…odeUtils.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…nts/FamilyTreeNodeForm.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…nts/CensusForm.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@buckhalt buckhalt merged commit f5f8b1f into v4 Jan 21, 2026
21 checks passed
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.

2 participants