Skip to content

Commit

Permalink
lazy loading, review #1 + #2
Browse files Browse the repository at this point in the history
lazy loading, lazy fixes for fink, add documentation and root hash change handling, fix push/ pull checkout, more pull fixes, empty workdir performance



Summary:

Test Plan:
  • Loading branch information
janfjohannes committed May 22, 2024
1 parent 8ef0bbf commit 1031b64
Show file tree
Hide file tree
Showing 48 changed files with 2,904 additions and 13,179 deletions.
5 changes: 5 additions & 0 deletions .changeset/nervous-nails-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@inlang/plugin-i18next": minor
---

increase batching to 50 for i18n plugin
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,8 @@ function Breadcrumbs() {
* The menu to select the branch.
*/
function BranchMenu() {
const { activeBranch, setActiveBranch, branchNames, currentBranch } = useEditorState()
const { activeBranch, setActiveBranch, setBranchListEnabled, branchList, currentBranch } =
useEditorState()
return (
<sl-tooltip
prop:content="Select branch"
Expand All @@ -476,12 +477,15 @@ function BranchMenu() {
class="small"
style={{ "--show-delay": "1s" }}
>
<sl-dropdown prop:distance={8}>
<sl-dropdown prop:distance={8} on:sl-show={() => setBranchListEnabled(true)}>
<sl-button
slot="trigger"
prop:caret={true}
prop:size="small"
prop:loading={currentBranch() !== activeBranch() && activeBranch() !== undefined}
prop:loading={
(currentBranch() !== activeBranch() && activeBranch() !== undefined) ||
(branchList.loading && !branchList())
}
>
<div slot="prefix">
{/* branch icon from github */}
Expand All @@ -497,15 +501,25 @@ function BranchMenu() {
</sl-button>

<sl-menu class="w-48 min-w-fit">
<For each={branchNames()}>
{(branch) => (
<div onClick={() => setActiveBranch(branch)}>
<sl-menu-item prop:type="checkbox" prop:checked={currentBranch() === branch}>
{branch}
</sl-menu-item>
</div>
)}
</For>
<Show
when={branchList()}
fallback={<sl-menu-item prop:disabled={true}>Loading...</sl-menu-item>}
>
<For each={branchList()}>
{(branch) => (
<div
onClick={() => {
setActiveBranch(branch)
setBranchListEnabled(false) // prevent refetching after selecting branch
}}
>
<sl-menu-item prop:type="checkbox" prop:checked={currentBranch() === branch}>
{branch}
</sl-menu-item>
</div>
)}
</For>
</Show>
</sl-menu>
</sl-dropdown>
</sl-tooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type EditorStateSchema = {
* Fork status of the repository.
*/

forkStatus: () => { ahead: number; behind: number; conflicts: boolean }
forkStatus: () => { ahead: number; behind: number; conflicts: Record<string, any> | undefined }
/**
* Refetch the fork status.
*/
Expand All @@ -75,7 +75,11 @@ type EditorStateSchema = {
/**
* The branch names of current repo.
*/
branchNames: Resource<string[] | undefined>
setBranchListEnabled: Setter<boolean>
/**
* Trigger the branch list to be fetched.
*/
branchList: Resource<string[] | undefined>
/**
* Additional information about a repository provided by GitHub.
*/
Expand Down Expand Up @@ -547,9 +551,9 @@ export function EditorStateProvider(props: { children: JSXElement }) {
)

/**
* createResource is not reacting to changes like: "false","Null", or "undefined".
* Hence, a string needs to be passed to the fetch of the resource.
*/
* createResource is not reacting to changes like: "false","Null", or "undefined".
* Hence, a string needs to be passed to the fetch of the resource.
*/
const [userIsCollaborator] = createResource(
() => {
// do not fetch if no owner or repository is given
Expand Down Expand Up @@ -602,16 +606,22 @@ export function EditorStateProvider(props: { children: JSXElement }) {
}
},
async (args) => {
await new Promise((resolve) => setTimeout(resolve, 10000))
// wait for the browser to be idle
await new Promise((resolve) => requestIdleCallback(resolve))

console.info("fetching forkStatus")

const value = await args.repo!.forkStatus()
if ("error" in value) {
// Silently ignore errors:
// The branch might only exist in the fork and not in the upstream repository.
return { ahead: 0, behind: 0, conflicts: false }
return { ahead: 0, behind: 0, conflicts: undefined }
} else {
return value
}
},
{ initialValue: { ahead: 0, behind: 0, conflicts: false } }
{ initialValue: { ahead: 0, behind: 0, conflicts: undefined } }
)

const [previousLoginStatus, setPreviousLoginStatus] = createSignal(localStorage?.user?.isLoggedIn)
Expand Down Expand Up @@ -647,16 +657,24 @@ export function EditorStateProvider(props: { children: JSXElement }) {
}
)

const [branchNames] = createResource(
const [branchListEnabled, setBranchListEnabled] = createSignal(false)
const [branchList] = createResource(
() => {
if (
repo() === undefined ||
githubRepositoryInformation() === undefined ||
!branchListEnabled()
) {
return false
}
return { repo: repo() }
},
async (args) => {
console.info("fetching branchList")
return await args.repo?.getBranches()
}
)


return (
<EditorStateContext.Provider
value={
Expand All @@ -670,7 +688,8 @@ export function EditorStateProvider(props: { children: JSXElement }) {
mergeUpstream,
createFork,
currentBranch,
branchNames,
setBranchListEnabled,
branchList,
githubRepositoryInformation,
routeParams,
searchParams,
Expand Down
Empty file modified inlang/source-code/paraglide/paraglide-sveltekit/bin/run.js
100644 → 100755
Empty file.
7 changes: 7 additions & 0 deletions lix/documentation/lix-concepts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## how does merge work
lix is supposed to be out of your way, not introduce unneeded concepts and work seamlessly for binary, text and strucutred text based files alike. Git conflict markers and git conflict repo states with semi-locked flow is a constant cause of pain, also reflected in the design of other vsc systems like jj and couchdb, where conflicts do not block activity but can be resolved with generic file based tools at a time convenient to the user and / or application layer!

lix will behave in all underlying git operations as if no conflict exsisted, always picking a predictable version as winning revision, similar to couchdb. alternate versions will be added to conflict markers with a file suffix .<commit hash>.conflict. the repo status api will report files with conflicts similar to modified files in a dirty workdir to inform the commit actions of this fact but its up to the user/ application to decide to commit conflict markers as regular files and delay resolution to be done in a seperate system/ later time. this has many advantages: workflows are not interrupted especially painful for things like rebase. conflict markers will not destroy syntax/ tooling making it much easier to compare and act on conflicts. tools can decide to handle any number of conflicts at the same time. if conflicts are caused by formatting tools such as prettier, you can format all the conflicting versions first and then run resolution on the resulting files which removes all but the real conflicts saving tons of headaches. this works for any file type not just text files leading to much more unified workflows.

## how does staging work
lix does not have a concept of staging but treats this as an implementation detail of the underlying git repo. a commit unless triggered with include/exclude options will always commit the current workdir state
2 changes: 1 addition & 1 deletion lix/packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"async-lock": "^1.4.1",
"clean-git-ref": "^2.0.1",
"crc-32": "^1.2.2",
"diff3": "^0.0.4",
"diff3": "./vendored/diff3",
"ignore": "^5.3.1",
"octokit": "3.1.2",
"pako": "^1.0.11",
Expand Down
211 changes: 0 additions & 211 deletions lix/packages/client/src/git-http/client.js

This file was deleted.

Loading

0 comments on commit 1031b64

Please sign in to comment.