Skip to content

Many features don't reset across different repositories #5821

Closed

Description

@kidonng

Description

With the recent deployment of Turbo on GitHub, more ajax navigation are enabled that used to be impossible. One of them is navigate from one repo to another repo (usually through notifications or profiles), which used to require a full load of the page.

Whether you like it or not is another topic, but for many Refined GitHub features, it poses a serious issue: we used to implicitly rely on a full load to reset their states across different repos, but that is not the case anymore. This results in them still using old states on a new repository and malfunctioning.

How to replicate the issue

Example: latest-tag-button appears on a different repo with no tag

Screen.Recording.2022-07-13.at.11.22.10.mov

Example: highlight-non-default-base-branch mistakenly use previous repo's default branch

Screen.Recording.2022-07-13.at.11.27.02.mov

Extension version

22.7.11

Browser(s) used

Chrome

Activity

  1. kidonng commented on Jul 13, 2022

    @kidonng
    MemberAuthor

    Maybe we can mem them based on repo? Example for latest-tag-button:

    EDIT: the following code does not work as expected, but you got the idea

    + import mem from 'mem';
    
    - const getRepoPublishState = cache.function(async (): Promise<RepoPublishState> => {
    + const getRepoPublishState = mem(cache.function(async (repo: string): Promise<RepoPublishState> => {
    ...snip...
    - cacheKey: () => 'tag-ahead-by:' + getRepo()!.nameWithOwner,
    + cacheKey: () => 'tag-ahead-by:' + repo,
    ...snip...
    + const repo = getRepo()!.nameWithOwner;
    - const {latestTag, aheadBy} = await getRepoPublishState();
    + const {latestTag, aheadBy} = await getRepoPublishState(repo);
  2. fregante commented on Jul 13, 2022

    @fregante
    Member

    Oof, that explains why I saw the wrong “latest tag” a few times.

    This issue also affects API calls that use an empty repository() because they’re all locally memoized and I don’t think their key ever depends on the current repo.

    But I don’t think the code you mentioned is affected, right? If cacheKey dynamically calls getRepo() then it will always get the latest/correct key. The problem is where we don’t use such dynamic key

  3. self-assigned this
    on Jul 20, 2022
  4. fregante commented on Jul 20, 2022

    @fregante
    Member

    Repro:

    1. Clear cache
    2. Open https://github.com/refined-github/sandbox/pulls (it uses a non-standard default branch name)
    3. Open the notifications
    4. Open any other repo
    5. Visit the Pull requests page on that repo
    6. See highlight-non-default-base-branch showing main even if it's the default for the current repo
  5. fregante commented on Jul 20, 2022

    @fregante
    Member

    I'm leaving this issue open just in case you still find broken features. I only addressed 2 very common scenarios (repository() and getDefaultBranch)

    This issue would probably cover most of the rest of the issues:

    And this could be nice, but I'm not sure I'll finish it:

  6. removed their assignment
    on Aug 5, 2022
  7. fregante commented on Feb 2, 2023

    @fregante
    Member

    This should be the last open AJAX issue 🥹

    I sure there's more though, I wonder where they're hiding

  8. methbkts commented on Feb 5, 2023

    @methbkts

    Thanks for the fix 🥳
    it was very annoying

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions