Skip to content

Guard home tab selection against stale/invalid tab query params#1123

Draft
Copilot wants to merge 3 commits intodevfrom
copilot/fix-missing-studies-bug
Draft

Guard home tab selection against stale/invalid tab query params#1123
Copilot wants to merge 3 commits intodevfrom
copilot/fix-missing-studies-bug

Conversation

Copy link
Contributor

Copilot AI commented Feb 27, 2026

In some new-study/Firebase setups, the home page could render top tabs but no study cards. The root cause is a stale or invalid ?tab= value selecting a tab that is not currently available after visibility filtering.

  • Root cause addressed

    • ConfigSwitcher previously trusted searchParams.get('tab') without validating it against tabs that actually exist for the current user/storage-mode visibility state.
    • When the requested tab had no corresponding rendered panel, the page appeared empty despite valid studies being present.
  • Implementation

    • Added a small resolver to validate requested tab selection and fall back to the first available tab:
      • resolveHomeTab(requestedTab, availableTabs, fallbackTab)
    • Computed availableTabs from currently rendered tab groups (Others, Demos, Examples, Tutorials, Tests, Libraries).
    • Switched tab selection logic to use the resolver instead of raw query-param value.
  • Regression coverage

    • Added focused unit tests for:
      • invalid tab → fallback tab
      • valid tab → preserved
      • null tab → fallback tab
export function resolveHomeTab(
  requestedTab: string | null,
  availableTabs: string[],
  fallbackTab: string,
) {
  if (requestedTab && availableTabs.includes(requestedTab)) {
    return requestedTab;
  }
  return fallbackTab;
}
    • Home page after invalid tab fallback
Original prompt

This section details on the original issue you should resolve

<issue_title>New study creation can trigger missing studies bug</issue_title>
<issue_description>Describe the bug

When creating a new study repo clone and setting up Firebase, sometimes the user will encounter the study homepage with the tabs at the top, but with no studies shown underneath.

To Reproduce
Steps to reproduce the behavior:

Fork repo, add new study, push, link up firebase. (I think this is mostly what leads to it)

Expected behavior
The studies should show. Maybe has to do with config hashing?

Work around
If you go to a known url like /demo-html/ it will load the study. Then when you go to the homepage it will work again and show all the studies that are available in the deployment.

Image

<agent_instructions>Please provide some clarity as to what the issue is here. Could it be to do with the currentParticipant parameter or something else from localstorage?</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 27, 2026 03:00
Co-authored-by: JackWilb <36867477+JackWilb@users.noreply.github.com>
Co-authored-by: JackWilb <36867477+JackWilb@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix missing studies bug on new study creation Guard home tab selection against stale/invalid tab query params Feb 27, 2026
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.

New study creation can trigger missing studies bug

2 participants