Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save command-result card to workspace #1647

Merged
merged 27 commits into from
Oct 8, 2024
Merged

Conversation

burieberry
Copy link
Contributor

@burieberry burieberry commented Oct 3, 2024

Opened the menu with the button again after copy for the screenshot:
copy-to-workspace

  • Added copyCard action in interact submode (because the logic for checking the realm of any open card in stack required this to live there)
  • Made actions in interact-submode available in card context (using the @provide pattern)
  • Added an option (isWritableRealm) to getRealmURL function in cardService for it to return a writable realm url. By default it returns a readable realm url.
  • How it works: CommandCard and CommandResult card are saved in the matrix server, however we do not save them locally. If a user clicks on Copy to Workspace, then we save a copy of the CommandResult card in user's workspace.

Note:

  • Each time the "Copy to Workspace" button is clicked, there'll be a new copy of the card saved. I think this is consistent with what the button is meant to do, but wanted to hear if people think otherwise.

Copy link

github-actions bot commented Oct 4, 2024

Host Test Results

    1 files  ±0      1 suites  ±0   18m 35s ⏱️ ±0s
658 tests +2  657 ✔️ +2  1 💤 ±0  0 ±0 
663 runs  +2  662 ✔️ +2  1 💤 ±0  0 ±0 

Results for commit 0d31e4e. ± Comparison against base commit e1bc7894.

♻️ This comment has been updated with latest results.

@burieberry burieberry requested a review from a team October 4, 2024 21:30
@burieberry burieberry marked this pull request as ready for review October 4, 2024 21:30
Copy link
Contributor

@tintinthong tintinthong left a comment

Choose a reason for hiding this comment

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

Is this supposed to show anything? the search result in edit mode

Screenshot 2024-10-07 at 21 17 43

@tintinthong
Copy link
Contributor

I sometimes see results not appearing. I thought this was actually fixed before.. is it your experience to see this often?

@tintinthong
Copy link
Contributor

So we copy the result card to the workspace but not the cards itself. The result card will just linksToMany back to wherever the cards come from?

@burieberry
Copy link
Contributor Author

burieberry commented Oct 7, 2024

I sometimes see results not appearing. I thought this was actually fixed before.. is it your experience to see this often?

Are you talking about CS-7255? I only saw that happen on prod. I haven't checked recently on prod.

@burieberry
Copy link
Contributor Author

So we copy the result card to the workspace but not the cards itself. The result card will just linksToMany back to wherever the cards come from?

Yes, the idea is that any card shared in chat can be copied to workspace the same way. In the isolated search results card, the results are clickable.

@burieberry
Copy link
Contributor Author

Is this supposed to show anything? the search result in edit mode

Screenshot 2024-10-07 at 21 17 43

Hmm, I'll take a look what we can do there.

@field toolCallId = contains(StringField);
@field name = contains(StringField);
@field payload = contains(CommandObjectField); //arguments of toolCall. Its not called arguments due to lint
@field payload = contains(ToolCallArg); //arguments of toolCall. Its not called arguments due to lint
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we prefer this to be more abstract than "ToolCallArg". That phrase is AI Bot specific as far as I understand it, and not all commands should interact with AI.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is CommandObjectField a better name then? I also considered converting it to a string and parsing as needed.

// @ts-ignore "cardContext is declared but not used"
private get cardContext() {
return {
actions: this.publicAPI(this, this.stacks[0]?.length ? 1 : 0),
Copy link
Contributor

Choose a reason for hiding this comment

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

I know that targeting the right column is the correct default for the copy command, but is it really the correct default for all actions?

Comment on lines 457 to 469
if (opts?.isWritableRealm) {
let url = card?.[api.realmURL];
if (url && this.realm.canWrite(url.href)) {
return url;
}
if (!this.realm.defaultWritableRealm) {
throw new Error('Could not find a writable realm');
}
return new URL(this.realm.defaultWritableRealm.path);
}
// in the case where we get no realm URL from the card, we are dealing with
// a new card instance that does not have a realm URL yet.
return card[api.realmURL] ?? new URL(this.realm.defaultReadableRealm.path);
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that this PR is extending the existing fallback behavior. But this fallback behavior doesn't belong here.

getRealmURL should only return a card's actual realm url. When there isn't one, it should return undefined, and it should be up to the caller to pick a default instead.

@burieberry burieberry merged commit 9db69e0 into main Oct 8, 2024
34 checks passed
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.

4 participants