Skip to content

Commit 472b331

Browse files
chore: generate
1 parent 2181472 commit 472b331

6 files changed

Lines changed: 25 additions & 13 deletions

File tree

packages/app/src/components/directory-picker.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ export function useDirectoryPicker() {
1717

1818
return (input: DirectoryPickerInput) => {
1919
if (directoryPickerKind(platform.platform, input.server) === "native" && platform.platform === "desktop") {
20-
void platform
21-
.openDirectoryPickerDialog({ title: input.title, multiple: input.multiple })
22-
.then(input.onSelect)
20+
void platform.openDirectoryPickerDialog({ title: input.title, multiple: input.multiple }).then(input.onSelect)
2321
return
2422
}
2523

packages/app/src/components/prompt-input/files.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ import { ACCEPTED_FILE_TYPES, ACCEPTED_IMAGE_TYPES } from "@/constants/file-pick
22

33
export { ACCEPTED_FILE_TYPES }
44

5-
type AttachmentPicker = (options: {
6-
defaultPath?: string
7-
multiple?: boolean
8-
accept?: string[]
9-
}, onFile: (file: File) => Promise<unknown>) => Promise<void>
5+
type AttachmentPicker = (
6+
options: {
7+
defaultPath?: string
8+
multiple?: boolean
9+
accept?: string[]
10+
},
11+
onFile: (file: File) => Promise<unknown>,
12+
) => Promise<void>
1013

1114
export function pickAttachmentFiles(input: {
1215
picker?: AttachmentPicker

packages/app/src/context/platform.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ type PlatformBase = {
5050
notify(title: string, description?: string, href?: string): Promise<void>
5151

5252
/** Open a native attachment picker and read selected files sequentially (desktop only) */
53-
openAttachmentPickerDialog?(opts: OpenAttachmentPickerOptions, onFile: (file: File) => Promise<unknown>): Promise<void>
53+
openAttachmentPickerDialog?(
54+
opts: OpenAttachmentPickerOptions,
55+
onFile: (file: File) => Promise<unknown>,
56+
): Promise<void>
5457

5558
/** Open a native save file picker dialog (desktop only) */
5659
saveFilePickerDialog?(opts?: SaveFilePickerOptions): Promise<string | null>

packages/desktop/src/main/attachment-picker.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import {
1111

1212
describe("assertAttachmentBudget", () => {
1313
test("accepts selections within the media ingest limit", () => {
14-
expect(() => assertAttachmentBudget([{ size: MAX_ATTACHMENT_BYTES / 2 }, { size: MAX_ATTACHMENT_BYTES / 2 }])).not.toThrow()
14+
expect(() =>
15+
assertAttachmentBudget([{ size: MAX_ATTACHMENT_BYTES / 2 }, { size: MAX_ATTACHMENT_BYTES / 2 }]),
16+
).not.toThrow()
1517
})
1618

1719
test("rejects the selection before files are read when its total exceeds the limit", () => {

packages/desktop/src/main/attachment-picker.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export function createPickedFileAuthorizations(
1717
},
1818
async read(sender: number, token: string, path: string) {
1919
const selection = selections.get(token)
20-
if (selection?.sender !== sender || !selection.paths.delete(path)) throw new Error("File was not selected by the picker")
20+
if (selection?.sender !== sender || !selection.paths.delete(path))
21+
throw new Error("File was not selected by the picker")
2122
const bytes = await read(path, selection.remaining)
2223
selection.remaining -= bytes.byteLength
2324
if (selection.paths.size === 0) selections.delete(token)
@@ -39,7 +40,8 @@ export async function readAttachment(filePath: string, maxBytes = MAX_ATTACHMENT
3940
const file = await open(filePath, "r")
4041
try {
4142
const info = await file.stat()
42-
if (info.size > maxBytes) throw new Error(`Selected attachments exceed the ${MAX_ATTACHMENT_BYTES / 1024 / 1024} MB limit`)
43+
if (info.size > maxBytes)
44+
throw new Error(`Selected attachments exceed the ${MAX_ATTACHMENT_BYTES / 1024 / 1024} MB limit`)
4345
const bytes = Buffer.allocUnsafe(info.size)
4446
let offset = 0
4547
while (offset < info.size) {

packages/desktop/src/main/ipc.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ export function registerIpcHandlers(deps: Deps) {
131131
})
132132
if (result.canceled) return null
133133
const files = await Promise.all(
134-
result.filePaths.map(async (filePath) => ({ path: filePath, name: basename(filePath), size: (await stat(filePath)).size })),
134+
result.filePaths.map(async (filePath) => ({
135+
path: filePath,
136+
name: basename(filePath),
137+
size: (await stat(filePath)).size,
138+
})),
135139
)
136140
assertAttachmentBudget(files)
137141
const token = pickedFiles.add(event.sender.id, result.filePaths)

0 commit comments

Comments
 (0)