feat: add AIUI node capabilities — file reading, log tailing, bitcoin/lnd deep data
Add readFileAsText() to filebrowser client, read-file and tail-logs action handlers to context broker, bitcoin.getinfo and lnd.getinfo RPC enrichment for context categories, and update AIUI protocol types. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,75 +1,145 @@
|
||||
# Fix Content Clipping + Hide Network Tabs in CloudFolder
|
||||
# Expand AIUI Node Capabilities
|
||||
|
||||
## Context
|
||||
Content clips/cuts off before reaching the bottom across CloudFolder, Marketplace, AppDetails — both desktop and mobile. Fixed UI elements (toolbars, search) must stay sticky while scrollable content extends to the tab bar (mobile) or viewport bottom (desktop). Also: hide Cloud/Network switcher on mobile in CloudFolder detail view.
|
||||
AIUI currently sees basic app status and file names but can't read files, check Bitcoin/LND details, or view app logs. Expanding these 4 capabilities makes AIUI a truly useful node assistant.
|
||||
|
||||
## Root Cause
|
||||
`.perspective-container-wrapper` has `height: 100%` + `overflow: hidden` + dynamic `pt-20`/`pt-40`. With `box-sizing: border-box`, the padding shrinks the content area by 80-160px on mobile.
|
||||
---
|
||||
|
||||
## 1. File Reading (frontend-only) [DONE]
|
||||
|
||||
### `neode-ui/src/api/filebrowser-client.ts`
|
||||
Add `readFileAsText(path, maxBytes = 102400)` method:
|
||||
- Fetch from existing `/app/filebrowser/api/raw{path}?auth={token}` endpoint
|
||||
- Limit response to 100KB (truncate with note)
|
||||
- Only allow text-like extensions: `.txt`, `.md`, `.json`, `.csv`, `.log`, `.conf`, `.yaml`, `.yml`, `.toml`, `.xml`, `.html`, `.css`, `.js`, `.ts`, `.py`, `.sh`
|
||||
- Return `{ content: string, truncated: boolean, size: number }`
|
||||
|
||||
### `neode-ui/src/types/aiui-protocol.ts`
|
||||
Add `'read-file'` and `'tail-logs'` to `AIActionType` union.
|
||||
|
||||
### `neode-ui/src/services/contextBroker.ts`
|
||||
Add `read-file` action handler:
|
||||
- Check `files` permission is enabled
|
||||
- Validate path param exists, validate extension
|
||||
- Call `fileBrowserClient.readFileAsText(path)`
|
||||
- Return content in action response
|
||||
|
||||
### `AIUI/packages/app/src/composables/useArchy.ts`
|
||||
- Add `readFile(path: string)` helper that calls `archyBridge.requestAction('read-file', { path })`
|
||||
- Update `buildArchyContext()` files section: mention "You can read file contents by requesting the read-file action with a file path."
|
||||
|
||||
---
|
||||
|
||||
## 2. App Log Viewing (frontend-only)
|
||||
|
||||
### `neode-ui/src/services/contextBroker.ts`
|
||||
Add `tail-logs` action handler:
|
||||
- Check `apps` permission is enabled
|
||||
- Params: `{ appId: string, lines?: string }` (default 50, max 200)
|
||||
- Call existing `rpcClient.call({ method: 'container-logs', params: { app_id, lines } })`
|
||||
- Return log lines in action response
|
||||
|
||||
### `AIUI/packages/app/src/composables/useArchy.ts`
|
||||
- Add `tailLogs(appId: string, lines?: number)` helper
|
||||
- Update `buildArchyContext()` apps section: "You can view recent app logs by requesting the tail-logs action with an appId."
|
||||
|
||||
---
|
||||
|
||||
## 3. Bitcoin Deep Data (backend + frontend)
|
||||
|
||||
### `core/archipelago/src/api/rpc/mod.rs`
|
||||
Add routing: `"bitcoin.getinfo" => self.handle_bitcoin_getinfo().await`
|
||||
|
||||
### New: `core/archipelago/src/api/rpc/bitcoin.rs`
|
||||
Add `handle_bitcoin_getinfo()`:
|
||||
- Use `reqwest` to POST to `http://127.0.0.1:8332` with Basic Auth `archipelago:archipelago123`
|
||||
- Call `getblockchaininfo` JSON-RPC method
|
||||
- Call `getmempoolinfo` JSON-RPC method
|
||||
- Return sanitized JSON:
|
||||
```json
|
||||
{
|
||||
"block_height": 800000,
|
||||
"sync_progress": 0.9999,
|
||||
"chain": "main",
|
||||
"difficulty": 72006146,
|
||||
"mempool_size": 45000000,
|
||||
"mempool_tx_count": 12500,
|
||||
"verification_progress": 0.9999
|
||||
}
|
||||
```
|
||||
<main flex-1 overflow-hidden pb-20> ← reserves tab bar space (correct)
|
||||
.perspective-container-wrapper h-100% pt-20 ← padding SHRINKS content area (BUG)
|
||||
.perspective-container h-100% overflow-hidden
|
||||
.view-wrapper absolute inset-0
|
||||
content div overflow-y-auto h-full ← scroll viewport 80-160px too small
|
||||
- Handle connection errors gracefully (Bitcoin Core might be syncing or down)
|
||||
|
||||
### `neode-ui/src/services/contextBroker.ts`
|
||||
Enrich `bitcoin` category sanitizer:
|
||||
- Call `rpcClient.call({ method: 'bitcoin.getinfo' })`
|
||||
- Merge with existing container status data
|
||||
- Return block height, sync %, chain, mempool stats
|
||||
|
||||
### `AIUI/packages/app/src/composables/useArchy.ts`
|
||||
- Add `bitcoinInfo` ref with block height, sync %, etc.
|
||||
- Update `buildArchyContext()`: "**Bitcoin:** Block 800,000 (99.99% synced), mainnet, mempool: 12,500 txs"
|
||||
|
||||
---
|
||||
|
||||
## 4. LND Deep Data (backend + frontend)
|
||||
|
||||
### `core/archipelago/src/api/rpc/mod.rs`
|
||||
Add routing: `"lnd.getinfo" => self.handle_lnd_getinfo().await`
|
||||
|
||||
### New: `core/archipelago/src/api/rpc/lnd.rs`
|
||||
Add `handle_lnd_getinfo()`:
|
||||
- Read admin macaroon from `/var/lib/archipelago/lnd/data/chain/bitcoin/mainnet/admin.macaroon`
|
||||
- Use `reqwest` to GET `https://127.0.0.1:8080/v1/getinfo` with `Grpc-Metadata-macaroon` header (hex-encoded)
|
||||
- GET `https://127.0.0.1:8080/v1/balance/channels` for channel balance
|
||||
- GET `https://127.0.0.1:8080/v1/balance/blockchain` for on-chain balance
|
||||
- Accept self-signed cert (`reqwest::Client::builder().danger_accept_invalid_certs(true)`)
|
||||
- Return sanitized JSON:
|
||||
```json
|
||||
{
|
||||
"alias": "my-node",
|
||||
"num_active_channels": 5,
|
||||
"num_peers": 8,
|
||||
"synced_to_chain": true,
|
||||
"block_height": 800000,
|
||||
"balance_sats": 1500000,
|
||||
"channel_balance_sats": 3000000,
|
||||
"pending_open_balance": 0
|
||||
}
|
||||
```
|
||||
- **Never expose**: private keys, seed, macaroon, node pubkey (optional — could include for identification)
|
||||
- Handle errors: LND might be locked, syncing, or not installed
|
||||
|
||||
## Solution: Move padding from wrapper to scroll container
|
||||
### `neode-ui/src/services/contextBroker.ts`
|
||||
Enrich `wallet` category:
|
||||
- Call `rpcClient.call({ method: 'lnd.getinfo' })`
|
||||
- Return alias, channels, balances, sync status
|
||||
|
||||
### File 1: `neode-ui/src/views/Dashboard.vue` [DONE]
|
||||
### `AIUI/packages/app/src/composables/useArchy.ts`
|
||||
- Add `lndInfo` ref
|
||||
- Update `buildArchyContext()`: "**Lightning:** 5 channels, 3M sats in channels, 1.5M on-chain, synced"
|
||||
|
||||
**A. Add computed** (~line 440):
|
||||
```ts
|
||||
const mobileTabPaddingTop = computed(() => {
|
||||
if (typeof window === 'undefined' || window.innerWidth >= 768) return 0
|
||||
if (showAppsTabs.value && showNetworkTabs.value) return 160
|
||||
if (showAppsTabs.value || showNetworkTabs.value) return 80
|
||||
return 0
|
||||
})
|
||||
```
|
||||
---
|
||||
|
||||
**B. Remove padding from wrapper** (line 258):
|
||||
Remove `'pt-40': showAppsTabs && showNetworkTabs, 'pt-20': showAppsTabs !== showNetworkTabs` from `:class`.
|
||||
## File Summary
|
||||
|
||||
**C. Apply offset to content div instead** (lines 269-277):
|
||||
```html
|
||||
<div v-else
|
||||
:class="['px-4 pt-4 md:pt-8 md:px-8 overflow-y-auto h-full',
|
||||
needsMobileBackButtonSpace
|
||||
? 'pb-[calc(var(--mobile-tab-bar-height,_72px)+96px)] md:pb-8'
|
||||
: 'pb-4 md:pb-8'
|
||||
]"
|
||||
:style="mobileTabPaddingTop ? { paddingTop: (mobileTabPaddingTop + 16) + 'px' } : undefined"
|
||||
>
|
||||
```
|
||||
- When mobile tabs showing: `:style` overrides `pt-4` with dynamic value
|
||||
- When no tabs (or desktop): `:style` is undefined, Tailwind `pt-4 md:pt-8` applies
|
||||
- Bottom padding reduced from `pb-28 md:pb-24` to `pb-4 md:pb-8` (main's `pb-20` already handles tab bar)
|
||||
| File | Change |
|
||||
|------|--------|
|
||||
| `neode-ui/src/api/filebrowser-client.ts` | Add `readFileAsText()` |
|
||||
| `neode-ui/src/types/aiui-protocol.ts` | Add `read-file`, `tail-logs` action types |
|
||||
| `neode-ui/src/services/contextBroker.ts` | Add 2 action handlers + enrich bitcoin/wallet categories |
|
||||
| `neode-ui/src/stores/aiPermissions.ts` | Update category descriptions |
|
||||
| `core/archipelago/src/api/rpc/mod.rs` | Add 2 route entries |
|
||||
| `core/archipelago/src/api/rpc/bitcoin.rs` | New: Bitcoin Core RPC proxy |
|
||||
| `core/archipelago/src/api/rpc/lnd.rs` | New: LND REST proxy |
|
||||
| `AIUI/packages/app/src/composables/useArchy.ts` | Add helpers + enrich buildArchyContext() |
|
||||
|
||||
**D. Hide Cloud/Network tabs in CloudFolder** (line 451):
|
||||
```ts
|
||||
if (route.name === 'cloud-folder') return false
|
||||
```
|
||||
|
||||
### File 2: `neode-ui/src/views/CloudFolder.vue` [DONE]
|
||||
Delete spacer div at line 156.
|
||||
|
||||
### File 3: `neode-ui/src/views/AppDetails.vue` [DONE]
|
||||
Delete spacer div at line 377.
|
||||
|
||||
### File 4: `neode-ui/src/views/MarketplaceAppDetails.vue` [DONE]
|
||||
Delete spacer div at line 324.
|
||||
|
||||
### File 5: `neode-ui/src/views/Marketplace.vue` [DONE]
|
||||
Change `pb-48` → `pb-4` on line 121.
|
||||
|
||||
## Safety
|
||||
- 3D transitions preserved: `overflow: hidden` stays on wrapper + perspective-container
|
||||
- Chat view unaffected: has its own branch bypassing the content div
|
||||
- Desktop unaffected: `mobileTabPaddingTop` returns 0
|
||||
- Back button space preserved: `needsMobileBackButtonSpace` still adds extra bottom padding
|
||||
|
||||
## Verification [DONE]
|
||||
1. `cd neode-ui && npm run build`
|
||||
2. `./scripts/deploy-to-target.sh --live`
|
||||
3. Test all views on mobile + desktop: CloudFolder, Marketplace, AppDetails, Chat, Home, page transitions
|
||||
## Verification
|
||||
1. `cd neode-ui && npm run build` — frontend builds
|
||||
2. `./scripts/deploy-to-target.sh --live` — deploys + builds Rust backend on server
|
||||
3. Test in AIUI chat:
|
||||
- "What files do I have?" → sees file list
|
||||
- "Read my config.txt" → gets file content
|
||||
- "How's my Bitcoin node?" → block height, sync %, mempool
|
||||
- "What's my Lightning balance?" → channel count, sats balance
|
||||
- "Why is Mempool not working?" → views recent logs
|
||||
- "Show me the last 50 lines of Bitcoin logs" → log output
|
||||
|
||||
Reference in New Issue
Block a user