Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
464e031
feat(mobile): add Android agents widget and live update
iscekic Aug 27, 2026
e7ed3ff
Merge branch 'audit-w8b-live-activities-3cf8-s2' into audit-w8b-live-…
iscekic Aug 27, 2026
aa2c2e1
Merge branch 'audit-w8b-live-activities-3cf8-s2' into audit-w8b-live-…
iscekic Aug 27, 2026
d58f9bb
Merge branch 'audit-w8b-live-activities-3cf8-s2' into audit-w8b-live-…
iscekic Aug 27, 2026
274dafc
Merge branch 'audit-w8b-live-activities-3cf8-s2' into audit-w8b-live-…
iscekic Aug 27, 2026
6b17fcd
fix(glanceable): harden Android ongoing promotion, alert, and tap
iscekic Aug 28, 2026
190654f
fix(mobile): restore Android widgets and notification taps
iscekic Aug 28, 2026
87a9643
Merge branch 'audit-w8b-live-activities-3cf8-s2' into audit-w8b-live-…
iscekic Aug 28, 2026
4527573
Merge branch 'audit-w8b-live-activities-3cf8-s2' into audit-w8b-live-…
iscekic Aug 28, 2026
881c481
Merge branch 'audit-w8b-live-activities-3cf8-s2' into audit-w8b-live-…
iscekic Aug 28, 2026
cfb5617
Merge branch 'audit-w8b-live-activities-3cf8-s2' into audit-w8b-live-…
iscekic Aug 28, 2026
f2a2901
fix(i18n): add the channel name with its Android consumer
iscekic Aug 28, 2026
a26d710
fix(mobile): restore Android glanceable count presentation
iscekic Aug 28, 2026
0f036a4
fix(mobile): persist Android glanceable deadlines natively
iscekic Aug 28, 2026
b342edb
Merge branch 'audit-w8b-live-activities-3cf8-s2' into audit-w8b-live-…
iscekic Sep 2, 2026
0b2539e
Merge branch 'audit-w8b-live-activities-3cf8-s2' into audit-w8b-live-…
iscekic Sep 3, 2026
fade277
Merge branch 'audit-w8b-live-activities-3cf8-s2' into audit-w8b-live-…
iscekic Sep 3, 2026
dbbc40e
Merge branch 'audit-w8b-live-activities-3cf8-s2' into audit-w8b-live-…
iscekic Sep 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions apps/mobile/modules/active-agents-live-update/android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apply plugin: 'com.android.library'

group = 'com.kilocode.activeagentsliveupdate'
version = '0.1.0'

def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
apply from: expoModulesCorePlugin
applyKotlinExpoModulesCorePlugin()
useCoreDependencies()
useExpoPublishing()
useDefaultAndroidSdkVersions()

