Skip to content

Pre-set profile to active profile when creating a new link#390

Merged
yogeshpaliyal merged 4 commits intomasterfrom
copilot/fix-profile-linking-issue
Mar 7, 2026
Merged

Pre-set profile to active profile when creating a new link#390
yogeshpaliyal merged 4 commits intomasterfrom
copilot/fix-profile-linking-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 21, 2026

When creating a new link, the profile dropdown defaulted to profile ID 1L regardless of which profile the user was currently in.

Root cause: Two compounding issues:

  • createDeeprObject() hardcoded profileId = 1L
  • AddLinkScreen tried to fall back to currentProfile?.id inside a remember(selectedLink) block, which captures the value at first composition — before the StateFlow emits, so currentProfile was null and the fallback to 1L applied

Changes:

  • Home.kt: Collect currentProfile from the ViewModel and pass currentProfile?.id ?: 1L to all three createDeeprObject() call sites (FAB button, clipboard banner, shared text handler)
  • AddLinkScreen.kt: Simplify selectedProfileId initialization to selectedLink.profileId directly — the timing-sensitive currentProfile fallback is no longer needed since the correct profile ID is now passed at navigation time
// Before
mutableStateOf(selectedLink.profileId.takeIf { !isCreate } ?: currentProfile?.id ?: 1L)

// After
mutableStateOf(selectedLink.profileId)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.13-bin/5xuhj0ry160q40clulazy9h7d/gradle-8.13/lib/gradle-daemon-main-8.13.jar (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>When creating a link, the profile should be already set to the profile I'm currently in</issue_title>
<issue_description></issue_description>

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


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: yogeshpaliyal <9381846+yogeshpaliyal@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix profile linking when creating a new link Pre-set profile to active profile when creating a new link Feb 21, 2026
Copilot AI requested a review from yogeshpaliyal February 21, 2026 12:40
@yogeshpaliyal yogeshpaliyal marked this pull request as ready for review February 21, 2026 16:05
Copilot AI review requested due to automatic review settings February 21, 2026 16:05
Copy link
Copy Markdown
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 PR fixes a bug where creating a new link defaulted to profile ID 1L instead of the user's currently active profile. The root cause was twofold: createDeeprObject() hardcoded profileId = 1L, and AddLinkScreen attempted to use a fallback to currentProfile?.id within a remember(selectedLink) block, which captured the value before the StateFlow could emit, resulting in null and falling back to 1L.

Changes:

  • Collect currentProfile from ViewModel in Home.kt and pass the current profile ID (or fallback to 1L) to all three createDeeprObject() call sites
  • Simplify AddLinkScreen.kt to directly use selectedLink.profileId without the timing-sensitive fallback logic

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
app/src/main/java/com/yogeshpaliyal/deepr/ui/screens/home/Home.kt Collects currentProfile StateFlow and passes currentProfile?.id ?: 1L to all three createDeeprObject() call sites (FAB, clipboard banner, shared text handler)
app/src/main/java/com/yogeshpaliyal/deepr/ui/screens/addlink/AddLinkScreen.kt Removes unnecessary currentProfile collection and simplifies profile ID initialization to directly use selectedLink.profileId since it's now correctly set at navigation time

@github-actions
Copy link
Copy Markdown

🧪 Integrated Test Results

The integrated UI tests have completed.

View full test results: Test Run #22259888771

Test reports are available in the artifacts section of the workflow run.

@github-actions
Copy link
Copy Markdown

📱 APK Build Complete!

Your debug APK has been built successfully and is ready for testing.

📥 Download APK

Download app-debug.apk

Note: Click the link above, scroll down to the "Artifacts" section, and download the app-debug artifact.

Retention: This artifact will be available for 3 days.

@github-actions
Copy link
Copy Markdown

🧪 Integrated Test Results

The integrated UI tests have completed.

View full test results: Test Run #22259978438

Test reports are available in the artifacts section of the workflow run.

@yogeshpaliyal yogeshpaliyal merged commit f44d5d5 into master Mar 7, 2026
2 checks passed
@yogeshpaliyal yogeshpaliyal deleted the copilot/fix-profile-linking-issue branch March 7, 2026 07:42
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.

When creating a link, the profile should be already set to the profile I'm currently in

3 participants