Skip to content

fix: Disable actions on autogenerated docs/nodes#2766

Open
thseiler wants to merge 1 commit into
strictdoc-project:mainfrom
thseiler:feature/no-edit-for-autogen-nodes-and-fields
Open

fix: Disable actions on autogenerated docs/nodes#2766
thseiler wants to merge 1 commit into
strictdoc-project:mainfrom
thseiler:feature/no-edit-for-autogen-nodes-and-fields

Conversation

@thseiler
Copy link
Copy Markdown
Contributor

@thseiler thseiler commented Apr 8, 2026

WHAT:
While working on the image PR, I noticed that it was possible to edit certain node types that StrictDoc cannot currently save:

  • autogenerated documents and nodes like test reports
  • nodes that were merged from source_code
    These changes appear to take effect initially (as the in-memory model is updated), but they are lost when the server is stopped.

WHY:
Ensures that the user notices that he can currently not edit these node types.

HOW:
The PR introduces an ActionPolicy object and hooks it:

  • to the document action button (edit metadata)
  • to the node action buttons (edit, clone, delete, add)
  • to the toc (move nodes)
  • to the individual fields in the edit form

Points for Discussion:

  • The ActionPolicy is currently a proposal. I am not really sure whether the policy correctly handles all the edge cases, especially for merged nodes. But as the logic is centralised, it should be easy to adapt as needed.
  • I noticed some issues when editing a merge node (where some fields are parsed from the source code and others come from the .sdoc). The origin metadata for fields would be lost on edit, and the UID / MID would not be written back to the sdoc, so that the link would be lost on subsequent server starts. I've tried to address these as well.
  • I had some trouble with the SDocTestServer hitting the ReadTimeout, and noticed that the exit handler is not called when an exception happens in the enter block. I added an exception handler to clean up the server so that the end-to-end tests could continue.

stanislaw added a commit that referenced this pull request Apr 27, 2026
…en diffing in/out folders

WHY: Ensures that the test diffing works correctly and the __pycache__ folder
does not get in the way.

HOW: Extracted from #2766.
@stanislaw stanislaw changed the title Disable actions for auto-generated nodes/docs fix(export): introduce action_policy, disable some actions on autogen content May 15, 2026
@stanislaw stanislaw changed the title fix(export): introduce action_policy, disable some actions on autogen content fix: Disable actions on autogenerated content May 15, 2026
@stanislaw stanislaw changed the title fix: Disable actions on autogenerated content fix: Disable actions on autogenerated docs/nodes May 15, 2026
@stanislaw stanislaw force-pushed the feature/no-edit-for-autogen-nodes-and-fields branch 6 times, most recently from a94276b to e64b441 Compare May 22, 2026 18:26
@stanislaw stanislaw force-pushed the feature/no-edit-for-autogen-nodes-and-fields branch from e64b441 to 5c7e974 Compare May 22, 2026 22:47
form_field_index
]

if hasattr(old_field, "origin"):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR had a few instances of this. @thseiler I am curious if this is produced by an AI tool. Which tool did you possibly use to create it? I would be curious if we could extend our Dev Guide and let all AI tools avoid creating this pattern in the future.

(I have been using Codex until now and haven't seen this pattern from it)


return self.get_prefix()

def is_managed_by_source_code(self) -> bool:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thseiler I started rebasing your branch and it needed a few changes that led me to editing your commit directly instead of push an additional code review one. The summary of my changes:

  • I removed ActionPolicy class. Instead I moved most methods to the DocumentScreenViewObject and here as is_managed_by_source_code. One pattern here I tried to avoid is to add global logic to Jinja templates as that contradicts to the currently adopted pattern of routing everything through the view object objects.
  • I did a minor clean up of the new e2e test fixtures, removing some of the unneeded files.

I am still reviewing the impact and consistency of your other changes, expecially the file_traceability_index. and update_requirement.py. Should be done by the end of this weekend.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, @mettta will review the CSS styles to ensure that this change is consistent with everything else.

@stanislaw stanislaw added this to the 2026-Q2 milestone May 25, 2026
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.

2 participants