android {
namespace "com.kilocode.activeagentsliveupdate"
defaultConfig {
versionCode 1
versionName "0.1.0"
}
lintOptions {
abortOnError false
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package com.kilocode.activeagentsliveupdate

import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.os.Build
import expo.modules.kotlin.modules.Module
import expo.modules.kotlin.modules.ModuleDefinition

/**
* Local Expo module for the Android aggregate ongoing notification.
*
* The JS side owns the translated copy and the revision guard; this module owns
* the fixed notification id, the dedicated `active-agents` channel (default
* importance, silent, no heads-up), and the API 36.1+ promotion gate.
*/
class ActiveAgentsLiveUpdateModule : Module() {
override fun definition() = ModuleDefinition {
Name("ActiveAgentsLiveUpdate")

Function("isPromotionCapable") {
isPromotionCapable()
}

Function("start") { title: String, text: String, promotion: Boolean ->
post(title, text, promotion)
}

Function("update") { title: String, text: String, promotion: Boolean ->
post(title, text, promotion)
}

Function("end") {
dismiss()
}
}

private val context: Context
get() = appContext.reactContext ?: appContext.applicationContext

private val notificationManager: NotificationManager
get() = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager

private fun smallIconId(): Int =
context.resources.getIdentifier("notification_icon", "drawable", context.packageName)

private fun isPromotionCapable(): Boolean =
Build.VERSION.SDK_INT_FULL >= 36_001_000 && notificationManager.canPostPromotedNotifications()
Comment thread
iscekic marked this conversation as resolved.
Resolved

private fun ensureChannel(title: String) {
if (Build.VERSION.SDK_INT < 26) {
return
}
if (notificationManager.getNotificationChannel(CHANNEL_ID) != null) {
return
}
val channel = NotificationChannel(CHANNEL_ID, title, NotificationManager.IMPORTANCE_DEFAULT)
channel.setSound(null, null)
channel.enableVibration(false)
channel.lockscreenVisibility = Notification.VISIBILITY_PUBLIC
notificationManager.createNotificationChannel(channel)
}

private fun newBuilder(title: String): Notification.Builder {
if (Build.VERSION.SDK_INT >= 26) {
ensureChannel(title)
return Notification.Builder(context, CHANNEL_ID)
}
return legacyBuilder()
}

@Suppress("DEPRECATION")
private fun legacyBuilder(): Notification.Builder = Notification.Builder(context)

private fun post(title: String, text: String, promotion: Boolean) {
val builder = newBuilder(title)
.setSmallIcon(smallIconId())
.setContentTitle(title)
.setContentText(text)
.setOngoing(true)
.setOnlyAlertOnce(true)
.setSound(null)
.setCategory(Notification.CATEGORY_STATUS)

// API 36.1+ Live Update: promote only when the device reports the capability.
// setRequestPromotedOngoing does not exist; use the documented flag setter.
if (promotion && isPromotionCapable()) {
builder.setFlag(Notification.FLAG_PROMOTED_ONGOING, true)
Comment thread
iscekic marked this conversation as resolved.
Resolved
builder.setStyle(Notification.ProgressStyle())
}

notificationManager.notify(NOTIFICATION_ID, builder.build())
Comment thread
iscekic marked this conversation as resolved.
Resolved
}

private fun dismiss() {
notificationManager.cancel(NOTIFICATION_ID)
}

private companion object {
const val CHANNEL_ID = "active-agents"
const val NOTIFICATION_ID = 1001
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"modules": []
},
"android": {
"modules": []
"modules": ["com.kilocode.activeagentsliveupdate.ActiveAgentsLiveUpdateModule"]
}
}
}
150 changes: 150 additions & 0 deletions apps/mobile/src/glanceable-android/active-agents-widget.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
import {
buildGlanceableSnapshot,
type GlanceableAgentsSnapshot,
} from '@kilocode/app-shared/glanceable-agents-snapshot';
import { describe, expect, it, vi } from 'vitest';

import { OPEN_AGENTS_CLICK, renderActiveAgentsWidget } from './active-agents-widget';
import { buildAndroidWidgetProps } from './widget-props';

// Stub the widget primitives so the layout functions return inspectable trees
// without loading react-native. The real components are exercised by prebuild.
vi.mock('react-native-android-widget', () => ({
FlexWidget: (props: Record<string, unknown>) => ({ kind: 'FlexWidget', props }),
TextWidget: (props: Record<string, unknown>) => ({ kind: 'TextWidget', props }),
requestWidgetUpdate: () => undefined,
}));

const NOW = 1_750_000_000_000;

type MockElement = {
kind: string;
props: {
text?: string;
clickAction?: string;
style?: { backgroundColor?: string };
children?: unknown;
};
};

const COPY: Record<string, string> = {
'glanceable.needsInput': 'Needs input',
'glanceable.reconnecting': 'Reconnecting',
'glanceable.running': 'Running',
'glanceable.empty': 'No work in progress',
'glanceable.expired': 'Status expired',
'glanceable.openAgents': 'Open agents',
};

function translate(key: string): string {
return COPY[key] ?? key;
}

function snapshotFor(
sessions: { status: string }[],
revision = 0,
status?: GlanceableAgentsSnapshot['status']
): GlanceableAgentsSnapshot {
return buildGlanceableSnapshot({
sessions,
userId: 'u1',
organizationId: null,
now: NOW,
previousRevision: revision,
...(status === undefined ? {} : { status }),
});
}

function collectText(node: unknown): string[] {
if (node == null) {
return [];
}
if (Array.isArray(node)) {
return node.flatMap(item => collectText(item));
}
if (typeof node !== 'object') {
return [];
}
const element = node as MockElement;
const output: string[] = [];
if (typeof element.props.text === 'string') {
output.push(element.props.text);
}
if (element.props.children !== undefined) {
output.push(...collectText(element.props.children));
}
return output;
}

function render(props: ReturnType<typeof buildAndroidWidgetProps>, width: number) {
return renderActiveAgentsWidget(props, {
widgetName: 'ActiveAgentsWidget',
widgetId: 1,
width,
height: 100,
screenInfo: { screenWidthDp: 400, screenHeightDp: 800, density: 2, densityDpi: 320 },
}) as unknown as { light: MockElement; dark: MockElement };
}

describe('renderActiveAgentsWidget', () => {
it('returns distinct light and dark layouts through the theme callback', () => {
const props = buildAndroidWidgetProps(snapshotFor([{ status: 'busy' }], 0), {}, translate);
const rep = render(props, 250);

expect(rep.light).toBeDefined();
expect(rep.dark).toBeDefined();
expect(rep.light).not.toBe(rep.dark);
expect(rep.light.props.style?.backgroundColor).toBe('#FFFFFF');
expect(rep.dark.props.style?.backgroundColor).toBe('#0B0F19');
});

it('shows only the primary count at a small width', () => {
const props = buildAndroidWidgetProps(
snapshotFor([{ status: 'question' }, { status: 'busy' }, { status: 'busy' }], 0),
{},
translate
);
const rep = render(props, 120);
const text = collectText(rep.light);

expect(text).toEqual(['1 Needs input']);
});

it('shows every non-zero count and the Open agents affordance at a wide width', () => {
const props = buildAndroidWidgetProps(
snapshotFor([{ status: 'question' }, { status: 'busy' }], 0),
{},
translate
);
const rep = render(props, 250);
const text = collectText(rep.light);

expect(text).toEqual(['1 Needs input', '1 Running', 'Open agents']);
});

it('hides counts and shows expired copy for an expired snapshot', () => {
const props = buildAndroidWidgetProps(
{
...snapshotFor([{ status: 'busy' }], 0),
status: 'expired',
running: 0,
needsInput: 0,
reconnecting: 0,
},
{},
translate
);
const rep = render(props, 250);
const text = collectText(rep.light);

expect(text).toEqual(['Status expired']);
});

it('labels the whole widget with the Open agents click action', () => {
const props = buildAndroidWidgetProps(snapshotFor([{ status: 'busy' }], 0), {}, translate);
const rep = render(props, 250);

expect(rep.light.props.clickAction).toBe(OPEN_AGENTS_CLICK);
expect(rep.dark.props.clickAction).toBe(OPEN_AGENTS_CLICK);
});
});
Loading