Files
orca/mobile/scripts/mock-server-encryption.ts
T
21a01c7d6b Mobile: worktree-list sidebar for tablet/foldable layouts (#5505)
* Add worktree-list sidebar for mobile tablet/foldable layouts

On wide canvases (tablet/foldable, >=700pt) the per-host worktree list now
renders as a persistent left sidebar with the routed screens (terminal,
source control, review, accounts, tasks) shown in a detail pane to its
right — mirroring the desktop's sidebar + center layout. Phones keep the
existing single-pane stack navigation unchanged.

- Reuse the existing worktree-list screen as the sidebar via an `embedded`
  mode (props for hostId/action, mount-driven fetch since a sidebar is never
  the focused route, hide-sidebar control in place of the back button, and
  open-into-detail-pane navigation that replaces rather than stacks).
- The default host route renders an empty WorkspaceDetailPlaceholder on wide
  layouts (the list lives in the sidebar) and the full screen on phones, so
  exactly one instance mounts either way.
- Hide button collapses the sidebar to give the detail pane full width; an
  elevated reveal tab brings it back.
- Detail-pane screen transitions use `animation: 'none'` while the split is
  active so workspaces swap instantly instead of sliding and flashing the
  screen beneath.
- Drag the sidebar's right edge to resize (clamped 280-560pt, detail pane
  kept >=320pt, tap-transparent so list rows still work); width persists via
  AsyncStorage.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Address PR review feedback (#5505)

- Clamp the restored/persisted sidebar width against the current window and
  re-clamp when the window shrinks, so a width saved on a larger device can't
  starve the detail pane below MIN_DETAIL_WIDTH. Extract a shared
  clampSidebarToWindow helper reused by load, window-resize, and drag.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Polish mobile tablet sidebar

Co-authored-by: Orca <help@stably.ai>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Jinwoo-H <jinwoo0825@gmail.com>
Co-authored-by: Orca <help@stably.ai>
2026-06-16 16:50:38 -07:00

36 lines
1.2 KiB
TypeScript

import nacl from 'tweetnacl'
export type E2EEState = {
sharedKey: Uint8Array
deviceToken: string | null
authenticated: boolean
}
export function deriveSharedKey(ourSecret: Uint8Array, peerPublic: Uint8Array): Uint8Array {
return nacl.box.before(peerPublic, ourSecret)
}
export function e2eeEncrypt(plaintext: string, sharedKey: Uint8Array): string {
const nonce = nacl.randomBytes(nacl.box.nonceLength)
const msg = new TextEncoder().encode(plaintext)
const ciphertext = nacl.box.after(msg, nonce, sharedKey)
const bundle = new Uint8Array(nonce.length + ciphertext.length)
bundle.set(nonce)
bundle.set(ciphertext, nonce.length)
return Buffer.from(bundle).toString('base64')
}
export function e2eeDecrypt(encrypted: string, sharedKey: Uint8Array): string | null {
const bundle = Uint8Array.from(Buffer.from(encrypted, 'base64'))
if (bundle.length < nacl.box.nonceLength + nacl.box.overheadLength) {
return null
}
const nonce = bundle.slice(0, nacl.box.nonceLength)
const ciphertext = bundle.slice(nacl.box.nonceLength)
const plaintext = nacl.box.open.after(ciphertext, nonce, sharedKey)
if (!plaintext) {
return null
}
return new TextDecoder().decode(plaintext)
}