Skip to content

fix(files): find a file named without its folders under the pane's folder - #49

Merged
devswha merged 1 commit into
mainfrom
fix/file-viewer-find-by-name
Sep 26, 2026
Merged

devswha merged 1 commit into
mainfrom
fix/file-viewer-find-by-name

Conversation

@devswha

@devswha devswha commented Sep 26, 2026

Copy link
Copy Markdown
Owner

Summary

Clicking demo-desktop.mp4 in a chat answer said "No readable file at this path." The file is docs/screenshots/demo-desktop.mp4, and a relative path was only looked for right under the pane's folder. Agents often name a file without its folders.

Fix. locateFile (server/file-view.ts) first tries the path as written. For a relative path that isn't there, it falls back to the files under the pane's folder whose path ends in that name (filesNamed in server/files.ts):

  • It walks the folder rather than asking git. The @-mention inventory comes from git ls-files, which leaves out ignored files such as recordings and build output, and these MP4s are git-ignored. The walk uses the same bounds (depth 6, 5,000 entries, the usual skipped folders) and a 5 s cache.
  • One match opens.
  • Several matches answer 409 ambiguous_path with the candidates. The viewer lists them, and you pick one.
  • Absolute, ~ and ../ paths are taken as written, never searched for.

After opening, the viewer streams from the absolute path it was given. Open in new tab and Download work for the found file as well.

Testing

  • Unit test: a bare demo.mp4 finds docs/screenshots/demo.mp4, and so does screenshots/demo.mp4. notes.md in two folders yields both candidates. A missing name, and an absolute path elsewhere, stay not found.
  • Browser, desktop and a 390×844 phone:
    • the bare demo.mp4 opened …/docs/demo.mp4 and played
    • notes.md listed two files, and choosing the second showed # B notes
    • the earlier viewer checks still pass, with no page errors
  • The failing case on the live 0.3.9 server: docs/screenshots/demo-desktop.mp4 resolves, and the bare demo-desktop.mp4 doesn't. This PR fixes the second.
  • bun run typecheck passes, bun test passes 351/351, and bun run test:ui passes 8/8.

🤖 Generated with Claude Code

…lder

A relative path was only looked for right under the pane's folder, so a
bare `demo-desktop.mp4` for docs/screenshots/demo-desktop.mp4 (as agents
often write it) answered "No readable file". locateFile now falls back
to the files under the folder whose path ends in the name: walked, not
taken from git, so ignored files such as recordings count, within the
mention inventory's bounds and a 5 s cache. One match opens; several
answer 409 ambiguous_path with the candidates, which the viewer lists
to choose from. The viewer then streams the absolute path it was given.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@devswha
devswha force-pushed the fix/file-viewer-find-by-name branch from c5dc39b to 0ef146b Compare September 26, 2026 06:39
@devswha
devswha merged commit 5d6df9a into main Sep 26, 2026
@devswha
devswha deleted the fix/file-viewer-find-by-name branch September 26, 2026 14:48
devswha added a commit that referenced this pull request Nov 20, 2026
## One-press PC add (app and PC side), behind the step-2 switch

