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!

chore: reconcile main with PDF import repairs (RX-93)

Amruth Pillai20f56fe19435
diff --cc apps/web/src/features/documents/new-document-dialog-provider.test.tsx
index 42941876c,3f80dc0d3..6467cca0e
--- a/apps/web/src/features/documents/new-document-dialog-provider.test.tsx
+++ b/apps/web/src/features/documents/new-document-dialog-provider.test.tsx
@@@ -69,9 -70,12 +69,12 @@@ function mount(file?: File)
it("imports a PDF through the local text reader when AI connection lookup fails", async () => {
const file = new File(["%PDF-test"], "resume.pdf", { type: "application/pdf" });
mount(file);
+ await screen.findByRole("heading", { name: "Choose how to read this file" });
+ expect(api.parsePdf).not.toHaveBeenCalled();
+ fireEvent.click(screen.getByRole("button", { name: "Read on this device (free)" }));
await screen.findByRole("heading", { name: "Imported" });
expect(api.providers).toHaveBeenCalled();
- expect(api.extractPdfLines).toHaveBeenCalledWith(file);
+ expect(api.readPdfResume).toHaveBeenCalledWith(file);
expect(api.importResume).toHaveBeenCalledWith({
data: expect.objectContaining({ basics: expect.objectContaining({ name: "Alex Morgan" }) }),
});
@@@ -80,14 -84,16 +83,16 @@@
expect(screen.getByRole("button", { name: "Open in editor" })).toBeEnabled();
});
- it("keeps a recoverable connection error for Word files that require AI", async () => {
+ it("explains Word prerequisites before any upload and retains the file for in-place setup", async () => {
mount(new File([new Uint8Array([0x50, 0x4b, 0x03, 0x04])], "resume.docx"));
- await screen.findByRole("heading", { name: "Couldn't import" });
- expect(screen.getByText("Couldn't load AI connections. Try again before importing this file.")).toBeVisible();
- expect(screen.getByRole("button", { name: "Try again" })).toBeEnabled();
+ await screen.findByRole("heading", { name: "Choose how to read this file" });
+ expect(
+ screen.getByText("Word import needs AI. For a local import, export a PDF or JSON file instead."),
+ ).toBeVisible();
+ expect(screen.getByRole("button", { name: "Set up AI" })).toBeEnabled();
expect(api.importResume).not.toHaveBeenCalled();
expect(api.parseDocx).not.toHaveBeenCalled();
- expect(api.extractPdfLines).not.toHaveBeenCalled();
+ expect(api.readPdfResume).not.toHaveBeenCalled();
});
it("creates one cover letter while a create is in flight, even across repeat clicks and a reopened dialog", async () => {
diff --cc apps/web/src/features/resume/import/read-file.ts
index b2d0a3618,1f56ea316..6d80d9320
--- a/apps/web/src/features/resume/import/read-file.ts
+++ b/apps/web/src/features/resume/import/read-file.ts
@@@ -173,12 -176,18 +176,15 @@@ export async function readResumeFile
if (options.aiAvailable) {
const base64 = await fileToBase64(file);
options.onRead?.(t`file read`);
- return client.ai.parsePdf({ file: { name: file.name, data: base64 } });
+ return client.ai.parsePdf(
+ { file: { name: file.name, data: base64 } },
+ options.signal ? { signal: options.signal } : {},
+ );
}
- const [{ extractPdfLines }, { parseResumeText }] = await Promise.all([
- import("./pdf-text"),
- import("@reactive-resume/import/plain-text"),
- ]);
- const lines = await extractPdfLines(file);
- if (lines.length === 0) {
+ const { readPdfResume } = await import("./pdf-text");
+ const data = await readPdfResume(file);
+ if (!data) {
throw new ImportError(
t`This PDF is a scanned image. There's no text to read. Try the Word version, or start blank and paste sections in.`,
);