Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

fix: preserve offer retry states and scoped field undo

Amruth Pillaid48fec6cd508
diff --cc apps/mobile/scripts/experience.test.mjs
index d371cebe7,642eb404f..c6bbedc0d
--- a/apps/mobile/scripts/experience.test.mjs
+++ b/apps/mobile/scripts/experience.test.mjs
@@@ -821,35 -815,16 +821,42 @@@ const { OfferEntry } = load("features/c
},
"./shared": { EditorSheet: "EditorSheet", LoadState: "LoadState" },
"@/features/application-detail/date-field": { WallClockField: "WallClockField" },
- "@/features/applications/queries": { useApplications: () => ({ data: [] }) },
+ "@/features/applications/queries": { useApplications: () => offerApplications },
});
reset();
+offerApplications = { isPending: true };
+assert.equal(render(OfferEntry, {}).type, "LoadState", "unknown metadata offers no ready action");
+offerApplications = { isError: true };
+assert.equal(render(OfferEntry, {}).type, "LoadState", "failed metadata stays retryable, not empty");
++offerApplications = { isError: true, data: [] };
++assert.equal(render(OfferEntry, {}).type, "LoadState", "failed refresh with cached empty metadata stays retryable");
+offerApplications = { data: [] };
+// With no application to attach it to, Add offer leads to saving a job first.
+control(render(OfferEntry, {}), "Add an application first").onPress();
+assert.deepEqual(calls, ["/applications?create=1"]);
+assert.ok(!nodes(render(OfferEntry, {})).some((node) => node.props.label === "Add offer"));
+reset();
const entryView = () => render(OfferEntry, { application: { id: "job", company: "Fictional Labs", role: "Engineer" } });
control(entryView(), "Add offer").onPress();
const formElement = nodes(entryView()).find((node) => typeof node.type === "function");
assert.ok(formElement);
reset();
const offerView = () => render(formElement.type, { ...formElement.props, onClose() {} });
++const initialOffers = savedOffers;
++savedOffers = [];
++offerView();
++assert.equal(control(offerView(), "Currency").value, "", "empty results do not invent a currency");
++savedOffers = initialOffers;
+offerView();
+assert.equal(control(offerView(), "Currency").value, "GBP", "starts in the last offer's currency");
+savedOffers = [{ createdAt: "2026-11-01T00:00:00Z", data: { kind: "offer", currency: "EUR" } }];
+assert.equal(control(offerView(), "Currency").value, "GBP", "late refetch cannot replace the draft currency");
+assert.equal(control(offerView(), "Currency").placeholder, undefined, "no placeholder posing as a value");
+assert.match(control(offerView(), "Currency").helper, /three-letter/);
+assert.ok(!nodes(offerView()).some((node) => node.props.label === "Learning budget"), "rarer terms start folded");
+assert.ok(!nodes(offerView()).some((node) => /Times are shown/.test(String(node.props.children))));
control(offerView(), "Currency").onChangeText("EUR");
+control(offerView(), "More options").onPress();
control(offerView(), "Learning budget").onChangeText("95k");
assert.equal(control(offerView(), "Learning budget").error, undefined, "typing shows no premature error");
control(offerView(), "Learning budget").onBlur();
@@@ -1529,3 -1501,3 +1536,43 @@@ for (const state of ["loading", "error"
}
assert.equal(scheduleRetries, 1);
console.log("PASS native preparation distinguishes loading/error from empty/configured AI lookup");
++
++const { CustomFields } = load("features/write/basics-screen.tsx", {
++ "expo-image": { Image: "Image" },
++ "@reactive-resume/utils/string": { generateId: () => "new-field" },
++ "./entry-fields": { BoundText: "BoundText", LinkField: "LinkField", useValidators: () => ({}) },
++ "./entry-screen": { EditorScreen: "EditorScreen" },
++ "./hooks": { useWriteData: () => null },
++ "./pickers": { IconPickerSheet: "IconPickerSheet", PromptSheet: "PromptSheet" },
++ "./picture-screen": { resolvePictureUrl: () => "" },
++ "@/auth/session": { useSession: () => ({}) },
++ "@/draft": { useIsResumeLocked: () => false, useResumeStore: {} },
++});
++reset();
++const removedField = { id: "field-one", icon: "acorn", text: "Portfolio", link: "https://portfolio.example/" };
++let fieldDocument = { headline: "Before", fields: [removedField] };
++const fieldHistory = [];
++const updateFields = (mutate) => {
++ fieldHistory.push(structuredClone(fieldDocument));
++ fieldDocument = structuredClone(fieldDocument);
++ mutate(fieldDocument.fields);
++};
++const fieldView = () =>
++ render(CustomFields, {
++ fields: fieldDocument.fields,
++ locked: false,
++ update: updateFields,
++ undo: () => (fieldDocument = fieldHistory.pop()),
++ });
++control(fieldView(), "Remove field").onPress();
++assert.equal(fieldDocument.fields.length, 0);
++const removalToast = calls.find((value) => value.message === "Field removed");
++assert.ok(removalToast);
++fieldHistory.push(structuredClone(fieldDocument));
++fieldDocument = { ...fieldDocument, headline: "Later edit" };
++removalToast.action.onPress();
++assert.equal(fieldDocument.headline, "Later edit", "field Undo preserves a later edit");
++assert.deepEqual(fieldDocument.fields, [removedField], "field Undo restores only the removed field");
++removalToast.action.onPress();
++assert.deepEqual(fieldDocument.fields, [removedField], "a restored field is never duplicated");
++console.log("PASS native custom-field Undo restores its field without reverting later edits or duplicating it");
diff --cc apps/mobile/src/features/career/offer-entry.tsx
index 2f1b5e48b,9808c13d6..02bb61901
--- a/apps/mobile/src/features/career/offer-entry.tsx
+++ b/apps/mobile/src/features/career/offer-entry.tsx
@@@ -14,21 -14,12 +14,22 @@@ import { Banner, Button, SelectSheet, T
type Application = { id: string; company: string; role: string };
type OfferEntryProps = { application?: Application; primary?: boolean };
+/** "Add offer". An offer belongs to an application, so with none yet it leads to adding one instead. */
export function OfferEntry({ application, primary = false }: OfferEntryProps) {
const { t } = useLingui();
+ const router = useRouter();
+ const applications = useApplications();
const [open, setOpen] = useState(false);
+ const variant = primary ? "primary" : "secondary";
- if (!open && !application && !applications.data) return <LoadState query={applications} />;
++ if (!open && !application && (!applications.data || (applications.isError && !applications.data.length)))
++ return <LoadState query={applications} />;
+ if (!open && !application && applications.data?.length === 0)
+ return (
+ <Button variant={variant} label={t`Add an application first`} onPress={() => router.push(routes.newJob())} />
+ );
return (
<>
- <Button variant={primary ? "primary" : "secondary"} label={t`Add offer`} onPress={() => setOpen(true)} />
+ <Button variant={variant} label={t`Add offer`} onPress={() => setOpen(true)} />
{open ? <OfferForm {...(application ? { application } : {})} onClose={() => setOpen(false)} /> : null}
</>
);
@@@ -48,12 -38,6 +49,15 @@@ function OfferForm({ application, onClo
...offerTermsSchema.parse({ currency: "USD", period: "year", base: null, variable: null }),
currency: "",
}));
+ // Until the currency is typed, it's the one the last offer was in, so the two compare.
+ const [currencyTyped, setCurrencyTyped] = useState(false);
+ const [previousCurrency, setPreviousCurrency] = useState<string>();
- if (previousCurrency === undefined && savedOffers.data) setPreviousCurrency(previousOfferCurrency(savedOffers.data));
++ if (previousCurrency === undefined && savedOffers.data) {
++ const currency = previousOfferCurrency(savedOffers.data);
++ if (currency) setPreviousCurrency(currency);
++ }
+ const terms = currencyTyped ? draft : { ...draft, currency: previousCurrency ?? "" };
+ const [more, setMore] = useState(false);
const [amounts, setAmounts] = useState({ base: "", variable: "", learning: "" });
const [date, setDate] = useState("");
const [time, setTime] = useState("17:00");
diff --cc apps/mobile/src/features/letters/write.tsx
index 8105e3b13,4ea44dc5e..79e760072
--- a/apps/mobile/src/features/letters/write.tsx
+++ b/apps/mobile/src/features/letters/write.tsx
@@@ -451,25 -445,6 +451,26 @@@ function FromSection({ letter, disable
/>
<BoundText label={t`Phone`} keyboardType="phone-pad" autoComplete="tel" {...text("phone")} />
<BoundText label={t`Location`} {...text("location")} />
+ <LinkField
+ label={t`Website`}
+ value={letter.style.basics.website}
+ allowInlineLink={false}
+ disabled={disabled}
+ onChange={(website) =>
+ edit("sender.website", (draft) => {
+ draft.style.basics.website = { url: website.url, label: website.label };
+ })
+ }
+ />
+ <CustomFields
+ fields={letter.style.basics.customFields}
+ locked={disabled}
- update={(mutate, options) =>
- useLetterStore.getState().update((draft) => mutate(draft.style.basics.customFields), options)
- }
- undo={() => useLetterStore.getState().undo()}
++ update={(mutate, options) => {
++ const store = useLetterStore.getState();
++ if (store.document?.id === letter.id)
++ store.update((draft) => mutate(draft.style.basics.customFields), options);
++ }}
+ />
</>
) : null}
</Section>
diff --cc apps/mobile/src/features/write/basics-screen.tsx
index 52f2f0423,09f6bdeed..62e1558a5
--- a/apps/mobile/src/features/write/basics-screen.tsx
+++ b/apps/mobile/src/features/write/basics-screen.tsx
@@@ -80,15 -79,7 +80,15 @@@ export function BasicsScreen({ resumeId
}
/>
</View>
- <CustomFields fields={basics.customFields} locked={locked} focusField={focusField} />
+ <CustomFields
+ fields={basics.customFields}
+ locked={locked}
+ focusField={focusField}
- update={(mutate, options) =>
- useResumeStore.getState().update((draft) => mutate(draft.basics.customFields), options)
- }
- undo={() => useResumeStore.getState().undo()}
++ update={(mutate, options) => {
++ const store = useResumeStore.getState();
++ if (store.document?.id === resumeId) store.update((draft) => mutate(draft.basics.customFields), options);
++ }}
+ />
</EditorScreen>
);
}
@@@ -148,21 -139,14 +148,20 @@@ function PhotoRow({ resumeId, locked }
);
}
-/** Extra contact details: icon, text and an optional link; move up and remove (with Undo). */
-type CustomFieldsProps = { fields: CustomField[]; locked: boolean; focusField?: string | undefined };
+/**
+ * Extra contact details: icon, text and an optional link; move up and remove (with Undo). `update` and `undo` act on
+ * the list where it's kept: the resume's basics, or a letter's own sender details.
+ */
+type CustomFieldsProps = {
+ fields: CustomField[];
+ locked: boolean;
+ focusField?: string | undefined;
+ update: (mutate: (list: CustomField[]) => void, options: UpdateOptions) => void;
- undo: () => void;
+};
- export function CustomFields({ fields, locked, focusField, update, undo }: CustomFieldsProps) {
-function CustomFields({ fields, locked, focusField }: CustomFieldsProps) {
++export function CustomFields({ fields, locked, focusField, update }: CustomFieldsProps) {
const { t } = useLingui();
const { colors, radius, space } = useTheme();
- const update = useResumeStore((state) => state.update);
- const undoToast = useUndoToast();
const [iconFor, setIconFor] = useState<string | null>(null);
const [group, index, part] = focusField?.split("/") ?? [];
const targeted = group === "customFields" ? fields[Number(index)] : undefined;
@@@ -231,8 -215,8 +230,21 @@@
label={t`Remove field`}
disabled={locked}
onPress={() => {
- update((draft) => void draft.basics.customFields.splice(index, 1), { newStep: true });
- undoToast(t`Field removed`);
+ update((list) => void list.splice(index, 1), { newStep: true });
- showToast({ message: t`Field removed`, action: { label: t`Undo`, onPress: undo } });
++ showToast({
++ message: t`Field removed`,
++ action: {
++ label: t`Undo`,
++ onPress: () =>
++ update(
++ (list) => {
++ if (!list.some((item) => item.id === field.id))
++ list.splice(Math.min(index, list.length), 0, field);
++ },
++ { newStep: true },
++ ),
++ },
++ });
}}
/>
</View>
diff --cc apps/web/src/features/career/knowledge/knowledge.test.tsx
index d8a950889,ed618e865..2d1ec0167
--- a/apps/web/src/features/career/knowledge/knowledge.test.tsx
+++ b/apps/web/src/features/career/knowledge/knowledge.test.tsx
@@@ -139,6 -135,6 +139,47 @@@ afterEach(() =>
vi.useRealTimers();
});
++it("retries failed application refreshes even when an empty result remains cached", async () => {
++ api.data.applications = [];
++ mount(<OfferEntry />);
++ await screen.findByRole("link", { name: "Add an application first" });
++ const client = clients[0];
++ if (!client) throw new Error("Missing mounted query client");
++ api.fail.add("applications");
++ await act(() => client.invalidateQueries({ queryKey: ["applications"] }));
++ expect(await screen.findByRole("button", { name: "Try again" })).toBeDefined();
++ expect(screen.queryByRole("link", { name: "Add an application first" })).toBeNull();
++ api.fail.delete("applications");
++ api.data.applications = [{ id: "job-a", company: "Acme", role: "Engineer" }];
++ fireEvent.click(screen.getByRole("button", { name: "Try again" }));
++ expect(await screen.findByRole("button", { name: "Add offer" })).toBeDefined();
++});
++
++it("prefills currency when an offer arrives after an initially empty saved-offers result", async () => {
++ mount(<OfferEntry application={{ id: "job-a", company: "Acme", role: "Engineer" }} />);
++ fireEvent.click(screen.getByRole("button", { name: "Add offer" }));
++ const client = clients[0];
++ if (!client) throw new Error("Missing mounted query client");
++ await waitFor(() => expect(client.getQueryState(["savedItems"])?.status).toBe("success"));
++ const currency = screen.getByLabelText("Currency") as HTMLInputElement;
++ expect(currency.value).toBe("");
++ await act(() => {
++ client.setQueryData(
++ ["savedItems"],
++ [{ id: "late", createdAt: new Date("2026-11-01"), data: { kind: "offer", currency: "GBP" } }],
++ );
++ });
++ await waitFor(() => expect(currency.value).toBe("GBP"));
++ fireEvent.change(currency, { target: { value: "EUR" } });
++ await act(() => {
++ client.setQueryData(
++ ["savedItems"],
++ [{ id: "later", createdAt: new Date("2026-11-02"), data: { kind: "offer", currency: "USD" } }],
++ );
++ });
++ expect(currency.value).toBe("EUR");
++});
++
it("keeps an unfinished story after navigating away and remounting, until Cancel explicitly discards it", async () => {
let view = mount(<StoriesPage storyId={undefined} edit />);
const title = await screen.findByRole("textbox", { name: "Title" });
diff --cc apps/web/src/features/career/offer-entry.tsx
index 59e637fb7,07e4801be..492605775
--- a/apps/web/src/features/career/offer-entry.tsx
+++ b/apps/web/src/features/career/offer-entry.tsx
@@@ -39,26 -28,9 +39,26 @@@ export function OfferEntry({ applicatio
<Trans>Add offer</Trans>
</Button>
);
+ return frame(application ? add : <FirstApplication variant={variant}>{add}</FirstApplication>);
}
-type OfferFormProps = OfferEntryProps & { onClose: () => void };
+type FirstApplicationProps = { variant: "primary" | "secondary"; children: ReactNode };
+
+/** An offer belongs to an application, so with none yet "Add offer" leads to adding one instead. */
+function FirstApplication({ variant, children }: FirstApplicationProps) {
+ const applications = useQuery(applicationsListQueryOptions());
- if (applications.isError && !applications.data)
++ if (applications.isError && !applications.data?.length)
+ return <CareerLoadError onRetry={() => void applications.refetch()} />;
+ if (applications.isPending) return <Skeleton className="h-9 w-40" />;
+ if (applications.data?.length !== 0) return children;
+ return (
+ <Link to="/dashboard/applications" search={{ create: true }} className={buttonVariants({ variant })}>
+ <Trans>Add an application first</Trans>
+ </Link>
+ );
+}
+
+type OfferFormProps = { application?: Application; onClose: () => void };
function OfferForm({ application, onClose }: OfferFormProps) {
const id = useId();
const { locale, timeZone } = useCareerTime();
@@@ -70,12 -41,6 +70,15 @@@
...offerTermsSchema.parse({ currency: "USD", period: "year", base: null, variable: null }),
currency: "",
}));
+ // Until the currency is typed, it's the one the last offer was in, so the two compare.
+ const [currencyTyped, setCurrencyTyped] = useState(false);
+ const [previousCurrency, setPreviousCurrency] = useState<string>();
- if (previousCurrency === undefined && savedOffers.data) setPreviousCurrency(previousOfferCurrency(savedOffers.data));
++ if (previousCurrency === undefined && savedOffers.data) {
++ const currency = previousOfferCurrency(savedOffers.data);
++ if (currency) setPreviousCurrency(currency);
++ }
+ const terms = currencyTyped ? draft : { ...draft, currency: previousCurrency ?? "" };
+ const [more, setMore] = useState(false);
const [amounts, setAmounts] = useState({ base: "", variable: "", learning: "" });
const [date, setDate] = useState("");
const [time, setTime] = useState("17:00");
diff --cc docs/spec.json
index a19ee8d33,f3f9a2dc4..34a8fa688
--- a/docs/spec.json
+++ b/docs/spec.json
@@@ -54736,68 -54732,6 +54736,68 @@@
"location": {
"type": "string",
"description": "The letter sender's location."
+ },
+ "website": {
+ "type": "object",
+ "properties": {
+ "url": {
+ "type": "string",
+ "description": "The URL to show as a link. Must be a valid URL with a protocol (http:// or https://)."
+ },
+ "label": {
+ "type": "string",
+ "description": "The label to display for the URL. Leave blank to display the URL as-is."
+ }
+ },
+ "required": [
+ "url",
+ "label"
+ ],
+ "description": "The letter sender's website."
+ },
+ "customFields": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string",
+ "description": "The unique identifier for the custom field. Usually generated as a UUID."
+ },
+ "icon": {
+ "type": "string",
+ "description": "The icon to display for the custom field. Must be a valid icon name from @phosphor-icons/web icon set, or an empty string to hide. Default to '' (empty string) when unsure which icons are available."
+ },
+ "text": {
+ "type": "string",
+ "description": "The text to display for the custom field."
+ },
+ "link": {
+ "type": "string",
+ "description": "If the custom field should be a link, the URL to link to."
+ }
+ },
+ "required": [
+ "id",
+ "icon",
+ "text",
+ "link"
+ ]
+ },
+ "description": "The letter sender's other contact details and profile links; replaces the whole list."
+ },
+ "picture": {
+ "type": "object",
+ "properties": {
+ "hidden": {
+ "type": "boolean",
- "description": "Whether to hide the picture from the resume."
++ "description": "Whether to hide the copied photo on the letter."
+ }
+ },
+ "required": [
+ "hidden"
+ ],
+ "description": "Whether the photo the letter copied from its resume is hidden on the letter."
}
},
"description": "Edits the letter's own sender details; turn the sender link off first."
@@@ -56148,68 -56078,6 +56148,68 @@@
"location": {
"type": "string",
"description": "The letter sender's location."
+ },
+ "website": {
+ "type": "object",
+ "properties": {
+ "url": {
+ "type": "string",
+ "description": "The URL to show as a link. Must be a valid URL with a protocol (http:// or https://)."
+ },
+ "label": {
+ "type": "string",
+ "description": "The label to display for the URL. Leave blank to display the URL as-is."
+ }
+ },
+ "required": [
+ "url",
+ "label"
+ ],
+ "description": "The letter sender's website."
+ },
+ "customFields": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string",
+ "description": "The unique identifier for the custom field. Usually generated as a UUID."
+ },
+ "icon": {
+ "type": "string",
+ "description": "The icon to display for the custom field. Must be a valid icon name from @phosphor-icons/web icon set, or an empty string to hide. Default to '' (empty string) when unsure which icons are available."
+ },
+ "text": {
+ "type": "string",
+ "description": "The text to display for the custom field."
+ },
+ "link": {
+ "type": "string",
+ "description": "If the custom field should be a link, the URL to link to."
+ }
+ },
+ "required": [
+ "id",
+ "icon",
+ "text",
+ "link"
+ ]
+ },
+ "description": "The letter sender's other contact details and profile links; replaces the whole list."
+ },
+ "picture": {
+ "type": "object",
+ "properties": {
+ "hidden": {
+ "type": "boolean",
- "description": "Whether to hide the picture from the resume."
++ "description": "Whether to hide the copied photo on the letter."
+ }
+ },
+ "required": [
+ "hidden"
+ ],
+ "description": "Whether the photo the letter copied from its resume is hidden on the letter."
}
},
"description": "Edits the letter's own sender details; turn the sender link off first."
diff --cc packages/api/src/dto/cover-letter.ts
index 3d3445aa7,0f88bcef1..b6c839d0b
--- a/packages/api/src/dto/cover-letter.ts
+++ b/packages/api/src/dto/cover-letter.ts
@@@ -99,13 -99,6 +99,18 @@@ export const coverLetterDto =
email: coverLetterStyleSchema.shape.basics.shape.email.describe("The letter sender's email address."),
phone: coverLetterStyleSchema.shape.basics.shape.phone.describe("The letter sender's phone number."),
location: coverLetterStyleSchema.shape.basics.shape.location.describe("The letter sender's location."),
+ website: coverLetterStyleSchema.shape.basics.shape.website.describe("The letter sender's website."),
+ customFields: coverLetterStyleSchema.shape.basics.shape.customFields.describe(
+ "The letter sender's other contact details and profile links; replaces the whole list.",
+ ),
+ picture: coverLetterStyleSchema.shape.picture
+ .pick({ hidden: true })
++ .extend({
++ hidden: coverLetterStyleSchema.shape.picture.shape.hidden.describe(
++ "Whether to hide the copied photo on the letter.",
++ ),
++ })
+ .describe("Whether the photo the letter copied from its resume is hidden on the letter."),
})
.partial()
.optional()