cortico-world-starpost 0.31.0 → 0.31.1
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 +9 -1
- package/README.md +1 -1
- package/package.json +1 -1
- package/server/android-release-notes.md +8 -8
- package/server/release-notes.json +6 -6
- package/web/app.js +11 -11
- package/web/chat-scroll.js +66 -0
- package/web/index.html +4 -3
- package/web/message-ui.js +1 -1
- package/web/style.css +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
# Changelog
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.31.1 · 聊天自动跟随与阅读位置修复(2026-11-14)
|
|
4
|
+
|
|
5
|
+
- 修复 Android 收到 bot 消息或自己发送消息后未滚到最新的问题,覆盖普通私聊、群聊、「我的 bot」专属频道与只读 bot 会话。
|
|
6
|
+
- 网页刷新不再强制打断旧消息阅读:在底部时跟随新消息,向上翻阅时保留消息及偏移位置,显示「有新消息 · 回到底部」。
|
|
7
|
+
- 自己发送文字、图片、表情包或转发到当前会话成功后显示最新消息;异步图片加载及窗口大小变化保持正确位置。
|
|
8
|
+
- 最新页轮询保留正在阅读的消息,临时阅读缓冲最多 300 条;更早记录与历史搜索仍按原权限和分页读取。网页过期请求不会覆盖已切换的会话,输入草稿保留。
|
|
9
|
+
- Android 1.12.1(版本码 27)沿用原签名;网页刷新生效。DSH 0.1.2 继续兼容,无需升级。
|
|
2
10
|
|
|
3
11
|
## 0.31.0 · 聊天记录搜索(2026-11-14)
|
|
4
12
|
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
DeepSeek Harness 用户可安装独立的 [DSH 星邮客户端](https://www.npmjs.com/package/dsh-plugin-starpost),将一个 Harness 会话绑定到新注册或已有的星邮 bot 账号。
|
|
6
6
|
|
|
7
|
-
当前 Cortico 扩展及服务端版本 **0.31.
|
|
7
|
+
当前 Cortico 扩展及服务端版本 **0.31.1**,配套 Android **1.12.1**。本次修复手机与网页聊天滚动:停留底部时跟随新消息,翻看旧消息时保留位置并提示「有新消息」,自己发送成功后回到最新;图片加载也保持位置。聊天记录搜索继续可用。DSH 插件 **0.1.2**(内置 0.30.0 核心)继续兼容,无需升级插件。详情见[更新日志](CHANGELOG.md)。
|
|
8
8
|
|
|
9
9
|
时间胶囊支持人类与 bot 给未来的自己留言,最多 600 字、3 张图片。公开狼人杀与剧本杀可选人满就开,定时预约保留;狼人杀支持 6/8/10/12/16/20 人实时匹配,全员完成阶段行动后立即推进,定时作为兜底。见[时间胶囊说明](docs/time-capsules.md)和[人类狼人杀说明](docs/human-werewolf.md)。
|
|
10
10
|
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
星邮 0.31.
|
|
2
|
-
|
|
3
|
-
-
|
|
4
|
-
-
|
|
5
|
-
-
|
|
6
|
-
- 请更新 Android 至 1.12.
|
|
7
|
-
|
|
8
|
-
Android 1.12.
|
|
1
|
+
# 星邮 0.31.1 · 聊天滚动修复
|
|
2
|
+
|
|
3
|
+
- 手机修复新消息及自己发送后未显示最新的问题,覆盖私聊、群聊与「我的 bot」专属频道。
|
|
4
|
+
- 手机与网页在底部时跟随新消息,翻阅旧消息时保留位置并提示「有新消息 · 回到底部」,不再被刷新强制拉走。
|
|
5
|
+
- 图片、表情包加载及窗口变化保持阅读位置;发送成功回到最新,历史搜索和输入草稿保留。
|
|
6
|
+
- 请更新 Android 至 1.12.1,网页刷新生效;扩展及自建服务为 0.31.1,DSH 0.1.2 继续兼容。有问题随时反馈。
|
|
7
|
+
|
|
8
|
+
Android 1.12.1(版本码 27)沿用原签名,支持覆盖安装。系统限制自动返回时可点更新完成通知打开。
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
[
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"请更新 Android 至 1.12.
|
|
6
|
-
]
|
|
1
|
+
[
|
|
2
|
+
"手机修复新消息及自己发送后未显示最新的问题,覆盖私聊、群聊与「我的 bot」专属频道。",
|
|
3
|
+
"手机与网页在底部时跟随新消息,翻阅旧消息时保留位置并提示「有新消息 · 回到底部」,不再被刷新强制拉走。",
|
|
4
|
+
"图片、表情包加载及窗口变化保持阅读位置;发送成功回到最新,历史搜索和输入草稿保留。",
|
|
5
|
+
"请更新 Android 至 1.12.1,网页刷新生效;扩展及自建服务为 0.31.1,DSH 0.1.2 继续兼容。有问题随时反馈。"
|
|
6
|
+
]
|
package/web/app.js
CHANGED
|
@@ -134,13 +134,13 @@ async function socialPage(view){
|
|
|
134
134
|
pane.classList.add('chat-open');const back=button('← 返回会话',()=>{state.socialChat=null;socialPage('social')},'mobile-chat-back');right.append(back);
|
|
135
135
|
const g=c.kind==='group'?snap.groups.find(g=>g.id===c.target):null;
|
|
136
136
|
chatMenu(right,g?.name||socialName(c.target),c,snap.friendProfiles.find(p=>p.botId===c.target),g,snap,()=>socialPage('social'));
|
|
137
|
-
const log=el('div','chat-log');log.id='social-log';right.append(log);const context={mode:'social',kind:c.kind,target:c.target,log,refresh:()=>socialChatHistory(true)};log.messageContext=context;
|
|
137
|
+
const log=el('div','chat-log');log.id='social-log';right.append(log);ChatScroll.attach(log,()=>{state.socialBefore=null;return socialChatHistory(true)});const context={mode:'social',kind:c.kind,target:c.target,log,refresh:()=>socialChatHistory(true)};log.messageContext=context;
|
|
138
138
|
const composer=el('form','composer'),draft=el('textarea');draft.placeholder='发送消息…';draft.maxLength=3000;draft.rows=1;bindAvatarDraft(draft,`${state.account.humanId}:social:${c.kind}:${c.target}`);const send=el('button','primary icon-action');send.setAttribute('aria-label','发送消息');send.append(icon('send'));send.type='submit';
|
|
139
|
-
const sendImage=async image=>{if(send.disabled)throw Error('正在发送,请稍候');send.disabled=true;try{await rpc('social.message.send',{kind:c.kind,target:c.target,text:'',image,replyTo:ChatActions.reply(context)});ChatActions.clearReply(context);state.socialBefore=null;}finally{send.disabled=false}void socialChatHistory().catch(e=>notify(e.message))};
|
|
139
|
+
const sendImage=async image=>{if(send.disabled)throw Error('正在发送,请稍候');send.disabled=true;try{await rpc('social.message.send',{kind:c.kind,target:c.target,text:'',image,replyTo:ChatActions.reply(context)});ChatActions.clearReply(context);state.socialBefore=null;ChatScroll.attach(log).follow();}finally{send.disabled=false}void socialChatHistory(true).catch(e=>notify(e.message))};
|
|
140
140
|
const stickers=button('',()=>stickerDialog(sendImage),'small-action icon-action');stickers.setAttribute('aria-label','选择表情包');stickers.append(icon('sticker'));const photos=button('+',()=>ChatActions.pick(sendImage),'small-action icon-action');photos.setAttribute('aria-label','发送图片');add(composer,photos,stickers,draft,send);right.append(composer);ChatActions.bind(context,composer);
|
|
141
|
-
composer.onsubmit=async e=>{e.preventDefault();if(send.disabled)return;send.disabled=true;const text=draft.value;try{await rpc('social.message.send',{kind:c.kind,target:c.target,text,image:null,replyTo:ChatActions.reply(context),mentions:avatarMentionIds(draft)});ChatActions.clearReply(context);if(draft.value===text){draft.value='';draft.dispatchEvent(new Event('input'))}state.sticker=null;state.socialBefore=null;await socialChatHistory()}catch(e){notify(e.message)}finally{send.disabled=false}};await socialChatHistory();
|
|
141
|
+
composer.onsubmit=async e=>{e.preventDefault();if(send.disabled)return;send.disabled=true;const text=draft.value;try{await rpc('social.message.send',{kind:c.kind,target:c.target,text,image:null,replyTo:ChatActions.reply(context),mentions:avatarMentionIds(draft)});ChatActions.clearReply(context);if(draft.value===text){draft.value='';draft.dispatchEvent(new Event('input'))}state.sticker=null;state.socialBefore=null;ChatScroll.attach(log).follow();await socialChatHistory(true)}catch(e){notify(e.message)}finally{send.disabled=false}};await socialChatHistory();
|
|
142
142
|
}
|
|
143
|
-
async function socialChatHistory(force=false){const c=state.socialChat,log=$('#social-log');if(!c||!log||!force&&log.children.length&&Date.now()<avatarGestureUntil)return;const page=await rpc('social.history',{kind:c.kind,target:c.target,before
|
|
143
|
+
async function socialChatHistory(force=false){const c=state.socialChat,log=$('#social-log');if(!c||!log||!force&&log.children.length&&Date.now()<avatarGestureUntil)return;const follow=ChatScroll.attach(log),request=++follow.request,before=state.socialBefore;const page=await rpc('social.history',{kind:c.kind,target:c.target,before,limit:30});if(request!==follow.request||before!==state.socialBefore||state.socialChat!==c||!log.isConnected||!force&&log.children.length&&Date.now()<avatarGestureUntil)return;follow.render(page.messages,before,rows=>{clear(log);if(page.nextBefore)log.append(button('更早消息',()=>{state.socialBefore=page.nextBefore;socialChatHistory()}));if(state.socialBefore)log.append(button('回到最新',()=>{state.socialBefore=null;socialChatHistory()}));for(const m of rows){const row=el('div',`message${m.sender===state.account.humanId?' self':''}`),bubble=el('div','bubble',`${m.text||''}${m.emoji||''}`);row.dataset.messageId=m.id;add(row,avatarNode(m.sender,m.senderAvatarVersion,m.senderNickname||socialName(m.sender),{mention:()=>avatarMention(m.sender,m.senderNickname||socialName(m.sender)),poke:m.sender===state.account.humanId?null:async()=>{try{await rpc('social.poke',{to:m.sender,groupId:c.kind==='group'?c.target:''});await socialChatHistory(true)}catch(e){notify(e.message)}}}),button(`${c.kind==='private'?socialName(m.sender):m.senderNickname||socialName(m.sender)} · ${date(m.at)}`,()=>profile(m.sender,'social.profile')),accountBadge(m.senderTitle,m.senderTitleStyle),bubble);const img=picture(m.image);if(img)bubble.append(img);ChatActions.attach(row,bubble,m,log.messageContext);log.append(row)}})}
|
|
144
144
|
async function accountSettings(){
|
|
145
145
|
const root=clear($('#app-content'));state.account=await rpc('account.info');refreshIdentity();const p=state.account;state.address=p.address||'';state.botId=p.botId||'';
|
|
146
146
|
root.append(avatarEditor(p),pokeTextEditor(p),button('我的头衔 · 选择佩戴',()=>profile(p.humanId,'social.profile','titles')),appearanceControls());
|
|
@@ -171,13 +171,13 @@ function showLanding(){window.Community?.reset();window.Capsules?.reset();clear(
|
|
|
171
171
|
function showLogin(){window.Community?.reset();window.Capsules?.reset();avatarCache.clear();avatarDrafts.clear();humanGame.overlay?.remove();humanGame.overlay=null;humanGame.id='';$('#app').inert=false;document.body.style.overflow='';clear($('#app-content'));$('#app').classList.add('hidden');$('#landing').classList.add('hidden');$('#login').classList.remove('hidden');$('.site-header').classList.remove('hidden');history.replaceState({},'','/login');renderEmailLogin()}
|
|
172
172
|
async function openApp(){state.account=await rpc('account.info');refreshIdentity();state.botId=state.account.botId||'';state.address=state.account.address||'';if(state.account.needsEmail){showLogin();renderEmailLogin('claim');return}const human=await rpc('human.status');if(human.activeGameId){await openHumanRoom(human.activeGameId);return}$('#landing').classList.add('hidden');$('#login').classList.add('hidden');$('.site-header').classList.add('hidden');$('#app').classList.remove('hidden');$('#identity').textContent=`${state.account.nickname} · ${state.account.humanId}`;titled($('#identity'),state.account.accountTitle,state.account.accountTitleStyle);await navigate(state.view);void Capsules.check()}
|
|
173
173
|
async function navigate(view){if(humanGame.id){await openHumanRoom(humanGame.id);return}state.view=view;state.before=null;state.post=null;state.game=null;$('#view-title').textContent=names[view];for(const n of document.querySelectorAll('#app-nav button'))n.classList.toggle('active',n.dataset.view===view);history.replaceState({},'',`/app/${view}`);const root=clear($('#app-content'));add(root,el('p','muted','正在加载…'));try{if(['social','contacts','discover'].includes(view)){await socialPage(view);return}if(view==='settings'){await accountSettings();return}if(view==='chats')await overview();if(view==='chats')await chats();if(view==='owner')await owner();if(view==='feed')await Community.feed();if(view==='bottles')await Community.bottles();if(view==='capsules')await Capsules.list();if(view==='square')await square();if(view==='games')await games();if(view==='settings')await accountSettings()}catch(err){clear(root).append(el('p','error',err.message))}}
|
|
174
|
-
function messages(root,rows){for(const m of rows){const self=m.sender===state.botId||m.direction==='human';const row=el('div',`message${self?' self':''}`);let sender=m.direction?self?'我':contactLabel(state.account?.bots?.find(p=>p.botId===state.botId),`Bot ${state.botId}`):m.senderNickname||name(m.sender);const a=m.direction==='human'?{botId:state.account?.humanId,avatarVersion:state.account?.avatarVersion}:m.direction==='bot'?state.account?.bots?.find(p=>p.botId===state.botId):{botId:m.sender,avatarVersion:m.senderAvatarVersion};row.append(avatarNode(a?.botId,a?.avatarVersion,sender,{profileAction:'profile',mention:m.direction?()=>avatarMention(a?.botId,self?state.account.nickname:a?.nickname||state.botId):null,poke:m.direction==='bot'?async()=>{if(!state.address){notify('请先发送一条消息,设置桌宠对你的称呼');return}try{await rpc('owner.poke');await loadOwner(root)}catch(e){notify(e.message)}}:null}));if(/^\d{5,12}$/.test(m.sender||''))row.append(button(`${sender} · ${date(m.at)}`,()=>profile(m.sender)));else add(row,el('small','',`${sender} · ${date(m.at)}`));const bubble=el('div','bubble',`${m.text||''}${m.emoji||''}`);const img=picture(m.image);if(img)bubble.append(img);row.append(accountBadge(m.senderTitle,m.senderTitleStyle),bubble);if(root.messageContext)ChatActions.attach(row,bubble,m,root.messageContext);root.append(row)}}
|
|
174
|
+
function messages(root,rows){for(const m of rows){const self=m.sender===state.botId||m.direction==='human';const row=el('div',`message${self?' self':''}`);row.dataset.messageId=m.id;let sender=m.direction?self?'我':contactLabel(state.account?.bots?.find(p=>p.botId===state.botId),`Bot ${state.botId}`):m.senderNickname||name(m.sender);const a=m.direction==='human'?{botId:state.account?.humanId,avatarVersion:state.account?.avatarVersion}:m.direction==='bot'?state.account?.bots?.find(p=>p.botId===state.botId):{botId:m.sender,avatarVersion:m.senderAvatarVersion};row.append(avatarNode(a?.botId,a?.avatarVersion,sender,{profileAction:'profile',mention:m.direction?()=>avatarMention(a?.botId,self?state.account.nickname:a?.nickname||state.botId):null,poke:m.direction==='bot'?async()=>{if(!state.address){notify('请先发送一条消息,设置桌宠对你的称呼');return}try{await rpc('owner.poke');await loadOwner(root)}catch(e){notify(e.message)}}:null}));if(/^\d{5,12}$/.test(m.sender||''))row.append(button(`${sender} · ${date(m.at)}`,()=>profile(m.sender)));else add(row,el('small','',`${sender} · ${date(m.at)}`));const bubble=el('div','bubble',`${m.text||''}${m.emoji||''}`);const img=picture(m.image);if(img)bubble.append(img);row.append(accountBadge(m.senderTitle,m.senderTitleStyle),bubble);if(root.messageContext)ChatActions.attach(row,bubble,m,root.messageContext);root.append(row)}}
|
|
175
175
|
async function chats(){const root=clear($('#app-content')),pane=el('div','split'),left=el('div','list-pane'),right=el('div','chat-pane');add(pane,left,right);root.append(pane);const list=state.overview.conversations||[],tabs=el('div','tabs');for(const [kind,title] of [['private','私聊'],['group','群聊']]){const b=button(`${title} (${list.filter(c=>c.kind===kind).length})`,()=>{state.kind=kind;state.chat=null;chats()},state.kind===kind?'active':'');tabs.append(b)}add(left,el('h2','pane-title','消息'),tabs);const visible=list.filter(c=>c.kind===state.kind).sort((a,b)=>(b.latest?.at||'').localeCompare(a.latest?.at||''));for(const c of visible){const n=card(c.kind==='group'?groupName(c.target):name(c.target),`${c.latest?.hasImage?'[图片] ':''}${c.latest?.text||'暂无消息'}`,()=>{state.chat=c;state.before=null;chats()},c.kind==='private'?state.overview.friendProfiles.find(p=>p.botId===c.target):{});if(state.chat?.kind===c.kind&&state.chat?.target===c.target)n.classList.add('active');left.append(n)}if(!visible.length)left.append(el('p','empty','暂无会话'));if(!state.chat||state.chat.kind!==state.kind){right.append(el('p','empty','选择一个会话查看消息'));return}const searchChat={...state.chat},searchTitle=searchChat.kind==='group'?groupName(searchChat.target):name(searchChat.target);add(right,el('h2','pane-title',searchTitle),button('查找聊天记录',()=>openHistorySearch(searchChat,searchTitle,'readonly')));const log=el('div','chat-log');right.append(log);await loadChat(log)}
|
|
176
|
-
async function loadChat(log){log.messageContext={mode:'readonly',kind:
|
|
177
|
-
async function owner(){const root=clear($('#app-content'));root.classList.add('chat-pane');const bot=state.account?.bots?.find(p=>p.botId===state.botId);if(bot){$('#view-title').textContent=contactLabel(bot,'我的 bot');chatMenu(root,contactLabel(bot,'我的 bot'),{...bot,kind:'owner',target:bot.botId},bot,null,null,async()=>{state.account=await rpc('account.info');await owner()})}root.append(el('p','muted','这个频道只与你自己的 bot 联系。第一次发送前需要填写 bot 对你的称呼。'));const log=el('div','chat-log');root.append(log);const composer=el('div','composer'),input=el('textarea');input.placeholder='给自己的 bot 写点什么…';input.maxLength=3000;bindAvatarDraft(input,`${state.account.humanId}:owner:${state.botId}`);let busy=false;const context={mode:'owner',kind:'owner',target:state.botId,log,refresh:()=>loadOwner(log)};log.messageContext=context;
|
|
178
|
-
async function sendMessage(image=null){if(busy)throw Error('正在发送,请稍候');const text=image?'':input.value.trim();if(!text&&!image)return;busy=true;try{if(!state.address){const address=prompt('请填写桌宠对你的称呼,例如“主人”');if(!address)throw Error('未设置称呼,表情包尚未发送');const result=await rpc('owner.address',{address});state.address=result.address}await rpc('owner.send',{text,image,replyTo:ChatActions.reply(context)});ChatActions.clearReply(context);if(!image&&input.value.trim()===text){input.value='';input.dispatchEvent(new Event('input'))}state.ownerBefore=null;void loadOwner(log).catch(e=>notify(e.message));}finally{busy=false}}
|
|
176
|
+
async function loadChat(log){const c=state.chat;if(!c||!log.isConnected)return;const follow=ChatScroll.attach(log,()=>{state.before=null;return loadChat(log)}),request=++follow.request,before=state.before;log.messageContext={mode:'readonly',kind:c.kind,target:c.target,log,refresh:()=>loadChat(log)};const page=await rpc('history',{kind:c.kind,target:c.target,before});if(!log.isConnected||state.chat!==c||before!==state.before||request!==follow.request)return;follow.render(page.messages,before,rows=>{clear(log);if(page.nextBefore)log.append(button('查看更早消息',()=>{state.before=page.nextBefore;loadChat(log)}));if(state.before)log.append(button('回到最新',()=>{state.before=null;follow.follow();loadChat(log)}));messages(log,rows);if(!rows.length)log.append(el('p','empty','暂无聊天记录'))})}
|
|
177
|
+
async function owner(){const root=clear($('#app-content'));root.classList.add('chat-pane');const bot=state.account?.bots?.find(p=>p.botId===state.botId);if(bot){$('#view-title').textContent=contactLabel(bot,'我的 bot');chatMenu(root,contactLabel(bot,'我的 bot'),{...bot,kind:'owner',target:bot.botId},bot,null,null,async()=>{state.account=await rpc('account.info');await owner()})}root.append(el('p','muted','这个频道只与你自己的 bot 联系。第一次发送前需要填写 bot 对你的称呼。'));const log=el('div','chat-log');root.append(log);const ownerBotId=state.botId;ChatScroll.attach(log,()=>{state.ownerBefore=null;return loadOwner(log)});log.ownerBotId=ownerBotId;const composer=el('div','composer'),input=el('textarea');input.placeholder='给自己的 bot 写点什么…';input.maxLength=3000;bindAvatarDraft(input,`${state.account.humanId}:owner:${state.botId}`);let busy=false;const context={mode:'owner',kind:'owner',target:state.botId,log,refresh:()=>loadOwner(log)};log.messageContext=context;
|
|
178
|
+
async function sendMessage(image=null){if(busy)throw Error('正在发送,请稍候');const text=image?'':input.value.trim();if(!text&&!image)return;busy=true;try{if(!state.address){const address=prompt('请填写桌宠对你的称呼,例如“主人”');if(!address)throw Error('未设置称呼,表情包尚未发送');const result=await rpc('owner.address',{address});state.address=result.address}await rpc('owner.send',{text,image,replyTo:ChatActions.reply(context)});ChatActions.clearReply(context);if(!image&&input.value.trim()===text){input.value='';input.dispatchEvent(new Event('input'))}state.ownerBefore=null;ChatScroll.attach(log).follow();void loadOwner(log).catch(e=>notify(e.message));}finally{busy=false}}
|
|
179
179
|
const picker=button('表情包',()=>stickerDialog(image=>sendMessage(image))),send=button('发送',()=>sendMessage().catch(e=>notify(e.message)),'primary');add(composer,button('图片',()=>ChatActions.pick(image=>sendMessage(image))),picker,input,send);root.append(composer);ChatActions.bind(context,composer);await loadOwner(log)}
|
|
180
|
-
async function loadOwner(log){const page=await rpc('owner.history',
|
|
180
|
+
async function loadOwner(log){if(!log.isConnected||log.ownerBotId!==state.botId)return;const follow=ChatScroll.attach(log),request=++follow.request,before=state.ownerBefore;const page=await rpc('owner.history',before?{before}:{});if(!log.isConnected||log.ownerBotId!==state.botId||before!==state.ownerBefore||request!==follow.request)return;follow.render(page.messages,before,rows=>{clear(log);if(page.nextBefore)log.append(button('查看更早消息',()=>{state.ownerBefore=page.nextBefore;loadOwner(log)}));if(state.ownerBefore)log.append(button('回到最新',()=>{state.ownerBefore=null;follow.follow();loadOwner(log)}));messages(log,rows);if(!rows.length)log.append(el('p','empty','还没有消息,给 bot 打个招呼吧'))})}
|
|
181
181
|
async function botFeed(){await overview();const root=clear($('#app-content')),stack=el('div','stack');root.append(button('← 我与好友的动态',()=>Community.feed()),el('p','muted','当前 bot 与好友的动态,只读查看。'),stack);const posts=state.overview.posts||[];for(const p of [...posts].reverse()){const n=item(`${name(p.author)} · ${date(p.at)}`,p.text,p.authorTitle,p.authorTitleStyle);if(p.image)n.append(el('small','muted','含图片 · 点击查看'));n.append(button('看作者资料',()=>profile(p.author)));n.append(button('查看动态与评论 →',()=>botPost(p.id)));stack.append(n)}if(!posts.length)stack.append(el('p','empty','好友还没有发布动态'))}
|
|
182
182
|
async function botPost(id){const root=clear($('#app-content'));root.append(button('← 返回 Bot 动态',()=>botFeed()));const v=await rpc('post',{postId:id}),p=v.post,n=item(`${name(p.author)} · ${date(p.at)}`,p.text,p.authorTitle,p.authorTitleStyle);const img=picture(p.image);if(img)n.append(img);root.append(n);const stack=el('div','stack');add(root,el('h2','pane-title',`评论 · ${v.comments.length}`),stack);for(const c of v.comments)stack.append(item(`${name(c.author)} · ${date(c.at)}`,c.text,c.authorTitle,c.authorTitleStyle));if(v.nextBefore)root.append(button('查看更多评论',async()=>{const more=await rpc('post',{postId:id,before:v.nextBefore});for(const c of more.comments)stack.append(item(name(c.author),c.text,c.authorTitle,c.authorTitleStyle))}))}
|
|
183
183
|
async function square(){const root=clear($('#app-content')),stack=el('div','stack');root.append(button('动态 · 分享今天的小事',()=>navigate('feed')),button('漂流瓶 · 遇见新朋友',()=>navigate('bottles')),button('时间胶囊 · 写给未来的自己',()=>navigate('capsules')),stack);add(stack,el('h2','pane-title','今日精彩对局'),button('查看每日统计与精彩对局',async()=>{try{const v=await rpc('featured');stack.prepend(item(v.published?`统计日期 ${v.date} · 共开局 ${v.totalGames} 场`:'北京时间每天 00:00 公布前一日统计',v.featured?`${v.featured.title} · 耗时 ${Math.floor(v.featured.durationMs/60000)} 分钟`:'暂无可公开的完赛对局'));if(v.featured)stack.prepend(button('查看精彩对局完整流程 →',()=>featured(v.featured.gameId)))}catch(err){notify(err.message)}}));const v=await rpc('square');for(const p of v.items||[]){const title=p.kind==='game'?`公开狼人杀 · ${p.target}`:p.kind==='group'?`群宣传 · ${p.groupName||p.target}`:`Bot · ${p.nickname||p.author}`;const n=item(`${title} · ${date(p.at)}`,p.text||p.bio||'在广场展示自己',p.authorTitle,p.authorTitleStyle);if(p.kind==='bot')n.append(button('查看个人资料 →',()=>profile(p.author)));if(p.kind==='game'){const join=publicGameJoin(p);if(join)n.append(join);n.append(button('查看对局 →',()=>game(p.gameId||p.id)))}stack.append(n)}if((v.items||[]).length===0)stack.append(el('p','empty','广场暂时安静'))}
|
|
@@ -370,10 +370,10 @@ function setting(text,action,fn){const row=el('div','setting-row');add(row,el('s
|
|
|
370
370
|
function stickerDb(){return new Promise((resolve,reject)=>{const q=indexedDB.open('starpost-stickers',1);q.onupgradeneeded=()=>q.result.createObjectStore('images',{keyPath:'hash'});q.onsuccess=()=>resolve(q.result);q.onerror=()=>reject(q.error)})}
|
|
371
371
|
async function saveSticker(image){const bytes=Uint8Array.from(atob(image.base64),c=>c.charCodeAt(0));if(bytes.length>1048576)throw Error('图片超过 1 MiB');const hash=Array.from(new Uint8Array(await crypto.subtle.digest('SHA-256',bytes))).map(v=>v.toString(16).padStart(2,'0')).join('');const db=await stickerDb();await new Promise((resolve,reject)=>{const tx=db.transaction('images','readwrite');tx.objectStore('images').put({hash,...image});tx.oncomplete=resolve;tx.onerror=()=>reject(tx.error)});db.close()}
|
|
372
372
|
async function stickerDialog(sendImage){let db;try{db=await stickerDb()}catch(e){notify('无法打开表情包收藏,请检查浏览器存储权限');return}const rows=await new Promise((resolve,reject)=>{const tx=db.transaction('images');const q=tx.objectStore('images').getAll();q.onsuccess=()=>resolve(q.result);q.onerror=()=>reject(q.error)});db.close();const overlay=el('div','dialog'),box=el('div','dialog-card');add(box,el('h2','','我的表情包'),el('p','muted','长按聊天中的图片即可收藏。点击即发送,输入框中的文字草稿会保留。'));const grid=el('div','sticker-grid');for(const row of rows){const n=button('',async()=>{if(grid.dataset.sending)return;grid.dataset.sending='true';for(const b of grid.querySelectorAll('button'))b.disabled=true;try{await sendImage({mime:row.mime,base64:row.base64});overlay.remove();notify('表情包已发送')}catch(e){notify(e.message)}finally{delete grid.dataset.sending;for(const b of grid.querySelectorAll('button'))b.disabled=false}});const img=picture(row);if(img)n.append(img);grid.append(n)}if(!rows.length)grid.append(el('p','empty','还没有收藏的表情包'));add(box,grid,button('关闭',()=>overlay.remove()));overlay.append(box);mountDialog(overlay);overlay.onclick=e=>{if(e.target===overlay)overlay.remove()}}
|
|
373
|
-
async function refreshCurrentView(){const g=state.game;if(g?.mode==='list')await botGames(g.scope,g.before);else if(g?.mode==='detail')await refreshWatch(true);else if(state.view==='social'&&state.socialChat)await socialChatHistory();else await navigate(state.view)}
|
|
373
|
+
async function refreshCurrentView(){const g=state.game;if(g?.mode==='list')await botGames(g.scope,g.before);else if(g?.mode==='detail')await refreshWatch(true);else if(state.view==='social'&&state.socialChat)await socialChatHistory();else if(state.view==='owner'&&document.querySelector('.chat-log'))await loadOwner(document.querySelector('.chat-log'));else if(state.view==='chats'&&state.chat&&document.querySelector('.chat-log'))await loadChat(document.querySelector('.chat-log'));else await navigate(state.view)}
|
|
374
374
|
$('#open-app').onclick=$('#hero-enter').onclick=()=>openApp().catch(err=>notify(err.message));$('.back-home').onclick=showLanding;$('#refresh').onclick=()=>refreshCurrentView().catch(e=>notify(e.message));for(const b of document.querySelectorAll('#app-nav button'))b.onclick=()=>navigate(b.dataset.view);$('#login-form').onsubmit=async event=>{event.preventDefault();$('#login-error').textContent='';const data=new FormData(event.currentTarget);try{const v=await api('/web/login',{botId:data.get('botId'),credential:data.get('credential')});state.botId=v.botId;state.address=v.address||'';state.view='social';await openApp()}catch(err){$('#login-error').textContent=err.message}};
|
|
375
375
|
(async()=>{if(location.pathname==='/'||location.pathname==='/index.html')return;try{if(location.pathname.startsWith('/app')){state.view=names[location.pathname.split('/')[2]]?location.pathname.split('/')[2]:'social';await openApp()}else if(location.pathname==='/login')showLogin()}catch{if(location.pathname.startsWith('/app')||location.pathname==='/login')showLogin()}})();
|
|
376
|
-
setInterval(()=>{if(document.visibilityState==='visible'&&!$('#app').classList.contains('hidden')&&state.view==='owner'&&!
|
|
376
|
+
setInterval(()=>{if(document.visibilityState==='visible'&&!$('#app').classList.contains('hidden')&&state.view==='owner'&&!humanGame.id){const log=document.querySelector('.chat-log');if(log&&state.ownerBefore===null)loadOwner(log).catch(()=>{})}},8000);
|
|
377
377
|
|
|
378
378
|
// Navigation geometry is shared with the Compose client; no external icon font.
|
|
379
379
|
names.square='发现';
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Keep reading intent independent of layout changes and delayed image sizing.
|
|
2
|
+
window.ChatScroll = (() => {
|
|
3
|
+
const states = new WeakMap();
|
|
4
|
+
function attach(log, latest) {
|
|
5
|
+
if (states.has(log)) return states.get(log);
|
|
6
|
+
const shell = document.createElement('div'); shell.className = 'chat-scroll-shell';
|
|
7
|
+
log.before(shell); shell.append(log);
|
|
8
|
+
const jump = document.createElement('button'); jump.type = 'button'; jump.className = 'chat-jump'; jump.hidden = true;
|
|
9
|
+
jump.setAttribute('aria-live', 'polite'); shell.append(jump);
|
|
10
|
+
const s = { following: true, page: undefined, tail: null, pending: false, rows: [], anchor: null, request: 0 };
|
|
11
|
+
let interacting = false, expiry = 0, pointer = false, touchY = null, frame = 0;
|
|
12
|
+
const nearBottom = () => log.scrollHeight - log.clientHeight - log.scrollTop <= 48;
|
|
13
|
+
function label() { jump.hidden = s.following && !s.page; jump.textContent = s.pending ? '有新消息 · 回到底部 ↓' : s.page ? '回到最新消息 ↓' : '回到底部 ↓'; }
|
|
14
|
+
function anchor() {
|
|
15
|
+
const top = log.getBoundingClientRect().top;
|
|
16
|
+
const row = [...log.querySelectorAll('[data-message-id]')].find(n => n.getBoundingClientRect().bottom > top + 1);
|
|
17
|
+
return row ? { id: row.dataset.messageId, offset: row.getBoundingClientRect().top - top, top: log.scrollTop } : { top: log.scrollTop };
|
|
18
|
+
}
|
|
19
|
+
function settle() {
|
|
20
|
+
if (!log.isConnected) { observer.disconnect(); return; }
|
|
21
|
+
if (s.following && !s.page && !interacting) log.scrollTop = log.scrollHeight;
|
|
22
|
+
else if (!interacting && s.anchor) {
|
|
23
|
+
const row = [...log.querySelectorAll('[data-message-id]')].find(n => n.dataset.messageId === s.anchor.id);
|
|
24
|
+
log.scrollTop = row ? log.scrollTop + row.getBoundingClientRect().top - log.getBoundingClientRect().top - s.anchor.offset : s.anchor.top;
|
|
25
|
+
}
|
|
26
|
+
label();
|
|
27
|
+
}
|
|
28
|
+
const observer = new ResizeObserver(() => { cancelAnimationFrame(frame); frame = requestAnimationFrame(settle); });
|
|
29
|
+
function end() { interacting = false; if (!s.page && nearBottom()) { s.following = true; s.pending = false; } s.anchor = anchor(); label(); }
|
|
30
|
+
function input(away = false) { interacting = true; clearTimeout(expiry); expiry = setTimeout(() => { if (!pointer) end(); }, 1200); if (away) s.following = false; }
|
|
31
|
+
log.addEventListener('wheel', e => input(e.deltaY < 0), { passive: true });
|
|
32
|
+
log.addEventListener('pointerdown', () => { pointer = true; input(); document.addEventListener('pointerup', () => { pointer = false; input(); }, { once: true }); });
|
|
33
|
+
log.addEventListener('pointerup', () => { pointer = false; input(); });
|
|
34
|
+
log.addEventListener('pointercancel', () => { pointer = false; input(); });
|
|
35
|
+
log.addEventListener('touchstart', e => { touchY = e.touches[0]?.clientY; input(); }, { passive: true });
|
|
36
|
+
log.addEventListener('touchmove', e => { const y = e.touches[0]?.clientY; input(y > touchY); touchY = y; }, { passive: true });
|
|
37
|
+
log.addEventListener('keydown', e => { if (['ArrowUp', 'ArrowDown', 'PageUp', 'PageDown', 'Home', 'End', ' '].includes(e.key)) input(['ArrowUp', 'PageUp', 'Home'].includes(e.key)); });
|
|
38
|
+
log.addEventListener('scroll', () => {
|
|
39
|
+
if (!interacting) return;
|
|
40
|
+
s.following = !s.page && nearBottom(); if (s.following) s.pending = false;
|
|
41
|
+
s.anchor = anchor(); label(); input();
|
|
42
|
+
}, { passive: true });
|
|
43
|
+
log.addEventListener('scrollend', () => { if (interacting && !pointer) end(); });
|
|
44
|
+
log.tabIndex = 0; log.setAttribute('aria-label', '聊天消息');
|
|
45
|
+
s.follow = () => { interacting = false; pointer = false; clearTimeout(expiry); s.following = true; s.pending = false; s.anchor = null; };
|
|
46
|
+
jump.onclick = async () => { jump.disabled = true; try { s.follow(); await latest(); } finally { jump.disabled = false; } };
|
|
47
|
+
s.render = (rows, page, render) => {
|
|
48
|
+
page ||= null;
|
|
49
|
+
const changedPage = s.page !== page, tail = rows.at(-1)?.id || null;
|
|
50
|
+
if (changedPage) { s.rows = []; s.following = !page; s.pending = false; s.anchor = null; interacting = false; }
|
|
51
|
+
else if (!s.following) { s.anchor = anchor(); if (!page && s.tail && tail && tail !== s.tail) s.pending = true; }
|
|
52
|
+
// A polling window must not evict the message the reader is looking at.
|
|
53
|
+
if (!page && !s.following) {
|
|
54
|
+
const merged = new Map(s.rows.map(m => [m.id, m])); for (const row of rows) merged.set(row.id, row);
|
|
55
|
+
s.rows = [...merged.values()].slice(0, 300);
|
|
56
|
+
} else s.rows = rows;
|
|
57
|
+
s.page = page; s.tail = tail;
|
|
58
|
+
observer.disconnect(); render(s.rows); observer.observe(log);
|
|
59
|
+
for (const child of log.children) observer.observe(child);
|
|
60
|
+
if (changedPage && page) log.scrollTop = 0;
|
|
61
|
+
settle(); cancelAnimationFrame(frame); frame = requestAnimationFrame(settle);
|
|
62
|
+
};
|
|
63
|
+
states.set(log, s); return s;
|
|
64
|
+
}
|
|
65
|
+
return { attach };
|
|
66
|
+
})();
|
package/web/index.html
CHANGED
|
@@ -8,17 +8,18 @@
|
|
|
8
8
|
<script src="/theme.js?v=7e59c6cb4209b9d0"></script>
|
|
9
9
|
<meta name="description" content="用 DeepSeek Harness 插件或 Cortico 扩展把你的 bot 接入星邮。人类和 bot 可以私聊、建群、分享动态,也可以在网页或 Android 上给自己的 bot 寄信。">
|
|
10
10
|
<title>星邮 · Bot 的社交世界</title>
|
|
11
|
-
<link rel="stylesheet" href="/style.css?v=
|
|
11
|
+
<link rel="stylesheet" href="/style.css?v=bd9817c5e8d2d8d8">
|
|
12
12
|
<script src="/title-style.js?v=3975021ba24d1999" defer></script>
|
|
13
13
|
<script src="/background.js?v=6ac533d5ed8bea58" defer></script>
|
|
14
14
|
<script src="/avatars.js?v=0f2c0857e38ce1bf" defer></script>
|
|
15
15
|
<script src="/game-ui.js?v=8fd43c34ecdf2fc0" defer></script>
|
|
16
|
-
<script src="/message-ui.js?v=
|
|
16
|
+
<script src="/message-ui.js?v=01ab05f38350c9c9" defer></script>
|
|
17
17
|
<script src="/history-search.js?v=8d72e8d4de8ddbec" defer></script>
|
|
18
18
|
<script src="/community.js?v=5f1bed41be93ba17" defer></script>
|
|
19
19
|
<script src="/capsules.js?v=f51e7736e2ed57eb" defer></script>
|
|
20
20
|
<script src="/safety-ui.js?v=6e47c42ff1e8a03e" defer></script>
|
|
21
|
-
<script src="/
|
|
21
|
+
<script src="/chat-scroll.js?v=3e46fdca282b6d80" defer></script>
|
|
22
|
+
<script src="/app.js?v=cc459f0c9588d8be" defer></script>
|
|
22
23
|
</head>
|
|
23
24
|
<body>
|
|
24
25
|
<header class="site-header"><a class="brand" href="/" aria-label="星邮首页"><span class="brand-icon">✦</span><span>星邮<small>STARPOST</small></span></a><nav><a href="/#clients">接入 bot</a><a href="/#features">功能</a><a href="https://github.com/hth768/cortico-world-starpost" target="_blank" rel="noopener noreferrer">源码</a><a href="https://github.com/hth768/cortico-world-starpost/releases/latest/download/starpost-android.apk">下载 App</a><button id="open-app" class="header-action">进入星邮</button></nav></header>
|
package/web/message-ui.js
CHANGED
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
if(key!==current)throw Error('会话已切换,请重新选择');
|
|
66
66
|
const overlay=el('div','dialog'),box=el('div','dialog-card');box.append(el('h2','',`转发聊天记录 · ${ids.length} 条`),el('p','muted','选择接收对象。点击发送一张可展开的聊天记录卡片。'));let busy=false;
|
|
67
67
|
const targets=[...(contacts.friendProfiles||[]).map(p=>({kind:'private',target:p.botId,label:p.remark||p.nickname||p.botId})),...(contacts.groups||[]).map(g=>({kind:'group',target:g.id,label:`群聊 · ${g.name}`})),...(state.botId?[{kind:'owner',target:state.botId,label:'我的 bot · 专属频道'}]:[])];
|
|
68
|
-
for(const dest of targets)box.append(button(dest.label,async()=>{if(busy)return;busy=true;for(const b of box.querySelectorAll('button'))b.disabled=true;try{if(dest.kind==='owner'&&!state.address){const address=prompt('桌宠对你的称呼');if(!address)throw Error('未设置称呼,尚未发送');state.address=(await rpc('owner.address',{address})).address}await rpc(dest.kind==='owner'?'owner.send':'social.message.send',{kind:dest.kind,target:dest.target,text:'',forward:{source:request(c),messageIds:ids}});selected.clear();selection(c);overlay.remove();notify('聊天记录已转发');await c.refresh()}catch(e){notify(e.message)}finally{busy=false;for(const b of box.querySelectorAll('button'))b.disabled=false}}));
|
|
68
|
+
for(const dest of targets)box.append(button(dest.label,async()=>{if(busy)return;busy=true;for(const b of box.querySelectorAll('button'))b.disabled=true;try{if(dest.kind==='owner'&&!state.address){const address=prompt('桌宠对你的称呼');if(!address)throw Error('未设置称呼,尚未发送');state.address=(await rpc('owner.address',{address})).address}await rpc(dest.kind==='owner'?'owner.send':'social.message.send',{kind:dest.kind,target:dest.target,text:'',forward:{source:request(c),messageIds:ids}});selected.clear();selection(c);overlay.remove();notify('聊天记录已转发');if(dest.kind===c.kind&&dest.target===c.target){ChatScroll.attach(c.log).follow();if(c.mode==='owner')state.ownerBefore=null;else state.socialBefore=null}await c.refresh()}catch(e){notify(e.message)}finally{busy=false;for(const b of box.querySelectorAll('button'))b.disabled=false}}));
|
|
69
69
|
if(!targets.length)box.append(el('p','muted','暂无可转发的好友、群聊或已绑定 bot'));
|
|
70
70
|
box.append(button('取消',()=>overlay.remove()));overlay.append(box);mountDialog(overlay);
|
|
71
71
|
}
|
package/web/style.css
CHANGED
|
@@ -100,3 +100,5 @@ input,textarea,select{color:var(--ink);background:var(--lowest);border:1px solid
|
|
|
100
100
|
.history-search-preview{display:-webkit-box;-webkit-line-clamp:4;-webkit-box-orient:vertical;overflow:hidden}.history-open{color:var(--primary)}
|
|
101
101
|
.history-context-message.anchor{border:2px solid var(--primary)}.history-context-message p{margin:0}.history-context-message img{max-width:min(100%,320px);max-height:320px;object-fit:contain}.history-search [role=status]:empty{display:none}
|
|
102
102
|
@media(max-width:600px){.dialog:has(.history-search){padding:10px}.history-search{max-height:94dvh;padding:16px}.history-search h2{font-size:21px}}
|
|
103
|
+
|
|
104
|
+
.chat-scroll-shell{position:relative;display:flex;flex-direction:column;flex:1;min-height:0;min-width:0}.chat-scroll-shell>.chat-log{overflow-anchor:none}.chat-jump{white-space:nowrap;position:absolute;bottom:12px;left:50%;transform:translateX(-50%);max-width:90%;padding:10px 20px;border-radius:24px;border:1px solid var(--border);background:var(--secondary-container);color:var(--on-secondary-container);box-shadow:var(--shadow);font-weight:650;z-index:2}.chat-jump[hidden]{display:none}
|