Skip to content

Fetch macOS native location permission to improve user experience#70833

Merged
carlosmiceli merged 23 commits into
Expensify:mainfrom
ShridharGoel:desktopLocation
Oct 16, 2025
Merged

Fetch macOS native location permission to improve user experience#70833
carlosmiceli merged 23 commits into
Expensify:mainfrom
ShridharGoel:desktopLocation

Conversation

@ShridharGoel

@ShridharGoel ShridharGoel commented Sep 18, 2025

Copy link
Copy Markdown
Contributor

Explanation of Change

Fetch macOS native location permission to improve user experience.

Fixed Issues

$ #70014
PROPOSAL: #70014 (comment)

Tests

Preconditions: disable location services for Expensify Desktop app in MacOS System settings (Location services)

  1. Sign in to ND
  2. Click on FAB - Create expense - Distance
  3. Click on the Start waypoint, select "Use current location"
  4. It should quickly show an error mentioning that location permission needs to be allowed.
  5. Then, allow the permission via system settings.
  6. Try the current location option again, it should fetch the location this time.

QA Steps

Same as tests.

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
LocationFix.mov
Android: mWeb Chrome
Screen.Recording.2025-10-14.at.8.14.59.PM.mov
iOS: Native

<Was facing Mapbox API issue because of which the map screen wasn't loading>

iOS: mWeb Safari
Simulator.Screen.Recording.-.iPhone.16.Plus.-.2025-10-14.at.20.08.01.mov
MacOS: Chrome / Safari
Screen.Recording.2025-10-14.at.7.48.03.PM.mov
MacOS: Desktop
DesktopLocation.mov

@ShridharGoel

Copy link
Copy Markdown
Contributor Author

@QichenZhu @carlosmiceli Can you let me know your thoughts on this? I believe this will provide a much better user experience than having a timeout.

@codecov

codecov Bot commented Sep 18, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 18 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/libs/getCurrentPosition/index.desktop.ts 0.00% 18 Missing ⚠️
Files with missing lines Coverage Δ
src/libs/getCurrentPosition/index.desktop.ts 0.00% <0.00%> (ø)

... and 71 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@carlosmiceli

Copy link
Copy Markdown
Contributor

@ShridharGoel can we split into some commits? There's a lot of changes for a single commit and it's hard to distinguish the "building blocks" of this PR.

@carlosmiceli

Copy link
Copy Markdown
Contributor

There's also failing test and missing coverage, not sure if that changes your solution.

@blimpich

blimpich commented Sep 18, 2025

Copy link
Copy Markdown
Contributor

Please ignore this CodeCov comment for now. It's something new that we're testing out and it shouldn't commented that yet. Updated a config and it shouldn't comment again.

@ShridharGoel

Copy link
Copy Markdown
Contributor Author

I'll split this into multiple commits.

@ShridharGoel ShridharGoel force-pushed the desktopLocation branch 3 times, most recently from 7f225bc to d4b2950 Compare September 19, 2025 07:50
@ShridharGoel ShridharGoel marked this pull request as ready for review September 19, 2025 08:15
@ShridharGoel ShridharGoel requested a review from a team as a code owner September 19, 2025 08:15
@melvin-bot melvin-bot Bot requested review from QichenZhu and removed request for a team September 19, 2025 08:15
@melvin-bot

melvin-bot Bot commented Sep 19, 2025

Copy link
Copy Markdown

@QichenZhu Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@carlosmiceli carlosmiceli self-requested a review September 20, 2025 00:16
@QichenZhu

Copy link
Copy Markdown
Contributor

@ShridharGoel, we have a process to add new libraries like we did for heic-to: https://expensify.slack.com/archives/C01GTK53T8Q/p1744200665946799, but I want to check first if you were able to build a universal app? I could only build an x64 app on my Intel Mac, not sure what environment setup is needed.

@ShridharGoel

Copy link
Copy Markdown
Contributor Author

Yes, npm run desktop-build worked (M3)

@ShridharGoel

Copy link
Copy Markdown
Contributor Author

@QichenZhu Can you check if you are able to build the universal app on main branch?

@QichenZhu

QichenZhu commented Sep 23, 2025

Copy link
Copy Markdown
Contributor

@QichenZhu Can you check if you are able to build the universal app on main branch?

@ShridharGoel, yes.

I think it's because this PR introduces some native code from node-mac-permissions.

@ShridharGoel

Copy link
Copy Markdown
Contributor Author

@QichenZhu Since universal builds are not needed generally in local setup, do you think it matters if local arm64 universal builds don't work on Intel macs?

@QichenZhu

Copy link
Copy Markdown
Contributor

@QichenZhu Since universal builds are not needed generally in local setup, do you think it matters if local arm64 universal builds don't work on Intel macs?

I'm fine with it as long as it doesn't break CI/CD.

