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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ flowchart TB

- Pair with a server by scanning a QR / opening a `pulsecam://` deep link — trust-on-first-use confirmation, capability negotiation against the server's `/capabilities` endpoint
- TUS v1 uploads that retry with exponential backoff, resuming from the server's true byte offset; they carry on in the background, and a link is used once — if an upload can't finish (or the app is killed), it's cleaned up and a new link is the retry
- A link can say which place in the host app its upload is for — a ticket, a team's update (protocol 2.7). Pulse then opens the recorder on the draft already started for that place, or on a new one named by the link, preselects the place when you upload, and offers the way back to the host once the video is in. The recorder opens once the server has answered (a toast says it is being asked, a few seconds at most), so a first link needs a connection; a link the place already holds opens its recorder at once. Until a draft uses it, a place has one link on the device: a newer one the server accepted replaces it, an expired one is refused. The link is still one upload — after a failed or cancelled one, a new link for the place comes back to the same draft
- A link can say which place in the host app its upload is for — a ticket, a team's update (protocol 2.7). Pulse then opens the recorder on the draft already started for that place, or on a new one named by the link, preselects the place when you upload, and offers the way back to the host once the video is in. The recorder opens once the server has answered (a toast says it is being asked, a few seconds at most), so a first link needs a connection; a link the place already holds opens its recorder at once. Until a draft uses it, a place has one link on the device: a newer one the server accepted replaces it, an expired one is refused. The link is still one upload — after a failed or cancelled one, a new link for the place comes back to the same draft. A project without a place of its own (a Blank project, a Duplicate, an imported `.pulse`) never has a place preselected: Export preselects the newest server paired without a place, or nothing until you choose
- Which place a link is for is read from its token, which Pulse can't verify: only a link the server has accepted replaces the one a place already has. What a link calls the place, the recording and the host app is unsigned text: shown as one clean line, never deciding where a video goes, and always beside the server's host. A web return opens only from the explicit browser action
- A TimeHuddle project can register its originating app and workflow. After delivery, **Back to TimeHuddle** reopens the release or branch build that started the recording. [Native pairing contract and supported routes](docs/native-return.md)
- A Pulse uploads as one video, plus its captions (WebVTT), beat manifest and thumbnail — each declaring `relatedTo` the video
Expand Down
9 changes: 8 additions & 1 deletion src/features/export/export-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import { libraryNewerSchema } from '@/db/host-context';
import { renameDraft, segmentsForDraft, setDraftCaptionsOff } from '@/db/drafts';
import { drafts } from '@/db/schema';
import type { ExportScreenProps } from '@/features/export/contract';
import { exportActions } from '@/features/export/primary-action';
import { CHOOSE_DESTINATION_LINE, exportActions } from '@/features/export/primary-action';
import { checkSend, TRIM_LABEL, uploadRulesOf } from '@/features/export/send-checks';
import { useExport } from '@/features/export/use-export';
import {
Expand Down Expand Up @@ -435,6 +435,13 @@ export function ExportScreen({
)}
{targets.available && (
<>
{/* Nothing is picked and there's no link to wait for (a draft without a place of its
own, when every destination is another ticket's place): Upload waits for a pick. */}
{!targets.picked && !targets.reopen && (
<ThemedText type="footnote" themeColor="textSecondary" accessibilityRole="text">
{CHOOSE_DESTINATION_LINE}
</ThemedText>
)}
{targets.picker}
{/* The section is already titled Upload: the icon and the destination say the rest.
Middle truncation keeps the domain's end (e.g. "…mieweb.org") visible. */}
Expand Down
5 changes: 5 additions & 0 deletions src/features/export/primary-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import type { ExportPolicy } from './contract';
export const USE_VIDEO_LABEL = 'Use this video';
export const UPLOAD_LABEL = 'Upload';
export const PREPARING_LABEL = 'Preparing video…';
/**
* Shown over the destinations while none is picked and the draft has no place of its own to
* wait for: nothing is chosen for it (`uploadChoice`), so Upload stays off until the person picks.
*/
export const CHOOSE_DESTINATION_LINE = 'Choose where to upload this project.';

export type ExportActionsInput = {
/** The shell's primary action (`onUse` isn't needed here). */
Expand Down
5 changes: 3 additions & 2 deletions src/features/upload/pairing/pool-targets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ export function usePoolTargets(draftId: string): UploadTargets {
);

// Which pool destination the user has picked to upload to, while it's still in the pool. Until
// they pick: the draft's own destination if it has a place, else the most-recent non-expired one
// — derived (see `uploadChoice`), so the draft's place still wins when it loads after the pool.
// they pick: the draft's own destination if it has a place, else the newest one that isn't a
// place, else none — derived (see `uploadChoice`), so the draft's place still wins when it loads
// after the pool.
const [pickedId, setSelectedId] = useState<string | null>(null);
const { destinations, selectedId, reopen } = useMemo(
() =>
Expand Down
31 changes: 30 additions & 1 deletion src/features/upload/pairing/upload-choice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const choose = (args: Partial<Parameters<typeof uploadChoice>[0]>) =>
});

describe('uploadChoice: a draft recorded for no place', () => {
it('defaults to the newest destination, in the pool’s own order', () => {
it('defaults to the newest destination that isn’t a place, in the pool’s own order', () => {
const pool = [option('newest'), option('older', { ref: 'some-place' })];
const choice = choose({ pool });
expect(choice.selectedId).toBe('newest');
Expand All @@ -47,6 +47,35 @@ describe('uploadChoice: a draft recorded for no place', () => {
expect(choice.reopen).toBeNull();
});

it('never preselects another ticket’s place, even when it is the newest', () => {
const pool = [
option('place-b', { ref: 'ticket:B', label: 'Ticket B' }),
option('plain'),
option('place-a', { ref: 'ticket:A', label: 'Ticket A' }),
option('older-plain'),
];
const choice = choose({ pool });
expect(choice.selectedId).toBe('plain');
// The places stay listed, in the pool's order.
expect(choice.destinations.map((d) => d.id)).toEqual([
'place-b',
'plain',
'place-a',
'older-plain',
]);
});

it('selects nothing when every destination is a place, and the person can pick one', () => {
const pool = [option('place-b', { ref: 'ticket:B' }), option('place-a', { ref: 'ticket:A' })];
const choice = choose({ pool });
expect(choice.selectedId).toBeNull();
expect(choice.reopen).toBeNull();
expect(choice.destinations.map((d) => d.id)).toEqual(['place-b', 'place-a']);
expect(choose({ pool, pickedId: 'place-a' }).selectedId).toBe('place-a');
// A pick that left the pool goes back to no default, not to another place.
expect(choose({ pool, pickedId: 'gone' }).selectedId).toBeNull();
});

it('never asks for a new link, with an empty pool or a full one', () => {
expect(choose({}).reopen).toBeNull();
expect(choose({ pool: [option('a')] }).reopen).toBeNull();
Expand Down
11 changes: 9 additions & 2 deletions src/features/upload/pairing/upload-choice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ export type UploadChoice = {
* draft's own name, else by the place's label while its expired row is still in the pool
* (`placeLabel`), else by the server's host. The person can still pick another destination.
*
* Any other draft defaults to the newest destination, as it always has.
* Any other draft (a Blank project, a Duplicate, an imported `.pulse`) is never given a place:
* a place's link is another ticket's single upload, so one tap must not spend it on this draft.
* It defaults to the newest destination that isn't a place (a server paired without a `ref`),
* else to nothing, and the person picks. Places stay in the list to pick.
*
* Nothing is decided before it is known: no default until the draft has loaded (`draft`
* undefined), and no "open a new link" until the pool has (`poolReady`) — an empty pool that
Expand All @@ -59,7 +62,11 @@ export function uploadChoice(args: {
const destinations = ownDestination
? [ownDestination, ...pool.filter((d) => d !== ownDestination)]
: [...pool];
const defaultId = !draft ? null : place ? (ownDestination?.id ?? null) : (pool[0]?.id ?? null);
const defaultId = !draft
? null
: place
? (ownDestination?.id ?? null)
: (pool.find((d) => d.ref === null)?.id ?? null);
const selectedId = pickedId && pool.some((d) => d.id === pickedId) ? pickedId : defaultId;
// Only an unsent draft: uploading, its link was just claimed; uploaded, it needs none.
const reopen =
Expand Down
Loading