web: fix mobile nav stuck-open on rejoin + paste-chip code fence
useViewport re-syncs the snapshot on pageshow/visibilitychange/resize/orientationchange — iOS reported a stale width on backgrounded-tab restore, leaving isMobile=false so the sidebar rendered as a permanent column with no close affordance. flattenToMessage now inserts pasted-text chips verbatim instead of wrapping them in a triple-backtick fence. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -57,15 +57,17 @@ export function inferLanguage(filename: string): string | null {
|
||||
export function flattenToMessage(attachments: Attachment[], text: string): string {
|
||||
if (attachments.length === 0) return text;
|
||||
const blocks = attachments.map(a => {
|
||||
const fence = '```' + (a.language ?? '');
|
||||
let header: string;
|
||||
if (a.kind === 'lines') {
|
||||
header = `// from: ${a.filename}:${a.range?.[0] ?? '?'}-${a.range?.[1] ?? '?'}`;
|
||||
} else if (a.kind === 'paste') {
|
||||
header = `// from: pasted text (${a.content.split('\n').length} lines)`;
|
||||
} else {
|
||||
header = `// from: ${a.filename}`;
|
||||
// Pasted text is raw context, not code from a file — insert it verbatim with
|
||||
// no ``` fence or provenance header. The chip only exists to keep the textarea
|
||||
// tidy while composing; on send it should be exactly what the user pasted.
|
||||
if (a.kind === 'paste') {
|
||||
return a.content;
|
||||
}
|
||||
const fence = '```' + (a.language ?? '');
|
||||
const header =
|
||||
a.kind === 'lines'
|
||||
? `// from: ${a.filename}:${a.range?.[0] ?? '?'}-${a.range?.[1] ?? '?'}`
|
||||
: `// from: ${a.filename}`;
|
||||
return `${fence}\n${header}\n${a.content}\n\`\`\``;
|
||||
});
|
||||
return [...blocks, text].filter(Boolean).join('\n\n');
|
||||
|
||||
Reference in New Issue
Block a user