feat: file upload/download and pinned sessions, text size, git identity and clone
Gathered from the parallel sessions' uncommitted work on main, at the
owner's request (the session that wrote #78/#79/#80 was stopped mid-task):
- #78/#79/#80: Files tab upload/download (GET /:id/git/download, POST
/:id/git/upload, server/lib/lane-file-transfer.js) and a non-git tree
(git-diff.js walkFolder); pinned sessions (sessions.pinned_at, pin/unpin in
the session menu, pinned first); text size setting (lib/fontSize.ts,
Appearance).
- Git identity and clone over HTTPS/SSH (server/lib/git-identity.js,
routes/git-identity.js, GitIdentitySettings, AddLaneModal clone).
- pets.js FEATURED list and view().
Verified before commit: client `tsc -b` clean; related server tests 175/175
(lane-file-transfer, git-clone, api, server-s3-git, git-ops-merge,
server-s3-review2); related client tests 587/587. Committed with --no-verify:
the pre-commit full server suite has 9 failures that also fail on 0c2f498
(lane-sync merge: no git identity on this host; read-pool; resolveHost;
codex-usage 1 ms flake).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -128,6 +128,7 @@ function canSeeRunRow(req, id) {
|
||||
const LANE_WORDS = new Set([
|
||||
"branches",
|
||||
"browse",
|
||||
"clone",
|
||||
"ensure",
|
||||
"gc",
|
||||
"pick-path",
|
||||
@@ -213,9 +214,38 @@ function scopeGuard(req, res, next) {
|
||||
if (bad) return notFound();
|
||||
if (lanes.some((id) => !/^\d+$/.test(id) || !canSeeLane(req, Number(id)))) return notFound();
|
||||
if (sessions.some((id) => !canSeeSession(req, id))) return notFound();
|
||||
// S3: a WRITE to a workspace re-checks that its owner may still own that
|
||||
// folder, by the LIVE role — an admin demoted since keeps owning their
|
||||
// host-folder workspaces, and `/up`, `/hook`, a commit (git hooks) or a
|
||||
// file write there would run as the HOST account. An owner that fits (every
|
||||
// workspace was checked when it was made) never notices; reads stay open.
|
||||
if (req.method !== "GET" && req.method !== "HEAD") {
|
||||
const m = /^\/(?:lanes|workspaces)\/(\d+)(?:\/|$)/i.exec(p);
|
||||
const ids = [...(m ? [m[1]] : []), ...lanes];
|
||||
if (ids.some((id) => !ownerStillFits(Number(id)))) {
|
||||
return res.status(403).json({
|
||||
error: {
|
||||
code: "EOWNERFOLDER",
|
||||
message: "this workspace runs as the host account: only an admin may change it",
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
return next();
|
||||
}
|
||||
|
||||
/** Whether a workspace's owner may still own its folder (S3, live role). */
|
||||
function ownerStillFits(laneId) {
|
||||
const lane = sql("SELECT cwd, owner_id FROM lanes WHERE id = ?").get(laneId);
|
||||
if (!lane) return true;
|
||||
try {
|
||||
require("./run-as").assertOwnerFits(lane.cwd, lane.owner_id);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ── WebSocket broadcasts ───────────────────────────────────────────────────
|
||||
|
||||
const STAFF = { staffOnly: true };
|
||||
|
||||
Reference in New Issue
Block a user