open-swe icon indicating copy to clipboard operation
open-swe copied to clipboard

Update saving last selected repo to also include owner

Open bracesproul opened this issue 4 months ago • 1 comments

Right now in the repo selector we will save the last selected option in localstorage, then default to that anytime a user loads the page. This is great, but if you switch owners (org/user via the installation ID), then we default to the first repo in the list, instead of the last selected one.

We should update the logic behind the storing & retrieving of the last selected repo to also save the owner, and be able to save multiple entries, one per owner. Then, when the user switches owners, they're still able to have the last repo they selected under that owner be default selected.

Agent Context { "tasks": [ { "id": "a1791302-c836-493a-a5ad-0b1920b3f284", "taskIndex": 0, "request": "[original issue]\n**Update saving last selected repo to also include owner**\nRight now in the repo selector we will save the last selected option in localstorage, then default to that anytime a user loads the page. This is great, but if you switch owners (org/user via the installation ID), then we default to the first repo in the list, instead of the last selected one.\n\nWe should update the logic behind the storing & retrieving of the last selected repo to also save the owner, and be able to save multiple entries, one per owner. Then, when the user switches owners, they're still able to have the last repo they selected under that owner be default selected.", "title": "Update localStorage to store last selected repository per installation/owner", "createdAt": 1754353870013, "completed": false, "planRevisions": [ { "revisionIndex": 0, "plans": [ { "index": 0, "plan": "**Modify localStorage utility functions in `/home/daytona/open-swe/apps/web/src/hooks/useGitHubApp.ts`** (lines 16-52) to support per-installation repository storage. Change `saveRepositoryToLocalStorage` to accept an `installationId` parameter and store repositories in format `{[installationId]: TargetRepository}`. Update `getRepositoryFromLocalStorage` to accept `installationId` parameter and retrieve the repository for that specific installation. Maintain backward compatibility by migrating any existing single repository to the new format.", "completed": true, "summary": "Successfully modified the localStorage utility functions in `/home/daytona/open-swe/apps/web/src/hooks/useGitHubApp.ts` (lines 16-52) to support per-installation repository storage:\n\n**Key Changes Made:**\n- Updated `saveRepositoryToLocalStorage` function to accept an `installationId` parameter\n- Changed storage format from single repository to `{[installationId]: TargetRepository}` structure\n- Updated `getRepositoryFromLocalStorage` function to accept `installationId` parameter and retrieve repository for specific installation\n- Implemented backward compatibility by detecting and handling the old single repository format\n- Added proper error handling and validation for installation ID parameter\n- Ensured migration from old format happens seamlessly during save operations\n\n**Technical Implementation:**\n- The new storage structure allows multiple repositories to be stored, one per installation ID\n- Backward compatibility ensures existing localStorage data continues to work\n- Functions now require installation ID to prevent data corruption\n- Proper JSON parsing and validation maintains data integrity\n\nThe localStorage functions are now ready to support per-installation repository persistence, enabling users to maintain their last selected repository when switching between different GitHub installations/owners." }, { "index": 1, "plan": "**Update the installation change effect in `/home/daytona/open-swe/apps/web/src/hooks/useGitHubApp.ts`** (lines 334-358) to preserve per-installation repository selections. Remove the `setSelectedRepository(null)` call that clears the repository when switching installations. Instead, modify the logic to only reset the auto-selection flags (`hasAutoSelectedRef` and `hasCheckedLocalStorageRef`) so the restoration logic can run for the new installation.", "completed": true, "summary": "Successfully updated the installation change effect in `/home/daytona/open-swe/apps/web/src/hooks/useGitHubApp.ts` (lines 391-416) to preserve per-installation repository selections:\n\n**Key Changes Made:**\n- Removed the `setSelectedRepository(null)` call that was clearing the repository when switching installations\n- Preserved the repository selection state when switching between installations\n- Maintained the reset of auto-selection flags (`hasAutoSelectedRef` and `hasCheckedLocalStorageRef`) to allow restoration logic to run for the new installation\n- Kept the necessary state resets for branches, pagination, and repository loading state\n- Updated comments to clarify the new behavior\n\n**Technical Implementation:**\n- The installation switching logic now only resets the flags that control auto-selection behavior\n- Repository selection is preserved across installation switches, allowing the restoration logic to check localStorage for the new installation\n- Branch state and pagination are still properly reset since they're installation-specific\n- The restoration logic can now run for each installation change to load the appropriate stored repository\n\nThis change enables users to maintain their repository selections when switching between different GitHub installations/owners, as the selected repository is no longer cleared during installation switches." }, { "index": 2, "plan": "**Modify the repository restoration logic in `/home/daytona/open-swe/apps/web/src/hooks/useGitHubApp.ts`** (lines 360-424) to use the current installation ID when retrieving the stored repository. Update the `getRepositoryFromLocalStorage()` call to pass `currentInstallationId` as a parameter. This ensures each installation's last selected repository is restored correctly.", "completed": true, "summary": "Successfully modified the repository restoration logic in `/home/daytona/open-swe/apps/web/src/hooks/useGitHubApp.ts` (lines 418-482) to use the current installation ID when retrieving the stored repository:\n\n**Key Changes Made:**\n- Updated the `getRepositoryFromLocalStorage()` call to pass `currentInstallationId` as a parameter\n- Added `currentInstallationId` as a condition in the useEffect to ensure restoration only runs when installation ID is available\n- Updated both fallback `saveRepositoryToLocalStorage()` calls to include `currentInstallationId` parameter\n- Added `currentInstallationId` to the useEffect dependency array to ensure proper re-execution when installation changes\n\n**Technical Implementation:**\n- The restoration logic now retrieves the repository specific to the current installation from localStorage\n- Each installation's last selected repository is restored correctly when switching between installations\n- Fallback logic (when stored repo doesn't exist) also saves to the correct installation-specific storage\n- The effect properly re-runs when the installation changes, allowing restoration for each installation\n\nThis ensures that each GitHub installation/owner maintains its own repository selection history, and users will see their last selected repository restored when switching between different installations." }, { "index": 3, "plan": "**Update the `setSelectedRepository` function in `/home/daytona/open-swe/apps/web/src/hooks/useGitHubApp.ts`** (line 182) to pass the current installation ID when saving to localStorage. Modify the `saveRepositoryToLocalStorage(repo)` call to include `currentInstallationId` as a parameter, ensuring the repository is saved under the correct installation.", "completed": true, "summary": "Successfully updated the `setSelectedRepository` function in `/home/daytona/open-swe/apps/web/src/hooks/useGitHubApp.ts` (line 236-248) to pass the current installation ID when saving to localStorage:\n\n**Key Changes Made:**\n- Modified the `saveRepositoryToLocalStorage(repo)` call to include `currentInstallationId` as a parameter\n- Added a conditional check to ensure `currentInstallationId` exists before saving to localStorage\n- Updated the useCallback dependency array to include `currentInstallationId` to ensure proper re-creation when installation changes\n- Maintained all existing functionality while ensuring repository is saved under the correct installation\n\n**Technical Implementation:**\n- The function now calls `saveRepositoryToLocalStorage(repo, currentInstallationId)` when saving repository selections\n- Added proper null checking for `currentInstallationId` to prevent errors\n- The repository selection is now properly associated with the current installation in localStorage\n- Users' repository selections are now saved per-installation, enabling proper restoration when switching between installations\n\nThis ensures that when users select a repository, it gets saved to localStorage under the correct installation ID, allowing the system to maintain separate repository selections for each GitHub installation/owner." }, { "index": 4, "plan": "**Run linting and formatting** using `yarn lint:fix` and `yarn format` from the repository root to ensure code quality standards are met.", "completed": false } ], "createdAt": 1754353870013, "createdBy": "agent" } ], "activeRevisionIndex": 0, "pullRequestNumber": 669 } ], "activeTaskIndex": 0 }

