@alexsun-top/opencode-chat-room 0.6.9 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +5 -4
- package/README.zh-CN.md +5 -4
- package/package.json +1 -1
- package/plugin.ts +49 -27
- package/server/assets/HIGHLIGHT-LICENSE +29 -0
- package/server/assets/NOTICE.txt +2 -1
- package/server/assets/base.css +5 -50
- package/server/assets/chat/editor.js +97 -16
- package/server/assets/chat/events.js +39 -6
- package/server/assets/chat/index.js +4 -0
- package/server/assets/chat/join-requests.js +37 -17
- package/server/assets/chat/locales/de.js +115 -0
- package/server/assets/chat/locales/es.js +115 -0
- package/server/assets/chat/locales/fr.js +115 -0
- package/server/assets/chat/locales/index.js +8 -0
- package/server/assets/chat/locales/it.js +115 -0
- package/server/assets/chat/locales/ja.js +115 -0
- package/server/assets/chat/locales/ko.js +115 -0
- package/server/assets/chat/markdown.js +100 -0
- package/server/assets/chat/members.js +1 -1
- package/server/assets/chat/mentions.js +1 -0
- package/server/assets/chat/message-polling.js +28 -5
- package/server/assets/chat/messages.js +20 -2
- package/server/assets/chat/panels.js +0 -9
- package/server/assets/chat/questions.js +11 -3
- package/server/assets/chat/recall.js +3 -3
- package/server/assets/chat/replies.js +1 -1
- package/server/assets/chat/room-watcher.js +4 -0
- package/server/assets/chat/settings.js +72 -0
- package/server/assets/chat/shortcuts.js +30 -5
- package/server/assets/chat/state.js +43 -21
- package/server/assets/chat/viewport.js +23 -0
- package/server/assets/code-highlight.css +124 -0
- package/server/assets/conversation.css +21 -3
- package/server/assets/highlight-10.7.3.min.js +1358 -0
- package/server/assets/responsive.css +3 -5
- package/server/assets/settings.css +138 -0
- package/server/chat-server.ts +4 -1
- package/server/chat.html +96 -30
- package/server/join-requests.ts +11 -0
- package/server/sw.js +3 -0
- package/skills/chatroom/SKILL.md +2 -1
- package/src/agent/admin-client.ts +13 -5
- package/src/agent/announcement-tool.ts +6 -6
- package/src/center/center-client.ts +17 -17
- package/src/center/reminder-client.ts +5 -5
- package/src/rooms/resource-read.ts +16 -9
- package/src/rooms/resource-upload.ts +2 -2
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// Korean UI dictionary. Keys mirror the English dictionary in state.js.
|
|
2
|
+
export const ko = {
|
|
3
|
+
brand: "OC Chat", documentTitle: "OC Chat",
|
|
4
|
+
roomTitle: ({ name }) => `${name} · OC Chat`,
|
|
5
|
+
tagline: "가벼운 채팅방입니다. 방 ID를 입력해 참여하거나 새로 만드세요.",
|
|
6
|
+
restoringSession: "세션을 복원하는 중…", retry: "다시 시도", roomOptions: "옵션",
|
|
7
|
+
languageLabel: "언어", roomIdLabel: "방 ID", roomIdPlaceholder: "방 ID를 붙여넣거나 입력하세요",
|
|
8
|
+
nameLabel: "이름", namePlaceholder: "어떻게 불러 드릴까요?", joinRoom: "방 참여",
|
|
9
|
+
or: "또는", newRoomNameLabel: "새 방 이름", newRoomNamePlaceholder: "예: 주말 영화의 밤",
|
|
10
|
+
createRoom: "방 만들기", joinRoomTitle: "방 참여", joinRoomHint: "누군가 방 ID를 공유했나요? 여기에 붙여넣으세요.",
|
|
11
|
+
createRoomTitle: "방 만들기", createRoomHint: "새 방을 만들고 ID로 사람들을 초대하세요.",
|
|
12
|
+
requireApproval: "참여 승인 필요", requireApprovalHint: "새 멤버는 사람 관리자의 승인이 필요합니다. Agent는 관리자 Agent가 승인할 수도 있습니다.",
|
|
13
|
+
joinPolicyEditHint: "새 멤버는 사람 관리자의 승인이 필요합니다. 끄면 대기 중인 모든 신청이 삭제됩니다.", joinPolicyOpenConfirm: "승인을 끌까요? 대기 중인 참여 신청이 모두 삭제됩니다.",
|
|
14
|
+
approvalRequired: "승인 필요", joinRequired: "승인 필요", joinPendingStatus: "승인 대기 중",
|
|
15
|
+
joinPendingTitle: "승인을 기다리는 중", joinPendingBody: ({ name }) => `“${name}” 방 참여 신청을 보냈습니다. 참여하려면 사람 관리자의 승인이 필요합니다.`,
|
|
16
|
+
joinPendingHint: "이 페이지를 나가도 신청은 유지됩니다. 나중에 방 목록에서 확인하세요.", joinPendingNotice: ({ name }) => `“${name}” 방 참여 신청을 보냈습니다. 사람 관리자의 승인을 기다리는 중입니다.`, joinPendingCancel: "신청 취소", joinPendingCancelError: "신청을 취소하지 못했습니다. 다시 시도하세요.",
|
|
17
|
+
joinPendingGoneTitle: "대기 중인 신청이 없습니다", joinPendingGoneBody: "거절되었거나 삭제되었을 수 있습니다. 새로 신청할 수 있습니다.", joinPendingAgain: "다시 신청",
|
|
18
|
+
joinPendingError: "신청을 확인하지 못했습니다. 다시 시도하세요.", joinPendingRoomGone: "이 방은 없어졌거나 더 이상 접근할 수 없습니다.",
|
|
19
|
+
joinNameTaken: "이 이름은 이미 이 방에서 사용 중입니다. 다른 이름을 선택하세요.",
|
|
20
|
+
joinRequestsTitle: "참여 신청", joinRequestsHint: "Agent 신청은 관리자 Agent도 승인할 수 있습니다.", joinRequestsEmpty: "대기 중인 신청이 없습니다.",
|
|
21
|
+
joinRequestsLoadFailed: "참여 신청을 불러오지 못했습니다.", joinRequestAlreadyHandled: "이미 처리된 신청입니다.", joinRequestApprove: "승인", joinRequestDeny: "거절", joinRequestAgent: "Agent", joinRequestHuman: "사람",
|
|
22
|
+
joinRequestApproveLabel: ({ name }) => `${name} 승인`, joinRequestDenyLabel: ({ name }) => `${name} 거절`,
|
|
23
|
+
joinRequestTime: ({ time }) => `신청 시각 ${time}`, joinRequestApproved: ({ name }) => `${name} 님을 승인했습니다.`, joinRequestDenied: ({ name }) => `${name} 님을 거절했습니다.`,
|
|
24
|
+
joinRequestActionFailed: ({ message }) => `신청을 변경하지 못했습니다: ${message}`, membersWithRequests: ({ count }) => `멤버, 참여 신청 ${count}건 대기 중`,
|
|
25
|
+
accessKeyTitle: "액세스 키", accessKeyHint: "이 서버는 액세스 키를 요구합니다. 키는 이 브라우저에 저장되고 모든 요청에 포함됩니다.",
|
|
26
|
+
tokenOptional: "액세스 토큰(선택)", bearerToken: "Bearer 토큰",
|
|
27
|
+
tokenPlaceholder: "서버에서 요구하는 경우 입력", save: "저장",
|
|
28
|
+
tokenHint: "서버가 액세스 토큰을 요구하면(401) 모든 요청에 포함됩니다.",
|
|
29
|
+
existingRooms: "방", noRooms: "아직 방이 없습니다. 하나 만들어 보세요.", copyRoomId: "방 ID 복사", loadingHistory: "이전 메시지 불러오는 중",
|
|
30
|
+
editRoom: "방 편집", roomOwnerOnlyTitle: "소유자 또는 관리자만", roomOwnerOnlyNote: ({ owner }) => `이 설정은 방 소유자나 방 관리자만 변경할 수 있습니다. 이 방의 소유자는 ${owner} 님입니다.`, roomNameLabel: "방 이름", roomDescriptionLabel: "설명", adminAgentLabel: "관리자 Agent", roomOwnerBadge: "소유자", roomAdminBadge: "관리자",
|
|
31
|
+
adminIdsLabel: "사람 관리자", adminIdsHint: "이 멤버들은 방 정보 편집, 멤버 관리, 파일 삭제, 후임자 지정을 할 수 있습니다. 소유자는 항상 같은 권한을 가집니다.", adminIdsEmpty: "이 방에는 아직 다른 멤버가 없습니다.", newOwnerLabel: "새 소유자", newOwnerHint: "방을 참여 중인 다른 사람에게 넘깁니다. 소유자만 할 수 있으며 Agent는 소유자가 될 수 없습니다.",
|
|
32
|
+
successorLabel: "소유자가 나갈 때의 후임자", successorNone: "가장 오래 참여한 멤버", successorHint: "소유자가 나가면 이 사람이 소유자가 됩니다. 관리자가 나가면 이 사람이 그 역할을 이어받습니다. 비워 두면 가장 오래 참여한 멤버가 됩니다.", ownerOnlySettingsNote: "관리자 Agent 변경과 방 넘기기는 소유자만 할 수 있습니다.", adminAgentHint: "지정된 Agent는 관리 도구로 이 방과 기록을 확인할 수 있습니다. 소유자만 변경할 수 있으며 비워 두면 없음입니다.",
|
|
33
|
+
noAdminAgent: "없음", roomNameRequired: "방 이름을 입력하세요", openQuestions: ({ count }) => `답변 없는 질문 ${count}개`,
|
|
34
|
+
newRoom: "방 만들기",
|
|
35
|
+
copyRoomIdTitle: ({ id }) => `클릭하여 전체 방 ID 복사: ${id}`, copied: "복사됨",
|
|
36
|
+
members: "멤버", membersCount: ({ count }) => `멤버 (${count})`, noMembers: "아직 멤버가 없습니다.", profileMenu: "프로필 및 설정",
|
|
37
|
+
questions: "질문", pendingQuestions: "대기 중인 질문", refreshQuestions: "새로 고침",
|
|
38
|
+
announcements: "공지", announcementName: "이름", announcementContent: "내용",
|
|
39
|
+
reminders: "리마인더", reminderSchedule: "일정", reminderOnce: "한 번만", reminderDate: "날짜 및 시간",
|
|
40
|
+
reminderCron: "5필드 CRON 식", reminderTimezone: "시간대 재정의(선택)", reminderTimezoneHint: "비워 두면 서버 시간대를 사용합니다. IANA 시간대는 두 일정 유형 모두에 적용됩니다. 일광 절약 시간 변경으로 건너뛰거나 반복되는 한 번짜리 시각은 서버가 거부합니다.",
|
|
41
|
+
reminderText: "리마인더 텍스트", reminderTemplateHint: "메시지에 {{time}}, {{initiator}}, {{room}}을 사용할 수 있습니다.", reminderCreate: "리마인더 만들기",
|
|
42
|
+
reminderLoading: "리마인더 불러오는 중…", reminderEmpty: "아직 리마인더가 없습니다.", reminderPaused: "일시 중지됨", reminderNext: ({ time }) => `다음: ${time}`,
|
|
43
|
+
reminderPause: "일시 중지", reminderResume: "재개", reminderDelete: "삭제", reminderDeleteConfirm: "이 리마인더를 삭제할까요?",
|
|
44
|
+
reminderEdit: "편집", reminderEditHeading: "리마인더 편집", reminderSave: "변경 사항 저장",
|
|
45
|
+
reminderCreated: "리마인더를 만들었습니다.", reminderUpdated: "리마인더를 수정했습니다.", reminderDeleted: "리마인더를 삭제했습니다.",
|
|
46
|
+
reminderInvalid: "날짜, 5필드 CRON 식, IANA 시간대, 리마인더 텍스트를 확인하세요.", reminderLoadFailed: "리마인더를 불러오지 못했습니다. 작성 중인 내용은 그대로 있습니다.",
|
|
47
|
+
diagramLoading: "다이어그램 그리는 중…", diagramRenderFailed: "다이어그램을 표시할 수 없습니다. 원본을 표시합니다.", resourceLoading: "파일 불러오는 중…", resourceFailed: "이 파일을 불러오지 못했습니다.", resourceDownload: "다운로드", resourceMoreActions: "{name}의 추가 작업", resourcePreview: "미리 보기", resourceHide: "미리 보기 숨기기", zoomImage: "이미지 열기", imagePreviewTitle: "이미지 미리 보기", imageZoomControls: "이미지 확대/축소", zoomIn: "확대", zoomOut: "축소", zoomReset: "확대/축소 초기화", installTitle: "OC Chat 설치", installBody: "홈 화면에 추가하면 전체 화면으로 채팅할 수 있습니다.", installAction: "설치", installHow: "설치 방법", installNotNow: "나중에", installIosGuide: "공유를 탭한 다음 홈 화면에 추가를 선택하세요.",
|
|
48
|
+
announcementDelete: "공지 삭제",
|
|
49
|
+
announcementNew: "새 공지", announcementEmpty: "아직 공지가 없습니다.", announcementLoading: "공지 불러오는 중…",
|
|
50
|
+
announcementLoadFailed: "공지를 불러오지 못했습니다. 작성 중인 내용은 그대로 있습니다.", announcementSaved: "공지를 저장했습니다.", announcementDeleted: "공지를 삭제했습니다.",
|
|
51
|
+
announcementDuplicate: "이미 있는 이름입니다. 선택해서 편집하거나 다른 이름을 선택하세요.", announcementDeleteConfirm: ({ name }) => `“${name}”을(를) 삭제할까요?`, announcementCount: ({ count }) => `${count} / 5000`, announcementInvalid: "이름은 1~64자, 내용은 5000자 이내로 입력하세요.",
|
|
52
|
+
questionsLoading: "질문 불러오는 중…", questionsEmpty: "답변 없는 질문이 없습니다.",
|
|
53
|
+
questionsFailed: "질문을 불러오지 못했습니다. 다시 시도하세요.", questionsUnsupported: "이 서버에서는 답변 없는 질문을 사용할 수 없습니다.", questionLabel: "질문",
|
|
54
|
+
answerQuestion: "답장", answerPlaceholder: "답장을 작성하세요…", sendAnswer: "답장 보내기", selectQuestion: "질문에 답장", copyQuestion: "질문 복사", questionCopied: "질문을 복사했습니다.", questionCopyFailed: "질문을 복사하지 못했습니다.",
|
|
55
|
+
answerFailed: "답장에 실패했습니다. 작성 중인 내용은 그대로 있습니다.", answerTooLong: "답장은 5,000자 이내여야 합니다.", questionAlreadyAnswered: "이 질문은 다른 곳에서 이미 답변되었습니다.",
|
|
56
|
+
adminBindingGuide: "방과 그 안의 Agent를 선택하세요. 초대를 비공개로 보내면 설정이 완료됩니다.", adminRoomLabel: "관리 방", adminDesignateAgent: "Agent 초대",
|
|
57
|
+
settings: "설정", adminAccess: "관리", adminToken: "관리 토큰", openAdministration: "관리 열기", administration: "관리", designations: "지정", adminRoom: "관리 방", targetRoom: "Agent 소속 방", adminScopeNote: "관리 방에서 Agent를 선택하세요. 관리자는 모든 방을 관리할 수 있습니다.", targetAgent: "등록된 Agent", designate: "관리자로 지정", revokeDesignation: "지정 해제", globalStatus: "전체 상태", adminTasks: "작업", taskText: "작업", dispatchTask: "작업 보내기", timers: "타이머", planName: "타이머 이름", createTimer: "타이머 만들기", tokenRequired: "서버가 액세스 토큰을 요구합니다(401).",
|
|
58
|
+
themeLabel: "테마", themeSystem: "시스템", themeLight: "라이트", themeDark: "다크", themeForest: "포레스트", themeSand: "샌드",
|
|
59
|
+
settingsLocalHint: "언어와 테마는 이 브라우저에 저장됩니다.",
|
|
60
|
+
adminLoading: "관리 화면 불러오는 중…", refreshAdmin: "새로 고침", adminRoomBadge: "관리", chooseAdminRoom: "일반 방 선택", chooseTargetRoom: "Agent 방 선택", chooseAgent: "등록된 Agent 선택", taskTargetRoom: "대상 방", taskTargetAgent: "대상 Agent", createAdminRoomFirst: "먼저 일반 방을 만든 다음 관리 방으로 선택하세요.", noAgents: "등록된 Agent 없음", selectAdminAgent: "관리 방과 등록된 Agent를 선택하세요.", adminDesignated: "관리자 지정은 즉시 적용되며 해제할 때까지 유지됩니다.", revokeConfirm: "이 관리자 지정을 해제할까요? 일반 방은 그대로 남습니다.", updateTask: "작업 업데이트", task_pending: "대기 중", task_working: "작업 중", task_blocked: "차단됨", task_completed: "완료", task_cancelled: "취소됨", nextRun: ({ time, minutes }) => `${minutes}분마다 · 다음 ${time}`, paused: "일시 중지됨", pauseTimer: "일시 중지", resumeTimer: "재개", deleteTimer: "삭제", deleteTimerConfirm: ({ name }) => `타이머 “${name}”을(를) 삭제할까요?`,
|
|
61
|
+
leave: "나가기", reconnecting: "연결이 끊겼습니다. 다시 연결하는 중…", messageList: "메시지 목록",
|
|
62
|
+
noMessages: "아직 메시지가 없습니다. 무언가 남겨 보세요.", latestMessages: "최신 메시지로 돌아가기",
|
|
63
|
+
mentionMembers: "멘션할 멤버 선택", messagePlaceholder: "메시지 · Enter로 전송",
|
|
64
|
+
attachments: "첨부 파일", addFiles: "파일 추가", dropFilesHere: "여기에 파일을 놓아 첨부하세요",
|
|
65
|
+
attachmentVolatile: "붙여넣은 파일은 새로 고침 후 복구됩니다. 선택한 파일은 이 탭에 남습니다.", attachmentNotPersisted: "이 파일은 너무 커서 새로 고침용으로 저장할 수 없습니다. 보낼 때까지 이 탭을 닫지 마세요.", retryUpload: "다시 시도", removeFile: "삭제",
|
|
66
|
+
uploadQueued: "업로드 대기 중", uploadReady: "보낼 준비됨", sendAsFileFailed: "업로드에 실패했습니다. 텍스트는 입력창에 그대로 있습니다.", uploadPercent: ({ percent }) => `업로드 중 ${percent}%`,
|
|
67
|
+
uploadFailed: ({ reason } = {}) => reason ? `업로드에 실패했습니다(${reason}). 파일을 다시 시도하거나 삭제하세요.` : "업로드에 실패했습니다. 파일을 다시 시도하거나 삭제하세요.",
|
|
68
|
+
fileUnreadable: "이 파일을 읽을 수 없습니다. 다른 앱의 임시 파일이거나 아직 클라우드에만 있을 수 있습니다. 디스크에 저장하거나 스크린샷을 찍어 첨부하세요.",
|
|
69
|
+
fileTooLarge: "파일이 서버의 현재 용량 제한을 초과했습니다.",
|
|
70
|
+
send: "보내기", roomMeta: ({ members, count }) => `멤버 ${members}명 · 메시지 ${count}개`,
|
|
71
|
+
joinArrow: "참여 →", joinDirectTitle: "클릭하여 바로 참여", mentionEmpty: "일치하는 멤버 없음",
|
|
72
|
+
joined: "참여함", joinAction: "방 참여", unreadMessages: ({ count }) => `읽지 않음 ${count}개`,
|
|
73
|
+
mentionHint: "↑↓ 선택 · Enter 확인 · Esc 닫기", today: "오늘", yesterday: "어제",
|
|
74
|
+
shortcutsTitle: "키보드 단축키", shortcutsLead: "ChatRoom 단축키입니다. {modifier} + / 를 눌러 이 목록을 여세요.",
|
|
75
|
+
shortcutsOpen: "모든 단축키",
|
|
76
|
+
shortcutsWriting: "작성", shortcutsSend: "메시지 보내기", shortcutsNewline: "줄 바꾸기",
|
|
77
|
+
shortcutsMention: "멘션할 멤버 선택", shortcutsRooms: "방",
|
|
78
|
+
shortcutsSwitchRoom: "이전 또는 다음 방으로 전환", shortcutsReading: "읽기",
|
|
79
|
+
shortcutsScroll: "입력 중에 메시지 스크롤", shortcutsJump: "대화의 시작이나 끝으로 이동", shortcutsMenus: "메뉴 및 대화 상자",
|
|
80
|
+
shortcutsClose: "열린 메뉴, 패널 또는 대화 상자 닫기",
|
|
81
|
+
earlierMessages: "이전 메시지는 생략됨", messagesBetweenOmitted: "이 읽기 지점과 최신 메시지 사이는 생략되었습니다.", you: "나", saved: "저장됨",
|
|
82
|
+
savedMemory: "이 탭에만 저장됨", copyFailed: ({ id }) => `복사하지 못했습니다. 직접 복사하세요: ${id}`,
|
|
83
|
+
copyMessage: "복사", copiedMessage: "복사됨", copyMessageFailed: "복사하지 못했습니다. 메시지를 선택해 직접 복사하세요.", wrapCode: "코드 줄 바꿈",
|
|
84
|
+
replyMessage: "답장", replyingTo: "답장 대상", cancelReply: "답장 취소", replyOpenOriginal: "원본 메시지 보기", replyOriginalUnavailable: "원본 메시지를 볼 수 없습니다.", replyOriginalRecalled: "원본 메시지가 철회되었습니다.",
|
|
85
|
+
recallMessage: "철회", recallSystemMessage: "이 방 공지 철회", recallSystemConfirm: "이 방 공지를 철회할까요? 모든 사람에게 철회된 것으로 표시됩니다.", recallConfirm: "이 메시지를 철회할까요? 모든 사람에게 철회된 것으로 표시됩니다.", recallAdminConfirm: ({ name }) => `${name} 님의 메시지를 철회할까요? 모든 사람에게 철회된 것으로 표시됩니다.`, recallFailed: "이 메시지를 철회하지 못했습니다.", messageRecalled: "메시지가 철회됨", recalledBy: ({ name }) => `${name} 님이 철회함`, showRecalled: "원본 보기", hideRecalled: "원본 숨기기", revealFailed: "불러오지 못했습니다. 다시 시도하세요.",
|
|
86
|
+
identityChanged: "이 브라우저 ID가 다른 탭에서 변경되었습니다. 계속하려면 이 탭을 새로 고치세요.",
|
|
87
|
+
networkError: "네트워크 연결에 실패했습니다", requestFailed: ({ status }) => `요청에 실패했습니다(HTTP ${status})`,
|
|
88
|
+
roomIdRequired: "방 ID를 입력하세요", nameRequired: "이름을 입력하세요", authRetry: "서버가 액세스 토큰을 요구합니다. 입력하고 다시 시도하세요.",
|
|
89
|
+
networkRetry: "서버에 연결할 수 없습니다. 네트워크를 확인하고 다시 시도하세요.",
|
|
90
|
+
joinFailed: ({ message }) => `참여하지 못했습니다: ${message}`, roomNameRequired: "방 이름을 입력하세요",
|
|
91
|
+
createFailed: ({ message }) => `방을 만들지 못했습니다: ${message}`,
|
|
92
|
+
roomNotFound: "이 방은 없어졌거나 더 이상 접근할 수 없습니다.",
|
|
93
|
+
sendAuth: "보내지 못했습니다. 액세스 토큰이 필요합니다", sendNetwork: "보내지 못했습니다. 메시지는 아래에 저장되었습니다.",
|
|
94
|
+
sendFailed: ({ message }) => `보내지 못했습니다: ${message}`,
|
|
95
|
+
adminRoomDeleteDenied: "이 방은 관리용으로 지정되어 있습니다. 방 소유자만 삭제할 수 있습니다.",
|
|
96
|
+
failedMessages: "보내지 못한 메시지", retryFailed: "다시 시도", discardFailed: "버리기",
|
|
97
|
+
roomListError: "방을 불러오지 못했습니다. 방 ID를 직접 입력할 수 있습니다.", guest: "게스트",
|
|
98
|
+
roomsLabel: "방", refreshRooms: "방 새로 고침", identityLabel: ({ name }) => `${name} 님으로 채팅 중`,
|
|
99
|
+
roomsMenu: "방 목록 열기", closeRoomList: "방 목록 닫기",
|
|
100
|
+
direct: "다이렉트", messagePrivately: "비공개 메시지", removeMember: "추방",
|
|
101
|
+
kickConfirm: ({ name }) => `${name} 님을 이 방에서 추방할까요? 방 ID로 다시 참여할 수 있습니다.`,
|
|
102
|
+
deleteRoom: "방 삭제", deleteConfirm: ({ name }) => `“${name}” 방과 모든 메시지를 삭제할까요? 되돌릴 수 없습니다.`,
|
|
103
|
+
allMembers: "모두", messageCount: ({ count }) => `${count} / 5000`,
|
|
104
|
+
pasteAsFile: ({ count }) => `붙여넣은 ${count}자를 텍스트 파일로 저장했습니다`,
|
|
105
|
+
sendAsFile: ({ count }) => `${count}자가 제한을 초과해 텍스트 파일로 보냅니다`,
|
|
106
|
+
privacyNote: "공유 토큰을 가진 사람은 누구나 다이렉트 메시지를 읽고 방을 관리할 수 있으며, 서버도 읽을 수 있습니다.",
|
|
107
|
+
resourceDelete: "파일 삭제", resourceDeleting: "삭제 중…", resourceDeleteConfirm: ({ name }) => `“${name}”을(를) 삭제할까요? 되돌릴 수 없습니다.`, resourceDeleted: "파일을 삭제했습니다.", resourceDeleteFailed: "이 파일을 삭제하지 못했습니다.",
|
|
108
|
+
systemJoined: ({ name }) => `${name} 님이 방에 참여했습니다`, systemLeft: ({ name }) => `${name} 님이 방을 나갔습니다`, systemRemoved: ({ name }) => `${name} 님이 방에서 추방되었습니다`,
|
|
109
|
+
systemDesignated: ({ actor, name }) => `${actor} 님이 ${name} 님을 관리자로 지정했습니다`, systemRevoked: ({ actor }) => `${actor} 님이 관리자 지정을 해제했습니다`, systemRenamed: ({ actor, from, to }) => `${actor} 님이 방 이름을 “${from}”에서 “${to}”(으)로 변경했습니다`, systemDescribed: ({ actor }) => `${actor} 님이 방 설명을 수정했습니다`, systemHanded: ({ actor, name }) => `${actor} 님이 방을 ${name} 님에게 넘겼습니다`, systemAdminsUpdated: ({ actor }) => `${actor} 님이 방 관리자를 수정했습니다`, systemSuccessorNamed: ({ actor, name }) => `${actor} 님이 ${name} 님을 방 후임자로 지정했습니다`, systemSuccessorCleared: ({ actor }) => `${actor} 님이 방 후임자 지정을 해제했습니다`, systemJoinPolicy: ({ actor, policy }) => policy === "approval" ? `${actor} 님이 이 방 참여에 승인을 요구하도록 변경했습니다` : `${actor} 님이 승인 없이 참여할 수 있도록 이 방을 열었습니다`,
|
|
110
|
+
activity_working: "작업 중", activity_idle: "포그라운드 유휴", activity_waiting: "대기 중", activity_unknown: "상태 알 수 없음", activity_offline: "상태 오래됨",
|
|
111
|
+
activityHint_working: "Agent가 작업 중이라고 보고했습니다.", activityHint_idle: "포그라운드는 유휴 상태이며 백그라운드 작업은 계속될 수 있습니다.", activityHint_waiting: "Agent가 대기 중이라고 보고했습니다.", activityHint_unknown: "활동 보고가 없습니다.", activityHint_offline: "마지막 상태가 오래되었습니다. Agent가 오프라인이라는 뜻은 아닙니다.",
|
|
112
|
+
receiptCount: ({ count }) => `${count}명 읽음`, receiptNone: "아직 읽은 사람 없음", receiptNotLoaded: "읽음 상태를 불러오지 않음", readerPanelTitle: "메시지를 읽은 사람", close: "닫기", departedMember: "나감",
|
|
113
|
+
confirmTitle: "확인해 주세요", cancel: "취소", confirmAction: "확인",
|
|
114
|
+
receiptEvidence_displayed: "화면에 표시됨", receiptEvidence_tool: "방 도구로 가져옴", receiptEvidence_context: "Agent 컨텍스트에 있음",
|
|
115
|
+
};
|
|
@@ -5,6 +5,7 @@ const mentionPattern = /<at>@([^<]+)<\/at>/g;
|
|
|
5
5
|
const resourcePattern = /\[\[resource:([\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})\]\]/gi;
|
|
6
6
|
let mermaidReady = false;
|
|
7
7
|
const previewUrls = new Map();
|
|
8
|
+
const svgNamespace = "http://www.w3.org/2000/svg";
|
|
8
9
|
let previewObserver;
|
|
9
10
|
|
|
10
11
|
export function renderMarkdown(root, text, app) {
|
|
@@ -38,6 +39,7 @@ export function renderMarkdown(root, text, app) {
|
|
|
38
39
|
link.rel = "noopener noreferrer";
|
|
39
40
|
});
|
|
40
41
|
fragment.querySelectorAll('input[type="checkbox"]').forEach((input) => { input.disabled = true; });
|
|
42
|
+
for (const code of fragment.querySelectorAll("pre > code")) decorateCodeBlock(code, app);
|
|
41
43
|
root.appendChild(fragment);
|
|
42
44
|
for (let i = 0; i < diagramNodes.length; i++) {
|
|
43
45
|
const source = diagrams.get(`CHATDIAGRAM${nonce}${i}END`);
|
|
@@ -46,6 +48,104 @@ export function renderMarkdown(root, text, app) {
|
|
|
46
48
|
for (const resource of resources) void loadResourceCard(resource.card, resource.roomId, app);
|
|
47
49
|
}
|
|
48
50
|
|
|
51
|
+
function decorateCodeBlock(code, app) {
|
|
52
|
+
const pre = code.parentElement;
|
|
53
|
+
if (!pre || pre.closest(".mermaid-diagram") || pre.parentElement?.classList.contains("code-block")) return;
|
|
54
|
+
highlightCode(code);
|
|
55
|
+
const block = document.createElement("div");
|
|
56
|
+
block.className = "code-block";
|
|
57
|
+
pre.replaceWith(block);
|
|
58
|
+
block.append(pre, codeToolbar(code, pre, block, app));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function highlightCode(code) {
|
|
62
|
+
const language = (/language-(\S+)/.exec(code.className) || [])[1]?.toLowerCase();
|
|
63
|
+
if (!language || language === "mermaid" || !window.hljs?.getLanguage?.(language)) return;
|
|
64
|
+
try {
|
|
65
|
+
const markup = window.hljs.highlight(code.textContent, { language }).value;
|
|
66
|
+
const fragment = window.DOMPurify.sanitize(markup, { RETURN_DOM_FRAGMENT: true, ALLOWED_TAGS: ["span"], ALLOWED_ATTR: ["class"] });
|
|
67
|
+
code.replaceChildren(fragment);
|
|
68
|
+
code.classList.add("hljs");
|
|
69
|
+
} catch { /* Keep the escaped text when a grammar rejects its input. */ }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function codeToolbar(code, pre, block, app) {
|
|
73
|
+
const toolbar = document.createElement("div");
|
|
74
|
+
toolbar.className = "code-toolbar";
|
|
75
|
+
const wrap = codeToolButton("code-wrap-toggle", "wrapCode", app, wrapIcon());
|
|
76
|
+
wrap.setAttribute("aria-pressed", "false");
|
|
77
|
+
wrap.addEventListener("click", (event) => {
|
|
78
|
+
event.stopPropagation();
|
|
79
|
+
const wrapped = !block.classList.contains("is-wrapped");
|
|
80
|
+
if (wrapped) block._codeScrollLeft = pre.scrollLeft;
|
|
81
|
+
block.classList.toggle("is-wrapped", wrapped);
|
|
82
|
+
wrap.setAttribute("aria-pressed", String(wrapped));
|
|
83
|
+
pre.scrollLeft = wrapped ? 0 : block._codeScrollLeft || 0;
|
|
84
|
+
});
|
|
85
|
+
const copy = codeToolButton("code-copy-button", "copyMessage", app, copyIcon(), checkIcon());
|
|
86
|
+
copy.addEventListener("click", (event) => { event.stopPropagation(); void copyCode(copy, code, app); });
|
|
87
|
+
toolbar.append(wrap, copy);
|
|
88
|
+
return toolbar;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function codeToolButton(className, key, app, ...icons) {
|
|
92
|
+
const button = document.createElement("button");
|
|
93
|
+
button.type = "button";
|
|
94
|
+
button.className = `code-tool-button ${className}`;
|
|
95
|
+
button.setAttribute("aria-label", app.t(key));
|
|
96
|
+
button.title = app.t(key);
|
|
97
|
+
button.dataset.i18nAriaLabel = key;
|
|
98
|
+
button.dataset.i18nTitle = key;
|
|
99
|
+
button.append(...icons);
|
|
100
|
+
return button;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function codeIcon(className, shapes) {
|
|
104
|
+
const svg = document.createElementNS(svgNamespace, "svg");
|
|
105
|
+
svg.setAttribute("viewBox", "0 0 24 24");
|
|
106
|
+
svg.setAttribute("aria-hidden", "true");
|
|
107
|
+
svg.classList.add("code-tool-icon", className);
|
|
108
|
+
for (const [tag, attributes] of shapes) {
|
|
109
|
+
const node = document.createElementNS(svgNamespace, tag);
|
|
110
|
+
for (const [name, value] of Object.entries(attributes)) node.setAttribute(name, value);
|
|
111
|
+
svg.append(node);
|
|
112
|
+
}
|
|
113
|
+
return svg;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function wrapIcon() {
|
|
117
|
+
return codeIcon("code-wrap-icon", [
|
|
118
|
+
["path", { d: "M4 5h16M4 11h13a3.5 3.5 0 0 1 0 7h-4M4 18h5" }],
|
|
119
|
+
["path", { d: "m8 16-3 3 3 3" }],
|
|
120
|
+
]);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function copyIcon() {
|
|
124
|
+
return codeIcon("code-copy-icon", [
|
|
125
|
+
["rect", { x: "4", y: "3", width: "13", height: "15", rx: "2" }],
|
|
126
|
+
["rect", { x: "8", y: "7", width: "12", height: "14", rx: "2" }],
|
|
127
|
+
]);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function checkIcon() {
|
|
131
|
+
return codeIcon("code-check-icon", [["path", { d: "m5 12 4.5 4.5L19 7" }]]);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async function copyCode(button, code, app) {
|
|
135
|
+
const copied = await copyTextToClipboard(code.textContent);
|
|
136
|
+
clearTimeout(button._feedbackTimer);
|
|
137
|
+
button.classList.toggle("is-copied", copied);
|
|
138
|
+
button.classList.toggle("is-copy-failed", !copied);
|
|
139
|
+
const key = copied ? "copiedMessage" : "copyMessageFailed";
|
|
140
|
+
button.setAttribute("aria-label", app.t(key));
|
|
141
|
+
button.title = app.t(key);
|
|
142
|
+
button._feedbackTimer = setTimeout(() => {
|
|
143
|
+
button.classList.remove("is-copied", "is-copy-failed");
|
|
144
|
+
button.setAttribute("aria-label", app.t("copyMessage"));
|
|
145
|
+
button.title = app.t("copyMessage");
|
|
146
|
+
}, 1600);
|
|
147
|
+
}
|
|
148
|
+
|
|
49
149
|
async function initializeMermaid() {
|
|
50
150
|
if (mermaidReady) return;
|
|
51
151
|
if (!window.mermaid) await new Promise((resolve, reject) => {
|
|
@@ -183,7 +183,7 @@ function visibleMessageIDs(app) {
|
|
|
183
183
|
return Array.from(thread.querySelectorAll("[data-msg-id]")).filter((row) => {
|
|
184
184
|
const rect = row.getBoundingClientRect();
|
|
185
185
|
return rect.bottom > top && rect.top < bottom && !overlays.some((overlay) => rect.left < overlay.right && rect.right > overlay.left && rect.top < overlay.bottom && rect.bottom > overlay.top);
|
|
186
|
-
}).map((row) => row.dataset.msgId).filter(Boolean);
|
|
186
|
+
}).map((row) => row.dataset.msgId).filter((id) => Boolean(id) && !id.startsWith("pending-"));
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
function acknowledgedMessages(app, key, set, ids) {
|
|
@@ -139,5 +139,6 @@ function highlightMention(app, mention) {
|
|
|
139
139
|
});
|
|
140
140
|
const active = options[mention.index];
|
|
141
141
|
if (!active) { input.removeAttribute("aria-activedescendant"); return; }
|
|
142
|
+
active.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
142
143
|
input.setAttribute("aria-activedescendant", active.id);
|
|
143
144
|
}
|
|
@@ -6,6 +6,14 @@ export function initMessagePolling(app, isUnreadMessage) {
|
|
|
6
6
|
const $ = app.$;
|
|
7
7
|
let pollDelay = 2000;
|
|
8
8
|
|
|
9
|
+
// A restarted network can leave the browser's old request hanging. Retry at
|
|
10
|
+
// once instead of waiting for the long-poll timeout.
|
|
11
|
+
window.addEventListener("online", () => {
|
|
12
|
+
if (!app.state.polling || !app.state.room) return;
|
|
13
|
+
pollDelay = 2000;
|
|
14
|
+
app.startPolling();
|
|
15
|
+
});
|
|
16
|
+
|
|
9
17
|
function isCurrentPoll(roomId, generation) {
|
|
10
18
|
return app.state.polling && app.state.pollGeneration === generation && app.state.room?.id === roomId;
|
|
11
19
|
}
|
|
@@ -43,7 +51,19 @@ export function initMessagePolling(app, isUnreadMessage) {
|
|
|
43
51
|
// Lets the server answer at once when a recall changed the room since our
|
|
44
52
|
// last rendered snapshot instead of holding the long-poll.
|
|
45
53
|
if (entry && Number.isFinite(entry.recallVersion)) query.set("recallVersion", String(entry.recallVersion));
|
|
46
|
-
|
|
54
|
+
// The server long-polls for 25s; abort a dead request so the retry loop
|
|
55
|
+
// can run and the connection bar can recover.
|
|
56
|
+
const request = new AbortController();
|
|
57
|
+
const abort = () => request.abort();
|
|
58
|
+
const timer = setTimeout(abort, 35000);
|
|
59
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
60
|
+
let data;
|
|
61
|
+
try {
|
|
62
|
+
data = await app.api(`/inbox?${query}`, { signal: request.signal });
|
|
63
|
+
} finally {
|
|
64
|
+
clearTimeout(timer);
|
|
65
|
+
signal.removeEventListener("abort", abort);
|
|
66
|
+
}
|
|
47
67
|
if (!isCurrentPoll(roomId, generation)) return;
|
|
48
68
|
if (data.member === false) {
|
|
49
69
|
void app.removeJoinedRoom(roomId, { reason: true });
|
|
@@ -53,9 +73,10 @@ export function initMessagePolling(app, isUnreadMessage) {
|
|
|
53
73
|
const items = data.items, previousReceivedTs = entry?.receivedTs || 0, messages = app.state.room.messages;
|
|
54
74
|
const known = new Set(messages.map((message) => message.id));
|
|
55
75
|
const previousUnreadOverflow = Boolean(entry?.unreadOverflow);
|
|
56
|
-
let sawSystem = false, added = 0, unreadChanged = false;
|
|
76
|
+
let sawSystem = false, sawQuestion = false, added = 0, unreadChanged = false;
|
|
57
77
|
for (const item of items) {
|
|
58
78
|
if (item.senderId === "system") sawSystem = true;
|
|
79
|
+
if (item.isQuestion || item.answerToMessageID) sawQuestion = true;
|
|
59
80
|
const wasKnown = known.has(item.id);
|
|
60
81
|
if (!wasKnown) {
|
|
61
82
|
messages.push({ ...item, roomId }); known.add(item.id);
|
|
@@ -83,7 +104,7 @@ export function initMessagePolling(app, isUnreadMessage) {
|
|
|
83
104
|
if (messages.length > LOADED_MESSAGE_LIMIT) { const anchorId = app.state.positions.get(roomId)?.messageId, anchor = anchorId && messages.find((item) => item.id === anchorId); messages.splice(0, messages.length - LOADED_MESSAGE_LIMIT); if (anchor && !messages.includes(anchor)) messages.unshift(anchor); }
|
|
84
105
|
app.cacheRoomSoon?.(roomId);
|
|
85
106
|
const rendered = app.renderMessages(true);
|
|
86
|
-
if (sawSystem) {
|
|
107
|
+
if (sawSystem || sawQuestion) {
|
|
87
108
|
await app.refreshRoomMeta(roomId, generation);
|
|
88
109
|
if (!isCurrentPoll(roomId, generation)) return;
|
|
89
110
|
}
|
|
@@ -105,7 +126,7 @@ export function initMessagePolling(app, isUnreadMessage) {
|
|
|
105
126
|
if (!isCurrentPoll(roomId, generation)) return;
|
|
106
127
|
if (error.status === 401) {
|
|
107
128
|
app.setOnline(false);
|
|
108
|
-
if (
|
|
129
|
+
if (!app.settingsOpen()) app.openChatSettings();
|
|
109
130
|
pollDelay = Math.min(pollDelay * 2, 30000);
|
|
110
131
|
} else if (error.status === 404) {
|
|
111
132
|
void app.removeJoinedRoom(roomId, { reason: true });
|
|
@@ -122,7 +143,9 @@ export function initMessagePolling(app, isUnreadMessage) {
|
|
|
122
143
|
const room = await app.api(`/rooms/${encodeURIComponent(roomId)}`);
|
|
123
144
|
if (!isCurrentPoll(roomId, generation)) return;
|
|
124
145
|
const before = JSON.stringify([app.state.room.ownerId, app.state.room.adminIds ?? [], app.state.room.successorId ?? null, app.state.room.adminSessionID ?? null]);
|
|
125
|
-
|
|
146
|
+
const openQuestions = Number(room.openQuestions);
|
|
147
|
+
Object.assign(app.state.room, { participants: room.participants, ownerId: room.ownerId ?? app.state.room.ownerId, adminIds: room.adminIds ?? [], successorId: room.successorId ?? null, adminSessionID: room.adminSessionID ?? null, openQuestions: Number.isFinite(openQuestions) ? Math.max(0, openQuestions) : app.state.room.openQuestions });
|
|
148
|
+
if (Number.isFinite(openQuestions)) app.updateQuestionBadge?.(openQuestions);
|
|
126
149
|
if (JSON.stringify([app.state.room.ownerId, app.state.room.adminIds ?? [], app.state.room.successorId ?? null, app.state.room.adminSessionID ?? null]) !== before) { app.renderHead(); app.rerenderMessages(); }
|
|
127
150
|
app.renderMembers();
|
|
128
151
|
} catch { /* The next room event will retry. */ }
|
|
@@ -13,6 +13,7 @@ export function initMessages(app) {
|
|
|
13
13
|
app.autoGrow = (textarea) => {
|
|
14
14
|
const thread = $("#thread"), atBottom = Boolean(app.state.room && Math.abs(thread.scrollHeight - thread.clientHeight - thread.scrollTop) < 1);
|
|
15
15
|
const scrollTop = textarea.scrollTop;
|
|
16
|
+
textarea.dataset.empty = textarea.value ? "false" : "true";
|
|
16
17
|
textarea.style.overflowY = "hidden";
|
|
17
18
|
const style = getComputedStyle(textarea), line = parseFloat(style.lineHeight);
|
|
18
19
|
const padding = parseFloat(style.paddingTop) + parseFloat(style.paddingBottom);
|
|
@@ -124,6 +125,7 @@ export function initMessages(app) {
|
|
|
124
125
|
const readTimestamp = (room, entry) => {
|
|
125
126
|
let timestamp = entry.readTs;
|
|
126
127
|
for (const message of room.messages) {
|
|
128
|
+
if (message.pending) continue;
|
|
127
129
|
if (app.failedRenderIds.has(message.id)) break;
|
|
128
130
|
timestamp = Math.max(timestamp, message.createdAt);
|
|
129
131
|
}
|
|
@@ -216,7 +218,8 @@ export function initMessages(app) {
|
|
|
216
218
|
renderMarkdown(body, message.text, app);
|
|
217
219
|
const content = document.createElement("div");
|
|
218
220
|
content.className = "msg-content";
|
|
219
|
-
content.append(body
|
|
221
|
+
content.append(body);
|
|
222
|
+
if (!message.pending) content.append(app.createReceiptButton(message, own));
|
|
220
223
|
row.append(meta, content);
|
|
221
224
|
}
|
|
222
225
|
if (message.senderId !== "system") {
|
|
@@ -242,6 +245,7 @@ export function initMessages(app) {
|
|
|
242
245
|
copy._copyText = String(message.text ?? "");
|
|
243
246
|
row.append(copy);
|
|
244
247
|
}
|
|
248
|
+
if (message.pending) row.classList.add("pending");
|
|
245
249
|
if (live) row.classList.add("in");
|
|
246
250
|
return row;
|
|
247
251
|
};
|
|
@@ -358,6 +362,15 @@ export function initMessages(app) {
|
|
|
358
362
|
app.updateDraftCount();
|
|
359
363
|
app.updateSendState();
|
|
360
364
|
app.hideSendError();
|
|
365
|
+
const pending = {
|
|
366
|
+
id: `pending-${createRandomId()}`, roomId: room.id, text,
|
|
367
|
+
senderId: room.kind === "direct" ? LS.sessionID : app.state.myName,
|
|
368
|
+
senderSessionID: LS.sessionID, createdAt: Date.now(), pending: true,
|
|
369
|
+
...(replyTarget ? { replyToMessageID: replyTarget.id } : {}),
|
|
370
|
+
};
|
|
371
|
+
room.messages.push(pending);
|
|
372
|
+
app.renderMessages(true);
|
|
373
|
+
if (followedBottom) thread.scrollTop = thread.scrollHeight;
|
|
361
374
|
try {
|
|
362
375
|
let updated;
|
|
363
376
|
if (replyTarget?.isQuestion) { await app.answerQuestionFromReply(room.id, replyTarget.id, text); updated = app.state.rooms.get(room.id)?.room || room; }
|
|
@@ -365,13 +378,15 @@ export function initMessages(app) {
|
|
|
365
378
|
method: "POST", body: JSON.stringify({ sessionID: LS.sessionID, text, ...(replyTarget ? { replyToMessageID: replyTarget.id } : {}) }),
|
|
366
379
|
});
|
|
367
380
|
app.completeAttachments?.(room.id, message.ids);
|
|
381
|
+
const pendingIndex = room.messages.findIndex((item) => item.id === pending.id);
|
|
382
|
+
if (pendingIndex >= 0) room.messages.splice(pendingIndex, 1);
|
|
368
383
|
if (app.state.room?.id !== room.id) return true;
|
|
369
384
|
const entry = app.state.rooms.get(room.id);
|
|
370
385
|
// The POST snapshot is older than anything polling received while it was
|
|
371
386
|
// in flight; merge instead of dropping those messages.
|
|
372
387
|
let current = updated;
|
|
373
388
|
if (entry) {
|
|
374
|
-
const merged = new Map([...entry.room.messages, ...updated.messages].map((item) => [item.id, { ...item, roomId: updated.id }]));
|
|
389
|
+
const merged = new Map([...entry.room.messages, ...updated.messages].filter((item) => !item.pending).map((item) => [item.id, { ...item, roomId: updated.id }]));
|
|
375
390
|
const messages = [...merged.values()].sort((a, b) => a.createdAt - b.createdAt);
|
|
376
391
|
if (messages.length > LOADED_MESSAGE_LIMIT) messages.splice(0, messages.length - LOADED_MESSAGE_LIMIT);
|
|
377
392
|
app.cacheRoomSoon?.(room.id);
|
|
@@ -394,6 +409,9 @@ export function initMessages(app) {
|
|
|
394
409
|
app.renderRoomOptions($("#roomListChat"), app.state.availableRooms || []);
|
|
395
410
|
return true;
|
|
396
411
|
} catch (error) {
|
|
412
|
+
const pendingIndex = room.messages.findIndex((item) => item.id === pending.id);
|
|
413
|
+
if (pendingIndex >= 0) room.messages.splice(pendingIndex, 1);
|
|
414
|
+
if (app.state.room?.id === room.id) app.renderMessages(false);
|
|
397
415
|
const unchanged = (app.state.draftRevision.get(room.id) || 0) === revision;
|
|
398
416
|
// Someone answered the question first; retrying the answer can never succeed,
|
|
399
417
|
// so keep the text as a draft instead of a failed message.
|
|
@@ -4,7 +4,6 @@ export function initPanels(app) {
|
|
|
4
4
|
app.closePanels = () => {
|
|
5
5
|
document.querySelectorAll(".panel").forEach((panel) => { panel.hidden = true; });
|
|
6
6
|
$("#btnMembers").setAttribute("aria-expanded", "false");
|
|
7
|
-
$("#btnSettings").setAttribute("aria-expanded", "false");
|
|
8
7
|
$("#btnRoomOptions").setAttribute("aria-expanded", "false");
|
|
9
8
|
};
|
|
10
9
|
app.togglePanel = (selector) => {
|
|
@@ -26,12 +25,4 @@ export function initPanels(app) {
|
|
|
26
25
|
if (!box.open) box.showModal();
|
|
27
26
|
$("#inToken").focus();
|
|
28
27
|
};
|
|
29
|
-
app.openChatSettings = () => {
|
|
30
|
-
app.closePanels();
|
|
31
|
-
app.lastFocus = $("#btnSettings");
|
|
32
|
-
$("#chatSettings").hidden = false;
|
|
33
|
-
$("#btnSettings").setAttribute("aria-expanded", "true");
|
|
34
|
-
$("#tokenHint").hidden = false;
|
|
35
|
-
$("#inTokenChat").focus();
|
|
36
|
-
};
|
|
37
28
|
}
|
|
@@ -25,6 +25,14 @@ export function initQuestions(app) {
|
|
|
25
25
|
return row;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
+
function renderBadge(count) {
|
|
29
|
+
const value = Math.max(0, Number(count) || 0);
|
|
30
|
+
$("#questionBadge").textContent = value > 99 ? "99+" : String(value);
|
|
31
|
+
$("#questionBadge").hidden = !value;
|
|
32
|
+
trigger.setAttribute("aria-label", `${app.t("questions")}: ${value}`);
|
|
33
|
+
}
|
|
34
|
+
app.updateQuestionBadge = renderBadge;
|
|
35
|
+
|
|
28
36
|
function render(roomId) {
|
|
29
37
|
const items = pending.get(roomId) || [];
|
|
30
38
|
const entry = app.state.rooms.get(roomId);
|
|
@@ -41,9 +49,7 @@ export function initQuestions(app) {
|
|
|
41
49
|
if (list.dataset.signature === signature) { renderReply(roomId); return; }
|
|
42
50
|
const hadItems = Boolean(list.querySelector(".question-item"));
|
|
43
51
|
list.dataset.signature = signature;
|
|
44
|
-
|
|
45
|
-
$("#questionBadge").hidden = !items.length;
|
|
46
|
-
trigger.setAttribute("aria-label", `${app.t("questions")}: ${items.length}`);
|
|
52
|
+
renderBadge(items.length);
|
|
47
53
|
list.textContent = "";
|
|
48
54
|
for (const question of items) {
|
|
49
55
|
const item = document.createElement("li"), card = document.createElement("article"), select = document.createElement("button"), body = document.createElement("div");
|
|
@@ -104,11 +110,13 @@ export function initQuestions(app) {
|
|
|
104
110
|
installEditor(input);
|
|
105
111
|
const key = `${roomId}\0${question.id}`;
|
|
106
112
|
input.draftValue = drafts.has(key) ? drafts.get(key) : questionAuthorMention(question, roomId, app);
|
|
113
|
+
input.dataset.empty = input.value ? "false" : "true";
|
|
107
114
|
send.type = "submit";
|
|
108
115
|
send.className = "btn primary small";
|
|
109
116
|
send.textContent = app.t("sendAnswer");
|
|
110
117
|
send.disabled = !input.value.trim() || input.value.length > 5000 || submitting.has(key);
|
|
111
118
|
input.addEventListener("input", (event) => {
|
|
119
|
+
input.dataset.empty = input.value ? "false" : "true";
|
|
112
120
|
drafts.set(`${roomId}\0${question.id}`, input.draftValue);
|
|
113
121
|
if (!event.isComposing) app.recomputeMention(input);
|
|
114
122
|
send.disabled = !input.value.trim() || input.value.length > 5000 || submitting.has(key);
|
|
@@ -4,15 +4,15 @@ import { isOwnMessage } from "./messages.js";
|
|
|
4
4
|
import { isRoomAdmin } from "./admin-badge.js";
|
|
5
5
|
import { formatSystemMessage, setRoomPreview } from "./system-messages.js";
|
|
6
6
|
|
|
7
|
-
const RECALL_ICON = '<svg class="message-recall-icon" aria-hidden="true" viewBox="0 0 24 24"><path d="M20
|
|
8
|
-
const RECALLED_ICON = '<svg class="recalled-icon" aria-hidden="true" viewBox="0 0 24 24"><path d="M20
|
|
7
|
+
const RECALL_ICON = '<svg class="message-recall-icon" aria-hidden="true" viewBox="0 0 24 24"><path d="M20 12a8 8 0 1 1-2.34-5.66"/><path d="M20 4v6h-6"/></svg>';
|
|
8
|
+
const RECALLED_ICON = '<svg class="recalled-icon" aria-hidden="true" viewBox="0 0 24 24"><path d="M20 12a8 8 0 1 1-2.34-5.66"/><path d="M20 4v6h-6"/></svg>';
|
|
9
9
|
|
|
10
10
|
// Recall is a soft hide: the server keeps the text and members may reveal it.
|
|
11
11
|
export function initRecall(app) {
|
|
12
12
|
const $ = app.$, base = app.renderMessage;
|
|
13
13
|
|
|
14
14
|
app.canRecallMessage = (message) => {
|
|
15
|
-
if (!message || message.recalledAt) return false;
|
|
15
|
+
if (!message || message.recalledAt || message.pending) return false;
|
|
16
16
|
const self = app.state.memberSessions.get(app.state.room?.id)?.find((member) => member.sessionID === LS.sessionID);
|
|
17
17
|
// Member data may not have loaded yet; the server re-checks the real membership.
|
|
18
18
|
const humanAdmin = (!self || self.type === "human") && isRoomAdmin(app);
|
|
@@ -32,7 +32,7 @@ function bindMessageActions(app) {
|
|
|
32
32
|
const render = app.renderMessage;
|
|
33
33
|
app.renderMessage = (message, live) => {
|
|
34
34
|
const row = render(message, live);
|
|
35
|
-
if (message.senderId === "system") return row;
|
|
35
|
+
if (message.senderId === "system" || message.pending) return row;
|
|
36
36
|
if (message.answerToMessageID) row.querySelector(".msg-meta")?.after(quoteButton(message, app));
|
|
37
37
|
const copy = row.querySelector("[data-copy-message]");
|
|
38
38
|
if (copy) {
|
|
@@ -32,6 +32,10 @@ export async function watchRoom(roomId, app) {
|
|
|
32
32
|
if (Number.isFinite(Number(latest.recallVersion))) entry.recallVersion = Number(latest.recallVersion);
|
|
33
33
|
entry.room.participants = latest.participants;
|
|
34
34
|
entry.room.openQuestions = latest.openQuestions;
|
|
35
|
+
if (sawQuestion) {
|
|
36
|
+
app.renderRoomOptions(app.$("#roomList"), app.state.availableRooms || []);
|
|
37
|
+
app.renderRoomOptions(app.$("#roomListChat"), app.state.availableRooms || []);
|
|
38
|
+
}
|
|
35
39
|
entry.room.messages = [...new Map([...entry.room.messages, ...latest.messages].map((message) => [message.id, message])).values()].sort((a, b) => a.createdAt - b.createdAt).slice(-LOADED_MESSAGE_LIMIT);
|
|
36
40
|
for (const message of latest.messages) if (message.recalledAt) app.applyRecall?.(roomId, { messageID: message.id, recalledAt: message.recalledAt, recalledBy: message.recalledBy });
|
|
37
41
|
const newest = latest.messages.at(-1);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Browser settings shared by the join page and the chat: language, theme, and the optional token.
|
|
2
|
+
export const THEMES = ["system", "light", "dark", "forest", "sand"];
|
|
3
|
+
|
|
4
|
+
export function initSettings(app) {
|
|
5
|
+
const $ = app.$;
|
|
6
|
+
const dialog = $("#chatSettings");
|
|
7
|
+
if (!dialog) return;
|
|
8
|
+
const tokenInput = $("#inTokenChat"), tokenHint = $("#tokenHint");
|
|
9
|
+
const scheme = matchMedia("(prefers-color-scheme: dark)");
|
|
10
|
+
let opener = null;
|
|
11
|
+
|
|
12
|
+
const syncThemeColor = () => {
|
|
13
|
+
const meta = document.querySelector('meta[name="theme-color"]');
|
|
14
|
+
const background = getComputedStyle(document.documentElement).getPropertyValue("--bg").trim();
|
|
15
|
+
if (meta && background) meta.content = background;
|
|
16
|
+
};
|
|
17
|
+
const syncThemeInputs = () => {
|
|
18
|
+
const stored = THEMES.includes(app.LS.theme) ? app.LS.theme : "system";
|
|
19
|
+
for (const input of dialog.querySelectorAll('input[name="theme"]')) input.checked = input.value === stored;
|
|
20
|
+
};
|
|
21
|
+
const applyTheme = (value, persist) => {
|
|
22
|
+
const theme = THEMES.includes(value) ? value : "system";
|
|
23
|
+
document.documentElement.dataset.theme = theme;
|
|
24
|
+
if (persist) app.LS.theme = theme;
|
|
25
|
+
syncThemeInputs();
|
|
26
|
+
syncThemeColor();
|
|
27
|
+
};
|
|
28
|
+
app.setTheme = (value) => applyTheme(value, true);
|
|
29
|
+
app.settingsOpen = () => dialog.open;
|
|
30
|
+
|
|
31
|
+
const open = ({ token = false } = {}) => {
|
|
32
|
+
app.closePanels?.();
|
|
33
|
+
syncThemeInputs();
|
|
34
|
+
tokenInput.value = app.LS.token;
|
|
35
|
+
if (tokenHint) tokenHint.hidden = !token;
|
|
36
|
+
if (dialog.open) {
|
|
37
|
+
if (token) tokenInput.focus();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
opener = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
41
|
+
opener?.setAttribute("aria-expanded", "true");
|
|
42
|
+
dialog.showModal();
|
|
43
|
+
(token ? tokenInput : $("#localeSelectSettings"))?.focus();
|
|
44
|
+
};
|
|
45
|
+
app.openSettings = () => open();
|
|
46
|
+
app.openChatSettings = () => open({ token: true });
|
|
47
|
+
|
|
48
|
+
$("#btnSettings")?.addEventListener("click", () => app.openSettings());
|
|
49
|
+
$("#btnJoinSettings")?.addEventListener("click", () => app.openSettings());
|
|
50
|
+
const close = () => {
|
|
51
|
+
opener?.setAttribute("aria-expanded", "false");
|
|
52
|
+
dialog.close();
|
|
53
|
+
};
|
|
54
|
+
$("#btnCloseSettings")?.addEventListener("click", close);
|
|
55
|
+
dialog.addEventListener("click", (event) => { if (event.target === dialog) close(); });
|
|
56
|
+
dialog.addEventListener("cancel", () => opener?.setAttribute("aria-expanded", "false"));
|
|
57
|
+
dialog.addEventListener("change", (event) => {
|
|
58
|
+
if (event.target instanceof HTMLInputElement && event.target.name === "theme") app.setTheme(event.target.value);
|
|
59
|
+
});
|
|
60
|
+
dialog.addEventListener("close", () => {
|
|
61
|
+
const target = opener;
|
|
62
|
+
opener = null;
|
|
63
|
+
if (target?.isConnected) {
|
|
64
|
+
target.setAttribute("aria-expanded", "false");
|
|
65
|
+
target.focus({ preventScroll: true });
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
// The palette follows the system through its media query; only the browser chrome needs a nudge.
|
|
69
|
+
scheme.addEventListener("change", () => { if (app.LS.theme === "system") syncThemeColor(); });
|
|
70
|
+
|
|
71
|
+
applyTheme(app.LS.theme, false);
|
|
72
|
+
}
|