@carlosmiceli, can you trigger an ad-hoc build to verify?

@github-actions

Copy link
Copy Markdown
Contributor

🚧 @carlosmiceli has triggered a test Expensify/App build. You can view the workflow run here.

@github-actions

This comment has been minimized.

@QichenZhu

Copy link
Copy Markdown
Contributor

@ShridharGoel, we need to sort out build failure.

⨯ Could not detect abi for version 37.3.1 and runtime electron. Updating "node-abi" might help solve this issue if it is a new release of electron failedTask=build stackTrace=Error: Could not detect abi for version 37.3.1 and runtime electron. Updating "node-abi" might help solve this issue if it is a new release of electron
at Object.getAbi (/Users/runner/work/App/App/node_modules/node-abi/index.js:39:9)
at get ABI [as ABI] (/Users/runner/work/App/App/node_modules/@electron/rebuild/lib/rebuild.js:89:39)
at PrebuildInstall.prebuiltModuleExists (/Users/runner/work/App/App/node_modules/@electron/rebuild/lib/module-type/prebuild-install.js:59:179)
at ModuleRebuilder.prebuildInstallNativeModuleExists (/Users/runner/work/App/App/node_modules/@electron/rebuild/lib/module-rebuilder.js:70:37)
at Rebuilder.rebuildModuleAt (/Users/runner/work/App/App/node_modules/@electron/rebuild/lib/rebuild.js:143:35)
at async Rebuilder.rebuild (/Users/runner/work/App/App/node_modules/@electron/rebuild/lib/rebuild.js:115:17)

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ This PR is possibly changing native code and/or updating libraries, it may cause problems with HybridApp. Please check if any patch updates are required in the HybridApp repo and run an AdHoc build to verify that HybridApp will not break. Ask Contributor Plus for help if you are not sure how to handle this. ⚠️

@ShridharGoel ShridharGoel force-pushed the desktopLocation branch 2 times, most recently from cb78ec1 to e45b476 Compare September 24, 2025 15:45
@ShridharGoel

Copy link
Copy Markdown
Contributor Author

@carlosmiceli Can we try the adhoc build once again?

@ShridharGoel

Copy link
Copy Markdown
Contributor Author

Update: Waiting for an adhoc build here.

CC: @carlosmiceli @AndrewGable

@ShridharGoel

Copy link
Copy Markdown
Contributor Author

@carlosmiceli @AndrewGable Gentle bump for the adhoc build, thanks.

@carlosmiceli

Copy link
Copy Markdown
Contributor

Just now getting to this, will proceed with the adhoc build.

@carlosmiceli

Copy link
Copy Markdown
Contributor

@carlosmiceli

Copy link
Copy Markdown
Contributor

@ShridharGoel here's teh build: #71362 (comment)

@ShridharGoel

Copy link
Copy Markdown
Contributor Author

@carlosmiceli Thanks.

@QichenZhu Can you test it when possible?

@QichenZhu

QichenZhu commented Oct 14, 2025

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
android-native.mp4
Android: mWeb Chrome
android-web.webm
iOS: HybridApp
ios-native.mp4
iOS: mWeb Safari
ios-web.mov
MacOS: Chrome / Safari
mac-web.mov
MacOS: Desktop
mac-desktop.mov

@QichenZhu

Copy link
Copy Markdown
Contributor

@ShridharGoel, I understand this PR focuses on desktop, but it's recommended to test on all platforms and include screenshots/videos.

@QichenZhu

Copy link
Copy Markdown
Contributor

The adhoc build works well in my testing 👍

How's the new library request going?

@ShridharGoel

Copy link
Copy Markdown
Contributor Author

I think @AndrewGable is handling the library request internally.

@roryabraham

Copy link
Copy Markdown
Contributor

@AndrewGable is OOO but the request to add node-mac-permissions is approved

@ShridharGoel

Copy link
Copy Markdown
Contributor Author

@carlosmiceli Please take a look when possible.

