Skip to content

armgit / andee

Public Imported from GitHub
0

Andee lives on your phone or Mac and uses any app like you do—no integrations, no root, any model; memory and passwords never leave your device | Andee 住进你的手机或 Mac,像你一样操作任何 App——无需集成、无需 Root、支持任意模型,记忆和密码绝不离开设备。

feat(desktop): the card system — self-check, notebook, scenes, expressions, glass

booboosui7df714af1845
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Cards.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Cards.kt
new file mode 100644
index 0000000..b052de9
--- /dev/null
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Cards.kt
@@ -0,0 +1,190 @@
+package net.kuafuai.andee.desktop
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.foundation.verticalScroll
+import androidx.compose.material.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
+
+/**
+ * The phone's cards, on the Mac: self-check (✓), the notebook (小本本) and
+ * scenes (情景). Same Glass surfaces, same "the person browses and deletes, the
+ * model writes" split.
+ */
+
+/** The readiness checklist — the phone's ✓ card, one row per thing that can silently break. */
+@Composable
+fun SelfCheckCard(onDone: () -> Unit, onOpenSettings: () -> Unit) {
+ val zh = Strings.lang() == "zh"
+ data class CheckRow(val id: String, val name: String, val ok: Boolean, val why: String, val fix: (() -> Unit)?)
+ val rows = buildList {
+ val ax = net.kuafuai.andee.desktop.mac.Bridge.axTrusted()
+ add(CheckRow("ax", if (zh) "辅助功能" else "Accessibility", ax,
+ if (ax) if (zh) "能读、能操作别的 app" else "Can read and drive other apps" else if (zh) "读不到屏幕,也无法操作" else "Cannot read or drive the screen",
+ { openPane("Privacy_Accessibility") }))
+ val rec = net.kuafuai.andee.desktop.mac.Bridge.screenCaptureAllowed()
+ add(CheckRow("rec", if (zh) "录屏" else "Screen Recording", rec,
+ if (rec) if (zh) "能看见屏幕" else "Can see the screen" else if (zh) "截图拿不到" else "Screenshots are blocked",
+ { openPane("Privacy_ScreenCapture") }))
+ val fda = net.kuafuai.andee.desktop.mac.MacNotifications.state != net.kuafuai.andee.desktop.mac.MacNotifications.State.NO_ACCESS
+ add(CheckRow("fda", if (zh) "完全磁盘访问" else "Full Disk Access", fda,
+ if (fda) if (zh) "能读通知" else "Can read notifications" else if (zh) "读不到通知数据库" else "Cannot read the notification store",
+ { openPane("Privacy_AllFiles") }))
+ val backend = Settings.get("llm_api_key").isNotBlank()
+ add(CheckRow("backend", if (zh) "大脑 Key" else "Model key", backend,
+ if (backend) if (zh) "已配置" else "Configured" else if (zh) "还没配,回答不了" else "Missing — Andee cannot answer",
+ { onOpenSettings() }))
+ val voice = net.kuafuai.andee.desktop.voice.MacVoice.configured()
+ add(CheckRow("voice", if (zh) "语音 Key" else "Voice key", voice,
+ if (voice) if (zh) "能听能说" else "Can hear and speak" else if (zh) "还没配,说不了话" else "Missing — Andee cannot speak",
+ { onOpenSettings() }))
+ }
+ Column(Modifier.fillMaxSize().background(Palette.base).padding(20.dp).verticalScroll(rememberScrollState())) {
+ GlassHeader(if (zh) "自检" else "Self-check", if (zh) "每一项都可能悄悄坏掉" else "Each of these can fail silently", onClose = onDone)
+ for (r in rows) {
+ Row(
+ Modifier.fillMaxWidth().glassPanel(14).padding(12.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ Text(if (r.ok) "✓" else "!", color = if (r.ok) Palette.ok else Palette.warn, fontSize = 16.sp)
+ Spacer(Modifier.width(10.dp))
+ Column(Modifier.weight(1f)) {
+ Text(r.name, color = Palette.label, fontSize = 14.sp)
+ Text(r.why, color = Palette.secondary, fontSize = 11.sp)
+ }
+ if (!r.ok && r.fix != null) {
+ Text(if (zh) "去处理" else "Fix", color = Palette.accent, fontSize = 13.sp,
+ modifier = Modifier.clickable { r.fix?.invoke() }.padding(6.dp))
+ }
+ }
+ Spacer(Modifier.height(8.dp))
+ }
+ }
+}
+
+private fun openPane(anchor: String) {
+ runCatching { net.kuafuai.andee.desktop.mac.Bridge.open("x-apple.systempreferences:com.apple.preference.security?$anchor") }
+}
+
+/** 小本本: what Andee remembers, browsable and deletable — plus the todos it owes. */
+@Composable
+fun NotebookCard(onDone: () -> Unit) {
+ val zh = Strings.lang() == "zh"
+ var refresh by remember { mutableStateOf(0) }
+ val memories = DesktopNotebook.book.memories().sortedByDescending { it.importance }
+ val todos = DesktopNotebook.book.todos("pending").filter { it.status in listOf("active", "paused") }
+ .sortedBy { if (it.nextRunAt > 0) it.nextRunAt else Long.MAX_VALUE }
+ Column(Modifier.fillMaxSize().background(Palette.base).padding(20.dp).verticalScroll(rememberScrollState())) {
+ GlassHeader(if (zh) "小本本" else "Notebook", if (zh) "它记得的事" else "What it remembers", onClose = onDone,
+ trailing = {
+ Text(if (zh) "复制全部" else "Copy all", color = Palette.accent, fontSize = 13.sp,
+ modifier = Modifier.clickable {
+ val dump = memories.joinToString("\n\n") { "【${it.name}】${it.type}\n${it.description}" }
+ java.awt.Toolkit.getDefaultToolkit().systemClipboard
+ .setContents(java.awt.datatransfer.StringSelection(dump), null)
+ }.padding(6.dp))
+ })
+
+ SectionTitle(if (zh) "记忆" else "Memories")
+ if (memories.isEmpty()) {
+ Text(if (zh) "还没有记住什么。" else "Nothing remembered yet.", color = Palette.muted, fontSize = 13.sp)
+ }
+ for (m in memories) {
+ Column(Modifier.fillMaxWidth().glassPanel(14).padding(12.dp)) {
+ Row(verticalAlignment = Alignment.CenterVertically) {
+ Column(Modifier.weight(1f)) {
+ Text(m.name, color = Palette.label, fontSize = 14.sp)
+ Text("${m.type} · ${m.description.take(60)}", color = Palette.secondary, fontSize = 11.sp)
+ }
+ Text(if (zh) "删除" else "Delete", color = Palette.danger, fontSize = 12.sp,
+ modifier = Modifier.clickable { DesktopNotebook.book.forget(m.name); refresh++ }.padding(6.dp))
+ }
+ }
+ Spacer(Modifier.height(8.dp))
+ }
+
+ SectionTitle(if (zh) "待办" else "Todos")
+ if (todos.isEmpty()) {
+ Text(if (zh) "没有待办。" else "Nothing pending.", color = Palette.muted, fontSize = 13.sp)
+ }
+ for (t in todos) {
+ Row(Modifier.fillMaxWidth().glassPanel(14).padding(12.dp), verticalAlignment = Alignment.CenterVertically) {
+ Column(Modifier.weight(1f)) {
+ Text(t.what, color = Palette.label, fontSize = 13.sp)
+ val whenTxt = if (t.mode == "cron") t.cronExpr else LocalTime.format(t.at)
+ Text(whenTxt + (if (t.status == "paused") "(暂停)" else ""), color = Palette.secondary, fontSize = 11.sp)
+ }
+ }
+ Spacer(Modifier.height(8.dp))
+ }
+ }
+}
+
+/** 情景: the ways of working Andee has learned — enter, leave, read, delete. */
+@Composable
+fun ScenesCard(onDone: () -> Unit) {
+ val zh = Strings.lang() == "zh"
+ var refresh by remember { mutableStateOf(0) }
+ val scenes = DesktopNotebook.book.scenes().sortedByDescending { it.lastUsedAt }
+ val active = Settings.get("scene").ifEmpty { null }
+ Column(Modifier.fillMaxSize().background(Palette.base).padding(20.dp).verticalScroll(rememberScrollState())) {
+ GlassHeader(if (zh) "情景" else "Scenes", if (zh) "它和你一起学会的做事方式" else "Ways of working it learned", onClose = onDone)
+ if (scenes.isEmpty()) {
+ Text(if (zh) "还没有情景。空对话里可以选一个预设,或让它学着提一个。" else "No scenes yet. Pick a preset from an empty chat, or let Andee propose one.", color = Palette.muted, fontSize = 13.sp)
+ }
+ for (s in scenes) {
+ var expanded by remember { mutableStateOf(false) }
+ val isActive = s.name == active
+ Column(Modifier.fillMaxWidth().glassPanel(14).padding(12.dp)) {
+ Row(verticalAlignment = Alignment.CenterVertically) {
+ Column(Modifier.weight(1f)) {
+ Text((if (isActive) "● " else "") + s.title, color = if (isActive) Palette.accent else Palette.label, fontSize = 14.sp)
+ Text(s.summary + " · ${s.uses} 次", color = Palette.secondary, fontSize = 11.sp)
+ }
+ }
+ Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
+ Text(if (isActive) (if (zh) "退出" else "Leave") else (if (zh) "进入" else "Enter"),
+ color = Palette.accent, fontSize = 12.sp,
+ modifier = Modifier.clickable {
+ Settings.save(mapOf("scene" to if (isActive) "" else s.name))
+ refresh++
+ }.padding(vertical = 6.dp))
+ Text(if (zh) "规则" else "Rules", color = Palette.secondary, fontSize = 12.sp,
+ modifier = Modifier.clickable { expanded = !expanded }.padding(vertical = 6.dp))
+ Spacer(Modifier.weight(1f))
+ Text(if (zh) "删除" else "Delete", color = Palette.danger, fontSize = 12.sp,
+ modifier = Modifier.clickable {
+ if (isActive) Settings.save(mapOf("scene" to ""))
+ DesktopNotebook.book.deleteScene(s.name)
+ refresh++
+ }.padding(vertical = 6.dp))
+ }
+ if (expanded) {
+ Text(s.prompt, color = Palette.label, fontSize = 12.sp,
+ modifier = Modifier.fillMaxWidth().glassWell(10).padding(10.dp))
+ }
+ }
+ Spacer(Modifier.height(8.dp))
+ }
+ }
+}
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/ChatScreen.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/ChatScreen.kt
index 4f9b6e3..9082426 100644
--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/ChatScreen.kt
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/ChatScreen.kt
@@ -45,22 +45,40 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
/** The phone's `Glass` palette, so the two apps look like one product. */
+/** The phone's `Glass` night palette, exactly — so the two apps read as one product. */
object Palette {
val base = Color(0xFF000000)
- val card = Color(0xF20A0A0C)
- val panel = Color(0x0FFFFFFF)
- val well = Color(0x14FFFFFF)
- val hairline = Color(0x1AFFFFFF)
- val text = Color(0xFFF2F2F7)
- val secondary = Color(0x99EBEBF5)
- val accent = Color(0xFF0A84FF)
- val accentSoft = Color(0x330A84FF)
- val user = Color(0xFF0A84FF)
- val error = Color(0xFFFF453A)
+ val cardSolid = Color(0xF2060608)
+ val cardFrosted = Color(0x99000000)
+ val panel = Color(0x0FFFFFFF) // 6% white
+ val panelEdge = Color(0x17FFFFFF) // 9% white
+ val glass = Color(0x1FFFFFFF) // 12% white
+ val glassEdge = Color(0x38FFFFFF) // 22% white
+ val well = Color(0x59000000) // 35% black
+ val wellEdge = Color(0x1AFFFFFF) // 10% white
+ val thumb = Color(0x2EFFFFFF) // 18% white
+ val thumbEdge = Color(0x40FFFFFF)
+ val hairline = Color(0x2BFFFFFF) // 17% white
+ val title = Color(0xFFFFFFFF)
+ val label = Color(0xFFDCE1EA)
+ val secondary = Color(0xFF8F97A6)
+ val muted = Color(0xFF5F6775)
+ val accent = Color(0xFF7FA5FF)
+ val tint = Color(0xFF4C6FFF)
+ val danger = Color(0xFFFF6B6B)
+ val ok = Color(0xFF4ADE80)
+ val warn = Color(0xFFFBBF24)
+
+ // kept for existing call sites
+ val text get() = title
+ val accentSoft = Color(0x267FA5FF)
+ val user = accent
+ val error get() = danger
+ val card get() = cardSolid
}
@Composable
-fun ChatScreen(onOpenSettings: () -> Unit) {
+fun ChatScreen(onOpenSettings: () -> Unit, onOpenSelfCheck: () -> Unit) {
var rows by remember { mutableStateOf(Scrollback.snapshot()) }
var progress by remember { mutableStateOf("") }
var busy by remember { mutableStateOf(false) }
@@ -115,6 +133,7 @@ fun ChatScreen(onOpenSettings: () -> Unit) {
if (recording) Meeting.stopFromUser() else if (busy) Assistant.stop()
},
onSettings = onOpenSettings,
+ onSelfCheck = onOpenSelfCheck,
)
Column(Modifier.weight(1f).fillMaxWidth().padding(horizontal = 16.dp)) {
@@ -172,7 +191,7 @@ fun ChatScreen(onOpenSettings: () -> Unit) {
/** Title plus a one-line status, with stop and settings on the right — the phone's control bar. */
@Composable
-private fun Header(status: String?, stoppable: Boolean, onStop: () -> Unit, onSettings: () -> Unit) {
+private fun Header(status: String?, stoppable: Boolean, onStop: () -> Unit, onSettings: () -> Unit, onSelfCheck: () -> Unit) {
Row(
Modifier.fillMaxWidth().padding(start = 16.dp, end = 16.dp, top = 14.dp, bottom = 10.dp),
verticalAlignment = Alignment.CenterVertically,
@@ -188,6 +207,8 @@ private fun Header(status: String?, stoppable: Boolean, onStop: () -> Unit, onSe
Pill(if (Strings.lang() == "zh") "■ 停止" else "■ Stop") { onStop() }
Spacer(Modifier.width(8.dp))
}
+ Pill("✓") { onSelfCheck() }
+ Spacer(Modifier.width(8.dp))
Pill("⚙") { onSettings() }
}
}
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/ExpressionsCard.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/ExpressionsCard.kt
new file mode 100644
index 0000000..63b4820
--- /dev/null
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/ExpressionsCard.kt
@@ -0,0 +1,124 @@
+package net.kuafuai.andee.desktop
+
+import androidx.compose.foundation.Canvas
+import androidx.compose.foundation.background
+import androidx.compose.foundation.border
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.foundation.verticalScroll
+import androidx.compose.material.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.DisposableEffect
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.asComposeImageBitmap
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.unit.Dp
+import androidx.compose.ui.unit.IntOffset
+import androidx.compose.ui.unit.IntSize
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
+import net.kuafuai.andee.ui.ball.BallLooks
+import net.kuafuai.andee.ui.ball.Mood
+import org.jetbrains.skia.Bitmap
+import org.jetbrains.skia.ColorAlphaType
+import org.jetbrains.skia.ColorType
+import org.jetbrains.skia.ImageInfo
+
+/** 形象与表情: every look and every expression, to look at and to choose. */
+@Composable
+fun ExpressionsCard(onDone: () -> Unit) {
+ val zh = Strings.lang() == "zh"
+ var pickedMood by remember { mutableStateOf(Mood.CALM) }
+ val currentLook = Settings.get("ball").ifEmpty { BallLooks.active.name }
+ Column(Modifier.fillMaxSize().background(Palette.base).padding(20.dp).verticalScroll(rememberScrollState())) {
+ GlassHeader(if (zh) "形象与表情" else "Look & expressions", if (zh) "选一个形象,表情跟着它变" else "Pick a look; the face follows", onClose = onDone)
+ Box(Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
+ BallPreview(pickedMood, 168.dp)
+ }
+ Spacer(Modifier.height(14.dp))
+
+ SectionTitle(if (zh) "形象" else "Look")
+ Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
+ for (look in BallLooks.ALL) {
+ val on = look.name == currentLook
+ Text(
+ Strings.get("ball_look_${look.name}"), color = if (on) Palette.accent else Palette.label, fontSize = 14.sp,
+ modifier = Modifier.fillMaxWidth().glassPanel(12)
+ .border(1.dp, if (on) Palette.accent.copy(alpha = 0.5f) else Palette.panelEdge, RoundedCornerShape(12.dp))
+ .clickable { MacBall.pickLook(look.name) }.padding(12.dp),
+ )
+ }
+ }
+
+ SectionTitle(if (zh) "表情" else "Expressions")
+ Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
+ val feelings = listOf(
+ Mood.CALM, Mood.HAPPY, Mood.CURIOUS, Mood.TENSE, Mood.ANXIOUS, Mood.CONCERNED,
+ Mood.WINK, Mood.WAVE, Mood.PROTECT, Mood.CELEBRATE, Mood.REST, Mood.SUCCESS, Mood.FAILED,
+ )
+ feelings.chunked(4).forEach { rowMoods ->
+ Row(horizontalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.fillMaxWidth()) {
+ for (m in rowMoods) {
+ val on = m == pickedMood
+ Text(
+ moodLabel(m, zh), color = if (on) Palette.title else Palette.secondary, fontSize = 13.sp,
+ modifier = Modifier
+ .background(if (on) Palette.thumb else Color.Transparent, RoundedCornerShape(10.dp))
+ .border(1.dp, if (on) Palette.thumbEdge else Palette.panelEdge, RoundedCornerShape(10.dp))
+ .clickable { pickedMood = m }.padding(horizontal = 10.dp, vertical = 6.dp),
+ )
+ }
+ }
+ }
+ }
+ }
+}
+
+private fun moodLabel(m: Mood, zh: Boolean): String = if (zh) when (m) {
+ Mood.CALM -> "平静"; Mood.HAPPY -> "开心"; Mood.CURIOUS -> "好奇"; Mood.TENSE -> "紧张"
+ Mood.ANXIOUS -> "焦虑"; Mood.CONCERNED -> "担心"; Mood.WINK -> "眨眼"; Mood.WAVE -> "挥手"
+ Mood.PROTECT -> "护着"; Mood.CELEBRATE -> "庆祝"; Mood.REST -> "歇着"; Mood.SUCCESS -> "成功"; Mood.FAILED -> "失败"
+ else -> m.name.lowercase()
+} else m.name.lowercase()
+
+/** A second ball, decoupled from the corner one so poking an expression touches only this card. */
+@Composable
+private fun BallPreview(mood: Mood, size: Dp) {
+ val px = with(LocalDensity.current) { size.roundToPx() }
+ val renderer = remember(px) { BallRenderer(px, px) }
+ val bitmap = remember(px) { Bitmap().apply { allocPixels(ImageInfo(px, px, ColorType.BGRA_8888, ColorAlphaType.PREMUL)) } }
+ val image = remember(bitmap) { bitmap.asComposeImageBitmap() }
+ var tick by remember { mutableStateOf(0) }
+ DisposableEffect(renderer) {
+ val queued = java.util.concurrent.atomic.AtomicBoolean(false)
+ renderer.onFrame = {
+ if (queued.compareAndSet(false, true)) javax.swing.SwingUtilities.invokeLater {
+ queued.set(false)
+ renderer.frame?.let { f -> bitmap.installPixels(f); bitmap.notifyPixelsChanged(); tick++ }
+ }
+ }
+ onDispose { renderer.onFrame = {}; renderer.stop() }
+ }
+ LaunchedEffect(renderer, mood) { renderer.setState(mood, listening = false, emotion = null) }
+ Canvas(Modifier.size(size)) {
+ if (tick > 0) drawImage(image, dstOffset = IntOffset.Zero, dstSize = IntSize(this.size.width.toInt(), this.size.height.toInt()))
+ }
+}
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Glass.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Glass.kt
new file mode 100644
index 0000000..ac70119
--- /dev/null
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Glass.kt
@@ -0,0 +1,141 @@
+package net.kuafuai.andee.desktop
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.border
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.foundation.text.BasicTextField
+import androidx.compose.material.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.drawBehind
+import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.graphics.Brush
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.SolidColor
+import androidx.compose.ui.text.TextStyle
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.text.input.PasswordVisualTransformation
+import androidx.compose.ui.text.input.VisualTransformation
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
+
+/**
+ * The phone's `Glass` surfaces, in Compose. Same tokens, same hierarchy: a near-
+ * black base, everything above it white at low alpha, a top-lit edge that reads
+ * as frosted glass. Real compositor blur does not apply here — the Mac window is
+ * opaque black rather than an overlay over another app — so the sheen plus the
+ * translucency is the whole effect, exactly as the phone's pills approximate it.
+ */
+
+/** A card surface: near-black fill, bright hairline, top sheen. */
+fun Modifier.glassCard(radius: Int = 18): Modifier = this
+ .background(Palette.cardSolid, RoundedCornerShape(radius.dp))
+ .border(1.dp, Palette.hairline, RoundedCornerShape(radius.dp))
+ .then(sheen(radius))
+
+/** A grouped surface sitting on a card. */
+fun Modifier.glassPanel(radius: Int = 14): Modifier = this
+ .background(Palette.panel, RoundedCornerShape(radius.dp))
+ .border(1.dp, Palette.panelEdge, RoundedCornerShape(radius.dp))
+
+/** A recessed surface: text fields and picker tracks. */
+fun Modifier.glassWell(radius: Int = 12): Modifier = this
+ .background(Palette.well, RoundedCornerShape(radius.dp))
+ .border(1.dp, Palette.wellEdge, RoundedCornerShape(radius.dp))
+
+/** The lit top edge — the one piece that reads as glass on a flat backdrop. */
+private fun Modifier.sheen(radius: Int): Modifier = this.drawBehind {
+ val h = size.height * 0.5f
+ drawRect(
+ brush = Brush.verticalGradient(
+ 0f to Color(0x1FFFFFFF),
+ h / size.height to Color(0x00FFFFFF),
+ endY = h,
+ ),
+ topLeft = Offset(0f, 0f),
+ size = androidx.compose.ui.geometry.Size(size.width, h),
+ )
+}
+
+@Composable
+fun GlassHeader(title: String, subtitle: String? = null, onClose: () -> Unit, trailing: @Composable (() -> Unit)? = null) {
+ Row(Modifier.fillMaxWidth().padding(bottom = 14.dp), verticalAlignment = Alignment.CenterVertically) {
+ Column {
+ Text(title, color = Palette.title, fontSize = 22.sp, fontWeight = FontWeight.SemiBold)
+ if (subtitle != null) Text(subtitle, color = Palette.secondary, fontSize = 12.sp)
+ }
+ Spacer(Modifier.weight(1f))
+ trailing?.invoke()
+ Text("✕", color = Palette.secondary, fontSize = 18.sp,
+ modifier = Modifier.glassPanel(18).clickable { onClose() }.padding(horizontal = 12.dp, vertical = 6.dp))
+ }
+}
+
+@Composable
+fun SectionTitle(title: String) {
+ Spacer(Modifier.height(16.dp))
+ Text(title, color = Palette.secondary, fontSize = 13.sp)
+ Spacer(Modifier.height(6.dp))
+}
+
+/** The phone's sliding-thumb segmented picker. */
+@Composable
+fun SegmentedPicker(options: List<Pair<String, String>>, selected: String, onPick: (String) -> Unit) {
+ val current = if (options.any { it.first == selected }) selected else options.first().first
+ Row(
+ Modifier.fillMaxWidth().glassWell(12).padding(3.dp),
+ horizontalArrangement = Arrangement.spacedBy(3.dp),
+ ) {
+ for ((value, label) in options) {
+ val on = value == current
+ Text(
+ label, color = if (on) Palette.title else Palette.secondary, fontSize = 14.sp,
+ textAlign = androidx.compose.ui.text.style.TextAlign.Center,
+ modifier = Modifier.weight(1f)
+ .background(if (on) Palette.thumb else Color.Transparent, RoundedCornerShape(9.dp))
+ .border(1.dp, if (on) Palette.thumbEdge else Color.Transparent, RoundedCornerShape(9.dp))
+ .clickable { onPick(value) }
+ .padding(vertical = 7.dp),
+ )
+ }
+ }
+}
+
+@Composable
+fun GlassField(label: String, value: String, onValue: (String) -> Unit, secret: Boolean = false) {
+ Spacer(Modifier.height(8.dp))
+ Text(label, color = Palette.secondary, fontSize = 12.sp)
+ Spacer(Modifier.height(4.dp))
+ BasicTextField(
+ value = value,
+ onValueChange = onValue,
+ singleLine = true,
+ visualTransformation = if (secret) PasswordVisualTransformation() else VisualTransformation.None,
+ textStyle = TextStyle(color = Palette.label, fontSize = 14.sp),
+ cursorBrush = SolidColor(Palette.accent),
+ modifier = Modifier.fillMaxWidth().glassWell(12).padding(horizontal = 12.dp, vertical = 10.dp),
+ )
+}
+
+@Composable
+fun PrimaryButton(label: String, onClick: () -> Unit) {
+ Text(
+ label, color = Palette.ON_TINT(), fontSize = 14.sp, fontWeight = FontWeight.Medium,
+ textAlign = androidx.compose.ui.text.style.TextAlign.Center,
+ modifier = Modifier.fillMaxWidth()
+ .background(Palette.tint, RoundedCornerShape(14.dp))
+ .clickable { onClick() }.padding(vertical = 11.dp),
+ )
+}
+
+private fun Palette.ON_TINT(): Color = Color(0xFFFFFFFF)
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Main.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Main.kt
index b5f07e6..76b229b 100644
--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Main.kt
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Main.kt
@@ -21,15 +21,19 @@ fun main() {
MacBall.restoreLook()
Assistant.start()
application {
- var settings by remember { mutableStateOf(false) }
var pending by remember { mutableStateOf(ApprovalGate.current) }
// The chat is the phone's unfolded card: the ball is always there, the chat comes and goes.
var chat by remember { mutableStateOf(true) }
- ApprovalGate.onChange = { pending = ApprovalGate.current; if (pending != null) chat = true }
+ // The card stack: each card is a full-window surface, opened on top of the last.
+ val stack = remember { androidx.compose.runtime.mutableStateListOf("chat") }
+ fun push(s: String) { stack.add(s) }
+ fun pop() { if (stack.size > 1) stack.removeAt(stack.lastIndex) }
+ val screen = stack.last()
+ ApprovalGate.onChange = { pending = ApprovalGate.current; if (pending != null) { chat = true; stack.clear(); stack.add("chat") } }
var ballWindow by remember { mutableStateOf<java.awt.Window?>(null) }
var chatWindow by remember { mutableStateOf<java.awt.Window?>(null) }
var ask by remember { mutableStateOf(AskGate.current) }
- AskGate.onChange = { ask = AskGate.current; if (ask != null) chat = true }
+ AskGate.onChange = { ask = AskGate.current; if (ask != null) { chat = true; stack.clear(); stack.add("chat") } }
// A click aimed at another app must not land on Andee: both windows step aside for the instant of it.
// (Native, not Window.opacity: AWT refuses that on the decorated chat window.)
Assistant.hideWindows = { hide -> net.kuafuai.andee.desktop.mac.Bridge.setOwnAlpha(if (hide) 0.0 else 1.0) }
@@ -37,7 +41,7 @@ fun main() {
FloatingBall(
onTap = {
if (Meeting.isActive()) Meeting.stopFromUser()
- else if (!net.kuafuai.andee.desktop.voice.MacVoice.toggle()) { chat = true; settings = true }
+ else if (!net.kuafuai.andee.desktop.voice.MacVoice.toggle()) { chat = true; stack.clear(); stack.add("chat"); push("settings") }
},
onLongPress = { chat = !chat },
onWindow = { ballWindow = it },
@@ -53,13 +57,26 @@ fun main() {
chatWindow = window
MenuBar {
Menu("Andee") {
- Item(if (Strings.lang() == "zh") "显示对话" else "Show chat", onClick = { chat = true })
+ Item(if (Strings.lang() == "zh") "显示对话" else "Show chat", onClick = { chat = true; stack.clear(); stack.add("chat") })
Item(if (Strings.lang() == "zh") "退出 Andee" else "Quit Andee", onClick = ::exitApplication,
shortcut = androidx.compose.ui.input.key.KeyShortcut(androidx.compose.ui.input.key.Key.Q, meta = true))
}
}
androidx.compose.foundation.layout.Box {
- if (settings) SettingsScreen { settings = false } else ChatScreen { settings = true }
+ when (screen) {
+ "settings" -> SettingsScreen(
+ onDone = { pop() },
+ onOpenNotebook = { push("notebook") },
+ onOpenScenes = { push("scenes") },
+ onOpenExpressions = { push("expressions") },
+ onOpenSelfCheck = { push("selfcheck") },
+ )
+ "selfcheck" -> SelfCheckCard(onDone = { pop() }, onOpenSettings = { push("settings") })
+ "notebook" -> NotebookCard(onDone = { pop() })
+ "scenes" -> ScenesCard(onDone = { pop() })
+ "expressions" -> ExpressionsCard(onDone = { pop() })
+ else -> ChatScreen(onOpenSettings = { push("settings") }, onOpenSelfCheck = { push("selfcheck") })
+ }
pending?.let { ApprovalCard(it) }
ask?.let { AskCard(it) }
}
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/SettingsScreen.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/SettingsScreen.kt
index 99e81bc..01888d6 100644
--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/SettingsScreen.kt
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/SettingsScreen.kt
@@ -1,7 +1,6 @@
package net.kuafuai.andee.desktop
import androidx.compose.foundation.background
-import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
@@ -11,10 +10,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
-import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@@ -25,21 +21,22 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
-import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.graphics.SolidColor
-import androidx.compose.ui.text.TextStyle
-import androidx.compose.ui.text.input.PasswordVisualTransformation
-import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
/**
- * The settings sheet. Same keys as the phone's, and the same rule for the
- * enum-like ones: a picker, whose leftmost option is what an unknown saved
- * value reads as.
+ * The settings sheet, the phone's card shape: a Glass header, segmented
+ * pickers, and a 更多 section that opens the notebook, scenes, the expression
+ * card and the self-check — the same four doors the phone's card reaches.
*/
@Composable
-fun SettingsScreen(onDone: () -> Unit) {
+fun SettingsScreen(
+ onDone: () -> Unit,
+ onOpenNotebook: () -> Unit,
+ onOpenScenes: () -> Unit,
+ onOpenExpressions: () -> Unit,
+ onOpenSelfCheck: () -> Unit,
+) {
val zh = Strings.lang() == "zh"
fun t(a: String, b: String) = if (zh) a else b
val v = remember { mutableStateMapOf<String, String>().apply { putAll(Settings.all()) } }
@@ -47,92 +44,67 @@ fun SettingsScreen(onDone: () -> Unit) {
var fullOpenAsk by remember { mutableStateOf(false) }
Column(Modifier.fillMaxSize().background(Palette.base).padding(20.dp).verticalScroll(rememberScrollState())) {
- Row(verticalAlignment = Alignment.CenterVertically) {
- Text(t("设置", "Settings"), color = Palette.text, fontSize = 22.sp)
- Spacer(Modifier.weight(1f))
- Text("✕", color = Palette.secondary, fontSize = 18.sp,
- modifier = Modifier.background(Palette.panel, RoundedCornerShape(18.dp))
- .border(1.dp, Palette.hairline, RoundedCornerShape(18.dp))
- .clickable { onDone() }.padding(horizontal = 12.dp, vertical = 6.dp))
- }
- Spacer(Modifier.height(16.dp))
-
- Section(t("界面语言", "Language"))
- Picker(listOf("zh" to "中", "en" to "EN"), lang) { lang = it; v["lang"] = it }
-
- Section(t("形象", "Look"))
- Picker(
- net.kuafuai.andee.ui.ball.BallLooks.ALL.map { it.name to Strings.get("ball_look_${it.name}") },
- v["ball"].orEmpty().ifEmpty { net.kuafuai.andee.ui.ball.BallLooks.ALL.first().name },
- ) { v["ball"] = it }
-
- Section(t("后端", "Backend"))
- Picker(
- listOf("local" to t("本机(自己的 Key)", "Own key"), "codeflying" to "CodeFlying"),
- v["brain"].orEmpty().ifEmpty { "local" },
- ) { v["brain"] = it }
- Field(t("API Key", "API key"), v, "llm_api_key", secret = true)
- Field(t("接口地址(留空用默认)", "Base URL (blank = default)"), v, "llm_base_url")
- Field(t("模型名(留空用默认)", "Model (blank = default)"), v, "llm_model")
- Section(t("思考", "Thinking"))
- Picker(listOf("disabled" to t("关", "Off"), "enabled" to t("开", "On")), v["llm_thinking"].orEmpty().ifEmpty { "disabled" }) {
- v["llm_thinking"] = it
- }
- Field(t("每轮最多步数(默认 25)", "Max steps per turn (default 25)"), v, "max_steps")
-
- Section(t("命令行", "Commands"))
- Picker(
- listOf(
- "ask" to t("问我", "Ask me"),
- "auto" to t("自动", "Automatic"),
- "read_only" to t("只读", "Read-only"),
- "full" to t("完全开放", "Full access"),
- ),
+ GlassHeader(t("设置", "Settings"), subtitle = t("所有设置都存在本机", "Everything stays on this Mac"), onClose = onDone)
+
+ SectionTitle(t("界面语言", "Language"))
+ SegmentedPicker(listOf("zh" to "中", "en" to "EN"), lang) { lang = it; v["lang"] = it }
+
+ SectionTitle(t("大脑", "Backend"))
+ SegmentedPicker(listOf("local" to t("本机", "Own key"), "codeflying" to "CodeFlying"), v["brain"].orEmpty().ifEmpty { "local" }) { v["brain"] = it }
+ GlassField(t("API Key", "API key"), v["llm_api_key"].orEmpty(), { v["llm_api_key"] = it }, secret = true)
+ GlassField(t("接口地址(留空用默认)", "Base URL (blank = default)"), v["llm_base_url"].orEmpty(), { v["llm_base_url"] = it })
+ GlassField(t("模型名(留空用默认)", "Model (blank = default)"), v["llm_model"].orEmpty(), { v["llm_model"] = it })
+ SectionTitle(t("思考", "Thinking"))
+ SegmentedPicker(listOf("disabled" to t("关", "Off"), "enabled" to t("开", "On")), v["llm_thinking"].orEmpty().ifEmpty { "disabled" }) { v["llm_thinking"] = it }
+ GlassField(t("每轮最多步数(默认 25)", "Max steps per turn (default 25)"), v["max_steps"].orEmpty(), { v["max_steps"] = it })
+
+ SectionTitle(t("命令行", "Commands"))
+ SegmentedPicker(
+ listOf("ask" to t("问我", "Ask me"), "auto" to t("自动", "Automatic"), "read_only" to t("只读", "Read-only"), "full" to t("完全开放", "Full")),
v["shell_mode"].orEmpty().ifEmpty { "ask" },
) { picked ->
if (picked == "full" && v["shell_mode"] != "full") fullOpenAsk = true else v["shell_mode"] = picked
}
Text(
when (v["shell_mode"].orEmpty().ifEmpty { "ask" }) {
- "auto" -> t("在沙箱里,普通命令直接跑;删除大量文件、强推这类仍然先问你。",
- "Runs ordinary commands inside the sandbox; destructive ones are still shown to you first.")
- "read_only" -> t("只允许查看类命令,其它一律拒绝。", "Only commands that read are allowed.")
- "full" -> t("不进沙箱、不问:Andee 能改动这台 Mac 上的任何文件。陌生人消息触发的回合仍然不能执行命令。",
- "No sandbox, no asking: Andee can change any file on this Mac. A turn started by someone else's message still cannot run commands.")
- else -> t("只读命令直接跑,其它每条先问你。", "Read-only commands run; everything else is shown to you first.")
+ "auto" -> t("在沙箱里,普通命令直接跑;删大量文件、强推这类仍先问你。", "Ordinary commands run in the sandbox; destructive ones still ask first.")
+ "read_only" -> t("只允许查看类命令,其它一律拒绝。", "Only read-only commands are allowed.")
+ "full" -> t("不进沙箱、不问:Andee 能改动这台 Mac 上的任何文件。", "No sandbox, no asking: Andee can change any file.")
+ else -> t("只读命令直接跑,其它每条先问你。", "Read-only commands run; everything else asks first.")
},
color = Palette.secondary, fontSize = 12.sp,
)
- Field(t("工作文件夹(逗号分隔,留空用 ~/Andee;桌面、文稿整个目录不能用)", "Work folders (comma-separated; blank = ~/Andee; not all of Desktop or Documents)"), v, "shell_workdirs")
- Section(t("SSH 钥匙", "SSH keys"))
+ GlassField(t("工作文件夹(逗号分隔,留空用 ~/Andee)", "Work folders (comma-separated; blank = ~/Andee)"), v["shell_workdirs"].orEmpty(), { v["shell_workdirs"] = it })
+ SectionTitle(t("SSH 钥匙", "SSH keys"))
SshKeys(zh)
if (fullOpenAsk) {
FullOpenConfirm(zh, onYes = { v["shell_mode"] = "full"; fullOpenAsk = false }, onNo = { fullOpenAsk = false })
}
- Section(t("通知", "Notifications"))
- Picker(
- listOf("off" to t("关", "Off"), "chat" to t("聊天类", "Chats"), "all" to t("全部", "All")),
- v["notify"].orEmpty().ifEmpty { "off" },
- ) { v["notify"] = it }
+ SectionTitle(t("通知", "Notifications"))
+ SegmentedPicker(listOf("off" to t("关", "Off"), "chat" to t("聊天类", "Chats"), "all" to t("全部", "All")), v["notify"].orEmpty().ifEmpty { "off" }) { v["notify"] = it }
Text(
when (net.kuafuai.andee.desktop.mac.MacNotifications.state) {
net.kuafuai.andee.desktop.mac.MacNotifications.State.NO_ACCESS -> t(
- "读不到通知:在 系统设置 → 隐私与安全性 → 完全磁盘访问权限 里加上 Andee,然后退出重开。",
- "Can't read notifications: add Andee under System Settings → Privacy & Security → Full Disk Access, then reopen it.")
- else -> t(
- "打开后,Andee 先自己判断:忽略、告诉你一声,还是动手处理。微信要在它自己的设置里打开「通知显示消息详情」,否则只看得到「收到一条消息」。",
- "When on, Andee decides for itself: ignore, tell you, or deal with it. WeChat shows only \"new message\" unless message details are on in its own settings.")
+ "读不到通知:在 系统设置 → 隐私与安全性 → 完全磁盘访问权限 里加上 Andee。",
+ "Can't read notifications: add Andee under System Settings → Privacy & Security → Full Disk Access.")
+ else -> t("打开后 Andee 先自己判断:忽略、告诉你,还是动手处理。", "When on, Andee decides for itself: ignore, tell you, or deal with it.")
},
color = Palette.secondary, fontSize = 12.sp,
)
- Section(t("语音(火山)", "Voice (Volcengine)"))
- Field(t("火山 Key", "Volcengine key"), v, "api_key", secret = true)
+ SectionTitle(t("语音", "Voice"))
+ GlassField(t("语音 Key", "Voice key"), v["api_key"].orEmpty(), { v["api_key"] = it }, secret = true)
+
+ SectionTitle(t("更多", "More"))
+ MoreRow(t("小本本", "Notebook"), t("它记得的事", "What it remembers"), onOpenNotebook)
+ MoreRow(t("情景", "Scenes"), t("和它一起学会的做事方式", "Ways of working it learned"), onOpenScenes)
+ MoreRow(t("形象与表情", "Look & expressions"), t("换一个样子", "Pick a face"), onOpenExpressions)
+ MoreRow(t("自检", "Self-check"), t("看看哪里没开", "What is missing"), onOpenSelfCheck)
Spacer(Modifier.height(20.dp))
Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
- PrimaryPill(t("保存", "Save")) {
+ PrimaryButton(t("保存", "Save")) {
Settings.save(v.toMap())
v["ball"]?.let { MacBall.pickLook(it) }
Thread { Assistant.ensure() }.start()
@@ -142,95 +114,52 @@ fun SettingsScreen(onDone: () -> Unit) {
}
Spacer(Modifier.height(12.dp))
Text(
- t("数据保存在 ~/Library/Application Support/Andee,笔记本的密钥在钥匙串里。",
- "Data lives in ~/Library/Application Support/Andee; the notebook's key is in your Keychain."),
+ t("数据保存在 ~/Library/Application Support/Andee,笔记本的密钥在钥匙串里。", "Data lives in ~/Library/Application Support/Andee; the notebook key is in your Keychain."),
color = Palette.secondary, fontSize = 12.sp,
)
}
}
@Composable
-private fun PrimaryPill(label: String, onClick: () -> Unit) {
- Text(
- label, color = Color(0xFF0A2540), fontSize = 14.sp,
- modifier = Modifier.background(Palette.accent, RoundedCornerShape(15.dp))
- .clickable { onClick() }.padding(horizontal = 16.dp, vertical = 7.dp),
- )
-}
-
-@Composable
-private fun Section(title: String) {
- Spacer(Modifier.height(14.dp))
- Text(title, color = Palette.secondary, fontSize = 13.sp)
- Spacer(Modifier.height(6.dp))
-}
-
-@Composable
-private fun Picker(options: List<Pair<String, String>>, selected: String, onPick: (String) -> Unit) {
- val current = if (options.any { it.first == selected }) selected else options.first().first
+private fun MoreRow(title: String, subtitle: String, onClick: () -> Unit) {
Row(
- Modifier.background(Palette.well, RoundedCornerShape(10.dp)).padding(3.dp),
- horizontalArrangement = Arrangement.spacedBy(3.dp),
+ Modifier.fillMaxWidth().glassPanel(14).clickable { onClick() }.padding(12.dp),
+ verticalAlignment = Alignment.CenterVertically,
) {
- for ((value, label) in options) {
- val on = value == current
- Text(
- label, color = if (on) Palette.accent else Palette.text, fontSize = 14.sp,
- modifier = Modifier
- .background(if (on) Palette.accentSoft else Palette.well.copy(alpha = 0f), RoundedCornerShape(8.dp))
- .border(1.dp, if (on) Palette.accent.copy(alpha = 0.5f) else Palette.hairline.copy(alpha = 0f), RoundedCornerShape(8.dp))
- .clickable { onPick(value) }
- .padding(horizontal = 12.dp, vertical = 6.dp),
- )
+ Column(Modifier.weight(1f)) {
+ Text(title, color = Palette.label, fontSize = 14.sp)
+ Text(subtitle, color = Palette.secondary, fontSize = 11.sp)
}
+ Text("›", color = Palette.secondary, fontSize = 18.sp)
}
-}
-
-@Composable
-private fun Field(label: String, v: MutableMap<String, String>, key: String, secret: Boolean = false) {
Spacer(Modifier.height(8.dp))
- Text(label, color = Palette.secondary, fontSize = 12.sp)
- Spacer(Modifier.height(4.dp))
- BasicTextField(
- value = v[key].orEmpty(),
- onValueChange = { v[key] = it },
- singleLine = true,
- visualTransformation = if (secret) PasswordVisualTransformation() else VisualTransformation.None,
- textStyle = TextStyle(color = Palette.text, fontSize = 14.sp),
- cursorBrush = SolidColor(Palette.accent),
- modifier = Modifier.fillMaxWidth().background(Palette.well, RoundedCornerShape(10.dp))
- .border(1.dp, Palette.hairline, RoundedCornerShape(10.dp)).padding(10.dp),
- )
}
-/** Full access needs the word typed, not a click (design doc §4.2). */
@Composable
private fun FullOpenConfirm(zh: Boolean, onYes: () -> Unit, onNo: () -> Unit) {
fun t(a: String, b: String) = if (zh) a else b
var typed by remember { mutableStateOf("") }
Column(
- Modifier.fillMaxWidth().padding(top = 8.dp).background(Palette.panel, RoundedCornerShape(12.dp))
- .border(1.dp, Palette.error, RoundedCornerShape(12.dp)).padding(12.dp),
+ Modifier.fillMaxWidth().padding(top = 8.dp).glassPanel(12).padding(12.dp),
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
Text(
- t("完全开放后,Andee 运行命令不再进沙箱、不再问你,能删除和修改这台 Mac 上的任何文件。确认的话输入「开启」。",
- "With full access, Andee's commands run outside the sandbox without asking, and can delete or change any file on this Mac. Type \"enable\" to confirm."),
- color = Palette.text, fontSize = 13.sp,
+ t("完全开放后,Andee 运行命令不再进沙箱、不再问你。确认的话输入「开启」。", "With full access, commands run without the sandbox or asking. Type \"enable\" to confirm."),
+ color = Palette.label, fontSize = 13.sp,
)
- BasicTextField(
+ androidx.compose.foundation.text.BasicTextField(
value = typed, onValueChange = { typed = it }, singleLine = true,
- textStyle = TextStyle(color = Palette.text, fontSize = 14.sp), cursorBrush = SolidColor(Palette.accent),
- modifier = Modifier.fillMaxWidth().background(Palette.well, RoundedCornerShape(10.dp)).padding(10.dp),
+ textStyle = androidx.compose.ui.text.TextStyle(color = Palette.label, fontSize = 14.sp),
+ cursorBrush = androidx.compose.ui.graphics.SolidColor(Palette.accent),
+ modifier = Modifier.fillMaxWidth().glassWell(10).padding(10.dp),
)
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
- if (typed.trim() == "开启" || typed.trim().equals("enable", true)) Pill(t("开启完全开放", "Enable full access")) { onYes() }
+ if (typed.trim() == "开启" || typed.trim().equals("enable", true)) PrimaryButton(t("开启完全开放", "Enable full access")) { onYes() }
Pill(t("取消", "Cancel")) { onNo() }
}
}
}
-/** Keys Andee signs with as an ssh-agent; the private half never leaves it. */
@Composable
private fun SshKeys(zh: Boolean) {
fun t(a: String, b: String) = if (zh) a else b
@@ -238,8 +167,8 @@ private fun SshKeys(zh: Boolean) {
var hosts by remember { mutableStateOf("github.com") }
var error by remember { mutableStateOf("") }
for (k in keys) {
- Column(Modifier.fillMaxWidth().padding(vertical = 4.dp).background(Palette.panel, RoundedCornerShape(10.dp)).padding(10.dp)) {
- Text(k.name + " → " + k.hosts.ifEmpty { listOf(t("任何主机", "any host")) }.joinToString(), color = Palette.text, fontSize = 13.sp)
+ Column(Modifier.fillMaxWidth().padding(vertical = 4.dp).glassPanel(10).padding(10.dp)) {
+ Text(k.name + " → " + k.hosts.ifEmpty { listOf(t("任何主机", "any host")) }.joinToString(), color = Palette.label, fontSize = 13.sp)
androidx.compose.foundation.text.selection.SelectionContainer {
Text(k.openSsh(), color = Palette.secondary, fontSize = 11.sp)
}
@@ -252,34 +181,28 @@ private fun SshKeys(zh: Boolean) {
}
}
Text(t("允许用于这些主机(逗号分隔)", "Allowed hosts (comma-separated)"), color = Palette.secondary, fontSize = 12.sp)
- BasicTextField(
+ androidx.compose.foundation.text.BasicTextField(
value = hosts, onValueChange = { hosts = it }, singleLine = true,
- textStyle = TextStyle(color = Palette.text, fontSize = 14.sp), cursorBrush = SolidColor(Palette.accent),
- modifier = Modifier.fillMaxWidth().background(Palette.well, RoundedCornerShape(10.dp)).padding(10.dp),
+ textStyle = androidx.compose.ui.text.TextStyle(color = Palette.label, fontSize = 14.sp),
+ cursorBrush = androidx.compose.ui.graphics.SolidColor(Palette.accent),
+ modifier = Modifier.fillMaxWidth().glassWell(10).padding(10.dp),
)
Row(Modifier.padding(top = 6.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
Pill(t("生成新钥匙", "Generate a key")) {
error = runCatching {
- net.kuafuai.andee.desktop.shell.AndeeAgent.generate("andee-" + (keys.size + 1), hostList(hosts))
- ""
+ net.kuafuai.andee.desktop.shell.AndeeAgent.generate("andee-" + (keys.size + 1), hostList(hosts)); ""
}.getOrElse { it.message.orEmpty() }
keys = runCatching { net.kuafuai.andee.desktop.shell.AndeeAgent.keys() }.getOrDefault(emptyList())
}
Pill(t("导入 ~/.ssh/id_ed25519", "Import ~/.ssh/id_ed25519")) {
error = runCatching {
val f = java.io.File(System.getProperty("user.home"), ".ssh/id_ed25519")
- net.kuafuai.andee.desktop.shell.AndeeAgent.import("id_ed25519", f.readText(), hostList(hosts))
- ""
+ net.kuafuai.andee.desktop.shell.AndeeAgent.import("id_ed25519", f.readText(), hostList(hosts)); ""
}.getOrElse { it.message.orEmpty() }
keys = runCatching { net.kuafuai.andee.desktop.shell.AndeeAgent.keys() }.getOrDefault(emptyList())
}
}
- Text(
- t("生成后把上面那行公钥贴到 GitHub → Settings → SSH keys。命令里的 git push 会请 Andee 签名,私钥本身拿不到。",
- "Paste the public line above into GitHub → Settings → SSH keys. git push in a command asks Andee to sign; the private key is never handed over."),
- color = Palette.secondary, fontSize = 11.sp,
- )
- if (error.isNotEmpty()) Text(error, color = Palette.error, fontSize = 12.sp)
+ if (error.isNotEmpty()) Text(error, color = Palette.danger, fontSize = 12.sp)
}
private fun hostList(s: String) = s.split(',', ' ', '\n').map { it.trim() }.filter { it.isNotEmpty() }