feat: attach photos from Search preview replies (Closes #955)
CI / lint (pull_request) Successful in 2m0s
CI / build-release (pull_request) Successful in 5s
CI / browser-journey (pull_request) Successful in 51s
CI / release-candidate (pull_request) Has been skipped

This commit is contained in:
timmy committed 2026-08-16 09:30:18 +00:00
1 parent 053f32c428
commit d3a57f222e
10 files changed
+320 -4

No files matched your search

+1
View File
@@ -646,6 +646,7 @@ textarea { resize: vertical; min-height: 120px; }
.search-preview-reply-actions button { min-height:44px; }
.search-preview-reply .voice-conversation-controls button,
.search-preview-reply .voice-conversation-review-actions button { min-height:44px; }
.search-preview-reply .conversation-photo-actions { max-width:100%; }
.search-preview-navigation { display:grid; grid-template-columns:minmax(0,1fr) auto minmax(0,1fr); align-items:center; gap:8px; }
.search-preview-actions { position:sticky; bottom:0; display:grid; gap:8px; padding:10px 0; padding-bottom:calc(10px + env(safe-area-inset-bottom)); background:#0b1526; }
.search-preview-actions button, .search-preview-actions a { min-height:44px; box-sizing:border-box; display:flex; align-items:center; justify-content:center; }
+64
View File
@@ -494,6 +494,61 @@
window.location.hash = '#/my-work/agenda';
qs('#my-work-action-status').textContent = 'Overdue sweep cancelled. No remaining deadline was changed.';
});
let searchReplyAttachmentTarget = null;
const updateSearchReplyButtons = state => {
const enabled = Boolean(state) || Boolean(qs('#search-preview-reply').value.trim());
qs('#send-search-preview-reply').disabled = !enabled;
qs('#send-search-preview-reply-next').disabled = !enabled;
};
const searchReplyAttachmentController = issueAttachment.mount({
maxFiles: 5,
input: qs('#search-reply-attachment'),
inputs: [qs('#take-search-reply-photo'), qs('#search-reply-attachment')],
preview: qs('#search-reply-attachment-preview'),
image: qs('#search-reply-attachment-image'),
meta: qs('#search-reply-attachment-meta'),
remove: qs('#remove-search-reply-attachment'),
tray: qs('#search-reply-attachment-tray'),
earlier: qs('#move-search-reply-attachment-earlier'),
later: qs('#move-search-reply-attachment-later'),
note: qs('#search-reply-attachment-note'),
noteLabel: qs('#search-reply-attachment-note-label'),
status: qs('#search-preview-reply-status'),
readyMessage: 'Photo ready to send with this Search reply.',
removedMessage: 'Photo removed. Your Search reply is unchanged.',
onChange: updateSearchReplyButtons,
editor: {
document,
edit: qs('#edit-search-reply-attachment'),
dialog: qs('#issue-evidence-editor'),
canvas: qs('#issue-evidence-editor-canvas'),
exportCanvas: qs('#issue-evidence-editor-export'),
crop: qs('#crop-issue-evidence'), redact: qs('#redact-issue-evidence'),
highlight: qs('#highlight-issue-evidence'), arrow: qs('#arrow-issue-evidence'),
undo: qs('#undo-issue-evidence-edit'), reset: qs('#reset-issue-evidence-edit'),
cancel: qs('#cancel-issue-evidence-edit'), apply: qs('#apply-issue-evidence-edit'),
status: qs('#issue-evidence-editor-status'),
appliedMessage: 'Edited photo flattened and ready to send.',
},
createObjectURL: file => URL.createObjectURL(file),
revokeObjectURL: url => URL.revokeObjectURL(url),
upload: payload => {
const target = searchReplyAttachmentTarget;
if (!target || target.repository !== payload.repository || Number(target.number) !== Number(payload.number)) {
return Promise.reject(new Error('Search result changed. Reopen it before sending this photo.'));
}
const repository = payload.repository.split('/').map(encodeURIComponent).join('/');
return fetchReviewJson(
'api/v1/repos/' + repository + '/issues/' + encodeURIComponent(payload.number) +
'/preview/attachments?kind=' + encodeURIComponent(target.kind),
{
method:'POST',
headers:{Accept:'application/json','Idempotency-Key':payload.operation_id},
body:issueAttachment.multipart(payload),
},
);
},
});
const issueAttachmentController = issueAttachment.mount({
maxFiles: 5,
input: qs('#issue-attachment'),
@@ -5034,6 +5089,15 @@
{ method:'PATCH', headers:{ Accept:'application/json' } }
),
...searchPreviewReplyOptions(fetchReviewJson, localStorage, globalThis.crypto),
prepareReply:(item,body) => {
searchReplyAttachmentTarget = item;
return searchReplyAttachmentController.prepareComment(item, body);
},
hasAttachments:() => Boolean(searchReplyAttachmentController.state()),
clearAttachments:() => {
searchReplyAttachmentTarget = null;
searchReplyAttachmentController.clear();
},
share: url => createWorkRoute.share(url, navigator, navigator.clipboard),
session:[()=>commandSearchState, commandSearch, item=>taskOverlayHistory.update({preview:item})],
onState: renderSearchPreview,
+21
View File
@@ -562,6 +562,27 @@
</div>
</div>
</section>
<div class="issue-attachment-controls conversation-photo-actions">
<label class="issue-attachment-trigger" for="take-search-reply-photo">Take photo</label>
<input class="visually-hidden" id="take-search-reply-photo" type="file" accept="image/*" capture="environment" />
<label class="issue-attachment-trigger" for="search-reply-attachment">Choose existing</label>
<input class="visually-hidden" id="search-reply-attachment" type="file" accept="image/png,image/jpeg,image/webp" multiple />
</div>
<div class="issue-attachment-preview conversation-evidence-review" id="search-reply-attachment-preview" hidden>
<img id="search-reply-attachment-image" alt="Selected reply photo preview" />
<span class="small" id="search-reply-attachment-meta"></span>
<div class="issue-evidence-tray" id="search-reply-attachment-tray" role="toolbar" aria-label="Search reply photos" hidden></div>
<label class="issue-evidence-note" for="search-reply-attachment-note">
<span id="search-reply-attachment-note-label">Photo caption (optional)</span>
<textarea id="search-reply-attachment-note" maxlength="240" rows="2" disabled placeholder="What does this photo show?"></textarea>
</label>
<div class="issue-evidence-review-actions" aria-label="Reorder selected photo">
<button id="move-search-reply-attachment-earlier" type="button">Move earlier</button>
<button id="edit-search-reply-attachment" type="button">Edit photo</button>
<button id="remove-search-reply-attachment" type="button">Remove selected</button>
<button id="move-search-reply-attachment-later" type="button">Move later</button>
</div>
</div>
<div id="search-preview-reply-status" class="small" aria-live="polite"></div>
<div class="search-preview-reply-actions">
<button id="send-search-preview-reply" type="button">Send</button>
+3
View File
@@ -255,6 +255,7 @@
input.disabled = false;
});
clearSelection();
options.onChange?.(controller.state());
}
function showPreview(file, optimized) {
@@ -311,6 +312,7 @@
options.status.textContent = values.length + ' screenshots ready to file in this order.';
}
}
options.onChange?.(controller.state());
}).catch(error => {
if (sequence === selectionSequence) {
options.status.textContent = error.message;
@@ -343,6 +345,7 @@
options.meta.textContent = values.length + ' screenshots ready · latest: ' + latest.filename;
}
options.status.textContent = options.removedMessage || 'Latest screenshot removed. Your text is unchanged.';
options.onChange?.(controller.state());
});
});
+17 -4
View File
@@ -81,7 +81,9 @@
}
input.value = preview.replyDraft();
const replying = state.status === 'replying';
buttons.forEach(button => { button.disabled = replying || !input.value.trim(); });
buttons.forEach(button => {
button.disabled = replying || (!input.value.trim() && !preview.hasReplyAttachments?.());
});
if (replying) status.textContent = 'Sending reply…';
else if (state.status === 'replied') status.textContent = 'Reply posted.';
else if (state.status === 'reply-error') status.textContent =
@@ -89,7 +91,7 @@
};
}
})(typeof globalThis !== 'undefined' ? globalThis : this, function () {
return function createSearchPreview({ fetchJson, fetchConversation, mutate, share, postReply, storage, createOperationId, session, getSession, loadMore, onNavigate, navigationRoot, onState }) {
return function createSearchPreview({ fetchJson, fetchConversation, mutate, share, postReply, prepareReply, hasAttachments, clearAttachments, storage, createOperationId, session, getSession, loadMore, onNavigate, navigationRoot, onState }) {
if (Array.isArray(session)) {
getSession = session[0];
loadMore = () => session[1].loadMore();
@@ -201,7 +203,11 @@
}
const api = {
hasReplyAttachments() {
return Boolean(hasAttachments?.());
},
open(item) {
if (current && !sameItem(current, item) && hasAttachments?.()) clearAttachments?.();
generation += 1;
const requestGeneration = generation;
current = { ...item };
@@ -225,6 +231,7 @@
});
},
close() {
clearAttachments?.();
generation += 1;
current = null;
onState({ status: 'closed' });
@@ -284,7 +291,7 @@
if (replyRequest) return replyRequest;
if (!current || typeof postReply !== 'function') return Promise.reject(new Error('Replying is unavailable.'));
const body = api.replyDraft().trim();
if (!body) return Promise.reject(new Error('Write a reply first.'));
if (!body && !hasAttachments?.()) return Promise.reject(new Error('Write a reply or add a photo first.'));
const item = { ...current };
const operationKey = replyKey(item, 'operation');
let operationId = stored(operationKey);
@@ -293,12 +300,18 @@
save(operationKey, operationId);
}
publish({ status:'replying', item:current, detail:current, conversation });
replyRequest = postReply(item, body, operationId).then(comment => {
replyRequest = Promise.resolve(
typeof prepareReply === 'function' ? prepareReply(item, body) : body
).then(preparedBody => {
if (!String(preparedBody || '').trim()) throw new Error('Write a reply or add a photo first.');
return postReply(item, preparedBody, operationId);
}).then(comment => {
const comments = [...(conversation?.comments || [])];
if (!comments.some(candidate => candidate?.id === comment?.id)) comments.push(comment);
conversation = { status:'ready', comments, olderPage:conversation?.olderPage ?? null };
save(replyKey(item, 'draft'), '');
save(operationKey, '');
clearAttachments?.();
publish({ status:'replied', item:current, detail:current, conversation, result:comment });
return advance ? api.next().then(() => comment) : comment;
}).catch(error => {