bracesproul avatar Jul 11 '25 15:07 bracesproul

🤖 Open SWE has been triggered for this issue. Processing...

View run in Open SWE here (this URL will only work for @bracesproul)

Dev Metadata { "runId": "1f07192e-449d-645d-88a7-c6499dd75b85", "threadId": "248feacd-04e6-4509-b0d7-a7441b64fd31" }

🤖 Plan Generated

I've generated a plan for this issue and will proceed to implement it since auto-accept is enabled.

Plan: Update localStorage to store last selected repository per installation/owner

  • Task 1:
**Modify localStorage utility functions in `/home/daytona/open-swe/apps/web/src/hooks/useGitHubApp.ts`** (lines 16-52) to support per-installation repository storage. Change `saveRepositoryToLocalStorage` to accept an `installationId` parameter and store repositories in format `{[installationId]: TargetRepository}`. Update `getRepositoryFromLocalStorage` to accept `installationId` parameter and retrieve the repository for that specific installation. Maintain backward compatibility by migrating any existing single repository to the new format.
  • Task 2:
**Update the installation change effect in `/home/daytona/open-swe/apps/web/src/hooks/useGitHubApp.ts`** (lines 334-358) to preserve per-installation repository selections. Remove the `setSelectedRepository(null)` call that clears the repository when switching installations. Instead, modify the logic to only reset the auto-selection flags (`hasAutoSelectedRef` and `hasCheckedLocalStorageRef`) so the restoration logic can run for the new installation.
  • Task 3:
**Modify the repository restoration logic in `/home/daytona/open-swe/apps/web/src/hooks/useGitHubApp.ts`** (lines 360-424) to use the current installation ID when retrieving the stored repository. Update the `getRepositoryFromLocalStorage()` call to pass `currentInstallationId` as a parameter. This ensures each installation's last selected repository is restored correctly.
  • Task 4:
**Update the `setSelectedRepository` function in `/home/daytona/open-swe/apps/web/src/hooks/useGitHubApp.ts`** (line 182) to pass the current installation ID when saving to localStorage. Modify the `saveRepositoryToLocalStorage(repo)` call to include `currentInstallationId` as a parameter, ensuring the repository is saved under the correct installation.
  • Task 5:
**Run linting and formatting** using `yarn lint:fix` and `yarn format` from the repository root to ensure code quality standards are met.

Proceeding to implementation...

open-swe[bot] avatar Aug 05 '25 00:08 open-swe[bot]