Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ popover, not for the person who wrote the commit.

## [Unreleased]

## [1.11.3] - 2026-10-27

### Fixed

- **Logging in again after a cloud session expires works again.** Clicking "Log In Again"
froze the sign-in dialog and could open hundreds of browser tabs at once: opening the dialog
kept restarting itself, opening a new sign-in page each time, until the app gave up. It now
opens the browser once

## [1.11.2] - 2026-10-24

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stashpad",
"version": "1.11.2",
"version": "1.11.3",
"description": "The staging area for your AI context.",
"author": {
"name": "Nico Wiedemann",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "stashpad"
version = "1.11.2"
version = "1.11.3"
description = "The staging area for your AI context."
authors = ["Nico Wiedemann <nico.wiedemann@gmail.com>"]
repository = "https://github.com/EarMaster/stashpad"
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
"productName": "stashpad",
"version": "1.11.2",
"version": "1.11.3",
"identifier": "org.stashpad",
"build": {
"frontendDist": "../dist",
Expand Down
13 changes: 10 additions & 3 deletions src/lib/components/CloudAuthModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

<script lang="ts">
import { _ } from "$lib/i18n";
import { untrack } from "svelte";
import { fade } from "svelte/transition";
import { openUrl } from "@tauri-apps/plugin-opener";
import { websiteOriginFromEndpoint } from "$lib/utils/cloud-urls";
Expand Down Expand Up @@ -221,17 +222,23 @@
};
});

// Open the browser and reset state when the dialog is opened
// Open the browser and reset state when the dialog is opened.
//
// Only `open` may trigger this, so the rest runs untracked. It writes `linkNonce` and
// then reads it back to build the URL, and a tracked read of a value the same effect
// just wrote reruns the effect: a new nonce and another browser tab each time, until
// Svelte gave up with effect_update_depth_exceeded and left the dialog frozen.
$effect(() => {
if (open) {
if (!open) return;
untrack(() => {
phase = "waiting";
showManualEntry = false;
linkCode = "";
linkCodeError = null;
linkCodeLoading = false;
linkNonce = crypto.randomUUID();
openBrowser();
}
});
});

// Move focus into the panel once it exists, so Escape and Tab act on the modal
Expand Down
83 changes: 83 additions & 0 deletions src/lib/components/__tests__/CloudAuthModal.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// SPDX-License-Identifier: AGPL-3.0-only

// Copyright (C) 2026 Nico Wiedemann
//
// This file is part of Stashpad.
// Stashpad is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License, version 3,
// as published by the Free Software Foundation.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Affero General Public License for more details.

import { describe, it, expect, vi, beforeEach } from 'vitest';
import { flushSync, mount, unmount } from 'svelte';
import { readable } from 'svelte/store';

const { openUrl } = vi.hoisted(() => ({
openUrl: vi.fn((_url: string) => Promise.resolve()),
}));

vi.mock('@tauri-apps/plugin-opener', () => ({ openUrl }));
vi.mock('@tauri-apps/plugin-deep-link', () => ({
onOpenUrl: vi.fn(() => Promise.resolve(() => {})),
}));
vi.mock('$lib/i18n', () => ({
_: readable((key: string) => key),
}));
vi.mock('$lib/services/desktop-adapter', () => ({
DesktopStorageAdapter: vi.fn(),
}));
vi.mock('$lib/services/cloud-sync', () => ({
getOrCreateDeviceId: vi.fn(),
}));

import CloudAuthModal from '../CloudAuthModal.svelte';

function settingsWithEndpoint() {
return { cloudConfig: { endpoint: 'https://api.stashpad.org' } } as never;
}

describe('CloudAuthModal', () => {
beforeEach(() => {
openUrl.mockClear();
});

// Opening the dialog wrote a fresh nonce and read it back in the same effect, which
// reran the effect until Svelte gave up: hundreds of browser tabs and a frozen dialog.
it('opens the browser exactly once when the dialog opens', () => {
const component = mount(CloudAuthModal, {
target: document.body,
props: {
open: true,
settings: settingsWithEndpoint(),
onSuccess: () => {},
onCancel: () => {},
},
});
flushSync();

expect(openUrl).toHaveBeenCalledTimes(1);
expect(openUrl.mock.calls[0][0]).toMatch(/action=link-desktop&nonce=[0-9a-f-]{36}$/);

unmount(component);
});

it('does not open the browser while the dialog is closed', () => {
const component = mount(CloudAuthModal, {
target: document.body,
props: {
open: false,
settings: settingsWithEndpoint(),
onSuccess: () => {},
onCancel: () => {},
},
});
flushSync();

expect(openUrl).not.toHaveBeenCalled();

unmount(component);
});
});
3 changes: 2 additions & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@

import { defineConfig } from 'vitest/config';
import { svelte } from '@sveltejs/vite-plugin-svelte';
import { svelteTesting } from '@testing-library/svelte/vite';
import path from 'path';

export default defineConfig({
plugins: [svelte({ hot: !process.env.VITEST })],
plugins: [svelte({ hot: !process.env.VITEST }), svelteTesting()],
test: {
globals: true,
environment: 'jsdom',
Expand Down
Loading