v4.3.40: 법률 앱 사건 관리 버그 2건 수정 (첨부파일 위치·자동 이름짓기)
실사용 중 발견된 버그: - 첨부파일 위치: PDF/DOCX 등 문서 파일을 업로드하면 어느 탭 버튼을 눌렀든 무조건 "제출서류" 탭으로만 가버려서, "첨부자료" 탭에서 업로드한 파일이 사라진 것처럼 보였음(탐정 앱의 증거/서류 분류 로직을 그대로 가져온 부작용). 파일 확장자가 아니라 실제 업로드한 탭(attachments/submissions 폴더) 기준으로 분리하도록 수정 — 기존에 폴더 구분 없이 올라간 파일은 첨부자료 탭에 계속 보이게 하위호환 유지. - 사건 자동 이름짓기: 메모 탭에 직접 타이핑해야만 작동했는데, 실사용자는 메모 대신 채팅으로만 사건을 상담해서 한 번도 안 뜬 것이었음. 채팅 한 턴이 끝날 때도(사건 선택 상태라면) 그 메시지로 이름짓기를 시도하도록 추가. 실제 사용자 데이터로 재현·검증 완료 (전세보증금 반환 사건 채팅 → "새 사건"이 "전세금반환소송"으로 자동 변경 확인). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2be697aff8
commit
9d76a0d7e9
1 file changed
+28
-11
+28
-11
@@ -896,16 +896,21 @@ async function quietChatCall(message){
|
||||
// in themselves (checked again after the AI call returns, in case they
|
||||
// switched case or renamed it while waiting).
|
||||
let lwAutoNaming=false;
|
||||
async function autoNameCaseIfNeeded(){
|
||||
// sourceText: content to name the case FROM. Falls back to the notes field
|
||||
// when omitted (notes-blur call site) — the chat-driven call site (callChat,
|
||||
// once a turn finishes with a case selected) passes the user's message
|
||||
// directly, since a case discussed only through chat never touches the notes
|
||||
// textarea at all and would otherwise never trigger this.
|
||||
async function autoNameCaseIfNeeded(sourceText){
|
||||
const c=currentCase();
|
||||
if(!c||lwAutoNaming)return;
|
||||
const title=(document.getElementById('case-name-input').value||'').trim();
|
||||
const notes=document.getElementById('case-notes').value||'';
|
||||
if(title!=='새 사건'||notes.trim().length<15)return;
|
||||
const text=(sourceText!==undefined?sourceText:document.getElementById('case-notes').value)||'';
|
||||
if(title!=='새 사건'||text.trim().length<15)return;
|
||||
lwAutoNaming=true;
|
||||
const targetId=c.id;
|
||||
try{
|
||||
const prompt=`다음은 법률 상담 메모입니다. 8자 이내의 간결한 사건명을 지어주세요. 사건명만 출력하고 다른 설명·따옴표·마침표는 넣지 마세요.\n\n${notes.slice(0,500)}`;
|
||||
const prompt=`다음은 법률 상담 내용입니다. 8자 이내의 간결한 사건명을 지어주세요. 사건명만 출력하고 다른 설명·따옴표·마침표는 넣지 마세요.\n\n${text.slice(0,500)}`;
|
||||
const result=await quietChatCall(prompt);
|
||||
if(!result||currentCaseId!==targetId)return; // case switched away while waiting
|
||||
const cur=cases.find(x=>x.id===targetId);
|
||||
@@ -1065,6 +1070,14 @@ const LW_CATEGORY_LABELS={photo:'📷 사진',video:'🎥 동영상',document:'
|
||||
const LW_CATEGORY_ORDER=['photo','video','document','other'];
|
||||
const LW_CATEGORY_ICONS={photo:'📷',video:'🎥',document:'📄',other:'📦'};
|
||||
|
||||
// Files are separated by which tab's upload button was actually used
|
||||
// (uploadOneCaseFile prefixes with 'attachments/' or 'submissions/'), not by
|
||||
// guessing from the file extension — a PDF uploaded as 참고자료 stayed a PDF,
|
||||
// but the old category-based split (mirroring detective-app's evidence/docs
|
||||
// split) silently routed every PDF/DOCX/etc into 제출서류 regardless of which
|
||||
// button was clicked, so an upload could "disappear" from the tab it was
|
||||
// added from. Files uploaded before this fix have no folder prefix (folder:
|
||||
// '') — those still show up under 첨부자료 so nothing already on disk goes missing.
|
||||
async function loadCaseFiles(){
|
||||
const list=document.getElementById('case-files-list');
|
||||
if(!currentCaseId){list.innerHTML='';return;}
|
||||
@@ -1073,8 +1086,7 @@ async function loadCaseFiles(){
|
||||
const r=await fetch('/api/lawyer/files?caseId='+encodeURIComponent(currentCaseId),{headers:authH()});
|
||||
const d=await r.json();
|
||||
const all=Array.isArray(d.files)?d.files:[];
|
||||
// Root-level documents live in the 제출서류 tab instead.
|
||||
renderCaseFileList(list,all.filter(f=>f.category!=='document'));
|
||||
renderCaseFileList(list,all.filter(f=>f.folder==='attachments'||f.folder===''));
|
||||
}catch{list.innerHTML='<div class="lw-cl-empty">파일 목록을 불러오지 못했습니다.</div>';}
|
||||
}
|
||||
|
||||
@@ -1086,7 +1098,7 @@ async function loadCaseDocs(){
|
||||
const r=await fetch('/api/lawyer/files?caseId='+encodeURIComponent(currentCaseId),{headers:authH()});
|
||||
const d=await r.json();
|
||||
const all=Array.isArray(d.files)?d.files:[];
|
||||
const docs=all.filter(f=>f.category==='document').sort((a,b)=>new Date(b.mtime)-new Date(a.mtime));
|
||||
const docs=all.filter(f=>f.folder==='submissions').sort((a,b)=>new Date(b.mtime)-new Date(a.mtime));
|
||||
if(!docs.length){list.innerHTML='<div class="lw-cl-empty">등록된 제출서류가 없습니다.</div>';return;}
|
||||
list.innerHTML=docs.map(f=>renderCaseFileRow(f)).join('');
|
||||
}catch{list.innerHTML='<div class="lw-cl-empty">서류 목록을 불러오지 못했습니다.</div>';}
|
||||
@@ -1122,10 +1134,12 @@ function renderCaseFileRow(f){
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function uploadOneCaseFile(file){
|
||||
// folder: 'attachments' or 'submissions' — determines which tab this file
|
||||
// shows up in (see loadCaseFiles/loadCaseDocs), independent of file type.
|
||||
function uploadOneCaseFile(file,folder){
|
||||
return new Promise((resolve,reject)=>{
|
||||
const fd=new FormData();
|
||||
fd.append('file',file,file.name);
|
||||
fd.append('file',file,`${folder}/${file.name}`);
|
||||
fetch('/api/lawyer/upload?caseId='+encodeURIComponent(currentCaseId),{
|
||||
method:'POST',headers:authH(),body:fd,
|
||||
}).then(r=>r.json()).then(d=>d.success?resolve(d):reject(d)).catch(reject);
|
||||
@@ -1138,7 +1152,7 @@ async function onCaseFilesPicked(fileList){
|
||||
const files=[...fileList];
|
||||
for(let i=0;i<files.length;i++){
|
||||
status.textContent=`업로드 중... (${i+1}/${files.length})`;
|
||||
try{await uploadOneCaseFile(files[i]);}catch{}
|
||||
try{await uploadOneCaseFile(files[i],'attachments');}catch{}
|
||||
}
|
||||
status.textContent='';
|
||||
document.getElementById('case-file-input').value='';
|
||||
@@ -1151,7 +1165,7 @@ async function onCaseDocsPicked(fileList){
|
||||
const files=[...fileList];
|
||||
for(let i=0;i<files.length;i++){
|
||||
status.textContent=`업로드 중... (${i+1}/${files.length})`;
|
||||
try{await uploadOneCaseFile(files[i]);}catch{}
|
||||
try{await uploadOneCaseFile(files[i],'submissions');}catch{}
|
||||
}
|
||||
status.textContent='';
|
||||
document.getElementById('case-doc-input').value='';
|
||||
@@ -1620,6 +1634,9 @@ async function callChat(message){
|
||||
typingDiv.remove();
|
||||
if(e.name!=='AbortError'){if(!bubble)bubble=addMsg('assistant','');bubble.innerHTML='<span style="color:var(--err)">오류: '+escHtml(e.message)+'</span>';}
|
||||
}finally{btn.disabled=false;btn.textContent='전송';}
|
||||
// A case discussed only through chat (never typed into the 메모 tab) would
|
||||
// otherwise never trigger auto-naming — try from this turn's own message too.
|
||||
if(currentCaseId)autoNameCaseIfNeeded(message);
|
||||
}
|
||||
|
||||
async function clearChat(){
|
||||
|
||||
Reference in new issue
Block a user