Skip to content

refactor(app): share deep link project opening - #44137

Open
anduimagui wants to merge 17 commits into
anomalyco:devfrom
anduimagui:codex/recreate-deep-link-project-creation
Open

refactor(app): share deep link project opening#44137
anduimagui wants to merge 17 commits into
anomalyco:devfrom
anduimagui:codex/recreate-deep-link-project-creation

Conversation

@anduimagui

Copy link
Copy Markdown

Issue for this PR

Closes #43472

Related to #40094. That issue also covers stale project records after a repository is moved.

This is a clean replacement for #43471 with the same changes, opened separately because #43471 received high-volume external automated AI review noise from an account that is not associated with the repo.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This adds useOpenProject. The hook checks the project list and asks the server to recognize an unknown directory before it opens the project.

It also adds useDeepLinks. This hook owns the pending links, desktop event listener, route creation, and project-open sequence.

Both layouts now use the same hooks. The legacy layout keeps its session handoff and worktree normalization through hook options.

How did you verify your code works?

  • bun typecheck in packages/app
  • bun test src/pages/layout/helpers.test.ts in packages/app (27 tests pass)
  • git diff --check
  • Push hook ran bun turbo typecheck successfully across 30 tasks

Screenshots / recordings

Not applicable. This changes project recognition and navigation behavior without changing the UI.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found

PR #43471 - refactor(app): share deep link project opening
#43471

Why it's related: PR #43471 is explicitly mentioned in the current PR's description as the predecessor that is being replaced. The description states: "This is a clean replacement for #43471 with the same changes, opened separately because #43471 received high-volume external automated AI review noise from an account that is not associated with the repo."

Both PRs appear to be identical in scope—implementing useOpenProject and useDeepLinks hooks to share deep link project opening logic between layouts. You should close or reference #43471 if it's still open.

@Enough1122

Copy link
Copy Markdown

AI code review — automated review for reference, author can ignore or act on any point.

Good extraction overall — use-deep-links.ts and open-project.ts remove a real duplication between layouts, and the option-object wiring keeps layout-specific differences explicit. Points to check:

1. Open-project deep links may land on a different route than before. The old legacy path went through navigateToProject(directory); the new shared hook always navigates to /${base64Encode(directory)}/session (packages/app/src/pages/layout/use-deep-links.ts:20-21). If navigateToProject did anything more (pick the latest existing session, reset sidebar state), that behavior is silently lost for deep-link opens — and neither layout passes a sidebar-resetting navigator here (layout-new.tsx:27 passes bare navigate). Worth confirming the two routes are equivalent, or letting the caller supply the post-open href builder.

2. ensureProject adds new behavior under a refactor label. The known-project check against serverSync().data.project + conditional project.current fetch (packages/app/src/pages/layout/open-project.ts:14-18) didn't exist in the old inline path (or lived elsewhere). Two edge cases: (a) if sync data hasn't loaded yet at deep-link time, known is false and an extra fetch fires — harmless but worth knowing; (b) two deep links for the same directory processed concurrently both see known === false and double-fetch, since there's no in-flight dedupe. A tiny per-directory promise cache would close that.

3. Silent failure policy.catch(() => undefined) (open-project.ts:17) means a failing project.current proceeds to options.open() anyway. That matches "best effort" UX, but consider logging at debug level; today a broken project-open deep link is completely invisible.

4. Drive-by UI change mixed in — the sticky MenuV2.GroupLabel restyle (packages/app/src/components/dialog-select-model.tsx:453) is unrelated to deep-link sharing. It'll work, but folding it into a refactor PR makes bisecting future popover regressions harder; consider splitting it out.

The legacy/new layout gating difference (isLocal() alone vs isLocal() && !newLayoutDesigns()) reads correct — flagging only so a reviewer consciously confirms it.

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.

Desktop deep links can open projects before they are recognized

7 participants