carlosmiceli
carlosmiceli previously approved these changes Oct 16, 2025
x64ArchFiles: '**/node_modules/node-mac-permissions/bin/**',
extendInfo: {
CFBundleIconName: getMacBundleIconName(),
NSLocationWhenInUseUsageDescription: 'This app uses location to help you track distance expenses.',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate to open up a can of worms, but how is this translated when you have the app set to Spanish for example?

@ShridharGoel ShridharGoel Oct 16, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we'll need language specific InfoPlist.strings files if we want to support translations. I'll add for en and es.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talked to @roryabraham 1:1 and he suggested we just stick with English only for now.

Comment thread desktop/main.ts Outdated
const status = getAuthStatus('location');

switch (status) {
case 'authorized':

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These feel like great uses for constants

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Comment thread patches/node-abi/details.md Outdated
ships support.
```

- Upstream PR/issue: N/A

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels necessary

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean we should be creating an issue in node-abi ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An issue and/or a PR, yes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checked, newer versions of node-abi have support for Electron 37. So, we'll need to update our node-abi version, and then this patch should not be needed. It seems that we are currently getting node-abi dependency via other dependencies.

├─┬ electron-builder@26.0.19
│ └─┬ app-builder-lib@26.0.19
│   └─┬ @electron/rebuild@3.7.2
│     └── node-abi@3.65.0
└─┬ react-fast-pdf@1.0.29
  └─┬ pdfjs-dist@4.8.69
    └─┬ canvas@3.1.0
      └─┬ prebuild-install@7.1.3
        └── node-abi@3.65.0 deduped

I'll add an override to use 3.78.0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@AndrewGable AndrewGable left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, all yours @carlosmiceli

@carlosmiceli carlosmiceli merged commit 818a8a4 into Expensify:main Oct 16, 2025
34 checks passed

- name: Setup Python for node-gyp
id: setup-python
uses: actions/setup-python@v5

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Immutable action refs only please:

Suggested change
uses: actions/setup-python@v5
# v6.0.0
uses: actions/setup-python@18566f86b301499665bd3eb1a2247e0849c64fa5

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment and quick fix.

@ShridharGoel, this one is already done in #72823. Can you follow up on the other comments asap?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, will be done today.

id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.12'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add a pip cache:

Suggested change
python-version: '3.12'
python-version: '3.12'
cache: 'pip'

python-version: '3.12'

- name: Ensure setuptools for node-gyp
run: python -m pip install --upgrade pip setuptools

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a requirements.txt for and use that to codify and pin python dependencies? Then this would just be pip install -r requirements.txt

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, why do we need python -m ...? The docs make it look like setup-python should add pip to the $PATH just fine: https://github.com/actions/setup-python?tab=readme-ov-file#caching-packages-dependencies

AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
GCP_GEOLOCATION_API_KEY: ${{ secrets.GCP_GEOLOCATION_API_KEY_PRODUCTION }}
S3_BUCKET: ${{ github.ref == 'refs/heads/production' && vars.PRODUCTION_S3_BUCKET || vars.STAGING_S3_BUCKET }}
PYTHON: ${{ steps.setup-python.outputs.python-path }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be necessary, since it looks like actions/setup-python is already adding the specified version of python to the front of the $PATH

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments in deploy.yml apply throughout this file as well

Comment thread desktop/main.ts
type MacPermissionsModule = {
getAuthStatus?: (authType: AuthType) => PermissionType | 'not determined';
};
const macPermissionsModule = (await import('node-mac-permissions')) as MacPermissionsModule | {default: MacPermissionsModule};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to import this every time the event callback is called?

I think it would make more sense to lift macPermissionsModule to the global scope and either:

  • synchronously import it once on app startup (probably simplest, and it's unlikely it would have a big impact on TTI, but you'd have to measure 🤷🏼), or
  • check if it's defined in the callback, and only if it's not then dynamically import it, but only once per app startup, not once per callback execution

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I'm not sure what kind of tree-shaking we have in place for the Electron main process, but if it's possible to import only getAuthStatus that would probably be better than importing the whole module.

import type {GetCurrentPosition} from './getCurrentPosition.types';
import {GeolocationErrorCode} from './getCurrentPosition.types';

const makeError = (code: (typeof GeolocationErrorCode)[keyof typeof GeolocationErrorCode], message: string) => ({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ValueOf from type-fest for improved readability:

Suggested change
const makeError = (code: (typeof GeolocationErrorCode)[keyof typeof GeolocationErrorCode], message: string) => ({
const makeError = (code: ValueOf<typeof GeolocationErrorCode>, message: string) => ({

if (typeof window !== 'undefined' && window.electron?.invoke) {
window.electron
.invoke('check-location-permission')
.then((permissionStatus: unknown) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the type out of desktop/main.ts into it's own file, then import it both in desktop/main.ts and here, then you can have strongly typed location permission status.

doGeoRequest();
})
.catch(() => {
doGeoRequest(); // Fallback to direct geolocation

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused by this. In desktop/main.ts you fallback on permission denied, but in here you seem to fallback on trying to access location anyways?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed this to denied

doGeoRequest(); // Fallback to direct geolocation
});

return; // handled via IPC

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also confused by this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this returns, everything after that point runs through the IPC response

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@roryabraham

Copy link
Copy Markdown
Contributor

@ShridharGoel sorry, I didn't get to finish my review before this was merged. Can you please create a follow-up to address these review comments?

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/carlosmiceli in version: 9.2.33-0 🚀

platform result
🖥 desktop 🖥 success ✅
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 9.2.33-4 🚀

platform result
🖥 desktop 🖥 success ✅
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

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.

7 participants