Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "writer"
version = "0.8.3rc16"
version = "0.8.3rc17"
description = "An open-source, Python framework for building feature-rich apps that are fully integrated with the Writer platform."
authors = ["Writer, Inc."]
readme = "README.md"
Expand Down
17 changes: 16 additions & 1 deletion src/ui/src/builder/BuilderHeader.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<template>
<div class="BuilderHeader">
<img src="../assets/logo.svg" alt="Writer Framework logo" />
<a
v-if="writerDeployUrl"
:href="writerDeployUrl.toString()"
target="_blank"
class="BuilderHeader__goBack"
>
<img src="../assets/logo.svg" alt="Writer Framework logo" />
</a>
<img v-else src="../assets/logo.svg" alt="Writer Framework logo" />
<BuilderSwitcher />
<div class="gap"></div>
<div class="BuilderHeader__toolbar">
Expand Down Expand Up @@ -109,6 +117,7 @@ const {
publishApplication,
hasBeenPublished,
lastDeployedAt,
writerDeployUrl,
} = useApplicationCloud(wf);

const undoRedoSnapshot = computed(() => getUndoRedoSnapshot());
Expand Down Expand Up @@ -209,6 +218,12 @@ function showStateExplorer() {
border-bottom: 1px solid var(--builderAreaSeparatorColor);
}

.BuilderHeader__goBack {
text-decoration: none;
display: flex;
align-items: center;
}

.BuilderHeader__toolbar {
display: flex;
align-items: center;
Expand Down
9 changes: 9 additions & 0 deletions src/ui/src/composables/useApplicationCloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ export function useApplicationCloud(wf: Core) {
return new URL(path, apiBaseUrl);
});

const writerDeployUrl = computed(() => {
if (!orgId.value || !appId.value) return;
return new URL(
`/aistudio/organization/${orgId.value}/agent/${appId.value}/deploy`,
apiBaseUrl,
);
});

const lastDeployedAt = computed(() => {
return deploymentInformation.value.lastDeployedAt
? new Date(deploymentInformation.value.lastDeployedAt)
Expand Down Expand Up @@ -134,6 +142,7 @@ export function useApplicationCloud(wf: Core) {
return {
isCloudApp,
canDeploy,
writerDeployUrl,
hasBeenPublished,
publishApplication,
isDeploying: readonly(isDeploying),
Expand Down
4 changes: 4 additions & 0 deletions src/writer/app_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,8 @@ def create_persisted_script(self, file="main.py", content: Union[str, bytes] = "

with open(path, mode, encoding=encoding) as f:
f.write(content)
f.flush()
os.fsync(f.fileno())

self.source_files = wf_project.build_source_files(self.app_path)

Expand Down Expand Up @@ -978,6 +980,8 @@ def save_code(self, session_id: str, code: str, path: List[str] = ["main.py"]) -

with open(filepath, "w") as f:
f.write(code)
f.flush()
os.fsync(f.fileno())

self.source_files = wf_project.build_source_files(self.app_path)

Expand Down
8 changes: 8 additions & 0 deletions src/writer/wf_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def write_files(app_path: str, metadata: MetadataDefinition, components: Dict[st

with io.open(os.path.join(wf_directory, "metadata.json"), "w") as f:
json.dump(metadata, f, indent=4)
f.flush()
os.fsync(f.fileno())

_write_root_files(wf_directory, components)
_write_component_files(wf_directory, components)
Expand Down Expand Up @@ -185,6 +187,8 @@ def create_default_blueprints_root(abs_path: str) -> None:
f.write('{"id": "blueprints_root", "type": "blueprints_root", "content": {}, "isCodeManaged": false, "position": 0, "handlers": {}, "visible": {"expression": true, "binding": "", "reversed": false}}')
logger = logging.getLogger('writer')
logger.warning('project format has changed and has been migrated with success. components-blueprints_root.jsonl has been added.')
f.flush()
os.fsync(f.fileno())


def _expected_component_fileinfos(components: dict[str, ComponentDefinition]) -> List[Tuple[str, str]]:
Expand Down Expand Up @@ -257,6 +261,8 @@ def _write_component_files(wf_directory: str, components: Dict[str, ComponentDef
with io.open(os.path.join(wf_directory, filename), "w") as f:
for p in _order_components(filtered_components):
f.write(json.dumps(_sort_wf_component_keys(p)) + "\n")
f.flush()
os.fsync(f.fileno())


def _write_root_files(wf_directory, components):
Expand All @@ -265,6 +271,8 @@ def _write_root_files(wf_directory, components):
if root_component:
with io.open(os.path.join(wf_directory, f"components-{root}.jsonl"), "w") as f:
f.write(json.dumps(_sort_wf_component_keys(root_component)))
f.flush()
os.fsync(f.fileno())


def _order_components(components: Dict[str, ComponentDefinition]) -> List[ComponentDefinition]:
Expand Down