-
Notifications
You must be signed in to change notification settings - Fork 17
feat(attachments): support remote CLI file delivery #4944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
56aecf7
feat(attachments): raise upload cap to 20 MB
iscekic 325349d
fix(mobile): separate attachment notices in bubbles
iscekic 5a4af15
feat(mobile): receive files from remote tools
iscekic a1e08c2
style(wrapper): format attachment cap error
iscekic f40abe9
fix(mobile): satisfy attachment lint contracts
iscekic 4f7cb84
style(mobile): format attachment tests
iscekic 9a5df70
fix(mobile): sanitize MIME cache filenames
iscekic dff9c21
fix(mobile): preserve safe image cache names
iscekic 3fd44d4
fix(mobile): preserve cache marker suffix
iscekic 66bcb6c
fix(mobile): derive cache marker pattern
iscekic d148d67
merge: origin/main into attachments-cli-f31a
iscekic 94249e2
fix(mobile): satisfy cache filename lint
iscekic 0001f68
refactor(mobile-e2e): simplified runbook, scripted stub setup, load-t…
iscekic 50e208c
fix(mobile-e2e): address review findings on retry and stub rollback
iscekic d5778b7
fix(mobile-e2e): close concurrency races found in adversarial review
iscekic 50be1ed
fix(mobile-e2e): adversarial-review round 2
iscekic 69e21e7
fix(mobile-e2e): seed verifies the endpoint's success flag
iscekic 7146391
fix(mobile-e2e): server stop verifies death before dropping state
iscekic 5c6f274
fix(mobile-e2e): address stub-claim, re-seed, and lsof review findings
iscekic e26d0d0
fix(mobile-e2e): tighten adoption, signal exits, and legacy-seed hand…
iscekic 48f61f5
fix(mobile-e2e): name both sources of an existing token row
iscekic e5a0494
fix(mobile-e2e): stub row verification, self-cleaning start, lsof fal…
iscekic c7835ac
fix(mobile-e2e): honest row probe, race-safe rollback, blind-lsof reuse
iscekic 449c242
fix(mobile-e2e): close the last rollback and adoption windows
iscekic fec3e1f
fix(mobile-e2e): serialize the stub per worktree instead of guarding …
iscekic 973fdf5
fix(mobile-e2e): row-probe failures skip the missing-user hint
iscekic 4f759f0
fix(mobile-e2e): bound the lock's hold time and the survivor edge
iscekic 616c33b
feat(mobile-e2e): copy a real GitHub integration onto an e2e account
iscekic 1f1eaed
fix(mobile-e2e): copies never donate or collide with the stub
iscekic 1a34adb
docs(mobile-e2e): STE pass over the runbook additions
iscekic ffd814c
fix(mobile-e2e): copies validate the donor live and can never refresh
iscekic 4ed26ca
fix(mobile-e2e): guard the integration copy's blast radius
iscekic c398e75
fix(mobile-e2e): env failures in the copy tool name their own fix
iscekic 66b7904
fix(mobile-e2e): make the copy's guards atomic and expiry-safe
iscekic 36f3437
fix(mobile-e2e): state the copy's real lifetime and align the lock bu…
iscekic f752367
fix(mobile-e2e): re-assert the usable window after the live probes
iscekic df4aac2
docs(mobile-e2e): bound big outputs, never doctor --json
iscekic 96200a3
docs(mobile-e2e): doctor is always a full JSON dump; never tail JSON
iscekic c776b71
Merge remote-tracking branch 'origin/mobile-e2e-ste' into attachments…
iscekic acd4504
fix(mobile): preserve picker filename in CLI attachments
iscekic f97b75d
fix(mobile): sanitize remote attachment filenames
iscekic dbec3e0
fix(mobile): bound remote filenames by UTF-8 bytes
iscekic 1d1966d
refactor(mobile): share UTF-8 filename helpers
iscekic 27f961b
fix(mobile): include shared UTF-8 filename utility
iscekic a62b0e3
fix(mobile): keep UTF-8 width helper internal
iscekic 38b171e
merge: origin/main into attachments-cli-f31a
iscekic c2f83da
chore(seed): drop the GitHub integration copy command
iscekic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
apps/mobile/src/components/agents/tool-card-file-attachments.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| /** | ||
| * Replicates the file-attachment label logic from ToolCardFileAttachments: | ||
| * const label = attachment.filename || 'File'; | ||
| * | ||
| * Also asserts the mimeType forwarding contract: the chip passes | ||
| * { mimeType: attachment.mime } to shareLocalFile(uri, { mimeType }). | ||
| * | ||
| * The actual rendering (unavailable row vs chip) and press handler are | ||
| * exercised through share-remote-file.test.ts (mimeType passthrough), the | ||
| * image-cache.test.ts (cache miss → no URI → unavailable row trigger), and | ||
| * manual E2E. | ||
| */ | ||
| function resolveFileAttachmentLabel(filename: string | undefined): string { | ||
| return filename ?? 'File'; | ||
| } | ||
|
|
||
| function buildShareMimeOptions(mime: string): { mimeType: string } { | ||
| return { mimeType: mime }; | ||
| } | ||
|
|
||
| describe('ToolCardFileAttachments (label + mimeType contract)', () => { | ||
| it('uses the attachment filename as the chip label', () => { | ||
| expect(resolveFileAttachmentLabel('report.pdf')).toBe('report.pdf'); | ||
| }); | ||
|
|
||
| it('falls back to "File" when filename is absent', () => { | ||
| expect(resolveFileAttachmentLabel(undefined)).toBe('File'); | ||
| // Empty string is a value, not absence — preserved as-is with ??. | ||
| expect(resolveFileAttachmentLabel('')).toBe(''); | ||
| }); | ||
|
|
||
| it('passes mimeType to the share options', () => { | ||
| expect(buildShareMimeOptions('application/pdf')).toEqual({ | ||
| mimeType: 'application/pdf', | ||
| }); | ||
| expect(buildShareMimeOptions('text/plain')).toEqual({ | ||
| mimeType: 'text/plain', | ||
| }); | ||
| }); | ||
| }); |
97 changes: 97 additions & 0 deletions
97
apps/mobile/src/components/agents/tool-card-file-attachments.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| import { type ToolPart } from '@kilocode/cloud-agent-sdk'; | ||
| import { FileIcon, Share2 } from 'lucide-react-native'; | ||
| import { Pressable, View } from 'react-native'; | ||
| import { toast } from 'sonner-native'; | ||
|
|
||
| import { Text } from '@/components/ui/text'; | ||
| import { useThemeColors } from '@/lib/hooks/use-theme-colors'; | ||
| import { | ||
| getShareRemoteFileReason, | ||
| shareLocalFile, | ||
| ShareRemoteFileError, | ||
| } from '@/lib/share-remote-file'; | ||
|
|
||
| import { getToolFileAttachments } from './tool-card-attachments'; | ||
| import { useToolCardImageUri } from './tool-card-image-cache'; | ||
|
|
||
| function FileChip({ | ||
| label, | ||
| mime, | ||
| partId, | ||
| }: Readonly<{ | ||
| label: string; | ||
| mime: string; | ||
| partId: string; | ||
| }>) { | ||
| const colors = useThemeColors(); | ||
| const uri = useToolCardImageUri(partId); | ||
| const available = uri !== undefined; | ||
|
|
||
| if (!available) { | ||
| return ( | ||
| <View className="flex-row items-center gap-2 rounded-md bg-neutral-100 px-3 py-2 dark:bg-neutral-900"> | ||
| <FileIcon size={14} color={colors.mutedForeground} /> | ||
| <Text className="text-xs text-muted-foreground">File unavailable in this session.</Text> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| const fileUri = uri; | ||
|
|
||
| async function handleShare() { | ||
| try { | ||
| await shareLocalFile(fileUri, { mimeType: mime }); | ||
| } catch (error: unknown) { | ||
| const reason = getShareRemoteFileReason(error); | ||
| if (reason === 'sharing-unavailable') { | ||
| toast.error('File sharing is not available on this device.'); | ||
| return; | ||
| } | ||
| if (error instanceof ShareRemoteFileError) { | ||
| toast.error('Failed to share file. Please try again.'); | ||
| return; | ||
| } | ||
| toast.error('Share failed'); | ||
| } | ||
| } | ||
|
|
||
| return ( | ||
| <View className="flex-row items-center gap-2 rounded-md bg-neutral-100 px-3 py-2 dark:bg-neutral-900"> | ||
| <FileIcon size={16} color={colors.mutedForeground} /> | ||
| <View className="flex-1"> | ||
| <Text className="text-xs font-medium text-foreground" numberOfLines={1}> | ||
| {label} | ||
| </Text> | ||
| <Text className="text-xs text-muted-foreground">{mime}</Text> | ||
| </View> | ||
| <Pressable | ||
| className="rounded p-1 active:opacity-60" | ||
| onPress={() => { | ||
| void handleShare(); | ||
| }} | ||
| accessibilityRole="button" | ||
| accessibilityLabel={`Share ${label}`} | ||
| > | ||
| <Share2 size={16} color={colors.mutedForeground} /> | ||
| </Pressable> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| export function ToolCardFileAttachments({ part }: Readonly<{ part: ToolPart }>) { | ||
| const attachments = getToolFileAttachments(part); | ||
| if (attachments.length === 0) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <View className="gap-2"> | ||
| {attachments.map(attachment => { | ||
| const label = attachment.filename ?? 'File'; | ||
| return ( | ||
| <FileChip key={attachment.id} label={label} mime={attachment.mime} partId={part.id} /> | ||
| ); | ||
| })} | ||
| </View> | ||
| ); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.