Feature: share location #437
No reviewers
Labels
No labels
app
app
bug
app
enhancement
client side exclusive
closed
completed
closed
duplicate
closed
invalid
closed
not open grind
closed
not planned
closed
question
🗳️ community vote
⚠️ critical
discussion
docs
emulator
help wanted
paywalled
bypassable
paywalled
non-bypassable
paywalled
unconfirmed
pr/dubious
question
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
open-grind/open-grind!437
Loading…
Reference in a new issue
No description provided.
Delete branch "Enucatl/open-grind:feature/location-messages"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I implemented the ability of sharing location.
See #35
4bf69499fba1c834780dPlease capture screenshots with the demo mode on or record a short demo video with all changes to UI
@Enucatl,
The map widget is partially covered by the bottom drawer's tab bar
Also try various designs of the title/caption and whether they're needed in general, considering it's the only element in the tab and the tab itself is titled
Screenshot from android, after the latest refinements on the widget position. I never did UI/frontend in my life so please be patient :)
I don't think we need the "1" in "send location" — there's no multiselection on that tab
This requires ifbranching the media action I was reusing, but there we go with a minimal adaptation.
I don't think it's worth building a further abstraction on top of both media and location, then deriving both only for this.
Still unimplemented?
7fcc50ab73d473402becAlso:
centerAteffect tracksGeoMapPickerinternalsSpinneris imported by file path instead of$lib/components/ui/spinner@ -0,0 +69,4 @@}const initialBounds = (await map.boundingBox())!;await page.getByPlaceholder("Search places...").fill("Berlin");// Android resizes the webview while the search keyboard is open.no-comments rule: rewrite code so it's self-explanatory and semantic without comments
@ -0,0 +107,4 @@.toBuffer();expect([...pixel],"map tiles must not paint over the send button",e2e magenta-pixel check can't see the map, so it doesn't test the overlap it's named for
@ -61,0 +61,4 @@$effect(() => {if (!map) return;const instance = map;// Tabs can mount the map before its container is visible.no-comments rule: rewrite code so it's self-explanatory and semantic without comments
@ -167,8 +176,10 @@url={"https://tile.openstreetmap.org/{z}/{x}/{y}.png"}options={{maxZoom: 19,// OSM requires a web referrer; omit private paths from it.no-comments rule: rewrite code so it's self-explanatory and semantic without comments
@ -41,3 +37,3 @@</script><MediaSheet bind:open fullsize={isFullsizeTab}><MediaSheet bind:open fullsize={selectedTab !== "location"}>selectedTab !== "location"written 4 times where isFullsizeTab was. TheautoLocation.suspend/resumecopied from LocationChooser does nothing useful here.@ -67,2 +63,2 @@<Tabs.Content value="location"><ComposerUnimplementedTab label="Sharing location" issue={35} /><Tabs.Content value="location" class="pb-12"><ComposerLocationTabThe map loads even when the Location tab isn't open, contradicts privacy.md and existing lazy-map precedent. Mount ComposerLocationTab only once the tab is selected.
@ -0,0 +8,4 @@let { message }: { message: LocationMessage["body"] } = $props();const mapUrl = $derived(`https://www.google.com/maps/search/?api=1&query=${message.lat}%2C${message.lon}`,Use
geo:lat,lon?q=…URI, as the official app does, never anything locked to Google.@ -0,0 +42,5 @@.querySelector('[data-slot="message-bubble"]')?.classList.contains(isOut? "bg-message-bubble-out": "bg-message-bubble-in",CONTRIBUTING forbids checking Tailwind classes
d473402bec5f7fd4e47dCloses #459
5f7fd4e47dac1fe7139cac1fe7139caf125e3097Rebase:
Also:
aria-label="Open map"hides "Location" and the coordinates from screen readers.geo:*permission, and the new cached-GPS-fix branch in auto-location.pb-12and-12remare hard-coded offsetsAdditionally:
geo:does nothing on macOS, so fall back to OpenStreetMap web link@ -60,0 +62,4 @@$effect(() => {if (!map) return;const instance = map;const observer = new ResizeObserver(() => instance.invalidateSize());A resize (keyboard, rotation, window) fires a map move. With no saved location, that turns a pin at Madrid (zoom 2) into something you can send in chat, or save in the first-run location screen.
@ -194,0 +218,4 @@pinPos.lon +360 *Math.round((centerLongitude - pinPos.lon) / 360,GeoMapPicker now has two ways to set the pin: the pin follows the map centre, but it can also still be dragged off-centre. After a drag, the next zoom, pan or resize snaps the pin back to the centre. This affects the chat tab and the browse-location chooser.
@ -0,0 +1,30 @@<script lang="ts">import { MapPinIcon } from "phosphor-svelte";Use
phosphor-svelte/lib/MapPinIconaf125e3097d9aa1c92c3repositionInputs={false}behavior.showCountprop to hide the location count.aboveTabBar, the preview-label map, the outbound-schema demo echo, andseedPreferences.geo:*permission, and cached-GPS reuse versus stale-fix requests.pb-12and-12remoffsets and reused shared sheet spacing.geo:links.d9aa1c92. Its title isShare locations in chat (closes #459), and its body describes the browse picker’s new pan behavior.d9aa1c92c381e3162493Thank you
@ -0,0 +169,4 @@if (!map || locked) return;const onMapClick: LeafletMouseEventHandlerFn = ({ latlng }) => {selectLocation(latlng);map?.panTo(latlng, cameraAnimation);The pin follows the pan animation's frames, so a resize during this pan moves the pin by half the height change. On Android: tap the map while the search keyboard is open, and the keyboard hides mid-pan. Same for movePin (search pick, Locate me).
Click, search, and Locate me now move the camera without animation. A resize cannot shift the selected point during that movement. The new tests fail when animation is restored.
@ -0,0 +223,25 @@}}/>{:else if pinPos && !covering}{#key locked}<MarkerlatLng={[pinPos.lat,pinPos.lon +360 *Math.round((centerLongitude - pinPos.lon) / 360,),]}options={{draggable: false,title: "Selected location",icon: divIcon({html: '<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="40" height="40" fill="#ffba20" stroke="#000000" stroke-width="8px" viewBox="0 0 256 256"><path d="M128,16a88.1,88.1,0,0,0-88,88c0,75.3,80,132.17,83.41,134.55a8,8,0,0,0,9.18,0C136,236.17,216,179.3,216,104A88.1,88.1,0,0,0,128,16Zm0,56a32,32,0,1,1-32,32A32,32,0,0,1,128,72Z"></path></svg>',iconAnchor: [20, 40],iconSize: [40, 40],className: "",}),}}/>{/key}These are leftovers from pin dragging; Leaflet markers aren't draggable by default.
Removed draggable: false and the keyed marker block. The marker now uses Leaflet's default behavior.
@ -32,2 +12,3 @@const gpsAvailable = isMobilePlatform();let map: GeoMapComponent | null = $state(null);let pendingCenter: (Coordinates & { zoom: number }) | undefined = $state();The initial view now passes through three pending-centre buffers: ComposerLocationTab's picker effect, this one, and GeoMap's. An initial-view prop read once into the Map options would replace them.
Replaced the pending-center buffers with an initialView prop. GeoMap reads it once for the Map options. Tests check the initial center and zoom.
@ -111,0 +114,4 @@vi.unstubAllGlobals();});it("saves the map center after keyboard or inertial panning, with a fixed marker", async () => {No keyboard or inertial panning here, only setView and panBy. Rename.
Renamed the test to describe panning. It no longer claims to test keyboard or inertial movement.
@ -111,0 +117,4 @@it("saves the map center after keyboard or inertial panning, with a fixed marker", async () => {const setView = vi.spyOn(Map.prototype, "setView");const onSubmit = open();await screen.findByRole("button", { name: "Locate me" });Times out on every run, see ComposerLocationTab.svelte.test.ts:34
Added the GeoMap.svelte preload. The map-center test now passes.
@ -111,0 +152,4 @@it("keeps the pin visible after GPS recenters from another world copy", async () => {const setView = vi.spyOn(Map.prototype, "setView");const onSubmit = open();runMock.mockImplementation(() =>reportFixruns synchronously insiderun(), so the fix lands in the same flush as the lock, which a real GPS fix never does. With the old longitude tracking restored, this test still passes. Resolve the fix after the switch click.The GPS fix now arrives after the switch click completes. The test checks that the pin remains visible after GPS is turned off.
@ -162,1 +162,3 @@{ "min-h-full": fullsize },{"min-h-full": fullsize,"pb-[calc(--spacing(30)+var(--bar-content-gap))]": !fullsize,This applies to every short sheet, including stickers sheet's GIF tab before GIPHY consent when it has no Send button — now it gets 40–52 px of empty space under Continue. It also fights
pb-20and repeats line 144's value. Keep it on the Location tab.Removed the padding override from the shared sheet. The extra space now applies only to the Location tab.
@ -584,2 +584,3 @@sticker.success &&(sticker.data.type === "Giphy" || sticker.data.type === "Gaymoji")(sticker.data.type === "Giphy" ||sticker.data.type === "Gaymoji" ||Rename
sticker, it now covers Location.Renamed sticker to attachment because the parsed message can also be a Location.
@ -62,6 +62,7 @@ const EXPIRING_VIDEO_TYPES = new Set(["Video", "PrivateVideo"]);const STICKER_LABELS: Record<string, string> = {Gaymoji: "Gaymoji",Giphy: "GIF",Location: "Location",Location isn't a sticker, so rename the map.
QUOTE_LABELS.Location(line 90) is now unreachable; delete it like Gaymoji and Giphy.Renamed STICKER_LABELS to ATTACHMENT_LABELS. Removed the unreachable Location entry from QUOTE_LABELS and the duplicate Location fallback.
@ -0,0 +11,4 @@vi.restoreAllMocks();});it("allows geo URLs through the native opener capability", () => {Capability pins live in Rust: add this to
opener_scope_pinsin src-tauri/src/lib.rs instead of reading src-tauri JSON from a frontend test.Moved the geo:* permission check to opener_scope_pins in src-tauri/src/lib.rs. Removed the frontend test that read the capability JSON.
@ -78,6 +92,7 @@aboveTabBarlabel={selection?.label ?? ""}count={selection?.count ?? 0}showCount={isFullsizeTab}Whether the count shows has nothing to do with sheet height; key it on the tab.
showCount now depends on the selected tab. The Location tab hides the count.
@ -0,0 +46,4 @@</script><divclass="relative mx-auto aspect-square w-[min(100%,max(12rem,50svh))] overflow-hidden rounded-lg"Add the sr-only hint LocationChooser has ("Drag the map to place the pin…"). Screen-reader users aren't told that moving the map moves the pin that gets sent.
Added a screen-reader hint that tells users to drag the map to place the pin where they want to share their location.
@ -0,0 +31,4 @@import ComposerLocationTab from "./ComposerLocationTab.svelte";await import("$lib/components/location-chooser/GeoMapPicker.svelte");Preload GeoMap.svelte in both files. GeoMapPicker is a static import now, so this preloads nothing. The lazy chunk is GeoMap.svelte, and tests that wait the default 1 s for "Locate me" fail on every run: both "sends wrapped longitude" cases here and "saves the map center" in LocationChooser.svelte.test.ts.
Both test files now preload GeoMap.svelte. The affected tests pass.
@ -0,0 +63,4 @@}describe("location attachment", () => {it("starts at the supplied browse coordinates rather than the cached GPS fix", () => {This submits before the map loads, so it never sees a cached GPS fix. The browse-over-GPS choice lives in ComposerAttachmentsMenu and is untested. Rename the test to what it checks or test the precedence there.
Renamed the test to state what it checks: sending the supplied coordinates on each mount. It no longer claims to test cached GPS precedence.
@ -0,0 +248,4 @@expect(mocks.abortStale).toHaveBeenCalledExactlyOnceWith(1);finish({ status: "ok", coords: mocks.lastFix });await Promise.resolve();expect(mocks.send).not.toHaveBeenCalled();Locate me never reaches sendMessages, so this can't fail. Removing the
if (!mounted) returnguard keeps the test green.The test now checks the LocateMeButton callback directly. A late GPS result must not call it after unmount. Removing the mounted guard makes the test fail.
@ -0,0 +10,4 @@let { message }: { message: LocationMessage["body"] } = $props();const mapUrl = $derived(isMacosPlatform()Name every platform with
currentPlatform(), don't add a default arm. Here iOS, Windows and Linux silently getgeo:geo:handler and the opener still reports successgeo:on Android and the OpenStreetMap link on iOS, macOS, Windows and LinuxAndroid uses geo:. iOS, macOS, Windows, and Linux use OpenStreetMap. Each platform has an explicit case. There is no default case.
@ -0,0 +30,4 @@openExternalLink(url);return;}pendingOpen = setTimeout(() => openExternalLink(url), 500);Name it as a
*_MSconstant after$props(). Android's double-tap window is 300 ms, so 500 adds 200 ms to every single tap.Added MAP_OPEN_DELAY_MS after $props() and set it to 300 ms.
@ -0,0 +40,5 @@<ahref={mapUrl}onclick={openMap}onpointerdown={cancelOpen}ondblclick={cancelOpen}Removing either cancel handler keeps every test green, because both double sequences send
detail: 2on the second click. Test click(detail 1), click(detail 1), dblclick.Both double-click and double-tap tests now send click(detail: 1), click(detail: 1), then dblclick. Separate tests check cancellation on the second pointer press.
@ -0,0 +42,4 @@onclick={openMap}onpointerdown={cancelOpen}ondblclick={cancelOpen}class="-mx-3 -my-2 flex items-center gap-3 rounded-xl px-3 py-2 select-none"rounded-xl ignores the bubble's square tail corner, so the focus ring on the last bubble of a stack is rounded there.
The link now inherits the bubble's corner radius. The focus ring follows the square corner at the tail.
81e31624939ac29fa941@ -0,0 +91,4 @@zoom: number;}) {selectLocation(latLng(lat, lon));// Keep resize events from shifting a programmatic selection mid-animation.Remove comment
Removed the comment.
@ -0,0 +143,4 @@if (!map || locked) return;const onMapClick: LeafletMouseEventHandlerFn = ({ latlng }) => {selectLocation(latlng);map?.panTo(latlng, { animate: false });Map taps, search picks and Locate me no longer animate in either picker, and reduced motion is no longer consulted. Keep the animation and stop
movefrom re-selecting during programmatic moves instead.Restored animation for map taps, search results, and Locate me. Reduced motion disables it. Programmatic movement no longer changes the selected pin. The tests cover both motion settings and a resize during movement.
@ -120,1 +82,3 @@{/await}<GeoMapPickerbind:pinPosinitialView={pinPos}GeoMap writes
pinPosback withoutzoom, so after any pan a remount opens at zoom 2: switching between dialog and drawer at the breakpoint, or reopening from the empty-location screen. Pass{ ...pinPos, zoom: PIN_ZOOM }like ComposerLocationTab and dropzoomfrompinPos's type.Removed zoom from the pin state and its caller. Each new map receives the selected coordinates and PIN_ZOOM.
@ -111,0 +123,4 @@const map = setView.mock.instances[0];if (!(map instanceof Map)) throw new Error("Map was not mounted");flushSync(() => {map.setView([PARIS.lat, PARIS.lon], 12, { animate: false });This
setViewhides the initial view: deletinginitialView={pinPos}keeps every LocationChooser test green. Assert the map opens at Paris instead.Removed the initial setView call. The test now checks that the map opens at Paris with PIN_ZOOM. It fails if initialView is removed.
@ -144,3 +144,3 @@"h-full scroll-pb-[calc(--spacing(30)+var(--bar-content-gap))] overflow-y-auto":fullsize,"h-fit": !fullsize,"h-fit max-h-screen-safe overflow-y-auto": !fullsize,No effect:
overflow-x-hiddenalready makesoverflow-yauto, andDrawer.Contentalready caps the height. Revert so this file stays untouched.Removed the extra height and overflow classes. The only remaining change in this file uses the shared clearance requested in the other comment.
@ -7,6 +7,23 @@ import {} from "$lib/model/messaging/message-preview";describe("previewFromMessage", () => {it("labels location messages in previews and quotes", () => {const preview = previewFromMessage({type: "Location",body: { lat: 51.5074, lon: -0.1278 },messageId: "location-1",conversationId: "conversation-1",senderId: 42,timestamp: 1_710_000_000_000,unsent: false,reactions: [],dynamic: false,});expect(previewLabel(preview)).toBe("Location");expect(quoteLabel(preview)).toBe("Location");});Duplicates the table row at line 187; delete.
Removed the duplicate test. The existing table still checks Location previews and quotes.
@ -60,3 +60,3 @@const EXPIRING_VIDEO_TYPES = new Set(["Video", "PrivateVideo"]);const STICKER_LABELS: Record<string, string> = {const ATTACHMENT_LABELS: Record<string, string> = {GIFs and Gaymoji are stickers, not attachments (
ComposerSheet = "attachments" | "stickers"). Use a neutral name, e.g.PREVIEW_LABELS.Renamed the map to PREVIEW_LABELS.
@ -34,2 +34,4 @@let locationPin: Coordinates | undefined = $state();const selection = $derived(selections[selectedTab]);const isFullsizeTab = $derived(selectedTab !== "location");Keep main's
FULLSIZE_TABS; this repeats line 95's expression.Restored FULLSIZE_TABS and used it for sheet height. showCount still depends on the selected tab.
@ -0,0 +33,6 @@}</script><p class="sr-only">Drag the map to place the pin where you want to share your location.</p>Nothing references this hint, so focusing the Location tab announces only "Location". Give it an id and point the Location
Tabs.Content'saria-describedbyat it. The pin isn't necessarily your location: "Drag the map to place the pin on the location you want to share."Added an ID to the hint and linked the Location panel to it with aria-describedby. The hint now uses your proposed text. The browser test checks the description.
@ -0,0 +37,4 @@Drag the map to place the pin where you want to share your location.</p><divclass="relative mx-auto mb-[calc(--spacing(10)+var(--bar-content-gap))] aspect-square w-[min(100%,max(12rem,50svh))] overflow-hidden rounded-lg"--spacing(10)is worked out by hand from MediaSheetActions' offset, the button height and the panel'spb-20. Name the clearance once and reuse it here and in MediaSheetBody'sscroll-pb.Defined --sheet-actions-clearance once in MediaSheet. The Location tab and the sheet scroll padding now use that value.
@ -0,0 +280,4 @@}height = 200;flushSync(() => resize?.());await new Promise((resolve) => setTimeout(resolve, 400));A real 400 ms sleep per case, and the ResizeObserver stub is now copied three times (lines 212 and 246 here, LocationChooser.svelte.test.ts:202). Share a helper and use fake timers.
Moved the ResizeObserver stub to a shared helper. The resize tests now use fake timers and check that the animation advances before the resize.
@ -0,0 +312,4 @@unmount();expect(mocks.abortStale).toHaveBeenCalledExactlyOnceWith(1);finish({ status: "ok", coords: mocks.lastFix });await Promise.resolve();Still passes with the
mountedguard removed: in the test buildonlocateruns two microtasks after the result, so oneawait Promise.resolve()checks too early. Wait a macrotask (setTimeout(0)). The test only renders LocateMeButton, so move it to LocateMeButton.svelte.test.ts.Moved the test to LocateMeButton.svelte.test.ts. It now waits for a macrotask. I also checked that the test fails when the mounted guard is removed.
@ -0,0 +50,4 @@async function pointerClick(target: HTMLElement,pointerType: "mouse" | "touch",detail = 1,detailis always 1 now; drop the parameter and the, 1at lines 147 and 167.Removed the parameter and both redundant arguments. The helper now always sends detail: 1.
My comment on Claude usage in PR reviews — https://matrix.to/#/!6A0aN28yRLpX1K8aLtfJWm87DXoyyMGjkPeORakOBZg/$9ONFe9id4n5bvR6tSkadFyT3P6acuZjLJLJ04JbJjGU
Please let me know if you have any questions, troubles with this or just want to talk. I'm always open to discussion here as well as in the Dev Matrix chat room. Thank you.
9ac29fa941a129790d43In response to the latest review:
The branch now has one signed commit,
a129790d. Its message is one line with no body:Share locations in chat (closes #459).The OpenStreetMap privacy entry now covers the chat Location tab and opening a shared location on openstreetmap.org.
Validation: 4,173 frontend tests, 804 Rust tests, and 40 layout checks passed. Lint, formatting, configuration, and type checks passed. The first browser run had 18 failures with four workers. All 18 passed when run with one worker. One browser test and three Rust tests were skipped.