Repository navigation
feat: Work in the project folder by default, and continue ended sessions - #6
Conversation
… end times Every project is added with its default workstream: core, in place, in the project folder, on the branch checked out there and named after it. POST /default-workstream adds it again after it was removed, and a pending or failed in-place create holds the project folder, so the create form no longer offers a taken one. The strategies get names for people (folder and worktree), and a worktree workstream shows and follows the branch checked out in its own folder. Sessions record when they ended (endedAt), kept across a daemon restart, and an Enclave session that ended on its own can be continued.
The project page shows its workstreams in two sections, in the project folder and separate folders, with Work here when the project folder has none. A workstream's header shows its branch, kind, folder and session counts. Ended sessions are grouped under a fold per workstream and dated. Enter or a click shows their details; Continue, an icon button, or Alt+S continues them. One line-icon set and a shape per session state. The selected project and the selected or focused session share one mark, a neutral tint and an accent bar, so teal keeps meaning running and primary. Row buttons carry a fill of their own, so their borders show on a tinted row. The log pane moves to the command palette.
Covers the default workstream over the API and in the UI, end times and continuing ended sessions, the two sections of the project page, the workstream header, keyboard access to the ended-sessions fold, and the shared selection mark. The e2e helpers find session rows by what they are, and a session-polling run removes its sessions so no bridge outlives it.
cf9f472 to
ebebde9
Compare
EclipseSourceAI
left a comment
There was a problem hiding this comment.
Note
Autonomous AI review. May contain mistakes.
Useful comment? React 👍. Disagree? React 👎 to reject it for follow-up reviews. A reply explaining why helps too.
This agent never approves PRs. A maintainer must sign off.
Only a maintainer can re-request a review from this agent.
Powered by Eclipse Enclave via review-guard-mcp
What this does: every project now comes with a default workstream that works in place, in the project folder (Service.AddProject / AddDefaultWorkstream, plus POST /default-workstream for "Work here"). The daemon sends inProjectFolder, and the store treats the project folder as taken by any workstream shown there, pending in-place creates included. The core provider is now a Refresher: each projection re-reads the checked-out branch, a watch loop polls for branch switches, and an in-place workstream keeps its name in step with the branch until it is renamed. Sessions get a persisted endedAt, stamped in store.stampEndedAtLocked, and the restored-but-not-yet-observed set keeps a daemon restart from re-stamping it. The UI splits the project page into "In the project folder" and "Separate folders", adds the Ended group with a fold, and moves to a single Lucide icon set with a shape per session state.
Where to look:
- Branch polling cost: the in-place branch read forks git on every refresh tick and every projection pass. Every project now has an in-place workstream, so idle load grows with the number of projects (inline).
- Synchronous reconcile on add: add-project runs a full provider discovery inside the request, and the comment justifying it is wrong (inline).
- Default strategy change: a git project's form and API default moved from in place to worktree, and the changelog block doesn't say so (inline).
- Duplicated rules: the "ended" rule lives in the client, and
nameTakenInduplicates the store's name rule and already differs from it (inline). - Endedat logic:
stampEndedAtLockedlooks right to me for the restart, first-seen and continue cases, and the store tests cover them.
Scope: this is 165 files. The visual overhaul in the UI commit (icon set, state shapes, selection mark, top-bar button refactor) doesn't depend on the default workstream or ended sessions, and would review more easily as its own PR.
Not run: no Go toolchain or node_modules in this environment and no build configured, so nothing was run and nothing was checked in a browser. A maintainer should do the make run walkthrough from the PR description.
| } | ||
| dir, read := workstream.WorkingDir, git.HeadBranch | ||
| if wsfs.Strategy(creatorData.Strategy) == wsfs.InPlace { | ||
| dir, read = project.Path, git.CurrentBranch |
There was a problem hiding this comment.
In place is the one path that spawns git symbolic-ref, and every project now gets an in-place workstream. branchMoved calls this for each of them at refreshIntervalSec (0.5 s by default), and so does every projection pass, so 10 projects means 20+ git processes a second while idle. HeadBranch is the cheap HEAD-file read. Resolving the project's git dir once (git rev-parse --git-dir, cached per project path) and reading HEAD from there would keep the below-the-root case working without forking on every tick.
There was a problem hiding this comment.
Thanks, good catch! Fixed in 97ea6e1, but without a cache: git.EnclosingHeadBranch walks up from the project folder to the nearest .git and reads HEAD there. That is a few stats per tick and no git process, and there is no cached git dir that could go stale if a project folder is moved or cloned again. A reftable HEAD still falls back to git symbolic-ref, like in HeadBranch.
| if err != nil { | ||
| return domain.Workstream{}, err | ||
| } | ||
| // AddWorkstream does not persist; a projection pass does, and attaches any |
There was a problem hiding this comment.
This premise is wrong: AddWorkstream calls persistLocked (store.go). The only remaining reason is attaching sessions, but this runs a full discovery of every session provider (Enclave CLI included) inside the add-project request. finishCreate does the same reconcile off the request path. Either fix the comment or move this off the request path too.
|
|
||
| // nameTakenIn reports whether a workstream other than exceptID answers to name, | ||
| // by the store's rule: trimmed and case-insensitive. | ||
| func nameTakenIn(workstreams []domain.Workstream, name, exceptID string) bool { |
There was a problem hiding this comment.
This copies the store's name rule from nameTakenLocked, and the two already disagree. The store skips failed create placeholders, but this doesn't, so a failed create named feature stops the in-place workstream from following a checkout of feature. Export the store helper (it only needs the workstream list) and call it here.
| live: Session[]; | ||
| ended: Session[]; | ||
| } { | ||
| const live = sessions.filter((s) => !isSessionEnded(s)); |
There was a problem hiding this comment.
"Ended session" is now a glossary term (stopped or done, not error), but the client is the one deciding it, and the Ended/live split and the counts are built on that. That's what the principles call a bug, and it's the reason this PR made the daemon send inProjectFolder. Send an ended flag on the session the same way.
| offer("copy", "Folder: a copy of the project") | ||
| defaultID := ids[0] | ||
| if gitBacked { | ||
| defaultID = "worktree" |
There was a problem hiding this comment.
This moves a git project's default from in place to worktree. The create form now preselects Worktree, and a POST /workstreams whose config has no strategy now creates a worktree. That's user-visible, but the PR's changelog block doesn't mention it.
… git Every project now has an in-place workstream, and the refresh loop and every projection pass read its branch. That forked git symbolic-ref for each, several times a second while idle. git.EnclosingHeadBranch reads the HEAD file of the nearest repository at or above the project folder instead, so a project folder below the repository's root still follows its branch. Review: #6 (comment)
The reconciler copied the store's workstream name rule and missed that a failed create's placeholder holds no name, so a failed create named feature kept the in-place workstream from following a checkout of feature. The store exports the rule as store.NameTaken and the reconciler calls it. Review: #6 (comment)
Adding a project, or Work here, ran a projection pass inside the request to attach sessions already running in the project folder, asking every session provider, the Enclave CLI included. The comment justifying it said the store does not persist the workstream, which it does. The pass now runs in the background, as finishCreate's does. Review: #6 (comment)
Whether a session has ended (stopped or done, not a failed start) is a domain rule, and the client decided it, splitting live from ended and counting on that. The daemon now derives Session.Ended in Recompute and sends it as `ended`; the UI lists and counts by it. Review: #6 (comment)
Recompute's and checkedOutBranch's docs read as one sentence again, EnclosingHeadBranch says when it falls back to git, NameTaken names its parameter, the Ended test lists each state's answer, and the session row reads ended the way the session groups do.
|
Re the scope note in this review: Thanks for the review! I'd rather keep the visual changes in this PR. It's already the first of three stacked PRs (#7 and #8 build on it), and the daemon, UI and e2e tests are in separate commits, so they can be reviewed one at a time. |
fismif
left a comment
There was a problem hiding this comment.
Tested locally: default workstream, Ended + continue (also Alt+S), Work here, the worktree default and the new look all work well. Approving, with two small notes inline. The branch-name one is fine as a follow-up.
| return domain.Workstream{}, err | ||
| } | ||
| creatorData := coreCreatorData{Strategy: strategy} | ||
| if wsfs.Strategy(strategy) == wsfs.InPlace && branch != "" && name == branch { |
There was a problem hiding this comment.
An in-place workstream's name only follows the branch if the name equalled the branch when it was created. Otherwise NameFromBranch stays empty, and a name HomeShell picked itself is treated like a user rename, so it never follows a checkout again. That happens whenever creation (adding the project, or Work here) doesn't get the plain branch name:
- Detached HEAD (a tag, mid-rebase): the workstream gets the folder's name. After switching to a branch, the header shows the new branch but the name stays the folder's name.
- Name already taken by another workstream: it gets a numbered name (
main-2). It keeps that name after the clash is gone and the branch changes. - No git yet, or
git.CurrentBranchfailing (its error is discarded at L641): same as a detached HEAD.
Recording that the core chose the name (e.g. storing the name it picked, not only a branch-derived one) would let the next refresh that sees a branch rename it, while a real user rename still sticks.
| ) : ( | ||
| <div className={styles.emptySection}> | ||
| <p className={styles.emptyText}> | ||
| Nothing works in the project folder. |
There was a problem hiding this comment.
Nit: "Nothing works in the project folder." reads a bit like "everything's broken". Maybe "No workstream in the project folder.", which would also match "No separate folders yet."
A pass re-reads the store after discovery, then refreshes and annotates its copy and writes the whole list back. A rename landing in between was overwritten with the old name, and since that name was still the branch it was given from, the in-place workstream followed the next checkout under it: the flaky "a renamed one keeps its name while its branch follows" e2e test. A dismissed status message or a removed workstream or session came back the same way. ReplaceWorkstreams now takes the read the pass started from and keeps every field, workstream or session removal that changed in the store since then (keepChangesSinceRead).
"Nothing works in the project folder." read like something was broken. Review: #6 (comment)
…ame from An in-place workstream's name followed the branch only if it was the branch when created. One added on a detached HEAD, without a branch git would name, or past a name clash got the folder's or a numbered name, which then stuck as if the user had chosen it. The core now records the name it gave (coreCreatorData.GivenName), so the next branch renames it while a user's rename still sticks. Review: #6 (comment)
keepChangesSinceRead merged field by field through reflection, skipping Sessions by name. It now takes a workstream or session that changed since the read from the store whole, so fields that belong together come from one writer, and the next pass brings it up to date. It also keeps a workstream added meanwhile (Work here adds one without a placeholder, which the swap used to erase) and does not give a name that another workstream took in the meantime.
stampEndedAtLocked reuses sessionsByID, the merge finds a workstream added meanwhile through an ID map instead of scanning, and the store test holds every rule in one table while the reconciler test keeps the rename that the flaky e2e test hit.
Create started the create's background half and only then read its placeholder back from the store. An in-place create can finish and promote the placeholder in between, and Create then answered with its local copy, which lacks what the store derives (inProjectFolder, the strategy label, the states): about 1 in 200 runs of the e2e test "an in-place create takes the project folder before it is made". Create now reads the placeholder back before the create goes on.
…first The placeholder table test now runs every create to its end before Create answers, and checks the strategy label too, instead of a second test repeating its setup. Create passes the detached context inline.
What and why
With this change, every project comes with a default workstream that works in the project folder,
on the branch checked out there, so a project is usable right after adding it. Sessions that end
stay listed under Ended with when they ended, and can be continued. The project page shows its
workstreams in two sections (in the project folder and separate folders), and the UI gets one icon
set, a shape per session state and one selection mark for projects and sessions.
This is the first of three stacked PRs: this one, then #7 (untracked worktrees), then #8
(Enclave CLI sessions). Each has three commits (daemon, UI, e2e tests) that can be reviewed one by
one.
To try it, run
make runand add a git repository as a project. Its workstream sits under In theproject folder, named after the branch. Start a session, stop it and continue it from Ended · 1
(or with Alt+S). After deleting the workstream, Work here adds it again.
make dev-demohas aworkstream with sessions that ended over time.
Changelog
Checklist
AGENTS.md)AGENTS.md