**Add this PC to my account** adds the PC in one press when the account
service admits it, with no
other device typing digits. Any refusal (service or PC, an older Ovis
included) leaves today's digit
wait unchanged. Contract r2 agreed with the account lane and cleared by
relay-hub (G1, G2) and
security-triage; the service side is the account service's separate PR
(#49 there).

Note: the PC's own Settings signs in by device code today, which the
service refuses for one press
(`own_sign_in_required`), so until the PC page's own redirect sign-in
lands (owned by another lane),
a press from the PC's page falls back to the digit wait. Nothing visible
changes before that.

### The four security conditions and where each is enforced here
| Condition | Here | Tests |
|---|---|---|
| 1 fresh own sign-in, two_step_set === 1 (or the account's first PC) |
service; the app presses the PC only after the service admits |
`src/lib/account/addThisPc.test.ts`, `AccountSection.addThisPc.test.tsx`
(refusal keeps the digit wait), `one-press.contract.test.ts` (first-PC
exemption, used account refused) |
| 2 notice on every other device, one-tap remove | `NewPcNotices` at the
top of the opened Ovis (`App.tsx`), never on the relay overview; remove
= `DELETE /v1/pcs/:id`; a PC bound in one press leaves its account on
`403 not_listed` from the snapshot (never on 404) |
`NewPcNotices.test.tsx`, `RelayShell.test.tsx` (overview: row marked, no
card), `one-press.contract.test.ts` |
| 3 24 h New mark, no automatic open | `new_until` from the directory:
mark in the PC lists and sidebar; a new PC's own page waits for a press
instead of opening by its account key | `shellAccountOpen.test.tsx`,
`SidebarAccountPcs.test.tsx` |
| 4 daily cap | service (`429 pc_add_cap`); the app falls back to digits
| `addThisPc.test.ts` |
| first PC told later | `admitted_before_you` rows: the card shows once
to a device that joined after an exempt first-PC add |
`NewPcNotices.test.tsx` |

### PC route: `POST /api/account/one-press` `{ account }`
- Owner here only: a relay device gets `owner_only`, a watching one
`read_only`, an open LAN window or Portal visitor `owner_only`.
- The account must equal the PC's named relay-account (`409
account_mismatch`), which the page sets from its own stored sign-in just
before; the PC must be in no account (`409 in_account`).
- The PC asks `POST /v1/pc/admission` with its relay-key proof, naming
that account (another account's admission is invisible); an answer for
another account binds nothing (`502 account_mismatch`).
- Binds `account-pc.json` with the mark `service: true`
(`bindByService`; refused in the store too when already in an account),
then reads the snapshot so the account's devices are let in by the
step-2 path.
- On HTTP 403 with code `not_listed` from `/v1/pc/snapshot`, a `service:
true` binding is cleared with the new reason `unlisted`; its account
rows end with the existing DropReason `remove` (no new row state). A 404
never clears it.
- With `OVIS_ACCOUNT_OPENS_ALL` off the route answers 404.

### Exported functions and their production callers
| Export | Caller |
|---|---|
| `addInOnePress` (src/lib/account/addThisPc.ts:215) |
src/components/AccountSection.tsx:519 |
| `AccountService.admitPc` (src/lib/account/service.ts) |
src/lib/account/addThisPc.ts:218 |
| `DeviceStore.bindByService` (server/devices.ts) |
server/account/routes.ts:88 |
| `DeviceStore.boundByService` (server/devices.ts:1264) |
server/account/mailbox.ts:288 |
| `PcAccountState.bindByService` (server/account/pc-binding.ts) |
server/devices.ts:1260 |
| `AccountMailbox.admission` (server/account/mailbox.ts) |
server/account/routes.ts:83 |
| `AccountServiceRefusal` (server/account/mailbox.ts) |
server/account/mailbox.ts (unbind check, 404 of the admission, every
refused PC route) |
| `NewPcNotices` (src/components/NewPcNotices.tsx) | src/App.tsx:1140 |
| `isNewAccountPc` (src/lib/account/myPcs.ts:23) |
src/lib/relay/shell.tsx:763, src/lib/account/myPcs.ts:28 |
| `PC_NEW_MS`, `PC_ADMITS_PER_DAY`, `registerSessionKey`
(shared/account-service-fake.ts) | test fake only |

### Design reference
The new-PC notice follows the existing S2-31 device notice and Not me
card (DevicePairedNotice) and
the linked-devices "a new device was added" pattern of WhatsApp and
Signal: told on every other device,
with the removal one tap away. Korean captures (light, phone 390 and PC
1280) were shown to the lead and
the owner before the new sentences shipped.

### Validation
- `bun test server/account/ src/lib/account/ src/lib/relay/
src/components/AccountSection.addThisPc.test.tsx
src/components/AccountSection.signInAddsPc.test.tsx
src/components/NewPcNotices.test.tsx src/components/RelayShell.test.tsx
src/components/SidebarAccountPcs.test.tsx
shared/account-service-fake.test.ts server/dispatch.test.ts
src/conventions.test.ts`: 1952 pass, 1 fail
(`server/account/catch-up-staleness.contract.test.ts` T56, a timing test
this PR does not touch; it passes 6/6 alone, a load flake).
- `bun run typecheck`: clean.
- `bun run check fast` on the remote heavy host: typecheck, build and
every unit file passed except `server/shell-agent.test.ts` (a 300 ms
shell timeout under load; 26/26 alone, untouched here). The last run
before the final rebase; CI runs the full set.
- Skipped: browser regressions in the CI image (the relay dashboard's
markup changed only by an added mark).

### Owner's overview rule
Nothing new appears on the relay overview (app.ovis.sh/#overview and its
PC table, map and details): no notice card and no New mark there. A new
PC there only loses its quick **Open** (a safety removal, not something
shown). The notice lives at the top of the opened Ovis, and the New mark
in the PC's own Ovis (its sidebar and the Add a connection list).

### Every place that picks a PC without a tap, and its guard
| Place | Guard |
|---|---|
| Launch: "the PC this device opened last", else the first saved one
(`launchPc`, src/lib/relay/shell.tsx) | Only saved pairings, never one
an account introduction alone saved (`introduced_at`); a hand open
clears `introduced_at` (`enterApp`) so it may be reopened later. An
account open is an in-memory overlay (`withAccountDevice`) that never
makes a saved pairing |
| A sign-in's return continuing the launch | The same `launchPc` |
| A PC's own page reached through the account (scoped account open) |
Waits for a press while `new_until` is in the future |
| Overview quick Open | Hidden for a PC with `new_until` in the future |
| Sidebar / overview default selection | None exists: the relay front
page draws a list and selects nothing; the Ovis sidebar lists the
account's PCs and opens one only on a tap |
| Notification or deep link | Opens the PC the notification or link
names, on the person's tap; no default PC |
| Update flow | Updates the PC whose Update was pressed; no default PC |

### Merge note
Owner-approved (via the lead): `POST /api/account/one-press`,
owner-only, this PC's own window only, binds only on a service-proven
admission for the account named here, is the one-button PC add.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant