Skip to content

知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.

feat(linux): Share… copies the link and password together as one message in the app's language

wquguru46e82e203398
diff --git a/linux/README.md b/linux/README.md
index 64ec8b5..1193f5f 100644
--- a/linux/README.md
+++ b/linux/README.md
@@ -55,7 +55,7 @@ linux/vm/vmctl.sh shot shot.png # 截屏(QEMU,不受 Wayland
linux/scripts/build.sh && linux/vm/push.sh # 把 build/cicada-linux 和测试工具放进虚拟机的 ~/cicada-linux
```
-在虚拟机里 `~/cicada-linux/bin/cicada --dev` 启动开发版(记录在 `~/.local/share/cicada-dev`,日志在 `~/.local/state/cicada-dev/debug.log`),再用 `scripts/cicadactl` 驱动它:`state`、`start`、`stop`、`feed <wav>`、`sample`、`view notes|subtitles`、`show records|notes|settings|onboarding`、`windows`、`quit`;结束会议用 `calls zoom=Zoom|none|real`(假装会议软件在通话)、`realcalls`、`endtimes <没人说话秒数> <倒计时> <挂断宽限>|off`、`endkeep`;纪要窗用 `notes-tab notes|transcript`、`notes-search <词>`、`notes-wide on|off`、`notes-end ask|keep|end`(结束前的确认)、`notes-status failed|invalidKey|rateLimited|idle`(看出错横幅);记录用 `rename <id> [标题]`(不给标题即恢复自动标题)、`delete <id>`;还有 `onboarding-step <0-4>`、`settings-scroll <0-1>`;AI 服务检查用 `ai-check`(现在查一次)、`ai-check-sim <原因|lowBalance|off>`(每次检查都按这个原因结束,截各状态的图)、`ask settings|fix|close`(回答开始听时的对话框)、`settings-ai`、`tray-menu`(顶栏菜单的各项);只有你能修的问题(key、余额、模型、地址)在顶栏图标上加橙点,纪要窗收起时每场会议发一次通知(连不上的话持续 2 分钟后才发),`hide notes` 收起纪要窗、`problem-wait <秒>|off` 缩短这 2 分钟、`state` 的 `aiProblem` 看结果。保存会议录音用 `codecs`(这台电脑有没有 AAC 编码器 / 解码器)、`play [秒]`、`pause`、`rate`、`playstate`(播放到哪、亮着哪一句)、`settings-general`;Ubuntu 默认没有 AAC 编码器,测录音要先在虚拟机里 `sudo apt install gstreamer1.0-libav`,测完再删掉,看默认的灰开关。改正听错的词:`start` 后用 `heard <一句话>`(不用声音,当作听到的一整句,走真实的翻译 + 改词请求),`fix-state` 看每句的改法,`fix-answer yes|no`、`fix-later`、`fix-revert <句子 id>`、`fix-edit <句子 id>=<改后>[|one][|keep0]`、`fix-undo`,`fix-editor <句子 id>=<改后>` 在会议记录里打开“改这句…”,`vocab-add Morpho=莫拉`、`vocab-state`、`word-list [import <文字>|edit <词>|heard <词>=<听成>|delete <词>]` 看设置里的词表。分享成链接(`cicada/core/share.py`,设备密钥是纯 Python 的 Ed25519,`cicada/core/ed25519.py`):`share <id>[,full][,pw]`、`unshare <id>`、`share-last`、`shareSheet <id>` 打开“分享…”,`share-ui scope|days|names|pw|summary|go|strip|back|confirm|revoke|close|state` 操作它;虚拟机连不上 cicada.indaloop.app 时用 `https_proxy=http://10.0.2.2:7890` 启动。`scripts/smoke.sh` 一步跑完:开窗口、放一段声音、确认 monitor 听到了。
+在虚拟机里 `~/cicada-linux/bin/cicada --dev` 启动开发版(记录在 `~/.local/share/cicada-dev`,日志在 `~/.local/state/cicada-dev/debug.log`),再用 `scripts/cicadactl` 驱动它:`state`、`start`、`stop`、`feed <wav>`、`sample`、`view notes|subtitles`、`show records|notes|settings|onboarding`、`windows`、`quit`;结束会议用 `calls zoom=Zoom|none|real`(假装会议软件在通话)、`realcalls`、`endtimes <没人说话秒数> <倒计时> <挂断宽限>|off`、`endkeep`;纪要窗用 `notes-tab notes|transcript`、`notes-search <词>`、`notes-wide on|off`、`notes-end ask|keep|end`(结束前的确认)、`notes-status failed|invalidKey|rateLimited|idle`(看出错横幅);记录用 `rename <id> [标题]`(不给标题即恢复自动标题)、`delete <id>`;还有 `onboarding-step <0-4>`、`settings-scroll <0-1>`;AI 服务检查用 `ai-check`(现在查一次)、`ai-check-sim <原因|lowBalance|off>`(每次检查都按这个原因结束,截各状态的图)、`ask settings|fix|close`(回答开始听时的对话框)、`settings-ai`、`tray-menu`(顶栏菜单的各项);只有你能修的问题(key、余额、模型、地址)在顶栏图标上加橙点,纪要窗收起时每场会议发一次通知(连不上的话持续 2 分钟后才发),`hide notes` 收起纪要窗、`problem-wait <秒>|off` 缩短这 2 分钟、`state` 的 `aiProblem` 看结果。保存会议录音用 `codecs`(这台电脑有没有 AAC 编码器 / 解码器)、`play [秒]`、`pause`、`rate`、`playstate`(播放到哪、亮着哪一句)、`settings-general`;Ubuntu 默认没有 AAC 编码器,测录音要先在虚拟机里 `sudo apt install gstreamer1.0-libav`,测完再删掉,看默认的灰开关。改正听错的词:`start` 后用 `heard <一句话>`(不用声音,当作听到的一整句,走真实的翻译 + 改词请求),`fix-state` 看每句的改法,`fix-answer yes|no`、`fix-later`、`fix-revert <句子 id>`、`fix-edit <句子 id>=<改后>[|one][|keep0]`、`fix-undo`,`fix-editor <句子 id>=<改后>` 在会议记录里打开“改这句…”,`vocab-add Morpho=莫拉`、`vocab-state`、`word-list [import <文字>|edit <词>|heard <词>=<听成>|delete <词>]` 看设置里的词表。分享成链接(`cicada/core/share.py`,设备密钥是纯 Python 的 Ed25519,`cicada/core/ed25519.py`):`share <id>[,full][,pw]`、`unshare <id>`、`share-last`、`shareSheet <id>` 打开“分享…”,`share-ui scope|days|names|pw|summary|options|go|strip|back|confirm|copy all|link|password|revoke|close|state` 操作它(`options` 即“更改”,`state` 的 `clipboard` 是剪贴板里的那条消息);虚拟机连不上 cicada.indaloop.app 时用 `https_proxy=http://10.0.2.2:7890` 启动。`scripts/smoke.sh` 一步跑完:开窗口、放一段声音、确认 monitor 听到了。
焦点:`bin/focus_test.sh` 开一个最大化的“会议 app”(`focus_probe.py`),用 `click.py`(uinput,真实指针)点纪要窗和“字幕”链接,再在 Mac 上 `linux/vm/vmctl.sh type ok`;`/tmp/focus-probe.log` 里不能出现 `active=False`,最后一行应是 `text=…ok`。xdotool 只到 XWayland,测不了这个。
diff --git a/linux/cicada/app/debug.py b/linux/cicada/app/debug.py
index 9acd7f2..781e7c0 100644
--- a/linux/cicada/app/debug.py
+++ b/linux/cicada/app/debug.py
@@ -20,7 +20,8 @@ per connection, one JSON line back. Never in release builds.
codecs (AAC encoder / decoders here) | play [<seconds>] | pause | rate (next speed) | playstate (the shown record's
recording: state, time, length, rate, the highlighted line) | settings-general (设置 at 通用)
share <record id>[,full][,pw] | unshare <record id> | share-last (how the last ended) | shareSheet <record id>|""
- share-ui scope notes|full | days 7|30|365 | names|pw|summary on|off | go | strip | back | confirm | revoke | close | state"""
+ share-ui scope notes|full | days 7|30|365 | names|pw|summary on|off | options (更改) | go | strip | back | confirm
+ | copy all|link|password | revoke | close | state"""
from __future__ import annotations
import os
@@ -474,7 +475,8 @@ def _share(app, cmd: str, arg: str) -> dict:
w.selected = arg
w.fill()
return {"ok": True, **share_dialog.open_for(app, s, w).state()}
- # share-ui scope notes|full | days 7|30|365 | names|pw|summary on|off | go | strip | back | confirm | revoke | close | state
+ # share-ui scope notes|full | days 7|30|365 | names|pw|summary on|off | options | go | strip | back | confirm
+ # | copy all|link|password | revoke | close | state
d = app.share_dialog
if d is None:
return {"ok": False, "error": "no share dialog"}
@@ -493,12 +495,17 @@ def _share(app, cmd: str, arg: str) -> dict:
d.step = "settings"
elif act == "confirm":
d.confirm = True
+ elif act == "options":
+ d.show_options = True
+ elif act == "copy" and d.record is not None:
+ r = d.record
+ d._copy({"link": r.url, "password": r.password or ""}.get(val) or d._message(r), val or "all")
elif act == "revoke":
d.revoke()
elif act == "close":
d.close()
return {"ok": True}
- if act in ("scope", "days", "names", "pw", "summary", "back", "confirm"):
+ if act in ("scope", "days", "names", "pw", "summary", "back", "confirm", "options", "copy"):
d.render()
return {"ok": True, **d.state()}
diff --git a/linux/cicada/app/share_dialog.py b/linux/cicada/app/share_dialog.py
index 503b5d7..af5cdbb 100644
--- a/linux/cicada/app/share_dialog.py
+++ b/linux/cicada/app/share_dialog.py
@@ -47,6 +47,7 @@ class ShareDialog:
self.views = None
self.confirm = False
self.copied = None
+ self.show_options = False
self.hits, self.kept, self.record, self.message = [], [], None, ""
self.busy = False
@@ -115,20 +116,36 @@ class ShareDialog:
content.pack_start(seg, False, False, 0)
self.body.pack_start(content, False, False, 0)
- days = Gtk.ComboBoxText()
- for n, label in zip(share.DAYS, (L("7 天"), L("30 天"), L("1 年"))):
- days.append(str(n), label)
- days.set_active_id(str(self.days))
- days.connect("changed", lambda c: setattr(self, "days", int(c.get_active_id())))
- self.body.pack_start(self._row(L("有效期"), days), False, False, 0)
- self.body.pack_start(self._row(L("显示说话人名字"), self._switch(self.names, lambda v: setattr(self, "names", v))),
- False, False, 0)
+ go = ui.button(L("生成并复制"), self.go, "darkbtn")
+ if self.show_options:
+ self._options(go)
+ else:
+ # The choices already made, in one line; 更改 opens them in place.
+ line = ui.hbox(8)
+ line.pack_start(ui.text(share.summary(self.use_password, self.days, self.names), 13, "secondary", wrap=False),
+ True, True, 0)
+
+ def change():
+ self.show_options = True
+ self.render()
+ more = ui.button(L("更改"), change, "outline")
+ more.set_valign(Gtk.Align.CENTER)
+ line.pack_end(more, False, False, 0)
+ self.body.pack_start(line, False, False, 0)
+ if not self.use_password:
+ self.body.pack_start(ui.text(L("内容将上传至 cicada.indaloop.app,拿到链接的人都能看。"), 12, "tertiary",
+ width_chars=46), False, False, 0)
+ go.set_sensitive(not self.use_password or len(self.password) >= 6)
+ self.body.pack_start(self._buttons(ui.button(L("取消"), self.close, "outline"), go), False, False, 0)
+ go.set_can_default(True)
+ self.window.set_default(go)
+ def _options(self, go) -> None:
+ """Password, expiry, names and the preview's summary, as the Mac lists them once 更改 is pressed."""
def password(v):
self.use_password = v
self.render()
self.body.pack_start(self._row(L("用密码保护"), self._switch(self.use_password, password)), False, False, 0)
- go = ui.button(L("生成链接"), self.go, "darkbtn")
if self.use_password:
entry = Gtk.Entry()
entry.set_text(self.password)
@@ -145,16 +162,17 @@ class ShareDialog:
row.pack_start(entry, True, True, 0)
row.pack_start(ui.button(L("换一个"), again, "outline"), False, False, 0)
self.body.pack_start(row, False, False, 0)
- go.set_sensitive(len(self.password) >= 6)
- elif self.has_notes:
+ days = Gtk.ComboBoxText()
+ for n, label in zip(share.DAYS, (L("7 天"), L("30 天"), L("1 年"))):
+ days.append(str(n), label)
+ days.set_active_id(str(self.days))
+ days.connect("changed", lambda c: setattr(self, "days", int(c.get_active_id())))
+ self.body.pack_start(self._row(L("有效期"), days), False, False, 0)
+ self.body.pack_start(self._row(L("显示说话人名字"), self._switch(self.names, lambda v: setattr(self, "names", v))),
+ False, False, 0)
+ if not self.use_password and self.has_notes:
self.body.pack_start(self._row(L("预览卡显示摘要"), self._switch(self.summary, lambda v: setattr(self, "summary", v))),
False, False, 0)
- self.body.pack_start(ui.text(L("建议把链接和密码分两条消息发送。") if self.use_password
- else L("内容将上传至 cicada.indaloop.app,拿到链接的人都能看。"), 12, "tertiary", width_chars=46),
- False, False, 0)
- self.body.pack_start(self._buttons(ui.button(L("取消"), self.close, "outline"), go), False, False, 0)
- go.set_can_default(True)
- self.window.set_default(go)
def options(self) -> share.Options:
return share.Options(scope=self.scope, days=self.days, names=self.names,
@@ -181,7 +199,7 @@ class ShareDialog:
return
if out.kind == "shared":
self.record, self.views, self.confirm = out.record, 0, False
- self._copy(out.record.url, "link")
+ self._copy(self._message(out.record), "all")
self.step = "done"
elif out.kind == "blocked":
self.hits, self.kept, self.step = out.hits, out.kept, "blocked"
@@ -259,22 +277,48 @@ class ShareDialog:
# Done
- def _field(self, value: str, copy_label: str, what: str) -> Gtk.Widget:
- l = ui.text(value, 12, "ink", wrap=False, selectable=True)
- ui.classes(l, "mono")
- l.set_ellipsize(Pango.EllipsizeMode.MIDDLE)
- row = ui.hbox(8)
- row.pack_start(ui.panel(ui.pad(l, 6, 8), "sharefield"), True, True, 0)
- row.pack_start(ui.button(L("已复制") if self.copied == what else copy_label,
- lambda: (self._copy(value, what), self.render()), "outline"), False, False, 0)
- return row
+ def _message(self, r) -> str:
+ return share.clipboard_text(r, session_store.display_title(self.s))
+
+ def _copy_control(self, r) -> Gtk.Widget:
+ """复制 puts the link and the password on the clipboard as one message; with a password, its
+ arrow copies either alone, for whoever sends them apart."""
+ def copy(text, what):
+ self._copy(text, what)
+ self.render()
+ main = ui.button(L("复制") if self.copied is None else L("已复制"), lambda: copy(self._message(r), "all"), "outline")
+ main.set_valign(Gtk.Align.CENTER)
+ if not r.password:
+ return main
+ menu = Gtk.Menu()
+ for label, text, what in ((L("只复制链接"), r.url, "link"), (L("只复制密码"), r.password, "password")):
+ item = Gtk.MenuItem(label=label)
+ item.connect("activate", lambda _i, t=text, w=what: GLib.idle_add(lambda: copy(t, w) and False))
+ menu.append(item)
+ menu.show_all()
+ arrow = Gtk.MenuButton()
+ arrow.set_popup(menu)
+ arrow.add(ui.icon("pan-down-symbolic", 12))
+ ui.classes(arrow, "outline", "arrow")
+ box = ui.hbox(0, main, arrow)
+ ui.classes(box, "linked", "copybtn")
+ box.set_valign(Gtk.Align.CENTER)
+ return box
def _done(self) -> None:
r = self.record
- self._header(L("链接已复制") if self.copied == "link" else L("已分享"))
- self.body.pack_start(self._field(r.url, L("复制链接"), "link"), False, False, 0)
+ self._header((L("链接和密码已复制") if r.password else L("链接已复制")) if self.copied == "all" else L("已分享"))
+ url = ui.text(r.url, 12, "ink", wrap=False, selectable=True)
+ url.set_ellipsize(Pango.EllipsizeMode.MIDDLE)
+ field = ui.vbox(4, url)
if r.password:
- self.body.pack_start(self._field(r.password, L("复制密码"), "password"), False, False, 0)
+ field.pack_start(ui.text(LF("密码:%@", r.password), 12, "secondary", wrap=False, selectable=True), False, False, 0)
+ for l in field.get_children():
+ ui.classes(l, "mono")
+ row = ui.hbox(8)
+ row.pack_start(ui.panel(ui.pad(field, 6, 8), "sharefield"), True, True, 0)
+ row.pack_start(self._copy_control(r), False, False, 0)
+ self.body.pack_start(row, False, False, 0)
status = LF("%lld 天后失效", r.days_left())
if self.views is not None:
status += " · " + LF("打开 %lld 次", self.views)
@@ -384,7 +428,8 @@ class ShareDialog:
"password": self.use_password, "summary": self.summary, "busy": self.busy, "confirm": self.confirm,
"hits": self.hits, "kept": self.kept, "removed": sorted(self.removed), "dropNotes": self.drop_notes,
"left": self._left_after() if self.step == "blocked" else None, "message": self.message or None,
- "url": r.url if r else None, "views": self.views}
+ "url": r.url if r else None, "views": self.views, "options": self.show_options, "copied": self.copied,
+ "clipboard": Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD).wait_for_text() if self.copied else None}
def open_for(app, s, parent=None) -> ShareDialog:
diff --git a/linux/cicada/app/ui.py b/linux/cicada/app/ui.py
index fefb308..4a0c7f4 100644
--- a/linux/cicada/app/ui.py
+++ b/linux/cicada/app/ui.py
@@ -110,6 +110,10 @@ dialog.endask { background-color: #FFFFFF; border: 1px solid #E4E6EA; border-rad
/* The share dialog (ShareViews.swift): the review's hits on the accent's pale, the link and password on the fill. */
.sharehit { background-color: #FCEDE7; border-radius: 8px; }
.sharefield { background-color: #F2F3F5; border-radius: 6px; }
+/* The share dialog's Copy and its arrow as one control (a linked box). */
+.copybtn button.outline:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
+.copybtn button.outline.arrow { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-width: 0; padding: 3px 5px; }
+.copybtn button.outline.arrow image { color: #5A5F6B; }
dialog.sharesheet separator { background-color: #EEF0F3; min-height: 1px; }
dialog.sharesheet entry.mono { font-family: "Ubuntu Sans Mono", monospace; }
.notice.error { background-color: #FDECEA; }
diff --git a/linux/cicada/core/share.py b/linux/cicada/core/share.py
index 83cb471..cbfc4fb 100644
--- a/linux/cicada/core/share.py
+++ b/linux/cicada/core/share.py
@@ -172,6 +172,23 @@ def message(code: str) -> str:
"network": "连不上 cicada.indaloop.app,请检查网络。"}.get(code, "服务器出了问题,请稍后再试。"))
+def summary(password: bool, days: int, names: bool) -> str:
+ """The settings already chosen, in one line (无密码 · 7 天有效 · 不显示名字); 更改 opens them."""
+ return " · ".join((L("密码保护") if password else L("无密码"),
+ L("1 年有效") if days == 365 else LF("%lld 天有效", days),
+ L("显示名字") if names else L("不显示名字")))
+
+
+def clipboard_text(r: "ShareRecord", title: str, now: float | None = None) -> str:
+ """What 复制 puts on the clipboard, in the UI's language (ShareSheet.clipboardText): the title,
+ the link on a line of its own (chat apps then make it a link), the password and how long it
+ stays open."""
+ left = r.days_left(now)
+ valid = L("1 年内有效") if left >= 365 else LF("%lld 天内有效", left)
+ last = LF("密码:%@(%@)", r.password, valid) if r.password else valid
+ return "\n".join((LF("「%@」会议记录", title), r.url, last))
+
+
# Passwords
_WORDS = ("amber apple arrow aspen basil beach birch bloom brook cedar cherry cloud coral comet dawn delta dune ember fern "
diff --git a/linux/tests/test_share.py b/linux/tests/test_share.py
index aea74dc..a2f8863 100644
--- a/linux/tests/test_share.py
+++ b/linux/tests/test_share.py
@@ -97,6 +97,23 @@ class ShareDocTests(unittest.TestCase):
self.assertEqual("分享得太频繁了,请稍后再试。", share.message("too_many_shares"))
self.assertEqual("服务器出了问题,请稍后再试。", share.message("whatever"))
+ def test_clipboard_message(self):
+ # One message, three lines, in the UI's language; days left round up, a year reads as a year.
+ now = 1_000_000.0
+ r = share.ShareRecord("a", "https://x/s/a", "t", now + 6.5 * 86400, "notes", "ruby-41-lake", now)
+ self.assertEqual("「周会」会议记录\nhttps://x/s/a\n密码:ruby-41-lake(7 天内有效)", share.clipboard_text(r, "周会", now))
+ r.password, r.expiresAt = None, now + 365 * 86400
+ self.assertEqual("「周会」会议记录\nhttps://x/s/a\n1 年内有效", share.clipboard_text(r, "周会", now))
+ self.assertEqual("无密码 · 7 天有效 · 不显示名字", share.summary(False, 7, False))
+ try:
+ strings.load("en", [os.path.join(REPO, "Resources")])
+ r.password, r.expiresAt = "ruby-41-lake", now + 30 * 86400
+ self.assertEqual("Meeting record: Standup\nhttps://x/s/a\nPassword: ruby-41-lake (valid for 30 days)",
+ share.clipboard_text(r, "Standup", now))
+ self.assertEqual("Password · Open 1 year · Names shown", share.summary(True, 365, True))
+ finally:
+ strings.load("zh-Hans", [os.path.join(REPO, "Resources")])
+
class Ed25519Tests(unittest.TestCase):
# RFC 8032 §7.1, tests 1–3: secret key, public key, message, signature.